a2py.c

filter: Statementstmt 0.0% 0 / 878 Branchbran 0.0% 0 / 664 Subroutinesub n/a totaltotal 0.0% 0 / 1542 CC 0 SCAR 0
CC
0
Cov
0%
CRAP 0
« blib/lib/App/a2p.pm ↑ Summary hash.c »
1 /* a2py.c
2 *
3 * Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4 * 2000, 2001, 2002, by Larry Wall and others
5 *
6 * You may distribute under the terms of either the GNU General Public
7 * License or the Artistic License, as specified in the README file.
8 */
9  
10 #if defined(WIN32)
11 #include <io.h>
12 #endif
13 #include "patchlevel.h"
14 #include "util.h"
15  
16 #if PERL_VERSION > 17
17 #include "unicode_constants.h"
18 #define DELETE_CHAR DEL_NATIVE
19 #else
20 #define DELETE_CHAR 127
21 #endif
22  
23 const char *filename;
24 const char *myname;
25  
26 int checkers = 0;
27  
28 int oper0(int type);
29 int oper1(int type, int arg1);
30 int oper2(int type, int arg1, int arg2);
31 int oper3(int type, int arg1, int arg2, int arg3);
32 int oper4(int type, int arg1, int arg2, int arg3, int arg4);
33 int oper5(int type, int arg1, int arg2, int arg3, int arg4, int arg5);
34 STR *walk(int useval, int level, int node, int *numericptr, int minprec);
35 #ifdef NETWARE
36 char *savestr(char *str);
37 char *cpy2(char *to, char *from, int delim);
38 #endif
39  
40 #if defined(OS2) || defined(WIN32) || defined(NETWARE)
41 static void usage(void);
42  
43 static void
44 usage()
45 {
46 printf("\nThis is the AWK to PERL translator, revision %d.0, version %d\n", PERL_REVISION, PERL_VERSION);
47 printf("\nUsage: %s [-D<number>] [-F<char>] [-n<fieldlist>] [-<number>] filename\n", myname);
48 printf("\n -D<number> sets debugging flags."
49 "\n -F<character> the awk script to translate is always invoked with"
50 "\n this -F switch."
51 "\n -n<fieldlist> specifies the names of the input fields if input does"
52 "\n not have to be split into an array."
53 "\n -<number> causes a2p to assume that input will always have that"
54 "\n many fields.\n");
55 exit(1);
56 }
57 #endif
58  
59 int
60 0 main(int argc, const char **argv)
61 {
62 STR *str;
63 int i;
64 STR *tmpstr;
65 /* char *namelist; */
66  
67 #ifdef NETWARE
68 fnInitGpfGlobals(); /* For importing the CLIB calls in place of Watcom calls */
69 #endif /* NETWARE */
70  
71 0 myname = argv[0];
72 0 linestr = str_new(80);
73 0 ▶ for (argc--,argv++; argc; argc--,argv++) {
Branch: 1 branch
BranchTrueFalseTotal
for (argc--,argv++; argc; argc--,argv++) { 0 0 0
74 0 ▶ if (argv[0][0] != '-' || !argv[0][1])
Branch: 2 branches
BranchTrueFalseTotal
if (argv[0][0] != '-' || !argv[0][1]) 0 0 0
if (argv[0][0] != '-' || !argv[0][1]) 0 0 0
75 break;
76 0 switch (argv[0][1]) {
77 #ifdef DEBUGGING
78 case 'D':
79 debug = atoi(argv[0]+2);
80 #if YYDEBUG
81 yydebug = (debug & 1);
82 #endif
83 break;
84 #endif
85 0 case '0': case '1': case '2': case '3': case '4':
86 case '5': case '6': case '7': case '8': case '9':
87 0 maxfld = atoi(argv[0]+1);
88 0 absmaxfld = TRUE;
89 0 break;
90 0 case 'F':
91 0 fswitch = argv[0][2];
92 0 break;
93 0 case 'n':
94 0 namelist = savestr(argv[0]+2);
95 0 break;
96 0 case 'o':
97 0 old_awk = TRUE;
98 0 break;
99 0 case '-':
100 0 argc--,argv++;
101 0 goto switch_end;
102 0 case 0:
103 0 break;
104 0 default:
105 #if defined(OS2) || defined(WIN32) || defined(NETWARE)
106 fprintf(stderr, "Unrecognized switch: %s\n",argv[0]);
107 usage();
108 #else
109 0 fatal("Unrecognized switch: %s\n",argv[0]);
110 #endif
111 }
112 }
113 0 switch_end:
114  
115 /* open script */
116  
117 0 ▶ if (argv[0] == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if (argv[0] == NULL) { 0 0 0
118 #if defined(OS2) || defined(WIN32) || defined(NETWARE)
119 if ( isatty(fileno(stdin)) )
120 usage();
121 #endif
122 0 argv[0] = "-";
123 }
124 0 filename = savestr(argv[0]);
125  
126 0 ▶ if (strEQ(filename,"-"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(filename,"-")) 0 0 0
127 0 argv[0] = "";
128 0 ▶ if (!*argv[0])
Branch: 1 branch
BranchTrueFalseTotal
if (!*argv[0]) 0 0 0
129 0 rsfp = stdin;
130 else
131 0 rsfp = fopen(argv[0],"r");
132 0 ▶ if (rsfp == NULL)
Branch: 1 branch
BranchTrueFalseTotal
if (rsfp == NULL) 0 0 0
133 0 fatal("Awk script \"%s\" doesn't seem to exist.\n",filename);
134  
135 /* init tokener */
136  
137 0 ▶ bufptr = str_get(linestr);
Branch: 1 branch
BranchTrueFalseTotal
bufptr = str_get(linestr); 0 0 0
138 0 symtab = hnew();
139 0 curarghash = hnew();
140  
141 /* now parse the report spec */
142  
143 0 ▶ if (yyparse())
Branch: 1 branch
BranchTrueFalseTotal
if (yyparse()) 0 0 0
144 0 fatal("Translation aborted due to syntax errors.\n");
145  
146 #ifdef DEBUGGING
147 if (debug & 2) {
148 int type, len;
149  
150 for (i=1; i<mop;) {
151 type = ops[i].ival;
152 len = type >> 8;
153 type &= 255;
154 printf("%d\t%d\t%d\t%-10s",i++,type,len,opname[type]);
155 if (type == OSTRING)
156 printf("\t\"%s\"\n",ops[i].cval),i++;
157 else {
158 while (len--) {
159 printf("\t%d",ops[i].ival),i++;
160 }
161 putchar('\n');
162 }
163 }
164 }
165 if (debug & 8)
166 dump(root);
167 #endif
168  
169 /* first pass to look for numeric variables */
170  
171 0 prewalk(0,0,root,&i);
172  
173 /* second pass to produce new program */
174  
175 0 tmpstr = walk(0,0,root,&i,P_MIN);
176 0 str = str_make(STARTPERL);
177 0 str_cat(str, "\neval 'exec ");
178 0 str_cat(str, BIN);
179 0 str_cat(str, "/perl -S $0 ${1+\"$@\"}'\n\
180 if $running_under_some_shell;\n\
181 # this emulates #! processing on NIH machines.\n\
182 # (remove #! line above if indigestible)\n\n");
183 0 str_cat(str,
184 "eval '$'.$1.'$2;' while $ARGV[0] =~ /^([A-Za-z_0-9]+=)(.*)/ && shift;\n");
185 0 str_cat(str,
186 " # process any FOO=bar switches\n\n");
187 0 ▶ if (do_opens && opens) {
Branch: 2 branches
BranchTrueFalseTotal
if (do_opens && opens) { 0 0 0
if (do_opens && opens) { 0 0 0
188 0 str_scat(str,opens);
189 0 str_free(opens);
190 0 str_cat(str,"\n");
191 }
192 0 str_scat(str,tmpstr);
193 0 str_free(tmpstr);
194 #ifdef DEBUGGING
195 if (!(debug & 16))
196 #endif
197 0 fixup(str);
198 0 putlines(str);
199 0 ▶ if (checkers) {
Branch: 1 branch
BranchTrueFalseTotal
if (checkers) { 0 0 0
200 0 fprintf(stderr,
201 "Please check my work on the %d line%s I've marked with \"#???\".\n",
202 0 ▶ checkers, checkers == 1 ? "" : "s" );
Branch: 1 branch
BranchTrueFalseTotal
checkers, checkers == 1 ? "" : "s" ); 0 0 0
203 0 fprintf(stderr,
204 "The operation I've selected may be wrong for the operand types.\n");
205 }
206 0 exit(0);
207 /* by ANSI specs return is needed. This also shuts up VC++ and his warnings */
208 return(0);
209 }
210  
211 #define RETURN(retval) return (bufptr = s,retval)
212 #define XTERM(retval) return (expectterm = TRUE,bufptr = s,retval)
213 #define XOP(retval) return (expectterm = FALSE,bufptr = s,retval)
214 #define ID(x) return (yylval=string(x,0),expectterm = FALSE,bufptr = s,idtype)
215  
216 int idtype;
217  
218 int
219 0 yylex(void)
220 {
221 0 char *s = bufptr;
222 char *d;
223 int tmp;
224  
225 0 retry:
226 #if YYDEBUG
227 if (yydebug) {
228 if (strchr(s,'\n'))
229 fprintf(stderr,"Tokener at %s",s);
230 else
231 fprintf(stderr,"Tokener at %s\n",s);
232 }
233 #endif
234 0 switch (*s) {
235 0 default:
236 0 fprintf(stderr,
237 "Unrecognized character %c in file %s line %d--ignoring.\n",
238 0 *s++,filename,line);
239 0 goto retry;
240 0 case '\\':
241 0 s++;
242 0 ▶ if (*s && *s != '\n') {
Branch: 2 branches
BranchTrueFalseTotal
if (*s && *s != '\n') { 0 0 0
if (*s && *s != '\n') { 0 0 0
243 0 yyerror("Ignoring spurious backslash");
244 0 goto retry;
245 }
246 /*FALLSTHROUGH*/
247 case 0:
248 0 ▶ s = str_get(linestr);
Branch: 1 branch
BranchTrueFalseTotal
s = str_get(linestr); 0 0 0
249 0 *s = '\0';
250 0 ▶ if (!rsfp)
Branch: 1 branch
BranchTrueFalseTotal
if (!rsfp) 0 0 0
251 0 RETURN(0);
252 0 line++;
253 0 ▶ if ((s = str_gets(linestr, rsfp)) == NULL) {
Branch: 1 branch
BranchTrueFalseTotal
if ((s = str_gets(linestr, rsfp)) == NULL) { 0 0 0
254 0 ▶ if (rsfp != stdin)
Branch: 1 branch
BranchTrueFalseTotal
if (rsfp != stdin) 0 0 0
255 0 fclose(rsfp);
256 0 rsfp = NULL;
257 0 ▶ s = str_get(linestr);
Branch: 1 branch
BranchTrueFalseTotal
s = str_get(linestr); 0 0 0
258 0 RETURN(0);
259 }
260 0 goto retry;
261 0 case ' ': case '\t':
262 0 s++;
263 0 goto retry;
264 0 case '\n':
265 0 *s = '\0';
266 0 XTERM(NEWLINE);
267 0 case '#':
268 0 yylval = string(s,0);
269 0 *s = '\0';
270 0 XTERM(COMMENT);
271 0 case ';':
272 0 tmp = *s++;
273 0 ▶ if (*s == '\n') {
Branch: 1 branch
BranchTrueFalseTotal
if (*s == '\n') { 0 0 0
274 0 s++;
275 0 XTERM(SEMINEW);
276 }
277 0 XTERM(tmp);
278 0 case '(':
279 0 tmp = *s++;
280 0 XTERM(tmp);
281 0 case '{':
282 case '[':
283 case ')':
284 case ']':
285 case '?':
286 case ':':
287 0 tmp = *s++;
288 0 XOP(tmp);
289 0 case DELETE_CHAR:
290 0 s++;
291 0 XTERM('}');
292 0 case '}':
293 0 ▶ for (d = s + 1; isSPACE(*d); d++) ;
Branch: 1 branch
BranchTrueFalseTotal
for (d = s + 1; isSPACE(*d); d++) ; 0 0 0
294 0 ▶ if (!*d)
Branch: 1 branch
BranchTrueFalseTotal
if (!*d) 0 0 0
295 0 s = d - 1;
296 0 *s = 127;
297 0 XTERM(';');
298 0 case ',':
299 0 tmp = *s++;
300 0 XTERM(tmp);
301 0 case '~':
302 0 s++;
303 0 yylval = string("~",1);
304 0 XTERM(MATCHOP);
305 0 case '+':
306 case '-':
307 0 ▶ if (s[1] == *s) {
Branch: 1 branch
BranchTrueFalseTotal
if (s[1] == *s) { 0 0 0
308 0 s++;
309 0 ▶ if (*s++ == '+')
Branch: 1 branch
BranchTrueFalseTotal
if (*s++ == '+') 0 0 0
310 0 XTERM(INCR);
311 else
312 0 XTERM(DECR);
313 }
314 /* FALL THROUGH */
315 case '*':
316 case '%':
317 case '^':
318 0 tmp = *s++;
319 0 ▶ if (*s == '=') {
Branch: 1 branch
BranchTrueFalseTotal
if (*s == '=') { 0 0 0
320 0 ▶ if (tmp == '^')
Branch: 1 branch
BranchTrueFalseTotal
if (tmp == '^') 0 0 0
321 0 yylval = string("**=",3);
322 else
323 0 yylval = string(s-1,2);
324 0 s++;
325 0 XTERM(ASGNOP);
326 }
327 0 XTERM(tmp);
328 0 case '&':
329 0 s++;
330 0 tmp = *s++;
331 0 ▶ if (tmp == '&')
Branch: 1 branch
BranchTrueFalseTotal
if (tmp == '&') 0 0 0
332 0 XTERM(ANDAND);
333 0 s--;
334 0 XTERM('&');
335 0 case '|':
336 0 s++;
337 0 tmp = *s++;
338 0 ▶ if (tmp == '|')
Branch: 1 branch
BranchTrueFalseTotal
if (tmp == '|') 0 0 0
339 0 XTERM(OROR);
340 0 s--;
341 0 ▶ while (*s == ' ' || *s == '\t')
Branch: 2 branches
BranchTrueFalseTotal
while (*s == ' ' || *s == '\t') 0 0 0
while (*s == ' ' || *s == '\t') 0 0 0
342 0 s++;
343 0 ▶ if (strnEQ(s,"getline",7))
Branch: 1 branch
BranchTrueFalseTotal
if (strnEQ(s,"getline",7)) 0 0 0
344 0 XTERM('p');
345 else
346 0 XTERM('|');
347 0 case '=':
348 0 s++;
349 0 tmp = *s++;
350 0 ▶ if (tmp == '=') {
Branch: 1 branch
BranchTrueFalseTotal
if (tmp == '=') { 0 0 0
351 0 yylval = string("==",2);
352 0 XTERM(RELOP);
353 }
354 0 s--;
355 0 yylval = string("=",1);
356 0 XTERM(ASGNOP);
357 0 case '!':
358 0 s++;
359 0 tmp = *s++;
360 0 ▶ if (tmp == '=') {
Branch: 1 branch
BranchTrueFalseTotal
if (tmp == '=') { 0 0 0
361 0 yylval = string("!=",2);
362 0 XTERM(RELOP);
363 }
364 0 ▶ if (tmp == '~') {
Branch: 1 branch
BranchTrueFalseTotal
if (tmp == '~') { 0 0 0
365 0 yylval = string("!~",2);
366 0 XTERM(MATCHOP);
367 }
368 0 s--;
369 0 XTERM(NOT);
370 0 case '<':
371 0 s++;
372 0 tmp = *s++;
373 0 ▶ if (tmp == '=') {
Branch: 1 branch
BranchTrueFalseTotal
if (tmp == '=') { 0 0 0
374 0 yylval = string("<=",2);
375 0 XTERM(RELOP);
376 }
377 0 s--;
378 0 XTERM('<');
379 0 case '>':
380 0 s++;
381 0 tmp = *s++;
382 0 ▶ if (tmp == '>') {
Branch: 1 branch
BranchTrueFalseTotal
if (tmp == '>') { 0 0 0
383 0 yylval = string(">>",2);
384 0 XTERM(GRGR);
385 }
386 0 ▶ if (tmp == '=') {
Branch: 1 branch
BranchTrueFalseTotal
if (tmp == '=') { 0 0 0
387 0 yylval = string(">=",2);
388 0 XTERM(RELOP);
389 }
390 0 s--;
391 0 XTERM('>');
392  
393 #define SNARFWORD \
394 d = tokenbuf; \
395 while (isWORDCHAR(*s)) \
396 *d++ = *s++; \
397 *d = '\0'; \
398 d = tokenbuf; \
399 if (*s == '(') \
400 idtype = USERFUN; \
401 else \
402 idtype = VAR;
403  
404 0 case '$':
405 0 s++;
406 0 ▶ if (*s == '0') {
Branch: 1 branch
BranchTrueFalseTotal
if (*s == '0') { 0 0 0
407 0 s++;
408 0 do_chop = TRUE;
409 0 need_entire = TRUE;
410 0 idtype = VAR;
411 0 ID("0");
412 }
413 0 do_split = TRUE;
414 0 ▶ if (isDIGIT(*s)) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT(*s)) { 0 0 0
415 0 ▶ for (d = s; isDIGIT(*s); s++) ;
Branch: 1 branch
BranchTrueFalseTotal
for (d = s; isDIGIT(*s); s++) ; 0 0 0
416 0 yylval = string(d,s-d);
417 0 tmp = atoi(d);
418 0 ▶ if (tmp > maxfld)
Branch: 1 branch
BranchTrueFalseTotal
if (tmp > maxfld) 0 0 0
419 0 maxfld = tmp;
420 0 XOP(FIELD);
421 }
422 0 ▶ for (d = s; isWORDCHAR(*s); )
Branch: 1 branch
BranchTrueFalseTotal
for (d = s; isWORDCHAR(*s); ) 0 0 0
423 0 s++;
424 0 split_to_array = TRUE;
425 0 ▶ if (d != s)
Branch: 1 branch
BranchTrueFalseTotal
if (d != s) 0 0 0
426 {
427 0 yylval = string(d,s-d);
428 0 XTERM(SVFIELD);
429 }
430 0 XOP(VFIELD);
431  
432 0 case '/': /* may either be division or pattern */
433 0 ▶ if (expectterm) {
Branch: 1 branch
BranchTrueFalseTotal
if (expectterm) { 0 0 0
434 0 s = scanpat(s);
435 0 XTERM(REGEX);
436 }
437 0 tmp = *s++;
438 0 ▶ if (*s == '=') {
Branch: 1 branch
BranchTrueFalseTotal
if (*s == '=') { 0 0 0
439 0 yylval = string("/=",2);
440 0 s++;
441 0 XTERM(ASGNOP);
442 }
443 0 XTERM(tmp);
444  
445 0 case '0': case '1': case '2': case '3': case '4':
446 case '5': case '6': case '7': case '8': case '9': case '.':
447 0 s = scannum(s);
448 0 XOP(NUMBER);
449 0 case '"':
450 0 s++;
451 0 s = cpy2(tokenbuf,s,s[-1]);
452 0 ▶ if (!*s)
Branch: 1 branch
BranchTrueFalseTotal
if (!*s) 0 0 0
453 0 ▶ fatal("String not terminated:\n%s",str_get(linestr));
Branch: 1 branch
BranchTrueFalseTotal
fatal("String not terminated:\n%s",str_get(linestr)); 0 0 0
454 0 s++;
455 0 yylval = string(tokenbuf,0);
456 0 XOP(STRING);
457  
458 0 case 'a': case 'A':
459 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
460 0 ▶ if (strEQ(d,"ARGV")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"ARGV")) { 0 0 0
461 0 yylval=numary(string("ARGV",0));
462 0 XOP(VAR);
463 }
464 0 ▶ if (strEQ(d,"atan2")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"atan2")) { 0 0 0
465 0 yylval = OATAN2;
466 0 XTERM(FUNN);
467 }
468 0 ID(d);
469 0 case 'b': case 'B':
470 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
471 0 ▶ if (strEQ(d,"break"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"break")) 0 0 0
472 0 XTERM(BREAK);
473 0 ▶ if (strEQ(d,"BEGIN"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"BEGIN")) 0 0 0
474 0 XTERM(BEGIN);
475 0 ID(d);
476 0 case 'c': case 'C':
477 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
478 0 ▶ if (strEQ(d,"continue"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"continue")) 0 0 0
479 0 XTERM(CONTINUE);
480 0 ▶ if (strEQ(d,"cos")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"cos")) { 0 0 0
481 0 yylval = OCOS;
482 0 XTERM(FUN1);
483 }
484 0 ▶ if (strEQ(d,"close")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"close")) { 0 0 0
485 0 do_fancy_opens = 1;
486 0 yylval = OCLOSE;
487 0 XTERM(FUN1);
488 }
489 0 ▶ if (strEQ(d,"chdir"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"chdir")) 0 0 0
490 0 *d = toUPPER(*d);
491 0 ▶ else if (strEQ(d,"crypt"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"crypt")) 0 0 0
492 0 *d = toUPPER(*d);
493 0 ▶ else if (strEQ(d,"chop"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"chop")) 0 0 0
494 0 *d = toUPPER(*d);
495 0 ▶ else if (strEQ(d,"chmod"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"chmod")) 0 0 0
496 0 *d = toUPPER(*d);
497 0 ▶ else if (strEQ(d,"chown"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"chown")) 0 0 0
498 0 *d = toUPPER(*d);
499 0 ID(d);
500 0 case 'd': case 'D':
501 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
502 0 ▶ if (strEQ(d,"do"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"do")) 0 0 0
503 0 XTERM(DO);
504 0 ▶ if (strEQ(d,"delete"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"delete")) 0 0 0
505 0 XTERM(DELETE);
506 0 ▶ if (strEQ(d,"die"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"die")) 0 0 0
507 0 *d = toUPPER(*d);
508 0 ID(d);
509 0 case 'e': case 'E':
510 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
511 0 ▶ if (strEQ(d,"END"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"END")) 0 0 0
512 0 XTERM(END);
513 0 ▶ if (strEQ(d,"else"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"else")) 0 0 0
514 0 XTERM(ELSE);
515 0 ▶ if (strEQ(d,"exit")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"exit")) { 0 0 0
516 0 saw_line_op = TRUE;
517 0 XTERM(EXIT);
518 }
519 0 ▶ if (strEQ(d,"exp")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"exp")) { 0 0 0
520 0 yylval = OEXP;
521 0 XTERM(FUN1);
522 }
523 0 ▶ if (strEQ(d,"elsif"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"elsif")) 0 0 0
524 0 *d = toUPPER(*d);
525 0 ▶ else if (strEQ(d,"eq"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"eq")) 0 0 0
526 0 *d = toUPPER(*d);
527 0 ▶ else if (strEQ(d,"eval"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"eval")) 0 0 0
528 0 *d = toUPPER(*d);
529 0 ▶ else if (strEQ(d,"eof"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"eof")) 0 0 0
530 0 *d = toUPPER(*d);
531 0 ▶ else if (strEQ(d,"each"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"each")) 0 0 0
532 0 *d = toUPPER(*d);
533 0 ▶ else if (strEQ(d,"exec"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"exec")) 0 0 0
534 0 *d = toUPPER(*d);
535 0 ID(d);
536 0 case 'f': case 'F':
537 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
538 0 ▶ if (strEQ(d,"FS")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"FS")) { 0 0 0
539 0 saw_FS++;
540 0 ▶ if (saw_FS == 1 && in_begin) {
Branch: 2 branches
BranchTrueFalseTotal
if (saw_FS == 1 && in_begin) { 0 0 0
if (saw_FS == 1 && in_begin) { 0 0 0
541 0 ▶ for (d = s; *d && isSPACE(*d); d++) ;
Branch: 2 branches
BranchTrueFalseTotal
for (d = s; *d && isSPACE(*d); d++) ; 0 0 0
for (d = s; *d && isSPACE(*d); d++) ; 0 0 0
542 0 ▶ if (*d == '=') {
Branch: 1 branch
BranchTrueFalseTotal
if (*d == '=') { 0 0 0
543 0 ▶ for (d++; *d && isSPACE(*d); d++) ;
Branch: 2 branches
BranchTrueFalseTotal
for (d++; *d && isSPACE(*d); d++) ; 0 0 0
for (d++; *d && isSPACE(*d); d++) ; 0 0 0
544 0 ▶ if (*d == '"' && d[2] == '"')
Branch: 2 branches
BranchTrueFalseTotal
if (*d == '"' && d[2] == '"') 0 0 0
if (*d == '"' && d[2] == '"') 0 0 0
545 0 const_FS = d[1];
546 }
547 }
548 0 ID(tokenbuf);
549 }
550 0 ▶ if (strEQ(d,"for"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"for")) 0 0 0
551 0 XTERM(FOR);
552 0 ▶ else if (strEQ(d,"function"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"function")) 0 0 0
553 0 XTERM(FUNCTION);
554 0 ▶ if (strEQ(d,"FILENAME"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"FILENAME")) 0 0 0
555 0 ID("ARGV");
556 0 ▶ if (strEQ(d,"foreach"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"foreach")) 0 0 0
557 0 *d = toUPPER(*d);
558 0 ▶ else if (strEQ(d,"format"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"format")) 0 0 0
559 0 *d = toUPPER(*d);
560 0 ▶ else if (strEQ(d,"fork"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"fork")) 0 0 0
561 0 *d = toUPPER(*d);
562 0 ▶ else if (strEQ(d,"fh"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"fh")) 0 0 0
563 0 *d = toUPPER(*d);
564 0 ID(d);
565 0 case 'g': case 'G':
566 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
567 0 ▶ if (strEQ(d,"getline"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"getline")) 0 0 0
568 0 XTERM(GETLINE);
569 0 ▶ if (strEQ(d,"gsub"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"gsub")) 0 0 0
570 0 XTERM(GSUB);
571 0 ▶ if (strEQ(d,"ge"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"ge")) 0 0 0
572 0 *d = toUPPER(*d);
573 0 ▶ else if (strEQ(d,"gt"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"gt")) 0 0 0
574 0 *d = toUPPER(*d);
575 0 ▶ else if (strEQ(d,"goto"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"goto")) 0 0 0
576 0 *d = toUPPER(*d);
577 0 ▶ else if (strEQ(d,"gmtime"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"gmtime")) 0 0 0
578 0 *d = toUPPER(*d);
579 0 ID(d);
580 0 case 'h': case 'H':
581 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
582 0 ▶ if (strEQ(d,"hex"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"hex")) 0 0 0
583 0 *d = toUPPER(*d);
584 0 ID(d);
585 0 case 'i': case 'I':
586 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
587 0 ▶ if (strEQ(d,"if"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"if")) 0 0 0
588 0 XTERM(IF);
589 0 ▶ if (strEQ(d,"in"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"in")) 0 0 0
590 0 XTERM(IN);
591 0 ▶ if (strEQ(d,"index")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"index")) { 0 0 0
592 0 XTERM(INDEX);
593 }
594 0 ▶ if (strEQ(d,"int")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"int")) { 0 0 0
595 0 yylval = OINT;
596 0 XTERM(FUN1);
597 }
598 0 ID(d);
599 0 case 'j': case 'J':
600 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
601 0 ▶ if (strEQ(d,"join"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"join")) 0 0 0
602 0 *d = toUPPER(*d);
603 0 ID(d);
604 0 case 'k': case 'K':
605 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
606 0 ▶ if (strEQ(d,"keys"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"keys")) 0 0 0
607 0 *d = toUPPER(*d);
608 0 ▶ else if (strEQ(d,"kill"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"kill")) 0 0 0
609 0 *d = toUPPER(*d);
610 0 ID(d);
611 0 case 'l': case 'L':
612 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
613 0 ▶ if (strEQ(d,"length")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"length")) { 0 0 0
614 0 yylval = OLENGTH;
615 0 XTERM(FUN1);
616 }
617 0 ▶ if (strEQ(d,"log")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"log")) { 0 0 0
618 0 yylval = OLOG;
619 0 XTERM(FUN1);
620 }
621 0 ▶ if (strEQ(d,"last"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"last")) 0 0 0
622 0 *d = toUPPER(*d);
623 0 ▶ else if (strEQ(d,"local"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"local")) 0 0 0
624 0 *d = toUPPER(*d);
625 0 ▶ else if (strEQ(d,"lt"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"lt")) 0 0 0
626 0 *d = toUPPER(*d);
627 0 ▶ else if (strEQ(d,"le"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"le")) 0 0 0
628 0 *d = toUPPER(*d);
629 0 ▶ else if (strEQ(d,"locatime"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"locatime")) 0 0 0
630 0 *d = toUPPER(*d);
631 0 ▶ else if (strEQ(d,"link"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"link")) 0 0 0
632 0 *d = toUPPER(*d);
633 0 ID(d);
634 0 case 'm': case 'M':
635 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
636 0 ▶ if (strEQ(d,"match")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"match")) { 0 0 0
637 0 XTERM(MATCH);
638 }
639 0 ▶ if (strEQ(d,"m"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"m")) 0 0 0
640 0 *d = toUPPER(*d);
641 0 ID(d);
642 0 case 'n': case 'N':
643 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
644 0 ▶ if (strEQ(d,"NF"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"NF")) 0 0 0
645 0 do_chop = do_split = split_to_array = TRUE;
646 0 ▶ if (strEQ(d,"next")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"next")) { 0 0 0
647 0 saw_line_op = TRUE;
648 0 XTERM(NEXT);
649 }
650 0 ▶ if (strEQ(d,"ne"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"ne")) 0 0 0
651 0 *d = toUPPER(*d);
652 0 ID(d);
653 0 case 'o': case 'O':
654 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
655 0 ▶ if (strEQ(d,"ORS")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"ORS")) { 0 0 0
656 0 saw_ORS = TRUE;
657 0 ID("\\");
658 }
659 0 ▶ if (strEQ(d,"OFS")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"OFS")) { 0 0 0
660 0 saw_OFS = TRUE;
661 0 ID(",");
662 }
663 0 ▶ if (strEQ(d,"OFMT")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"OFMT")) { 0 0 0
664 0 ID("#");
665 }
666 0 ▶ if (strEQ(d,"open"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"open")) 0 0 0
667 0 *d = toUPPER(*d);
668 0 ▶ else if (strEQ(d,"ord"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"ord")) 0 0 0
669 0 *d = toUPPER(*d);
670 0 ▶ else if (strEQ(d,"oct"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"oct")) 0 0 0
671 0 *d = toUPPER(*d);
672 0 ID(d);
673 0 case 'p': case 'P':
674 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
675 0 ▶ if (strEQ(d,"print")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"print")) { 0 0 0
676 0 XTERM(PRINT);
677 }
678 0 ▶ if (strEQ(d,"printf")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"printf")) { 0 0 0
679 0 XTERM(PRINTF);
680 }
681 0 ▶ if (strEQ(d,"push"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"push")) 0 0 0
682 0 *d = toUPPER(*d);
683 0 ▶ else if (strEQ(d,"pop"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"pop")) 0 0 0
684 0 *d = toUPPER(*d);
685 0 ID(d);
686 0 case 'q': case 'Q':
687 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
688 0 ID(d);
689 0 case 'r': case 'R':
690 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
691 0 ▶ if (strEQ(d,"RS")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"RS")) { 0 0 0
692 0 saw_RS = TRUE;
693 0 ID("/");
694 }
695 0 ▶ if (strEQ(d,"rand")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"rand")) { 0 0 0
696 0 yylval = ORAND;
697 0 XTERM(FUN1);
698 }
699 0 ▶ if (strEQ(d,"return"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"return")) 0 0 0
700 0 XTERM(RET);
701 0 ▶ if (strEQ(d,"reset"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"reset")) 0 0 0
702 0 *d = toUPPER(*d);
703 0 ▶ else if (strEQ(d,"redo"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"redo")) 0 0 0
704 0 *d = toUPPER(*d);
705 0 ▶ else if (strEQ(d,"rename"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"rename")) 0 0 0
706 0 *d = toUPPER(*d);
707 0 ID(d);
708 0 case 's': case 'S':
709 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
710 0 ▶ if (strEQ(d,"split")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"split")) { 0 0 0
711 0 XOP(SPLIT);
712 }
713 0 ▶ if (strEQ(d,"substr")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"substr")) { 0 0 0
714 0 XTERM(SUBSTR);
715 }
716 0 ▶ if (strEQ(d,"sub"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"sub")) 0 0 0
717 0 XTERM(SUB);
718 0 ▶ if (strEQ(d,"sprintf")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"sprintf")) { 0 0 0
719 /* In old awk, { print sprintf("str%sg"),"in" } prints
720 * "string"; in new awk, "in" is not considered an argument to
721 * sprintf, so the statement breaks. To support both, the
722 * grammar treats arguments to SPRINTF_OLD like old awk,
723 * SPRINTF_NEW like new. Here we return the appropriate one.
724 */
725 0 ▶ XTERM(old_awk ? SPRINTF_OLD : SPRINTF_NEW);
Branch: 1 branch
BranchTrueFalseTotal
XTERM(old_awk ? SPRINTF_OLD : SPRINTF_NEW); 0 0 0
726 }
727 0 ▶ if (strEQ(d,"sqrt")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"sqrt")) { 0 0 0
728 0 yylval = OSQRT;
729 0 XTERM(FUN1);
730 }
731 0 ▶ if (strEQ(d,"SUBSEP")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"SUBSEP")) { 0 0 0
732 0 ID(";");
733 }
734 0 ▶ if (strEQ(d,"sin")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"sin")) { 0 0 0
735 0 yylval = OSIN;
736 0 XTERM(FUN1);
737 }
738 0 ▶ if (strEQ(d,"srand")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"srand")) { 0 0 0
739 0 yylval = OSRAND;
740 0 XTERM(FUN1);
741 }
742 0 ▶ if (strEQ(d,"system")) {
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"system")) { 0 0 0
743 0 yylval = OSYSTEM;
744 0 XTERM(FUN1);
745 }
746 0 ▶ if (strEQ(d,"s"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"s")) 0 0 0
747 0 *d = toUPPER(*d);
748 0 ▶ else if (strEQ(d,"shift"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"shift")) 0 0 0
749 0 *d = toUPPER(*d);
750 0 ▶ else if (strEQ(d,"select"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"select")) 0 0 0
751 0 *d = toUPPER(*d);
752 0 ▶ else if (strEQ(d,"seek"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"seek")) 0 0 0
753 0 *d = toUPPER(*d);
754 0 ▶ else if (strEQ(d,"stat"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"stat")) 0 0 0
755 0 *d = toUPPER(*d);
756 0 ▶ else if (strEQ(d,"study"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"study")) 0 0 0
757 0 *d = toUPPER(*d);
758 0 ▶ else if (strEQ(d,"sleep"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"sleep")) 0 0 0
759 0 *d = toUPPER(*d);
760 0 ▶ else if (strEQ(d,"symlink"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"symlink")) 0 0 0
761 0 *d = toUPPER(*d);
762 0 ▶ else if (strEQ(d,"sort"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"sort")) 0 0 0
763 0 *d = toUPPER(*d);
764 0 ID(d);
765 0 case 't': case 'T':
766 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
767 0 ▶ if (strEQ(d,"tr"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"tr")) 0 0 0
768 0 *d = toUPPER(*d);
769 0 ▶ else if (strEQ(d,"tell"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"tell")) 0 0 0
770 0 *d = toUPPER(*d);
771 0 ▶ else if (strEQ(d,"time"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"time")) 0 0 0
772 0 *d = toUPPER(*d);
773 0 ▶ else if (strEQ(d,"times"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"times")) 0 0 0
774 0 *d = toUPPER(*d);
775 0 ID(d);
776 0 case 'u': case 'U':
777 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
778 0 ▶ if (strEQ(d,"until"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"until")) 0 0 0
779 0 *d = toUPPER(*d);
780 0 ▶ else if (strEQ(d,"unless"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"unless")) 0 0 0
781 0 *d = toUPPER(*d);
782 0 ▶ else if (strEQ(d,"umask"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"umask")) 0 0 0
783 0 *d = toUPPER(*d);
784 0 ▶ else if (strEQ(d,"unshift"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"unshift")) 0 0 0
785 0 *d = toUPPER(*d);
786 0 ▶ else if (strEQ(d,"unlink"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"unlink")) 0 0 0
787 0 *d = toUPPER(*d);
788 0 ▶ else if (strEQ(d,"utime"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"utime")) 0 0 0
789 0 *d = toUPPER(*d);
790 0 ID(d);
791 0 case 'v': case 'V':
792 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
793 0 ▶ if (strEQ(d,"values"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"values")) 0 0 0
794 0 *d = toUPPER(*d);
795 0 ID(d);
796 0 case 'w': case 'W':
797 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
798 0 ▶ if (strEQ(d,"while"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"while")) 0 0 0
799 0 XTERM(WHILE);
800 0 ▶ if (strEQ(d,"write"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"write")) 0 0 0
801 0 *d = toUPPER(*d);
802 0 ▶ else if (strEQ(d,"wait"))
Branch: 1 branch
BranchTrueFalseTotal
else if (strEQ(d,"wait")) 0 0 0
803 0 *d = toUPPER(*d);
804 0 ID(d);
805 0 case 'x': case 'X':
806 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
807 0 ▶ if (strEQ(d,"x"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"x")) 0 0 0
808 0 *d = toUPPER(*d);
809 0 ID(d);
810 0 case 'y': case 'Y':
811 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
812 0 ▶ if (strEQ(d,"y"))
Branch: 1 branch
BranchTrueFalseTotal
if (strEQ(d,"y")) 0 0 0
813 0 *d = toUPPER(*d);
814 0 ID(d);
815 0 case 'z': case 'Z':
816 0 ▶ SNARFWORD;
Branch: 2 branches
BranchTrueFalseTotal
SNARFWORD; 0 0 0
SNARFWORD; 0 0 0
817 0 ID(d);
818 }
819 }
820  
821 char *
822 0 scanpat(char *s)
823 {
824 char *d;
825  
826 0 ▶ switch (*s++) {
Branch: 1 branch
BranchTrueFalseTotal
switch (*s++) { 0 0 0
827 0 case '/':
828 0 break;
829 0 default:
830 0 ▶ fatal("Search pattern not found:\n%s",str_get(linestr));
Branch: 1 branch
BranchTrueFalseTotal
fatal("Search pattern not found:\n%s",str_get(linestr)); 0 0 0
831 }
832  
833 0 d = tokenbuf;
834 0 ▶ for (; *s; s++,d++) {
Branch: 1 branch
BranchTrueFalseTotal
for (; *s; s++,d++) { 0 0 0
835 0 ▶ if (*s == '\\') {
Branch: 1 branch
BranchTrueFalseTotal
if (*s == '\\') { 0 0 0
836 0 ▶ if (s[1] == '/')
Branch: 1 branch
BranchTrueFalseTotal
if (s[1] == '/') 0 0 0
837 0 *d++ = *s++;
838 0 ▶ else if (s[1] == '\\')
Branch: 1 branch
BranchTrueFalseTotal
else if (s[1] == '\\') 0 0 0
839 0 *d++ = *s++;
840 0 ▶ else if (s[1] == '[')
Branch: 1 branch
BranchTrueFalseTotal
else if (s[1] == '[') 0 0 0
841 0 *d++ = *s++;
842 }
843 0 ▶ else if (*s == '[') {
Branch: 1 branch
BranchTrueFalseTotal
else if (*s == '[') { 0 0 0
844 0 *d++ = *s++;
845 do {
846 0 ▶ if (*s == '\\' && s[1])
Branch: 2 branches
BranchTrueFalseTotal
if (*s == '\\' && s[1]) 0 0 0
if (*s == '\\' && s[1]) 0 0 0
847 0 *d++ = *s++;
848 0 ▶ if (*s == '/' || (*s == '-' && s[1] == ']'))
Branch: 3 branches
BranchTrueFalseTotal
if (*s == '/' || (*s == '-' && s[1] == ']')) 0 0 0
if (*s == '/' || (*s == '-' && s[1] == ']')) 0 0 0
if (*s == '/' || (*s == '-' && s[1] == ']')) 0 0 0
849 0 *d++ = '\\';
850 0 *d++ = *s++;
851 0 ▶ } while (*s && *s != ']');
Branch: 2 branches
BranchTrueFalseTotal
} while (*s && *s != ']'); 0 0 0
} while (*s && *s != ']'); 0 0 0
852 }
853 0 ▶ else if (*s == '/')
Branch: 1 branch
BranchTrueFalseTotal
else if (*s == '/') 0 0 0
854 0 break;
855 0 *d = *s;
856 }
857 0 *d = '\0';
858  
859 0 ▶ if (!*s)
Branch: 1 branch
BranchTrueFalseTotal
if (!*s) 0 0 0
860 0 ▶ fatal("Search pattern not terminated:\n%s",str_get(linestr));
Branch: 1 branch
BranchTrueFalseTotal
fatal("Search pattern not terminated:\n%s",str_get(linestr)); 0 0 0
861 0 s++;
862 0 yylval = string(tokenbuf,0);
863 0 return s;
864 }
865  
866 void
867 0 yyerror(const char *s)
868 {
869 0 fprintf(stderr,"%s in file %s at line %d\n",
870 s,filename,line);
871 0 }
872  
873 char *
874 0 scannum(char *s)
875 {
876 char *d;
877  
878 0 ▶ switch (*s) {
Branch: 1 branch
BranchTrueFalseTotal
switch (*s) { 0 0 0
879 0 case '1': case '2': case '3': case '4': case '5':
880 case '6': case '7': case '8': case '9': case '0' : case '.':
881 0 d = tokenbuf;
882 0 ▶ while (isDIGIT(*s)) {
Branch: 1 branch
BranchTrueFalseTotal
while (isDIGIT(*s)) { 0 0 0
883 0 *d++ = *s++;
884 }
885 0 ▶ if (*s == '.') {
Branch: 1 branch
BranchTrueFalseTotal
if (*s == '.') { 0 0 0
886 0 ▶ if (isDIGIT(s[1])) {
Branch: 1 branch
BranchTrueFalseTotal
if (isDIGIT(s[1])) { 0 0 0
887 0 *d++ = *s++;
888 0 ▶ while (isDIGIT(*s)) {
Branch: 1 branch
BranchTrueFalseTotal
while (isDIGIT(*s)) { 0 0 0
889 0 *d++ = *s++;
890 }
891 }
892 else
893 0 s++;
894 }
895 0 ▶ if (strchr("eE",*s) && strchr("+-0123456789",s[1])) {
Branch: 2 branches
BranchTrueFalseTotal
if (strchr("eE",*s) && strchr("+-0123456789",s[1])) { 0 0 0
if (strchr("eE",*s) && strchr("+-0123456789",s[1])) { 0 0 0
896 0 *d++ = *s++;
897 0 ▶ if (*s == '+' || *s == '-')
Branch: 2 branches
BranchTrueFalseTotal
if (*s == '+' || *s == '-') 0 0 0
if (*s == '+' || *s == '-') 0 0 0
898 0 *d++ = *s++;
899 0 ▶ while (isDIGIT(*s))
Branch: 1 branch
BranchTrueFalseTotal
while (isDIGIT(*s)) 0 0 0
900 0 *d++ = *s++;
901 }
902 0 *d = '\0';
903 0 yylval = string(tokenbuf,0);
904 0 break;
905 }
906 0 return s;
907 }
908  
909 int
910 0 string(const char *ptr, int len)
911 {
912 0 int retval = mop;
913  
914 0 ops[mop++].ival = OSTRING + (1<<8);
915 0 ▶ if (!len)
Branch: 1 branch
BranchTrueFalseTotal
if (!len) 0 0 0
916 0 len = strlen(ptr);
917 0 ops[mop].cval = (char *) safemalloc(len+1);
918 0 strncpy(ops[mop].cval,ptr,len);
919 0 ops[mop++].cval[len] = '\0';
920 0 ▶ if (mop >= OPSMAX)
Branch: 1 branch
BranchTrueFalseTotal
if (mop >= OPSMAX) 0 0 0
921 0 fatal("Recompile a2p with larger OPSMAX\n");
922 0 return retval;
923 }
924  
925 int
926 0 oper0(int type)
927 {
928 0 int retval = mop;
929  
930 0 ▶ if (type > 255)
Branch: 1 branch
BranchTrueFalseTotal
if (type > 255) 0 0 0
931 0 fatal("type > 255 (%d)\n",type);
932 0 ops[mop++].ival = type;
933 0 ▶ if (mop >= OPSMAX)
Branch: 1 branch
BranchTrueFalseTotal
if (mop >= OPSMAX) 0 0 0
934 0 fatal("Recompile a2p with larger OPSMAX\n");
935 0 return retval;
936 }
937  
938 int
939 0 oper1(int type, int arg1)
940 {
941 0 int retval = mop;
942  
943 0 ▶ if (type > 255)
Branch: 1 branch
BranchTrueFalseTotal
if (type > 255) 0 0 0
944 0 fatal("type > 255 (%d)\n",type);
945 0 ops[mop++].ival = type + (1<<8);
946 0 ops[mop++].ival = arg1;
947 0 ▶ if (mop >= OPSMAX)
Branch: 1 branch
BranchTrueFalseTotal
if (mop >= OPSMAX) 0 0 0
948 0 fatal("Recompile a2p with larger OPSMAX\n");
949 0 return retval;
950 }
951  
952 int
953 0 oper2(int type, int arg1, int arg2)
954 {
955 0 int retval = mop;
956  
957 0 ▶ if (type > 255)
Branch: 1 branch
BranchTrueFalseTotal
if (type > 255) 0 0 0
958 0 fatal("type > 255 (%d)\n",type);
959 0 ops[mop++].ival = type + (2<<8);
960 0 ops[mop++].ival = arg1;
961 0 ops[mop++].ival = arg2;
962 0 ▶ if (mop >= OPSMAX)
Branch: 1 branch
BranchTrueFalseTotal
if (mop >= OPSMAX) 0 0 0
963 0 fatal("Recompile a2p with larger OPSMAX\n");
964 0 return retval;
965 }
966  
967 int
968 0 oper3(int type, int arg1, int arg2, int arg3)
969 {
970 0 int retval = mop;
971  
972 0 ▶ if (type > 255)
Branch: 1 branch
BranchTrueFalseTotal
if (type > 255) 0 0 0
973 0 fatal("type > 255 (%d)\n",type);
974 0 ops[mop++].ival = type + (3<<8);
975 0 ops[mop++].ival = arg1;
976 0 ops[mop++].ival = arg2;
977 0 ops[mop++].ival = arg3;
978 0 ▶ if (mop >= OPSMAX)
Branch: 1 branch
BranchTrueFalseTotal
if (mop >= OPSMAX) 0 0 0
979 0 fatal("Recompile a2p with larger OPSMAX\n");
980 0 return retval;
981 }
982  
983 int
984 0 oper4(int type, int arg1, int arg2, int arg3, int arg4)
985 {
986 0 int retval = mop;
987  
988 0 ▶ if (type > 255)
Branch: 1 branch
BranchTrueFalseTotal
if (type > 255) 0 0 0
989 0 fatal("type > 255 (%d)\n",type);
990 0 ops[mop++].ival = type + (4<<8);
991 0 ops[mop++].ival = arg1;
992 0 ops[mop++].ival = arg2;
993 0 ops[mop++].ival = arg3;
994 0 ops[mop++].ival = arg4;
995 0 ▶ if (mop >= OPSMAX)
Branch: 1 branch
BranchTrueFalseTotal
if (mop >= OPSMAX) 0 0 0
996 0 fatal("Recompile a2p with larger OPSMAX\n");
997 0 return retval;
998 }
999  
1000 int
1001 0 oper5(int type, int arg1, int arg2, int arg3, int arg4, int arg5)
1002 {
1003 0 int retval = mop;
1004  
1005 0 ▶ if (type > 255)
Branch: 1 branch
BranchTrueFalseTotal
if (type > 255) 0 0 0
1006 0 fatal("type > 255 (%d)\n",type);
1007 0 ops[mop++].ival = type + (5<<8);
1008 0 ops[mop++].ival = arg1;
1009 0 ops[mop++].ival = arg2;
1010 0 ops[mop++].ival = arg3;
1011 0 ops[mop++].ival = arg4;
1012 0 ops[mop++].ival = arg5;
1013 0 ▶ if (mop >= OPSMAX)
Branch: 1 branch
BranchTrueFalseTotal
if (mop >= OPSMAX) 0 0 0
1014 0 fatal("Recompile a2p with larger OPSMAX\n");
1015 0 return retval;
1016 }
1017  
1018 int depth = 0;
1019  
1020 void
1021 0 dump(int branch)
1022 {
1023 int type;
1024 int len;
1025 int i;
1026  
1027 0 type = ops[branch].ival;
1028 0 len = type >> 8;
1029 0 type &= 255;
1030 0 ▶ for (i=depth; i; i--)
Branch: 1 branch
BranchTrueFalseTotal
for (i=depth; i; i--) 0 0 0
1031 0 printf(" ");
1032 0 ▶ if (type == OSTRING) {
Branch: 1 branch
BranchTrueFalseTotal
if (type == OSTRING) { 0 0 0
1033 0 printf("%-5d\"%s\"\n",branch,ops[branch+1].cval);
1034 }
1035 else {
1036 0 printf("(%-5d%s %d\n",branch,opname[type],len);
1037 0 depth++;
1038 0 ▶ for (i=1; i<=len; i++)
Branch: 1 branch
BranchTrueFalseTotal
for (i=1; i<=len; i++) 0 0 0
1039 0 dump(ops[branch+i].ival);
1040 0 depth--;
1041 0 ▶ for (i=depth; i; i--)
Branch: 1 branch
BranchTrueFalseTotal
for (i=depth; i; i--) 0 0 0
1042 0 printf(" ");
1043 0 printf(")\n");
1044 }
1045 0 }
1046  
1047 int
1048 0 bl(int arg, int maybe)
1049 {
1050 0 ▶ if (!arg)
Branch: 1 branch
BranchTrueFalseTotal
if (!arg) 0 0 0
1051 0 return 0;
1052 0 ▶ else if ((ops[arg].ival & 255) != OBLOCK)
Branch: 1 branch
BranchTrueFalseTotal
else if ((ops[arg].ival & 255) != OBLOCK) 0 0 0
1053 0 return oper2(OBLOCK,arg,maybe);
1054 0 ▶ else if ((ops[arg].ival >> 8) < 2)
Branch: 1 branch
BranchTrueFalseTotal
else if ((ops[arg].ival >> 8) < 2) 0 0 0
1055 0 return oper2(OBLOCK,ops[arg+1].ival,maybe);
1056 else
1057 0 return arg;
1058 }
1059  
1060 void
1061 0 strmove(char* out, const char* in)
1062 {
1063 0 size_t len = strlen(in);
1064 0 memmove(out, in, len);
1065 0 out[len] = '\0';
1066 0 }
1067  
1068 void
1069 0 fixup(STR *str)
1070 {
1071 char *s;
1072 char *t;
1073  
1074 0 ▶ for (s = str->str_ptr; *s; s++) {
Branch: 1 branch
BranchTrueFalseTotal
for (s = str->str_ptr; *s; s++) { 0 0 0
1075 0 ▶ if (*s == ';' && s[1] == ' ' && s[2] == '\n') {
Branch: 3 branches
BranchTrueFalseTotal
if (*s == ';' && s[1] == ' ' && s[2] == '\n') { 0 0 0
if (*s == ';' && s[1] == ' ' && s[2] == '\n') { 0 0 0
if (*s == ';' && s[1] == ' ' && s[2] == '\n') { 0 0 0
1076 0 strmove(s+1,s+2);
1077 0 s++;
1078 }
1079 0 ▶ else if (*s == '\n') {
Branch: 1 branch
BranchTrueFalseTotal
else if (*s == '\n') { 0 0 0
1080 0 ▶ for (t = s+1; isSPACE(*t & 127); t++) ;
Branch: 1 branch
BranchTrueFalseTotal
for (t = s+1; isSPACE(*t & 127); t++) ; 0 0 0
1081 0 t--;
1082 0 ▶ while (isSPACE(*t & 127) && *t != '\n') t--;
Branch: 2 branches
BranchTrueFalseTotal
while (isSPACE(*t & 127) && *t != '\n') t--; 0 0 0
while (isSPACE(*t & 127) && *t != '\n') t--; 0 0 0
1083 0 ▶ if (*t == '\n' && t-s > 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (*t == '\n' && t-s > 1) { 0 0 0
if (*t == '\n' && t-s > 1) { 0 0 0
1084 0 ▶ if (s[-1] == '{')
Branch: 1 branch
BranchTrueFalseTotal
if (s[-1] == '{') 0 0 0
1085 0 s--;
1086 0 strmove(s+1,t);
1087 }
1088 0 s++;
1089 }
1090 }
1091 0 }
1092  
1093 void
1094 0 putlines(STR *str)
1095 {
1096 char *d, *s, *t, *e;
1097 int pos, newpos;
1098  
1099 0 d = tokenbuf;
1100 0 pos = 0;
1101 0 ▶ for (s = str->str_ptr; *s; s++) {
Branch: 1 branch
BranchTrueFalseTotal
for (s = str->str_ptr; *s; s++) { 0 0 0
1102 0 *d++ = *s;
1103 0 pos++;
1104 0 ▶ if (*s == '\n') {
Branch: 1 branch
BranchTrueFalseTotal
if (*s == '\n') { 0 0 0
1105 0 *d = '\0';
1106 0 d = tokenbuf;
1107 0 pos = 0;
1108 0 putone();
1109 }
1110 0 ▶ else if (*s == '\t')
Branch: 1 branch
BranchTrueFalseTotal
else if (*s == '\t') 0 0 0
1111 0 pos += 7;
1112 0 ▶ if (pos > 78) { /* split a long line? */
Branch: 1 branch
BranchTrueFalseTotal
if (pos > 78) { /* split a long line? */ 0 0 0
1113 0 *d-- = '\0';
1114 0 newpos = 0;
1115 0 ▶ for (t = tokenbuf; isSPACE(*t & 127); t++) {
Branch: 1 branch
BranchTrueFalseTotal
for (t = tokenbuf; isSPACE(*t & 127); t++) { 0 0 0
1116 0 ▶ if (*t == '\t')
Branch: 1 branch
BranchTrueFalseTotal
if (*t == '\t') 0 0 0
1117 0 newpos += 8;
1118 else
1119 0 newpos += 1;
1120 }
1121 0 e = d;
1122 0 ▶ while (d > tokenbuf && (*d != ' ' || d[-1] != ';'))
Branch: 3 branches
BranchTrueFalseTotal
while (d > tokenbuf && (*d != ' ' || d[-1] != ';')) 0 0 0
while (d > tokenbuf && (*d != ' ' || d[-1] != ';')) 0 0 0
while (d > tokenbuf && (*d != ' ' || d[-1] != ';')) 0 0 0
1123 0 d--;
1124 0 ▶ if (d < t+10) {
Branch: 1 branch
BranchTrueFalseTotal
if (d < t+10) { 0 0 0
1125 0 d = e;
1126 0 ▶ while (d > tokenbuf &&
Branch: 1 branch
BranchTrueFalseTotal
while (d > tokenbuf && 0 0 0
1127 0 ▶ (*d != ' ' || d[-1] != '|' || d[-2] != '|') )
Branch: 3 branches
BranchTrueFalseTotal
(*d != ' ' || d[-1] != '|' || d[-2] != '|') ) 0 0 0
(*d != ' ' || d[-1] != '|' || d[-2] != '|') ) 0 0 0
(*d != ' ' || d[-1] != '|' || d[-2] != '|') ) 0 0 0
1128 0 d--;
1129 }
1130 0 ▶ if (d < t+10) {
Branch: 1 branch
BranchTrueFalseTotal
if (d < t+10) { 0 0 0
1131 0 d = e;
1132 0 ▶ while (d > tokenbuf &&
Branch: 1 branch
BranchTrueFalseTotal
while (d > tokenbuf && 0 0 0
1133 0 ▶ (*d != ' ' || d[-1] != '&' || d[-2] != '&') )
Branch: 3 branches
BranchTrueFalseTotal
(*d != ' ' || d[-1] != '&' || d[-2] != '&') ) 0 0 0
(*d != ' ' || d[-1] != '&' || d[-2] != '&') ) 0 0 0
(*d != ' ' || d[-1] != '&' || d[-2] != '&') ) 0 0 0
1134 0 d--;
1135 }
1136 0 ▶ if (d < t+10) {
Branch: 1 branch
BranchTrueFalseTotal
if (d < t+10) { 0 0 0
1137 0 d = e;
1138 0 ▶ while (d > tokenbuf && (*d != ' ' || d[-1] != ','))
Branch: 3 branches
BranchTrueFalseTotal
while (d > tokenbuf && (*d != ' ' || d[-1] != ',')) 0 0 0
while (d > tokenbuf && (*d != ' ' || d[-1] != ',')) 0 0 0
while (d > tokenbuf && (*d != ' ' || d[-1] != ',')) 0 0 0
1139 0 d--;
1140 }
1141 0 ▶ if (d < t+10) {
Branch: 1 branch
BranchTrueFalseTotal
if (d < t+10) { 0 0 0
1142 0 d = e;
1143 0 ▶ while (d > tokenbuf && *d != ' ')
Branch: 2 branches
BranchTrueFalseTotal
while (d > tokenbuf && *d != ' ') 0 0 0
while (d > tokenbuf && *d != ' ') 0 0 0
1144 0 d--;
1145 }
1146 0 ▶ if (d > t+3) {
Branch: 1 branch
BranchTrueFalseTotal
if (d > t+3) { 0 0 0
1147 char save[2048];
1148 0 strcpy(save, d);
1149 0 *d = '\n';
1150 0 d[1] = '\0';
1151 0 putone();
1152 0 putchar('\n');
1153 0 ▶ if (d[-1] != ';' && !(newpos % 4)) {
Branch: 2 branches
BranchTrueFalseTotal
if (d[-1] != ';' && !(newpos % 4)) { 0 0 0
if (d[-1] != ';' && !(newpos % 4)) { 0 0 0
1154 0 *t++ = ' ';
1155 0 *t++ = ' ';
1156 0 newpos += 2;
1157 }
1158 0 strcpy(t,save+1);
1159 0 newpos += strlen(t);
1160 0 d = t + strlen(t);
1161 0 pos = newpos;
1162 }
1163 else
1164 0 d = e + 1;
1165 }
1166 }
1167 0 }
1168  
1169 void
1170 0 putone(void)
1171 {
1172 char *t;
1173  
1174 0 ▶ for (t = tokenbuf; *t; t++) {
Branch: 1 branch
BranchTrueFalseTotal
for (t = tokenbuf; *t; t++) { 0 0 0
1175 0 *t &= 127;
1176 0 ▶ if (*t == 127) {
Branch: 1 branch
BranchTrueFalseTotal
if (*t == 127) { 0 0 0
1177 0 *t = ' ';
1178 0 strcpy(t+strlen(t)-1, "\t#???\n");
1179 0 checkers++;
1180 }
1181 }
1182 0 t = tokenbuf;
1183 0 ▶ if (*t == '#') {
Branch: 1 branch
BranchTrueFalseTotal
if (*t == '#') { 0 0 0
1184 0 ▶ if (strnEQ(t,"#!/bin/awk",10) || strnEQ(t,"#! /bin/awk",11))
Branch: 2 branches
BranchTrueFalseTotal
if (strnEQ(t,"#!/bin/awk",10) || strnEQ(t,"#! /bin/awk",11)) 0 0 0
if (strnEQ(t,"#!/bin/awk",10) || strnEQ(t,"#! /bin/awk",11)) 0 0 0
1185 0 return;
1186 0 ▶ if (strnEQ(t,"#!/usr/bin/awk",14) || strnEQ(t,"#! /usr/bin/awk",15))
Branch: 2 branches
BranchTrueFalseTotal
if (strnEQ(t,"#!/usr/bin/awk",14) || strnEQ(t,"#! /usr/bin/awk",15)) 0 0 0
if (strnEQ(t,"#!/usr/bin/awk",14) || strnEQ(t,"#! /usr/bin/awk",15)) 0 0 0
1187 0 return;
1188 }
1189 0 fputs(tokenbuf,stdout);
1190 }
1191  
1192 int
1193 0 numary(int arg)
1194 {
1195 STR *key;
1196 int dummy;
1197  
1198 0 key = walk(0,0,arg,&dummy,P_MIN);
1199 0 str_cat(key,"[]");
1200 0 hstore(symtab,key->str_ptr,str_make("1"));
1201 0 str_free(key);
1202 0 return arg;
1203 }
1204  
1205 int
1206 0 rememberargs(int arg)
1207 {
1208 int type;
1209 STR *str;
1210  
1211 0 ▶ if (!arg)
Branch: 1 branch
BranchTrueFalseTotal
if (!arg) 0 0 0
1212 0 return arg;
1213 0 type = ops[arg].ival & 255;
1214 0 ▶ if (type == OCOMMA) {
Branch: 1 branch
BranchTrueFalseTotal
if (type == OCOMMA) { 0 0 0
1215 0 rememberargs(ops[arg+1].ival);
1216 0 rememberargs(ops[arg+3].ival);
1217 }
1218 0 ▶ else if (type == OVAR) {
Branch: 1 branch
BranchTrueFalseTotal
else if (type == OVAR) { 0 0 0
1219 0 str = str_new(0);
1220 0 hstore(curarghash,ops[ops[arg+1].ival+1].cval,str);
1221 }
1222 else
1223 0 fatal("panic: unknown argument type %d, line %d\n",type,line);
1224 0 return arg;
1225 }
1226  
1227 int
1228 0 aryrefarg(int arg)
1229 {
1230 0 int type = ops[arg].ival & 255;
1231 STR *str;
1232  
1233 0 ▶ if (type != OSTRING)
Branch: 1 branch
BranchTrueFalseTotal
if (type != OSTRING) 0 0 0
1234 0 fatal("panic: aryrefarg %d, line %d\n",type,line);
1235 0 str = hfetch(curarghash,ops[arg+1].cval);
1236 0 ▶ if (str)
Branch: 1 branch
BranchTrueFalseTotal
if (str) 0 0 0
1237 0 str_set(str,"*");
1238 0 return arg;
1239 }
1240  
1241 int
1242 0 fixfargs(int name, int arg, int prevargs)
1243 {
1244 int type;
1245 STR *str;
1246 0 int numargs = 0;
1247  
1248 0 ▶ if (!arg)
Branch: 1 branch
BranchTrueFalseTotal
if (!arg) 0 0 0
1249 0 return prevargs;
1250 0 type = ops[arg].ival & 255;
1251 0 ▶ if (type == OCOMMA) {
Branch: 1 branch
BranchTrueFalseTotal
if (type == OCOMMA) { 0 0 0
1252 0 numargs = fixfargs(name,ops[arg+1].ival,prevargs);
1253 0 numargs = fixfargs(name,ops[arg+3].ival,numargs);
1254 }
1255 0 ▶ else if (type == OVAR) {
Branch: 1 branch
BranchTrueFalseTotal
else if (type == OVAR) { 0 0 0
1256 0 str = hfetch(curarghash,ops[ops[arg+1].ival+1].cval);
1257 0 ▶ if (strEQ(str_get(str),"*")) {
Branch: 2 branches
BranchTrueFalseTotal
if (strEQ(str_get(str),"*")) { 0 0 0
if (strEQ(str_get(str),"*")) { 0 0 0
1258 char tmpbuf[128];
1259  
1260 0 str_set(str,""); /* in case another routine has this */
1261 0 ops[arg].ival &= ~255;
1262 0 ops[arg].ival |= OSTAR;
1263 0 sprintf(tmpbuf,"%s:%d",ops[name+1].cval,prevargs);
1264 0 fprintf(stderr,"Adding %s\n",tmpbuf);
1265 0 str = str_new(0);
1266 0 str_set(str,"*");
1267 0 hstore(curarghash,tmpbuf,str);
1268 }
1269 0 numargs = prevargs + 1;
1270 }
1271 else
1272 0 fatal("panic: unknown argument type %d, arg %d, line %d\n",
1273 type,prevargs+1,line);
1274 0 return numargs;
1275 }
1276  
1277 int
1278 0 fixrargs(char *name, int arg, int prevargs)
1279 {
1280 int type;
1281 STR *str;
1282 int numargs;
1283  
1284 0 ▶ if (!arg)
Branch: 1 branch
BranchTrueFalseTotal
if (!arg) 0 0 0
1285 0 return prevargs;
1286 0 type = ops[arg].ival & 255;
1287 0 ▶ if (type == OCOMMA) {
Branch: 1 branch
BranchTrueFalseTotal
if (type == OCOMMA) { 0 0 0
1288 0 numargs = fixrargs(name,ops[arg+1].ival,prevargs);
1289 0 numargs = fixrargs(name,ops[arg+3].ival,numargs);
1290 }
1291 else {
1292 0 char *tmpbuf = (char *) safemalloc(strlen(name) + (sizeof(prevargs) * 3) + 5);
1293 0 sprintf(tmpbuf,"%s:%d",name,prevargs);
1294 0 str = hfetch(curarghash,tmpbuf);
1295 0 safefree(tmpbuf);
1296 0 ▶ if (str && strEQ(str->str_ptr,"*")) {
Branch: 2 branches
BranchTrueFalseTotal
if (str && strEQ(str->str_ptr,"*")) { 0 0 0
if (str && strEQ(str->str_ptr,"*")) { 0 0 0
1297 0 ▶ if (type == OVAR || type == OSTAR) {
Branch: 2 branches
BranchTrueFalseTotal
if (type == OVAR || type == OSTAR) { 0 0 0
if (type == OVAR || type == OSTAR) { 0 0 0
1298 0 ops[arg].ival &= ~255;
1299 0 ops[arg].ival |= OSTAR;
1300 }
1301 else
1302 0 fatal("Can't pass expression by reference as arg %d of %s\n",
1303 prevargs+1, name);
1304 }
1305 0 numargs = prevargs + 1;
1306 }
1307 0 return numargs;
1308 }
« blib/lib/App/a2p.pm ↑ Summary hash.c »