diff options
author | Karl Heuer <kwzh@gnu.org> | 1995-05-12 00:44:17 +0000 |
---|---|---|
committer | Karl Heuer <kwzh@gnu.org> | 1995-05-12 00:44:17 +0000 |
commit | 765b651c848cd5785241942ad38e52218c4c6455 (patch) | |
tree | 5299b0337b179732204b90fe0fbba183a6adc118 /src/print.c | |
parent | 72d9b52149f2995b158ed0e4133079cdae07922e (diff) | |
download | emacs-765b651c848cd5785241942ad38e52218c4c6455.tar.gz |
(float_to_string): Fix type mismatch and simplify.
Diffstat (limited to 'src/print.c')
-rw-r--r-- | src/print.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/print.c b/src/print.c index 3609684c640..1e83d1907e8 100644 --- a/src/print.c +++ b/src/print.c @@ -668,19 +668,21 @@ float_to_string (buf, data) /* Check the width specification. */ width = -1; if ('0' <= *cp && *cp <= '9') - for (width = 0; (*cp >= '0' && *cp <= '9'); cp++) - width = (width * 10) + (*cp - '0'); + { + width = 0; + do + width = (width * 10) + (*cp++ - '0'); + while (*cp >= '0' && *cp <= '9'); + + /* A precision of zero is valid only for %f. */ + if (width > DBL_DIG + || (width == 0 && *cp != 'f')) + goto lose; + } if (*cp != 'e' && *cp != 'f' && *cp != 'g') goto lose; - /* A precision of zero is valid for %f; everything else requires - at least one. Width may be omitted anywhere. */ - if (width != -1 - && (width < (*cp != 'f') - || width > DBL_DIG)) - goto lose; - if (cp[1] != 0) goto lose; |