mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-02-17 10:27:41 +00:00
(float_to_string): Fix type mismatch and simplify.
This commit is contained in:
parent
01d8fc64ac
commit
381cd4bb8f
1 changed files with 11 additions and 9 deletions
20
src/print.c
20
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;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue