# HG changeset patch # User Karl Heuer # Date 800239457 0 # Node ID 7646040d73830e863dc0db3ace16c0ef4c279f7b # Parent 562d7cdc38e3a6477990e2b429f999d10375ab51 (float_to_string): Fix type mismatch and simplify. diff -r 562d7cdc38e3 -r 7646040d7383 src/print.c --- a/src/print.c Fri May 12 00:19:09 1995 +0000 +++ b/src/print.c Fri May 12 00:44:17 1995 +0000 @@ -668,19 +668,21 @@ /* 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;