Lines Matching full:vp

297 Awkfloat setfval(Cell *vp, Awkfloat f)	/* set float val of a Cell */  in setfval()  argument
302 if ((vp->tval & (NUM | STR)) == 0) in setfval()
303 funnyvar(vp, "assign to"); in setfval()
304 if (isfld(vp)) { in setfval()
306 fldno = atoi(vp->nval); in setfval()
310 } else if (&vp->fval == NF) { in setfval()
314 } else if (isrec(vp)) { in setfval()
318 } else if (vp == ofsloc) { in setfval()
322 if (freeable(vp)) 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()
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() argument
335 if (isarr(vp)) 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() argument
350 (void*)vp, NN(vp->nval), s, vp->tval, donerec, donefld); in setsval()
351 if ((vp->tval & (NUM | STR)) == 0) in setsval()
352 funnyvar(vp, "assign to"); in setsval()
353 if (CSV && (vp == rsloc)) in setsval()
355 if (CSV && (vp == fsloc)) in setsval()
357 if (isfld(vp)) { in setsval()
359 fldno = atoi(vp->nval); in setsval()
363 } else if (isrec(vp)) { in setsval()
367 } else if (vp == ofsloc) { in setsval()
372 if (freeable(vp)) 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()
382 f = getfval(vp); in setsval()
387 return(vp->sval); in setsval()
390 Awkfloat getfval(Cell *vp) /* get float val of a Cell */ in getfval() argument
392 if ((vp->tval & (NUM | STR)) == 0) in getfval()
393 funnyvar(vp, "read value of"); in getfval()
394 if (isfld(vp) && !donefld) in getfval()
396 else if (isrec(vp) && !donerec) in getfval()
398 if (!isnum(vp)) { /* not a number */ 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()
424 static char *get_str_val(Cell *vp, char **fmt) /* get string val of a Cell */ in get_str_val() argument
430 if ((vp->tval & (NUM | STR)) == 0) in get_str_val()
431 funnyvar(vp, "read value of"); in get_str_val()
432 if (isfld(vp) && ! donefld) in get_str_val()
434 else if (isrec(vp) && ! donerec) in get_str_val()
461 #define update_str_val(vp) \ in get_str_val() argument
463 if (freeable(vp)) \ 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()
476 if (isstr(vp) == 0) { in get_str_val()
477 update_str_val(vp); 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()
489 } else if (isstr(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()
493 update_str_val(vp); 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()
502 update_str_val(vp); 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() argument
517 return get_str_val(vp, CONVFMT); in getsval()
520 char *getpssval(Cell *vp) /* get string val of a Cell for print */ in getpssval() argument
522 return get_str_val(vp, OFMT); in getpssval()