diff options
author | Kevin Ryde <user42@zip.com.au> | 2001-10-09 01:35:33 +0200 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2001-10-09 01:35:33 +0200 |
commit | 2084456812a1d659fcdbcf7e4e87c15a19869279 (patch) | |
tree | b53854e7b3e702c3e70f124118f5846dd0c8dbf2 | |
parent | 4a1be403e4d0106d19bee989da39ce2be5925e7b (diff) | |
download | gmp-2084456812a1d659fcdbcf7e4e87c15a19869279.tar.gz |
* printf/doprnt.c, tests/printf/t-printf.c: Remove support for %.*Fe
prec -1 meaning all digits.
-rw-r--r-- | printf/doprnt.c | 24 | ||||
-rw-r--r-- | tests/printf/t-printf.c | 5 |
2 files changed, 18 insertions, 11 deletions
diff --git a/printf/doprnt.c b/printf/doprnt.c index 42ed1f32a..123d60d9c 100644 --- a/printf/doprnt.c +++ b/printf/doprnt.c @@ -143,7 +143,11 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data, TRACE (printf ("gmp_doprnt \"%s\"\n", orig_fmt)); - /* don't modify orig_ap, if va_list is actually an array */ + /* Don't modify orig_ap, if va_list is actually an array and hence call by + reference. It could be argued that it'd be more efficient to leave the + caller to make a copy if it cared, but doing so here is going to be a + very small part of the total work, and we may as well keep applications + out of trouble. */ va_copy (ap, orig_ap); /* The format string is chopped up into pieces to be passed to @@ -436,13 +440,21 @@ __gmp_doprnt (const struct doprnt_funs_t *funs, void *data, { int n = va_arg (ap, int); - /* negative width means left justify */ - if (value == ¶m.width && n < 0) + if (value == ¶m.width) { - param.justify = DOPRNT_JUSTIFY_LEFT; - n = -n; + /* negative width means left justify */ + if (n < 0) + { + param.justify = DOPRNT_JUSTIFY_LEFT; + n = -n; + } + param.width = n; + } + else + { + /* don't allow negative precision */ + param.prec = MAX (0, n); } - *value = n; } break; diff --git a/tests/printf/t-printf.c b/tests/printf/t-printf.c index 9697f054b..59142ea35 100644 --- a/tests/printf/t-printf.c +++ b/tests/printf/t-printf.c @@ -750,11 +750,6 @@ check_misc (void) check_one ("12345 and 678", "%Zd and %d", z, 678); check_one ("12345,1,12345,2,12345", "%Zd,%d,%Zd,%d,%Zd", z, 1, z, 2, z); - mpf_set_str_or_abort (f, "0.99609375", 10); - check_one ("0.99609375", "%.*Ff", -1, f); - check_one ("9.9609375e-01", "%.*Fe", -1, f); - check_one ("0.99609375", "%.*Fg", -1, f); - mpz_clear (z); mpf_clear (f); } |