]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Define NDIGIT_MAX.
authorUlrich Drepper <drepper@redhat.com>
Wed, 23 Jun 1999 12:40:47 +0000 (12:40 +0000)
committerUlrich Drepper <drepper@redhat.com>
Wed, 23 Jun 1999 12:40:47 +0000 (12:40 +0000)
(fcvt_r): Limit precision in snprintf call to NDIGIT_MAX.

misc/efgcvt_r.c

index 1c237eed4a9c9b60533d1f7d26e46ad9e798a8b8..167bd7a809414c5df0b715e716b7e9e066a0b044 100644 (file)
@@ -1,5 +1,5 @@
 /* Compatibility functions for floating point formatting, reentrant versions.
-   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
 #include <sys/param.h>
 
 #ifndef FLOAT_TYPE
-#define FLOAT_TYPE double
-#define FUNC_PREFIX
-#define FLOAT_FMT_FLAG
-#define FLOAT_NAME_EXT
+# define FLOAT_TYPE double
+# define FUNC_PREFIX
+# define FLOAT_FMT_FLAG
+# define FLOAT_NAME_EXT
+# define NDIGIT_MAX DBL_DIG
 #endif
 
 #define APPEND(a, b) APPEND2 (a, b)
@@ -87,7 +88,8 @@ APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
     /* Value is Inf or NaN.  */
     *sign = 0;
 
-  n = __snprintf (buf, len, "%.*" FLOAT_FMT_FLAG "f", ndigit, value);
+  n = __snprintf (buf, len, "%.*" FLOAT_FMT_FLAG "f", MIN (ndigit, NDIGIT_MAX),
+                 value);
   if (n < 0)
     return -1;