aboutsummaryrefslogtreecommitdiffstats
path: root/src/print.c
diff options
context:
space:
mode:
authorKarl Heuer1995-05-12 00:44:17 +0000
committerKarl Heuer1995-05-12 00:44:17 +0000
commit381cd4bb8ff3113edaf79c3af474efd5d0726133 (patch)
treec42f5dad4129371be037d1a5ef19a8140f51a541 /src/print.c
parent01d8fc64acb9482eb9443540f3229e572efa1c73 (diff)
downloademacs-381cd4bb8ff3113edaf79c3af474efd5d0726133.tar.gz
emacs-381cd4bb8ff3113edaf79c3af474efd5d0726133.zip
(float_to_string): Fix type mismatch and simplify.
Diffstat (limited to 'src/print.c')
-rw-r--r--src/print.c20
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)
668 /* Check the width specification. */ 668 /* Check the width specification. */
669 width = -1; 669 width = -1;
670 if ('0' <= *cp && *cp <= '9') 670 if ('0' <= *cp && *cp <= '9')
671 for (width = 0; (*cp >= '0' && *cp <= '9'); cp++) 671 {
672 width = (width * 10) + (*cp - '0'); 672 width = 0;
673 do
674 width = (width * 10) + (*cp++ - '0');
675 while (*cp >= '0' && *cp <= '9');
676
677 /* A precision of zero is valid only for %f. */
678 if (width > DBL_DIG
679 || (width == 0 && *cp != 'f'))
680 goto lose;
681 }
673 682
674 if (*cp != 'e' && *cp != 'f' && *cp != 'g') 683 if (*cp != 'e' && *cp != 'f' && *cp != 'g')
675 goto lose; 684 goto lose;
676 685
677 /* A precision of zero is valid for %f; everything else requires
678 at least one. Width may be omitted anywhere. */
679 if (width != -1
680 && (width < (*cp != 'f')
681 || width > DBL_DIG))
682 goto lose;
683
684 if (cp[1] != 0) 686 if (cp[1] != 0)
685 goto lose; 687 goto lose;
686 688