version 1.9, 2003/04/04 00:42:34 |
version 1.10, 2003/04/06 06:12:01 |
|
|
if (freeable(vp)) |
if (freeable(vp)) |
xfree(vp->sval); |
xfree(vp->sval); |
if (modf(vp->fval, &dtemp) == 0) /* it's integral */ |
if (modf(vp->fval, &dtemp) == 0) /* it's integral */ |
sprintf(s, "%.30g", vp->fval); |
snprintf(s, sizeof(s), "%.30g", vp->fval); |
else |
else |
sprintf(s, *fmt, vp->fval); |
snprintf(s, sizeof(s), *fmt, vp->fval); |
vp->sval = tostring(s); |
vp->sval = tostring(s); |
vp->tval &= ~DONTFREE; |
vp->tval &= ~DONTFREE; |
vp->tval |= STR; |
vp->tval |= STR; |
|
|
|
|
char *tostring(const char *s) /* make a copy of string s */ |
char *tostring(const char *s) /* make a copy of string s */ |
{ |
{ |
char *p; |
return (strdup(s)); |
|
|
p = (char *) malloc(strlen(s)+1); |
|
if (p == NULL) |
|
FATAL("out of space in tostring on %s", s); |
|
strcpy(p, s); |
|
return(p); |
|
} |
} |
|
|
char *qstring(const char *is, int delim) /* collect string up to next delim */ |
char *qstring(const char *is, int delim) /* collect string up to next delim */ |