summaryrefslogtreecommitdiff
path: root/printf/doprnt.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2001-10-09 01:35:33 +0200
committerKevin Ryde <user42@zip.com.au>2001-10-09 01:35:33 +0200
commit2084456812a1d659fcdbcf7e4e87c15a19869279 (patch)
treeb53854e7b3e702c3e70f124118f5846dd0c8dbf2 /printf/doprnt.c
parent4a1be403e4d0106d19bee989da39ce2be5925e7b (diff)
downloadgmp-2084456812a1d659fcdbcf7e4e87c15a19869279.tar.gz
* printf/doprnt.c, tests/printf/t-printf.c: Remove support for %.*Fe
prec -1 meaning all digits.
Diffstat (limited to 'printf/doprnt.c')
-rw-r--r--printf/doprnt.c24
1 files changed, 18 insertions, 6 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 == &param.width && n < 0)
+ if (value == &param.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;