aboutsummaryrefslogtreecommitdiff
path: root/sys/fmtio/zzdebug.x
blob: 3729a1ff242600ad764607ff4a7d4b2f9b3d6d59 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.

include	<evexpr.h>
include	<lexnum.h>

task	ev	= t_ev,
	lex	= t_lex,
	eq	= t_eq,
	ne	= t_ne,
	lt	= t_lt,
	le	= t_le,
	gt	= t_gt,
	ge	= t_ge,
	cmp	= t_cmp,
	ncmp	= t_ncmp,
	mat	= t_mat,
	srch	= t_srch,
	ctowrd	= t_ctowrd


# EV -- Text EVEXPR.

procedure t_ev

char	expr[SZ_LINE]
pointer	o, evexpr()
int	clglstr()

begin
	while (clglstr ("expr", expr, SZ_LINE) != EOF) {
	    o = evexpr (expr, 0, 0)

	    switch (O_TYPE(o)) {
	    case TY_BOOL:
		call printf ("%b = %s\n")
		    call pargb (O_VALB(o))
		    call pargstr (expr)

	    case TY_CHAR:
		call printf ("%s = %s\n")
		    call pargstr (O_VALC(o))
		    call pargstr (expr)

	    case TY_INT:
		call printf ("%d = %s\n")
		    call pargi (O_VALI(o))
		    call pargstr (expr)

	    case TY_REAL:
		call printf ("%g = %s\n")
		    call pargr (O_VALR(o))
		    call pargstr (expr)

	    default:
		call error (1, "expression datatype unknown")
	    }
	} 

	call printf ("\n")
end


# LEX -- Test LEXNUM.

procedure t_lex()

int	ip, nchars, toktype
char	token[SZ_FNAME]
int	lexnum(), strlen()

begin
	repeat {
	    call clgstr ("token", token, SZ_FNAME)
	    if (strlen (token) == 0)
		break

	    ip = 1
	    toktype = lexnum (token, ip, nchars)

	    call printf ("tokchars=%d, type = %s\n")
		call pargi (nchars)

		switch (toktype) {
		case LEX_OCTAL:
		    call pargstr ("octal")
		case LEX_DECIMAL:
		    call pargstr ("decimal")
		case LEX_HEX:
		    call pargstr ("hex")
		case LEX_REAL:
		    call pargstr ("real")
		case LEX_NONNUM:
		    call pargstr ("nonnumeric")
		default:
		    call pargstr ("unknown")
		}
	}
end


# EQ -- Test string equals.

procedure t_eq()

char	s1[SZ_FNAME], s2[SZ_FNAME]
bool	streq()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("s2", s2, SZ_FNAME)
	    call printf ("%s == %s: %b\n")
		call pargstr (s1)
		call pargstr (s2)
		call pargb (streq (s1, s2))
	    call flush (STDOUT)
	}
end


# NE -- Test string not equals.

procedure t_ne()

char	s1[SZ_FNAME], s2[SZ_FNAME]
bool	strne()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("s2", s2, SZ_FNAME)
	    call printf ("%s != %s: %b\n")
		call pargstr (s1)
		call pargstr (s2)
		call pargb (strne (s1, s2))
	    call flush (STDOUT)
	}
end


# LT -- Test string less than.

procedure t_lt()

char	s1[SZ_FNAME], s2[SZ_FNAME]
bool	strlt()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("s2", s2, SZ_FNAME)
	    call printf ("%s < %s: %b\n")
		call pargstr (s1)
		call pargstr (s2)
		call pargb (strlt (s1, s2))
	    call flush (STDOUT)
	}
end


# LE -- Test string less than or equals.

procedure t_le()

char	s1[SZ_FNAME], s2[SZ_FNAME]
bool	strle()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("s2", s2, SZ_FNAME)
	    call printf ("%s <= %s: %b\n")
		call pargstr (s1)
		call pargstr (s2)
		call pargb (strle (s1, s2))
	    call flush (STDOUT)
	}
end


# GT -- Test string greater than.

procedure t_gt()

char	s1[SZ_FNAME], s2[SZ_FNAME]
bool	strgt()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("s2", s2, SZ_FNAME)
	    call printf ("%s > %s: %b\n")
		call pargstr (s1)
		call pargstr (s2)
		call pargb (strgt (s1, s2))
	    call flush (STDOUT)
	}
end


# GE -- Test string greater than or equals.

procedure t_ge()

char	s1[SZ_FNAME], s2[SZ_FNAME]
bool	strge()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("s2", s2, SZ_FNAME)
	    call printf ("%s >= %s: %b\n")
		call pargstr (s1)
		call pargstr (s2)
		call pargb (strge (s1, s2))
	    call flush (STDOUT)
	}
end


# CMP -- Test string compare.

procedure t_cmp()

char	s1[SZ_FNAME], s2[SZ_FNAME]
int	strcmp()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("s2", s2, SZ_FNAME)
	    call printf ("compare %s, %s: %d\n")
		call pargstr (s1)
		call pargstr (s2)
		call pargi (strcmp (s1, s2))
	    call flush (STDOUT)
	}
end


# NCMP -- Test counted string compare.

procedure t_ncmp()

char	s1[SZ_FNAME], s2[SZ_FNAME]
int	strncmp(), clgeti()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("s2", s2, SZ_FNAME)
	    call printf ("compare %s, %s: %d\n")
		call pargstr (s1)
		call pargstr (s2)
		call pargi (strncmp (s1, s2, clgeti("nchars")))
	    call flush (STDOUT)
	}
end


# MAT -- Test string match.

procedure t_mat()

char	s1[SZ_FNAME], pat[SZ_FNAME]
int	strmatch()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("pat", pat, SZ_FNAME)
	    call printf ("match %s, pat=%s: %d\n")
		call pargstr (s1)
		call pargstr (pat)
		call pargi (strmatch (s1, pat))
	    call flush (STDOUT)
	}
end


# SRCH -- Test string search.

procedure t_srch()

char	s1[SZ_FNAME], pat[SZ_FNAME]
int	strsearch()

begin
	repeat {
	    call clgstr ("s1", s1, SZ_FNAME)
	    call clgstr ("pat", pat, SZ_FNAME)
	    call printf ("search %s, pat=%s: %d\n")
		call pargstr (s1)
		call pargstr (pat)
		call pargi (strsearch (s1, pat))
	    call flush (STDOUT)
	}
end


# CTOWRD -- Test ctowrd.

procedure t_ctowrd()

char	buf1[SZ_LINE], buf2[SZ_LINE]
int	n, ip, ctowrd(), getline()

begin
	while (getline (STDIN, buf1) != EOF) {
	    ip = 1
	    repeat {
		buf2[1] = EOS
		n = ctowrd (buf1, ip, buf2, SZ_LINE)
		call printf ("n=%d, token=%s\n")
		    call pargi (n)
		    call pargstr (buf2)
	    } until (n <= 0)
	}
end