diff options
author | Larry Wall <lwall@jpl-devvax.jpl.nasa.gov> | 1990-10-16 02:28:17 +0000 |
---|---|---|
committer | Larry Wall <lwall@jpl-devvax.jpl.nasa.gov> | 1990-10-16 02:28:17 +0000 |
commit | d9d8d8de9462d72f6b4520fc11dd84dbe2c8bf1d (patch) | |
tree | 42dd9d991eecc159ab1e232be5f9941456228df0 /form.c | |
parent | c2ab57d4ffc80c0e2a9e968e66e52c289ac9ed45 (diff) | |
download | perl-d9d8d8de9462d72f6b4520fc11dd84dbe2c8bf1d.tar.gz |
perl 3.0 patch #32 patch #29, continued
See patch #29.
Diffstat (limited to 'form.c')
-rw-r--r-- | form.c | 30 |
1 files changed, 29 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Header: form.c,v 3.0.1.2 90/08/09 03:38:40 lwall Locked $ +/* $Header: form.c,v 3.0.1.3 90/10/15 17:26:24 lwall Locked $ * * Copyright (c) 1989, Larry Wall * @@ -6,6 +6,9 @@ * as specified in the README file that comes with the perl 3.0 kit. * * $Log: form.c,v $ + * Revision 3.0.1.3 90/10/15 17:26:24 lwall + * patch29: added @###.## fields to format + * * Revision 3.0.1.2 90/08/09 03:38:40 lwall * patch19: did preliminary work toward debugging packages and evals * @@ -281,6 +284,31 @@ int sp; d += size; linebeg = fcmd->f_next; break; + case F_DECIMAL: { + double value; + + (void)eval(fcmd->f_expr,G_SCALAR,sp); + str = stack->ary_array[sp+1]; + /* If the field is marked with ^ and the value is undefined, + blank it out. */ + if ((fcmd->f_flags & FC_CHOP) && !str->str_pok && !str->str_nok) { + while (size) { + size--; + *d++ = ' '; + } + break; + } + value = str_gnum(str); + size = fcmd->f_size; + CHKLEN(size); + if (fcmd->f_flags & FC_DP) { + sprintf(d, "%#*.*f", size, fcmd->f_decimals, value); + } else { + sprintf(d, "%*.0f", size, value); + } + d += size; + break; + } } } CHKLEN(1); |