Lines Matching refs:vp
325 setfval(Cell *vp, Awkfloat f) in setfval() argument
329 if ((vp->tval & (NUM | STR)) == 0) in setfval()
330 funnyvar(vp, "assign to"); in setfval()
331 if (vp->tval & FLD) { in setfval()
333 i = fldidx(vp); in setfval()
337 } else if (vp->tval & REC) { in setfval()
341 vp->tval &= ~STR; /* mark string invalid */ in setfval()
342 vp->tval |= NUM; /* mark number ok */ in setfval()
343 dprintf(("setfval %p: %s = %g, t=%p\n", (void *)vp, in setfval()
344 vp->nval ? vp->nval : (unsigned char *)"NULL", in setfval()
345 f, (void *)vp->tval)); in setfval()
346 return (vp->fval = f); in setfval()
350 funnyvar(Cell *vp, char *rw) in funnyvar() argument
352 if (vp->tval & ARR) in funnyvar()
353 ERROR "can't %s %s; it's an array name.", rw, vp->nval FATAL; in funnyvar()
354 if (vp->tval & FCN) in funnyvar()
355 ERROR "can't %s %s; it's a function.", rw, vp->nval FATAL; in funnyvar()
357 vp, vp->nval, vp->sval, vp->fval, vp->tval CONT; in funnyvar()
361 setsval(Cell *vp, uchar *s) in setsval() argument
365 if ((vp->tval & (NUM | STR)) == 0) in setsval()
366 funnyvar(vp, "assign to"); in setsval()
367 if (vp->tval & FLD) { in setsval()
369 i = fldidx(vp); in setsval()
373 } else if (vp->tval & REC) { in setsval()
377 vp->tval &= ~NUM; in setsval()
378 vp->tval |= STR; in setsval()
379 if (freeable(vp)) in setsval()
380 xfree(vp->sval); in setsval()
381 vp->tval &= ~DONTFREE; in setsval()
383 (void *)vp, in setsval()
384 vp->nval ? (char *)vp->nval : "", in setsval()
386 (void *)(vp->tval ? (char *)vp->tval : ""))); in setsval()
387 return (vp->sval = tostring(s)); in setsval()
391 r_getfval(Cell *vp) in r_getfval() argument
393 if ((vp->tval & (NUM | STR)) == 0) in r_getfval()
394 funnyvar(vp, "read value of"); in r_getfval()
395 if ((vp->tval & FLD) && donefld == 0) in r_getfval()
397 else if ((vp->tval & REC) && donerec == 0) in r_getfval()
399 if (!isnum(vp)) { /* not a number */ in r_getfval()
400 vp->fval = atof((const char *)vp->sval); /* best guess */ in r_getfval()
401 if (is_number(vp->sval) && !(vp->tval&CON)) in r_getfval()
402 vp->tval |= NUM; /* make NUM only sparingly */ in r_getfval()
405 (void *)vp, vp->nval, vp->fval, (void *)vp->tval)); in r_getfval()
406 return (vp->fval); in r_getfval()
410 r_getsval(Cell *vp) in r_getsval() argument
414 if ((vp->tval & (NUM | STR)) == 0) in r_getsval()
415 funnyvar(vp, "read value of"); in r_getsval()
416 if ((vp->tval & FLD) && donefld == 0) in r_getsval()
418 else if ((vp->tval & REC) && donerec == 0) in r_getsval()
420 if ((vp->tval & STR) == 0) { in r_getsval()
421 if (!(vp->tval&DONTFREE)) in r_getsval()
422 xfree(vp->sval); in r_getsval()
423 if ((long long)vp->fval == vp->fval) { in r_getsval()
425 "%.20g", vp->fval); in r_getsval()
429 (char *)*OFMT, vp->fval); in r_getsval()
431 vp->sval = tostring(s); in r_getsval()
432 vp->tval &= ~DONTFREE; in r_getsval()
433 vp->tval |= STR; in r_getsval()
436 (void *)vp, in r_getsval()
437 vp->nval ? (char *)vp->nval : "", in r_getsval()
438 vp->sval ? (char *)vp->sval : "", in r_getsval()
439 (void *)vp->tval)); in r_getsval()
440 return (vp->sval); in r_getsval()