Lines Matching +full:1 +full:- +full:cell
50 Awkfloat *RSTART; /* start of re matched with ~; origin 1 (!) */
53 Cell *fsloc; /* FS */
54 Cell *nrloc; /* NR */
55 Cell *nfloc; /* NF */
56 Cell *fnrloc; /* FNR */
57 Cell *ofsloc; /* OFS */
58 Cell *orsloc; /* ORS */
59 Cell *rsloc; /* RS */
60 Cell *ARGVcell; /* cell with symbol table containing ARGV[...] */
61 Cell *rstartloc; /* RSTART */
62 Cell *rlengthloc; /* RLENGTH */
63 Cell *subseploc; /* SUBSEP */
64 Cell *symtabloc; /* SYMTAB */
66 Cell *nullloc; /* a guaranteed empty cell */
68 Cell *literal0;
70 extern Cell **fldtab;
80 FS = &fsloc->sval; in syminit()
82 RS = &rsloc->sval; in syminit()
84 OFS = &ofsloc->sval; in syminit()
86 ORS = &orsloc->sval; in syminit()
87 OFMT = &setsymtab("OFMT", "%.6g", 0.0, STR|DONTFREE, symtab)->sval; in syminit()
88 CONVFMT = &setsymtab("CONVFMT", "%.6g", 0.0, STR|DONTFREE, symtab)->sval; in syminit()
89 FILENAME = &setsymtab("FILENAME", "", 0.0, STR|DONTFREE, symtab)->sval; in syminit()
91 NF = &nfloc->fval; in syminit()
93 NR = &nrloc->fval; in syminit()
95 FNR = &fnrloc->fval; in syminit()
97 SUBSEP = &subseploc->sval; in syminit()
99 RSTART = &rstartloc->fval; in syminit()
101 RLENGTH = &rlengthloc->fval; in syminit()
103 free(symtabloc->sval); in syminit()
104 symtabloc->sval = (char *) symtab; in syminit()
110 Cell *cp; in arginit()
114 ARGC = &setsymtab("ARGC", "", (Awkfloat) ac, NUM, symtab)->fval; in arginit()
117 free(cp->sval); in arginit()
118 cp->sval = (char *) ap; in arginit()
135 Cell *cp; in envinit()
140 free(cp->sval); in envinit()
141 cp->sval = (char *) ap; in envinit()
154 p[-1] = '='; /* restore in case env is passed down to a shell */ in envinit()
161 Cell **tp; in makesymtab()
164 tp = (Cell **) calloc(n, sizeof(*tp)); in makesymtab()
167 ap->nelem = 0; in makesymtab()
168 ap->size = n; in makesymtab()
169 ap->tab = tp; in makesymtab()
173 void freesymtab(Cell *ap) /* free a symbol table */ in freesymtab()
175 Cell *cp, *temp; in freesymtab()
181 tp = (Array *) ap->sval; in freesymtab()
184 for (i = 0; i < tp->size; i++) { in freesymtab()
185 for (cp = tp->tab[i]; cp != NULL; cp = temp) { in freesymtab()
186 xfree(cp->nval); in freesymtab()
188 xfree(cp->sval); in freesymtab()
189 temp = cp->cnext; /* avoids freeing then using */ in freesymtab()
191 tp->nelem--; in freesymtab()
193 tp->tab[i] = NULL; in freesymtab()
195 if (tp->nelem != 0) in freesymtab()
196 WARNING("can't happen: inconsistent element count freeing %s", ap->nval); in freesymtab()
197 free(tp->tab); in freesymtab()
201 void freeelem(Cell *ap, const char *s) /* free elem s from ap (i.e., ap["s"] */ in freeelem()
204 Cell *p, *prev = NULL; in freeelem()
207 tp = (Array *) ap->sval; in freeelem()
208 h = hash(s, tp->size); in freeelem()
209 for (p = tp->tab[h]; p != NULL; prev = p, p = p->cnext) in freeelem()
210 if (strcmp(s, p->nval) == 0) { in freeelem()
211 if (prev == NULL) /* 1st one */ in freeelem()
212 tp->tab[h] = p->cnext; in freeelem()
214 prev->cnext = p->cnext; in freeelem()
216 xfree(p->sval); in freeelem()
217 free(p->nval); in freeelem()
219 tp->nelem--; in freeelem()
224 Cell *setsymtab(const char *n, const char *s, Awkfloat f, unsigned t, Array *tp) in setsymtab()
227 Cell *p; in setsymtab()
231 (void*)p, NN(p->nval), NN(p->sval), p->fval, p->tval); in setsymtab()
234 p = (Cell *) malloc(sizeof(*p)); in setsymtab()
237 p->nval = tostring(n); in setsymtab()
238 p->sval = s ? tostring(s) : tostring(""); in setsymtab()
239 p->fval = f; in setsymtab()
240 p->tval = t; in setsymtab()
241 p->csub = CUNK; in setsymtab()
242 p->ctype = OCELL; in setsymtab()
243 tp->nelem++; in setsymtab()
244 if (tp->nelem > FULLTAB * tp->size) in setsymtab()
246 h = hash(n, tp->size); in setsymtab()
247 p->cnext = tp->tab[h]; in setsymtab()
248 tp->tab[h] = p; in setsymtab()
250 (void*)p, p->nval, p->sval, p->fval, p->tval); in setsymtab()
266 Cell *cp, *op, **np; in rehash()
268 nsz = GROWTAB * tp->size; in rehash()
269 np = (Cell **) calloc(nsz, sizeof(*np)); in rehash()
272 for (i = 0; i < tp->size; i++) { in rehash()
273 for (cp = tp->tab[i]; cp; cp = op) { in rehash()
274 op = cp->cnext; in rehash()
275 nh = hash(cp->nval, nsz); in rehash()
276 cp->cnext = np[nh]; in rehash()
280 free(tp->tab); in rehash()
281 tp->tab = np; in rehash()
282 tp->size = nsz; in rehash()
285 Cell *lookup(const char *s, Array *tp) /* look for s in tp */ in lookup()
287 Cell *p; in lookup()
290 h = hash(s, tp->size); in lookup()
291 for (p = tp->tab[h]; p != NULL; p = p->cnext) in lookup()
292 if (strcmp(s, p->nval) == 0) in lookup()
297 Awkfloat setfval(Cell *vp, Awkfloat f) /* set float val of a Cell */ in setfval()
302 if ((vp->tval & (NUM | STR)) == 0) in setfval()
306 fldno = atoi(vp->nval); in setfval()
310 } else if (&vp->fval == NF) { in setfval()
315 donefld = false; /* mark $1... invalid */ in setfval()
323 xfree(vp->sval); /* free any previous string */ in setfval()
324 vp->tval &= ~(STR|CONVC|CONVO); /* mark string invalid */ in setfval()
325 vp->fmt = NULL; in setfval()
326 vp->tval |= NUM; /* mark number ok */ in setfval()
327 if (f == -0) /* who would have thought this possible? */ in setfval()
329 DPRINTF("setfval %p: %s = %g, t=%o\n", (void*)vp, NN(vp->nval), f, vp->tval); in setfval()
330 return vp->fval = f; in setfval()
333 void funnyvar(Cell *vp, const char *rw) in funnyvar()
336 FATAL("can't %s %s; it's an array name.", rw, vp->nval); in funnyvar()
337 if (vp->tval & FCN) in funnyvar()
338 FATAL("can't %s %s; it's a function.", rw, vp->nval); in funnyvar()
340 (void *)vp, vp->nval, vp->sval, vp->fval, vp->tval); in funnyvar()
343 char *setsval(Cell *vp, const char *s) /* set string val of a Cell */ in setsval()
350 (void*)vp, NN(vp->nval), s, vp->tval, donerec, donefld); in setsval()
351 if ((vp->tval & (NUM | STR)) == 0) in setsval()
354 WARNING("danger: don't set RS when --csv is in effect"); in setsval()
356 WARNING("danger: don't set FS when --csv is in effect"); in setsval()
359 fldno = atoi(vp->nval); in setsval()
364 donefld = false; /* mark $1... invalid */ in setsval()
371 t = s ? tostring(s) : tostring(""); /* in case it's self-assign */ in setsval()
373 xfree(vp->sval); in setsval()
374 vp->tval &= ~(NUM|DONTFREE|CONVC|CONVO); in setsval()
375 vp->tval |= STR; in setsval()
376 vp->fmt = NULL; in setsval()
378 (void*)vp, NN(vp->nval), t, (void*)t, vp->tval, donerec, donefld); in setsval()
379 vp->sval = t; in setsval()
380 if (&vp->fval == NF) { in setsval()
387 return(vp->sval); in setsval()
390 Awkfloat getfval(Cell *vp) /* get float val of a Cell */ in getfval()
392 if ((vp->tval & (NUM | STR)) == 0) in getfval()
402 if (is_valid_number(vp->sval, true, & no_trailing, & fval)) { in getfval()
403 vp->fval = fval; in getfval()
404 if (no_trailing && !(vp->tval&CON)) in getfval()
405 vp->tval |= NUM; /* make NUM only sparingly */ in getfval()
407 vp->fval = 0.0; in getfval()
410 (void*)vp, NN(vp->nval), vp->fval, vp->tval); in getfval()
411 return(vp->fval); in getfval()
417 return (d < 0 ? "-inf" : "+inf"); in get_inf_nan()
419 return (signbit(d) != 0 ? "-nan" : "+nan"); in get_inf_nan()
424 static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cell */ in get_str_val()
430 if ((vp->tval & (NUM | STR)) == 0) in get_str_val()
464 xfree(vp->sval); \ in get_str_val()
465 if ((p = get_inf_nan(vp->fval)) != NULL) \ in get_str_val()
467 else if (modf(vp->fval, &dtemp) == 0) /* it's integral */ \ in get_str_val()
468 snprintf(s, sizeof (s), "%.30g", vp->fval); \ in get_str_val()
470 snprintf(s, sizeof (s), *fmt, vp->fval); \ in get_str_val()
471 vp->sval = tostring(s); \ in get_str_val()
472 vp->tval &= ~DONTFREE; \ in get_str_val()
473 vp->tval |= STR; \ in get_str_val()
479 vp->tval &= ~CONVC; in get_str_val()
480 vp->tval |= CONVO; in get_str_val()
483 vp->tval &= ~CONVO; in get_str_val()
484 vp->tval |= CONVC; in get_str_val()
486 vp->fmt = *fmt; in get_str_val()
487 } else if ((vp->tval & DONTFREE) != 0 || ! isnum(vp) || isfld(vp)) { in get_str_val()
491 if ((vp->tval & CONVC) != 0 in get_str_val()
492 || ((vp->tval & CONVO) != 0 && vp->fmt != *fmt)) { in get_str_val()
494 vp->tval &= ~CONVC; in get_str_val()
495 vp->tval |= CONVO; in get_str_val()
496 vp->fmt = *fmt; in get_str_val()
500 if ((vp->tval & CONVO) != 0 in get_str_val()
501 || ((vp->tval & CONVC) != 0 && vp->fmt != *fmt)) { in get_str_val()
503 vp->tval &= ~CONVO; in get_str_val()
504 vp->tval |= CONVC; in get_str_val()
505 vp->fmt = *fmt; in get_str_val()
511 (void*)vp, NN(vp->nval), vp->sval, (void*)vp->sval, vp->tval); in get_str_val()
512 return(vp->sval); in get_str_val()
515 char *getsval(Cell *vp) /* get string val of a Cell */ in getsval()
520 char *getpssval(Cell *vp) /* get string val of a Cell for print */ in getpssval()
545 Cell *catstr(Cell *a, Cell *b) /* concatenate a and b */ in catstr()
547 Cell *c; in catstr()
551 size_t l = strlen(sa) + strlen(sb) + 1; in catstr()
603 n = c - '0'; in qstring()
604 if (isdigit(s[1])) { in qstring()
605 n = 8 * n + *++s - '0'; in qstring()
606 if (isdigit(s[1])) in qstring()
607 n = 8 * n + *++s - '0'; in qstring()