Lines Matching +full:2 +full:- +full:cell
50 void tempfree(Cell *p) { in tempfree()
51 if (p->ctype == OCELL && (p->csub < CUNK || p->csub > CFREE)) { in tempfree()
52 WARNING("bad csub %d in Cell %d %s", in tempfree()
53 p->csub, p->ctype, p->sval); in tempfree()
80 Cell *tmps; /* free temporary cells for execution */
82 static Cell truecell ={ OBOOL, BTRUE, 0, 0, 1.0, NUM, NULL, NULL };
83 Cell *True = &truecell;
84 static Cell falsecell ={ OBOOL, BFALSE, 0, 0, 0.0, NUM, NULL, NULL };
85 Cell *False = &falsecell;
86 static Cell breakcell ={ OJUMP, JBREAK, 0, 0, 0.0, NUM, NULL, NULL };
87 Cell *jbreak = &breakcell;
88 static Cell contcell ={ OJUMP, JCONT, 0, 0, 0.0, NUM, NULL, NULL };
89 Cell *jcont = &contcell;
90 static Cell nextcell ={ OJUMP, JNEXT, 0, 0, 0.0, NUM, NULL, NULL };
91 Cell *jnext = &nextcell;
92 static Cell nextfilecell ={ OJUMP, JNEXTFILE, 0, 0, 0.0, NUM, NULL, NULL };
93 Cell *jnextfile = &nextfilecell;
94 static Cell exitcell ={ OJUMP, JEXIT, 0, 0, 0.0, NUM, NULL, NULL };
95 Cell *jexit = &exitcell;
96 static Cell retcell ={ OJUMP, JRET, 0, 0, 0.0, NUM, NULL, NULL };
97 Cell *jret = &retcell;
98 static Cell tempcell ={ OCELL, CTEMP, 0, EMPTY, 0.0, NUM|STR|DONTFREE, NULL, NULL };
118 int boff = pbptr ? *pbptr - *pbuf : 0; in adjbuf()
121 minlen += quantum - rminlen; in adjbuf()
145 Cell *execute(Node *u) /* execute a node of the parse tree */ in execute()
147 Cell *(*proc)(Node **, int); in execute()
148 Cell *x; in execute()
153 for (a = u; ; a = a->nnext) { in execute()
156 x = (Cell *) (a->narg[0]); in execute()
163 if (notlegal(a->nobj)) /* probably a Cell* but too risky to print */ in execute()
165 proc = proctab[a->nobj-FIRSTTOKEN]; in execute()
166 x = (*proc)(a->narg, a->nobj); in execute()
175 if (a->nnext == NULL) in execute()
182 Cell *program(Node **a, int n) /* execute an awk program */ in program()
183 { /* a[0] = BEGIN, a[1] = body, a[2] = END */ in program()
184 Cell *x; in program()
196 if (a[1] || a[2]) in program()
206 if (a[2]) { /* END */ in program()
207 x = execute(a[2]); in program()
218 Cell *fcncell; /* pointer to Cell for function */
219 Cell **args; /* pointer to array of arguments after execute */
220 Cell *retval; /* return value */
229 Cell *call(Node **a, int n) /* function call. very kludgy and fragile */ in call()
231 static const Cell newcopycell = { OCELL, CCOPY, 0, EMPTY, 0.0, NUM|STR|DONTFREE, NULL, NULL }; in call()
235 Cell *args[NARGS], *oargs[NARGS]; /* BUG: fixed size arrays */ in call()
236 Cell *y, *z, *fcn; in call()
240 s = fcn->nval; in call()
248 for (ncall = 0, x = a[1]; x != NULL; x = x->nnext) /* args in call */ in call()
250 ndef = (int) fcn->fval; /* args in defn */ in call()
251 DPRINTF("calling %s, %d args (%d in defn), frp=%d\n", s, ncall, ndef, (int) (frp-frame)); in call()
257 for (i = 0, x = a[1]; x != NULL; i++, x = x->nnext) { /* get call args */ in call()
258 DPRINTF("evaluate args[%d], frp=%d:\n", i, (int) (frp-frame)); in call()
262 i, NN(y->nval), y->fval, isarr(y) ? "(array)" : NN(y->sval), y->tval); in call()
264 FATAL("can't use function %s as argument in %s", y->nval, s); in call()
277 int dfp = frp - frame; /* old index */ in call()
283 frp->fcncell = fcn; in call()
284 frp->args = args; in call()
285 frp->nargs = ndef; /* number defined with (excess are locals) */ in call()
286 frp->retval = gettemp(); in call()
288 DPRINTF("start exec of %s, frp=%d\n", s, (int) (frp-frame)); in call()
289 y = execute((Node *)(fcn->sval)); /* execute body */ in call()
290 DPRINTF("finished exec of %s, frp=%d\n", s, (int) (frp-frame)); in call()
293 Cell *t = frp->args[i]; in call()
295 if (t->csub == CCOPY) { in call()
298 t->csub = CTEMP; in call()
301 oargs[i]->tval = t->tval; in call()
302 oargs[i]->tval &= ~(STR|NUM|DONTFREE); in call()
303 oargs[i]->sval = t->sval; in call()
308 t->csub = CTEMP; in call()
310 } else if (t == y && t->csub == CCOPY) { in call()
311 t->csub = CTEMP; in call()
322 z = frp->retval; /* return value */ in call()
323 DPRINTF("%s returns %g |%s| %o\n", s, getfval(z), getsval(z), z->tval); in call()
324 frp--; in call()
328 Cell *copycell(Cell *x) /* make a copy of a cell in a temp */ in copycell()
330 Cell *y; in copycell()
335 y->tval = x->tval & ~(CON|FLD|REC); in copycell()
336 y->csub = CCOPY; /* prevents freeing until call is over */ in copycell()
337 y->nval = x->nval; /* BUG? */ in copycell()
338 if (isstr(x) /* || x->ctype == OCELL */) { in copycell()
339 y->sval = tostring(x->sval); in copycell()
340 y->tval &= ~DONTFREE; in copycell()
342 y->tval |= DONTFREE; in copycell()
343 y->fval = x->fval; in copycell()
347 Cell *arg(Node **a, int n) /* nth argument of a function */ in arg()
351 DPRINTF("arg(%d), frp->nargs=%d\n", n, frp->nargs); in arg()
352 if (n+1 > frp->nargs) in arg()
354 n+1, frp->fcncell->nval); in arg()
355 return frp->args[n]; in arg()
358 Cell *jump(Node **a, int n) /* break, continue, next, nextfile, return */ in jump()
360 Cell *y; in jump()
373 if ((y->tval & (STR|NUM)) == (STR|NUM)) { in jump()
374 setsval(frp->retval, getsval(y)); in jump()
375 frp->retval->fval = getfval(y); in jump()
376 frp->retval->tval |= NUM; in jump()
378 else if (y->tval & STR) in jump()
379 setsval(frp->retval, getsval(y)); in jump()
380 else if (y->tval & NUM) in jump()
381 setfval(frp->retval, getfval(y)); in jump()
383 FATAL("bad type variable %d", y->tval); in jump()
402 Cell *awkgetline(Node **a, int n) /* get next line from specific input */ in awkgetline()
403 { /* a[0] is variable, a[1] is operator, a[2] is filename */ in awkgetline()
404 Cell *r, *x; in awkgetline()
405 extern Cell **fldtab; in awkgetline()
419 x = execute(a[2]); /* filename */ in awkgetline()
426 n = -1; in awkgetline()
434 if (is_number(x->sval, & result)) { in awkgetline()
435 x->fval = result; in awkgetline()
436 x->tval |= NUM; in awkgetline()
441 if (is_number(fldtab[0]->sval, & result)) { in awkgetline()
442 fldtab[0]->fval = result; in awkgetline()
443 fldtab[0]->tval |= NUM; in awkgetline()
454 if (is_number(x->sval, & result)) { in awkgetline()
455 x->fval = result; in awkgetline()
456 x->tval |= NUM; in awkgetline()
467 Cell *getnf(Node **a, int n) /* get NF */ in getnf()
471 return (Cell *) a[0]; in getnf()
488 for (; p; p = p->nnext) { in makearraystring()
489 Cell *x = execute(p); /* expr */ in makearraystring()
492 size_t nsub = p->nnext ? seplen : 0; in makearraystring()
498 func, x->nval, buf); in makearraystring()
511 Cell *array(Node **a, int n) /* a[0] is symtab, a[1] is list of subscripts */ in array()
513 Cell *x, *z; in array()
516 x = execute(a[0]); /* Cell* for symbol table */ in array()
519 DPRINTF("making %s into an array\n", NN(x->nval)); in array()
521 xfree(x->sval); in array()
522 x->tval &= ~(STR|NUM|DONTFREE); in array()
523 x->tval |= ARR; in array()
524 x->sval = (char *) makesymtab(NSYMTAB); in array()
526 z = setsymtab(buf, "", 0.0, STR|NUM, (Array *) x->sval); in array()
527 z->ctype = OCELL; in array()
528 z->csub = CVAR; in array()
534 Cell *awkdelete(Node **a, int n) /* a[0] is symtab, a[1] is list of subscripts */ in awkdelete()
536 Cell *x; in awkdelete()
538 x = execute(a[0]); /* Cell* for symbol table */ in awkdelete()
546 x->tval &= ~STR; in awkdelete()
547 x->tval |= ARR; in awkdelete()
548 x->sval = (char *) makesymtab(NSYMTAB); in awkdelete()
558 Cell *intest(Node **a, int n) /* a[0] is index (list), a[1] is symtab */ in intest()
560 Cell *ap, *k; in intest()
565 DPRINTF("making %s into an array\n", ap->nval); in intest()
567 xfree(ap->sval); in intest()
568 ap->tval &= ~(STR|NUM|DONTFREE); in intest()
569 ap->tval |= ARR; in intest()
570 ap->sval = (char *) makesymtab(NSYMTAB); in intest()
573 k = lookup(buf, (Array *) ap->sval); in intest()
583 /* ======== utf-8 code ========== */
586 * Awk strings can contain ascii, random 8-bit items (eg Latin-1),
587 * or utf-8. u8_isutf tests whether a string starts with a valid
588 * utf-8 sequence, and returns 0 if not (e.g., high bit set).
590 * 1 for ascii, 2..4 for utf-8, or 1 for high bit non-utf.
591 * u8_strlen returns length of string in valid utf-8 sequences
592 * and/or high-bit bytes. Conversion functions go between byte
595 * In theory, this behaves the same as before for non-utf8 bytes.
600 /* is s the beginning of a valid utf-8 string? */
612 if (n >= 2 && ((c>>5) & 0x7) == 0x6 && (s[1] & 0xC0) == 0x80) { in u8_isutf()
613 ret = 2; /* 110xxxxx 10xxxxxx */ in u8_isutf()
615 && (s[2] & 0xC0) == 0x80) { in u8_isutf()
618 && (s[2] & 0xC0) == 0x80 && (s[3] & 0xC0) == 0x80) { in u8_isutf()
626 /* Convert (prefix of) utf8 string to utf-32 rune. */
641 if (n >= 2 && ((c>>5) & 0x7) == 0x6 && (s[1] & 0xC0) == 0x80) { in u8_rune()
643 ret = 2; in u8_rune()
645 && (s[2] & 0xC0) == 0x80) { in u8_rune()
646 *rune = ((c & 0xF) << 12) | ((s[1] & 0x3F) << 6) | (s[2] & 0x3F); in u8_rune()
650 && (s[2] & 0xC0) == 0x80 && (s[3] & 0xC0) == 0x80) { in u8_rune()
651 *rune = ((c & 0x7) << 18) | ((s[1] & 0x3F) << 12) | ((s[2] & 0x3F) << 6) | (s[3] & 0x3F); in u8_rune()
661 /* return length of next sequence: 1 for ascii or random, 2..4 for valid utf8 */
672 /* return number of utf characters or single non-utf bytes */
694 /* convert utf-8 char number in a string to its byte offset */
704 charnum--; in u8_char2byte()
709 /* convert byte offset in s to utf-8 char number that starts there */
718 return -1; /* ??? */ in u8_byte2char()
739 Bit5 = 2,
741 T1 = ((1<<(Bit1+1))-1) ^ 0xFF, /* 0000 0000 */
742 Tx = ((1<<(Bitx+1))-1) ^ 0xFF, /* 1000 0000 */
743 T2 = ((1<<(Bit2+1))-1) ^ 0xFF, /* 1100 0000 */
744 T3 = ((1<<(Bit3+1))-1) ^ 0xFF, /* 1110 0000 */
745 T4 = ((1<<(Bit4+1))-1) ^ 0xFF, /* 1111 0000 */
746 T5 = ((1<<(Bit5+1))-1) ^ 0xFF, /* 1111 1000 */
748 Rune1 = (1<<(Bit1+0*Bitx))-1, /* 0000 0000 0000 0000 0111 1111 */
749 Rune2 = (1<<(Bit2+1*Bitx))-1, /* 0000 0000 0000 0111 1111 1111 */
750 Rune3 = (1<<(Bit3+2*Bitx))-1, /* 0000 0000 1111 1111 1111 1111 */
751 Rune4 = (1<<(Bit4+3*Bitx))-1, /* 0011 1111 1111 1111 1111 1111 */
753 Maskx = (1<<Bitx)-1, /* 0011 1111 */
760 /* one character sequence 00000-0007F => 00-7F */ in runetochar()
766 /* two character sequence 00080-007FF => T2 Tx */ in runetochar()
770 return 2; in runetochar()
773 /* three character sequence 00800-0FFFF => T3 Tx Tx */ in runetochar()
777 str[0] = T3 | (c >> 2*Bitx); in runetochar()
779 str[2] = Tx | (c & Maskx); in runetochar()
783 /* four character sequence 010000-1FFFFF => T4 Tx Tx Tx */ in runetochar()
785 str[1] = Tx | ((c >> 2*Bitx) & Maskx); in runetochar()
786 str[2] = Tx | ((c >> 1*Bitx) & Maskx); in runetochar()
796 Cell *matchop(Node **a, int n) /* ~ and match() */ in matchop()
798 Cell *x, *y, *z; in matchop()
811 if (a[0] == NULL) /* a[1] == 0: already-compiled reg expr */ in matchop()
812 i = (*mf)((fa *) a[2], s); in matchop()
814 y = execute(a[2]); /* a[2] = regular expr */ in matchop()
822 int start = patbeg - s + 1; /* origin 1 */ in matchop()
826 cstart = u8_byte2char(s, start-1); in matchop()
840 x->tval = NUM; in matchop()
841 x->fval = start; in matchop()
852 Cell *boolop(Node **a, int n) /* a[0] || a[1], a[0] && a[1], !a[0] */ in boolop()
854 Cell *x, *y; in boolop()
884 Cell *relop(Node **a, int n) /* a[0 < a[1], etc. */ in relop()
887 Cell *x, *y; in relop()
893 x_is_nan = isnan(x->fval); in relop()
894 y_is_nan = isnan(y->fval); in relop()
895 if (x->tval&NUM && y->tval&NUM) { in relop()
898 j = x->fval - y->fval; in relop()
899 i = j<0? -1: (j>0? 1: 0); in relop()
925 void tfree(Cell *a) /* free a tempcell */ in tfree()
928 DPRINTF("freeing %s %s %o\n", NN(a->nval), NN(a->sval), a->tval); in tfree()
929 xfree(a->sval); in tfree()
933 a->cnext = tmps; in tfree()
937 Cell *gettemp(void) /* get a tempcell */ in gettemp()
939 Cell *x; in gettemp()
942 tmps = (Cell *) calloc(100, sizeof(*tmps)); in gettemp()
946 tmps[i-1].cnext = &tmps[i]; in gettemp()
947 tmps[i-1].cnext = NULL; in gettemp()
950 tmps = x->cnext; in gettemp()
955 Cell *indirect(Node **a, int n) /* $( a[0] ) */ in indirect()
958 Cell *x; in indirect()
965 FATAL("trying to access out of range field %s", x->nval); in indirect()
968 FATAL("illegal field $(%s), name \"%s\"", s, x->nval); in indirect()
969 /* BUG: can x->nval ever be null??? */ in indirect()
972 x->ctype = OCELL; /* BUG? why are these needed? */ in indirect()
973 x->csub = CFLD; in indirect()
977 Cell *substr(Node **a, int nnn) /* substr(a[0], a[1], a[2]) */ in substr()
983 Cell *x, *y, *z = NULL; in substr()
987 if (a[2] != NULL) in substr()
988 z = execute(a[2]); in substr()
994 if (a[2] != NULL) { in substr()
1007 if (a[2] != NULL) { in substr()
1011 n = k - 1; in substr()
1014 else if (n > k - m) in substr()
1015 n = k - m; in substr()
1019 mb = u8_char2byte(s, m-1); /* byte offset of start char in s */ in substr()
1020 nb = u8_char2byte(s, m-1+n); /* byte offset of end+1 char in s */ in substr()
1030 Cell *sindex(Node **a, int nnn) /* index(a[0], a[1]) */ in sindex()
1032 Cell *x, *y, *z; in sindex()
1046 /* v = (Awkfloat) (p1 - s1 + 1); origin 1 */ in sindex()
1051 for (i = 0; i < p1-s1+1; i += len) { in sindex()
1064 int has_utf8(char *s) /* return 1 if s contains any utf-8 (2 bytes or more) character */ in has_utf8()
1078 int format(char **pbuf, int *pbufsize, const char *s, Node *a) /* printf-like conversions */ in format()
1083 Cell *x; in format()
1089 #define FMTSZ(a) (fmtsz - ((a) - fmt)) in format()
1090 #define BUFSZ(a) (bufsize - ((a) - buf)) in format()
1108 adjbuf(&buf, &bufsize, MAXNUMSIZE+1+p-buf, recsize, &p, "format1"); in format()
1115 s += 2; in format()
1120 fmtwd = -fmtwd; in format()
1121 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format2"); in format()
1123 if (!adjbuf(&fmt, &fmtsz, MAXNUMSIZE+1+t-fmt, recsize, &t, "format3")) in format()
1127 t--; in format()
1140 a = a->nnext; in format()
1141 snprintf(t - 1, FMTSZ(t - 1), in format()
1144 fmtwd = -fmtwd; in format()
1145 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format"); in format()
1152 fmtwd = -fmtwd; in format()
1153 adjbuf(&buf, &bufsize, fmtwd+1+p-buf, recsize, &p, "format4"); in format()
1166 *(t-1) = 'j'; in format()
1184 a = a->nnext; in format()
1188 adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format5"); in format()
1196 adjbuf(&buf, &bufsize, 1+strlen(p)+n+p-buf, recsize, &p, "format6"); in format()
1209 /* if simple format or no utf-8 in the string, sprintf works */ in format()
1213 if (!adjbuf(&buf, &bufsize, 1+n+p-buf, recsize, &p, "format7")) in format()
1220 /* get here if string has utf-8 chars and fmt is not plain %s */ in format()
1221 /* "%-w.ps", where -, w and .p are all optional */ in format()
1226 if (f[0] == '-') { in format()
1249 pad = wid>prec ? wid - prec : 0; // has to be >= 0 in format()
1286 * our best to convert it back into UTF-8. If we in format()
1320 if (n < 2) { /* not utf8 */ in format()
1328 if (f[0] == '-') { in format()
1349 if (prec > 1) // %c --> only one character in format()
1351 pad = wid>prec ? wid - prec : 0; // has to be >= 0 in format()
1382 for ( ; a; a = a->nnext) { /* evaluate any remaining args */ in format()
1388 return p - buf; in format()
1391 Cell *awksprintf(Node **a, int n) /* sprintf(a[0]) */ in awksprintf()
1393 Cell *x; in awksprintf()
1400 y = a[0]->nnext; in awksprintf()
1402 if (format(&buf, &bufsz, getsval(x), y) == -1) in awksprintf()
1406 x->sval = buf; in awksprintf()
1407 x->tval = STR; in awksprintf()
1411 Cell *awkprintf(Node **a, int n) /* printf */ in awkprintf()
1413 /* a[1] is redirection operator, a[2] is redirection file */ in awkprintf()
1415 Cell *x; in awkprintf()
1423 y = a[0]->nnext; in awkprintf()
1425 if ((len = format(&buf, &bufsz, getsval(x), y)) == -1) in awkprintf()
1434 fp = redirect(ptoi(a[1]), a[2]); in awkprintf()
1445 Cell *arith(Node **a, int n) /* a[0] + a[1], etc. also -a[0] */ in arith()
1449 Cell *x, *y, *z; in arith()
1465 i -= j; in arith()
1479 i = i - j * v; in arith()
1482 i = -i; in arith()
1507 v = ipow(x, n/2); in ipow()
1508 if (n % 2 == 0) in ipow()
1514 Cell *incrdecr(Node **a, int n) /* a[0]++, etc. */ in incrdecr()
1516 Cell *x, *z; in incrdecr()
1522 k = (n == PREINCR || n == POSTINCR) ? 1 : -1; in incrdecr()
1534 Cell *assign(Node **a, int n) /* a[0] = a[1], a[0] += a[1], etc. */ in assign()
1536 Cell *x, *y; in assign()
1543 if (x == y && !(x->tval & (FLD|REC)) && x != nfloc) in assign()
1544 ; /* self-assignment: leave alone unless it's a field or NF */ in assign()
1545 else if ((y->tval & (STR|NUM)) == (STR|NUM)) { in assign()
1548 x->fval = yf; in assign()
1549 x->tval |= NUM; in assign()
1567 xf -= yf; in assign()
1581 xf = xf - yf * v; in assign()
1600 Cell *cat(Node **a, int q) /* a[0] cat a[1] */ in cat()
1602 Cell *x, *y, *z; in cat()
1610 memcpy(s, x->sval, n1); in cat()
1617 memcpy(s + n1, y->sval, n2); in cat()
1623 z->sval = s; in cat()
1624 z->tval = STR; in cat()
1629 Cell *pastat(Node **a, int n) /* a[0] { a[1] } */ in pastat()
1631 Cell *x; in pastat()
1645 Cell *dopa2(Node **a, int n) /* a[0], a[1] { a[2] } */ in dopa2()
1647 Cell *x; in dopa2()
1662 x = execute(a[2]); in dopa2()
1668 Cell *split(Node **a, int nnn) /* split(a[0], a[1], a[2]); a[3] is type */ in split()
1670 Cell *x = NULL, *y, *ap; in split()
1684 if (a[2] == NULL) { /* BUG: CSV should override implicit fs but not explicit */ in split()
1687 x = execute(a[2]); in split()
1699 DPRINTF("split: s=|%s|, a=%s, sep=|%s|\n", s, NN(ap->nval), fs); in split()
1700 ap->tval &= ~STR; in split()
1701 ap->tval |= ARR; in split()
1702 ap->sval = (char *) makesymtab(NSYMTAB); in split()
1705 if (arg3type == REGEXPR && strlen((char*)((fa*)a[2])->restr) == 0) { in split()
1714 pfa = (fa *) a[2]; in split()
1719 tempstat = pfa->initstat; in split()
1720 pfa->initstat = 2; in split()
1727 setsymtab(num, s, result, STR|NUM, (Array *) ap->sval); in split()
1729 setsymtab(num, s, 0.0, STR, (Array *) ap->sval); in split()
1732 if (*(patbeg+patlen-1) == '\0' || *s == '\0') { in split()
1735 setsymtab(num, "", 0.0, STR, (Array *) ap->sval); in split()
1736 pfa->initstat = tempstat; in split()
1740 pfa->initstat = tempstat; /* bwk: has to be here to reset */ in split()
1746 setsymtab(num, s, result, STR|NUM, (Array *) ap->sval); in split()
1748 setsymtab(num, s, 0.0, STR, (Array *) ap->sval); in split()
1752 } else if (a[2] == NULL && CSV) { /* CSV only if no explicit separator */ in split()
1760 s += 2; /* doubled quote */ in split()
1777 setsymtab(num, newt, result, STR|NUM, (Array *) ap->sval); in split()
1779 setsymtab(num, newt, 0.0, STR, (Array *) ap->sval); in split()
1801 setsymtab(num, t, result, STR|NUM, (Array *) ap->sval); in split()
1803 setsymtab(num, t, 0.0, STR, (Array *) ap->sval); in split()
1821 setsymtab(num, buf, atof(buf), STR|NUM, (Array *) ap->sval); in split()
1823 setsymtab(num, buf, 0.0, STR, (Array *) ap->sval); in split()
1836 setsymtab(num, t, result, STR|NUM, (Array *) ap->sval); in split()
1838 setsymtab(num, t, 0.0, STR, (Array *) ap->sval); in split()
1848 x->tval = NUM; in split()
1849 x->fval = n; in split()
1853 Cell *condexpr(Node **a, int n) /* a[0] ? a[1] : a[2] */ in condexpr()
1855 Cell *x; in condexpr()
1863 x = execute(a[2]); in condexpr()
1868 Cell *ifstat(Node **a, int n) /* if (a[0]) a[1]; else a[2] */ in ifstat()
1870 Cell *x; in ifstat()
1876 } else if (a[2] != NULL) { in ifstat()
1878 x = execute(a[2]); in ifstat()
1883 Cell *whilestat(Node **a, int n) /* while (a[0]) a[1] */ in whilestat()
1885 Cell *x; in whilestat()
1903 Cell *dostat(Node **a, int n) /* do a[0]; while(a[1]) */ in dostat()
1905 Cell *x; in dostat()
1921 Cell *forstat(Node **a, int n) /* for (a[0]; a[1]; a[2]) a[3] */ in forstat()
1923 Cell *x; in forstat()
1939 x = execute(a[2]); in forstat()
1944 Cell *instat(Node **a, int n) /* for (a[0] in a[1]) a[2] */ in instat()
1946 Cell *x, *vp, *arrayp, *cp, *ncp; in instat()
1955 tp = (Array *) arrayp->sval; in instat()
1957 for (i = 0; i < tp->size; i++) { /* this routine knows too much */ in instat()
1958 for (cp = tp->tab[i]; cp != NULL; cp = ncp) { in instat()
1959 setsval(vp, cp->nval); in instat()
1960 ncp = cp->cnext; in instat()
1961 x = execute(a[2]); in instat()
2011 n > 0 && n != (size_t)-1 && n != (size_t)-2) in nawk_convert()
2016 if (n == (size_t)-1) in nawk_convert()
2061 Cell *bltin(Node **a, int n) /* builtin functions. a[0] is type, a[1] is arg list */ in bltin()
2063 Cell *x, *y; in bltin()
2077 nextarg = a[1]->nnext; in bltin()
2081 u = ((Array *) x->sval)->nelem; /* GROT. should be function*/ in bltin()
2108 y = execute(a[1]->nnext); in bltin()
2111 nextarg = nextarg->nnext; in bltin()
2123 y = execute(a[1]->nnext); in bltin()
2126 nextarg = nextarg->nnext; in bltin()
2134 y = execute(a[1]->nnext); in bltin()
2137 nextarg = nextarg->nnext; in bltin()
2145 y = execute(a[1]->nnext); in bltin()
2148 nextarg = nextarg->nnext; in bltin()
2156 y = execute(a[1]->nnext); in bltin()
2159 nextarg = nextarg->nnext; in bltin()
2167 y = execute(a[1]->nnext); in bltin()
2170 nextarg = nextarg->nnext; in bltin()
2175 if (status != -1) { in bltin()
2187 /* else estatus was set to -1 */ in bltin()
2191 /* random() returns numbers in [0..2^31-1] in bltin()
2192 * in order to get a number in [0, 1), divide it by 2^31 in bltin()
2219 flush_all(); /* fflush() or fflush("") -> all */ in bltin()
2230 &tm->tm_year, &tm->tm_mon, &tm->tm_mday, &tm->tm_hour, in bltin()
2231 &tm->tm_min, &tm->tm_sec, &tm->tm_isdst); in bltin()
2234 tm->tm_isdst = -1; /* let mktime figure it out */ in bltin()
2237 tm->tm_year -= 1900; in bltin()
2238 tm->tm_mon--; in bltin()
2242 u = -1; in bltin()
2253 nextarg = nextarg->nnext; in bltin()
2271 if ((buf = realloc(buf, (sz *= 2))) == NULL) in bltin()
2290 for ( ; nextarg; nextarg = nextarg->nnext) { in bltin()
2298 Cell *printstat(Node **a, int n) /* print a[0] */ in printstat()
2301 Cell *y; in printstat()
2304 if (a[1] == NULL) /* a[1] is redirection operator, a[2] is file */ in printstat()
2307 fp = redirect(ptoi(a[1]), a[2]); in printstat()
2308 for (x = a[0]; x != NULL; x = x->nnext) { in printstat()
2312 if (x->nnext == NULL) in printstat()
2324 Cell *nullproc(Node **a, int n) in nullproc()
2333 Cell *x; in redirect()
2365 files[2].fp = stderr; in stdinit()
2366 files[2].fname = tostring("/dev/stderr"); in stdinit()
2367 files[2].mode = GT; in stdinit()
2415 fp = strcmp(s, "-") == 0 ? stdin : fopen(s, "r"); /* "-" is stdin */ in openfile()
2440 Cell *closefile(Node **a, int n) in closefile()
2442 Cell *x; in closefile()
2450 if (!files[i].fname || strcmp(x->sval, files[i].fname) != 0) in closefile()
2465 stat = pclose(files[i].fp) == -1; in closefile()
2477 setfval(x, (Awkfloat) (stat ? -1 : 0)); in closefile()
2502 stat = pclose(files[i].fp) == -1; in closeall()
2521 Cell *dosub(Node **a, int subop) /* sub and gsub */ in dosub()
2526 Cell *x; in dosub()
2539 if (a[0] == NULL) { /* 0 => a[1] is already-compiled regexpr */ in dosub()
2547 x = execute(a[2]); /* replacement string */ in dosub()
2569 tempstat = pfa->initstat; in dosub()
2570 pfa->initstat = 2; in dosub()
2576 #define MT_REPLACE 2 /* selected, not empty */ in dosub()
2590 adjbuf(&buf, &bufsz, (pb - buf) + (patbeg - start), in dosub()
2602 adjbuf(&buf, &bufsz, 5+pb-buf, recsize, &pb, "dosub"); in dosub()
2607 adjbuf(&buf, &bufsz, 1+patlen+pb-buf, recsize, in dosub()
2622 adjbuf(&buf, &bufsz, (pb-buf) + patlen, recsize, &pb, "dosub"); in dosub()
2642 pfa->initstat = tempstat; in dosub()
2645 adjbuf(&buf, &bufsz, 1+strlen(start)+pb-buf, 0, &pb, "dosub"); in dosub()
2655 x->tval = NUM; in dosub()
2656 x->fval = m; in dosub()
2660 Cell *gensub(Node **a, int nnn) /* global selective substitute */ in gensub()
2661 /* XXX incomplete - doesn't support backreferences \0 ... \9 */ in gensub()
2663 Cell *x, *y, *res, *h; in gensub()
2678 res = copycell(x); /* target string - initially copy of source */ in gensub()
2679 res->csub = CTEMP; /* result values are temporary */ in gensub()
2680 if (a[0] == 0) /* 0 => a[1] is already-compiled regexpr */ in gensub()
2687 y = execute(a[2]); /* replacement string */ in gensub()
2691 whichm = -1; in gensub()
2698 whichm = (int) getfval(h) - 1; in gensub()
2707 tempstat = pfa->initstat; in gensub()
2708 pfa->initstat = 2; in gensub()
2724 adjbuf(&buf, &bufsz, (pb - buf) + (patbeg - t) + patlen, recsize, &pb, "gensub"); in gensub()
2738 adjbuf(&buf, &bufsz, 5+pb-buf, recsize, &pb, "gensub"); in gensub()
2743 adjbuf(&buf, &bufsz, 1+patlen+pb-buf, recsize, &pb, "gensub"); in gensub()
2752 adjbuf(&buf, &bufsz, 2+pb-buf, recsize, &pb, "gensub"); in gensub()
2761 adjbuf(&buf, &bufsz, 1+(patbeg-sptr)+pb-buf, recsize, &pb, "gensub"); in gensub()
2766 adjbuf(&buf, &bufsz, 5+pb-buf, recsize, &pb, "gensub"); in gensub()
2771 adjbuf(&buf, &bufsz, 1+patlen+pb-buf, recsize, &pb, "gensub"); in gensub()
2778 if (patlen == 0 || *t == 0 || *(t-1) == 0) in gensub()
2786 adjbuf(&buf, &bufsz, 1+strlen(sptr)+pb-buf, 0, &pb, "gensub"); in gensub()
2793 pfa->initstat = tempstat; in gensub()
2814 if (sptr[2] == '\\' && sptr[3] == '&') { /* \\\& -> \& */ in backsub()
2818 } else if (sptr[2] == '&') { /* \\& -> \ + matched */ in backsub()
2820 sptr += 2; in backsub()
2821 } else if (do_posix) { /* \\x -> \x */ in backsub()
2824 } else { /* \\x -> \\x */ in backsub()
2862 // 0x00010000 - 0x10FFFF in wide_char_to_byte_str()