aboutsummaryrefslogtreecommitdiff
path: root/misc/efgcvt_r.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-01-31 02:43:20 +0000
committerUlrich Drepper <drepper@redhat.com>1998-01-31 02:43:20 +0000
commit07b51ba59a50eadbda72fad0b2e55a4f0e26a291 (patch)
treebb65ad1cd7e3262bd6c20832d20e5891b4141a2c /misc/efgcvt_r.c
parentacaee4d7aa686e058f3cce22fda157c572f4de2c (diff)
downloadglibc-07b51ba59a50eadbda72fad0b2e55a4f0e26a291.tar
glibc-07b51ba59a50eadbda72fad0b2e55a4f0e26a291.tar.gz
glibc-07b51ba59a50eadbda72fad0b2e55a4f0e26a291.tar.bz2
glibc-07b51ba59a50eadbda72fad0b2e55a4f0e26a291.zip
Update.
1998-01-31 11:18 Ulrich Drepper <drepper@cygnus.com> * misc/efgcvt_r.c (fcvt_r): Handle illegal NDIGIT correctly. [PR libc/410] * misc/Makefile (tests): Add tst-efgcvt. * misc/tst-efgcvt.c: New file. * manual/arith.texi (Parsing of Integers): Correct description of strtoul. Pointed out by Scott Snyder <snyder@fnald0.fnal.gov>. [PR libc/396] * misc/lsearch.c (lsearch): Return a pointer to the new element if one was "allocated". * string/strsignal.c: NSIG is not a valid index into _sys_siglist. Don't zap the last character of the "Unknown signal" message.
Diffstat (limited to 'misc/efgcvt_r.c')
-rw-r--r--misc/efgcvt_r.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
index 69caef01d7..2dd0c9f02a 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -1,5 +1,5 @@
/* Compatibility functions for floating point formatting, reentrant versions.
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+ Copyright (C) 1995, 1996, 1997, 1998 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
@@ -61,6 +61,17 @@ APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
if (*sign)
value = -value;
}
+ else
+ /* Value is Inf or NaN. */
+ *sign = 0;
+
+ if (ndigit <= 0)
+ {
+ if (len > 0)
+ buf[0] = '\0';
+ *decpt = 0;
+ return 0;
+ }
n = snprintf (buf, len, "%.*" FLOAT_FMT_FLAG "f", ndigit, value);
if (n < 0)
@@ -72,11 +83,8 @@ APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
*decpt = i;
if (i == 0)
- {
- /* Value is Inf or NaN. */
- *sign = 0;
- return 0;
- }
+ /* Value is Inf or NaN. */
+ return 0;
if (i < n)
{
@@ -84,7 +92,7 @@ APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
++i;
while (i < n && !isdigit (buf[i]));
memmove (&buf[*decpt], &buf[i], n - i);
- buf[n - (i - *decpt)] = 0;
+ buf[n - (i - *decpt)] = '\0';
}
return 0;