bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] strtod: fix const diagnostic


From: Paul Eggert
Subject: [PATCH] strtod: fix const diagnostic
Date: Tue, 10 Aug 2010 19:43:31 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6

Recent changes to lib/strtod.c put in a couple of assignments
of const char * to char *, which some compilers reject.
I pushed this to work around the problem:

* lib/strtod.c (strtod): Don't assign const char * to char *,
as this elicits a warning from GCC when warnings are enabled.
---
 ChangeLog    |    6 ++++++
 lib/strtod.c |   11 ++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dffc9ed..b6e8887 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-08-10  Paul Eggert  <address@hidden>
+
+       strtod: fix const diagnostic
+       * lib/strtod.c (strtod): Don't assign const char * to char *,
+       as this elicits a warning from GCC when warnings are enabled.
+
 2010-08-10  Pádraig Brady <address@hidden>
        and Eric Blake  <address@hidden>
 
diff --git a/lib/strtod.c b/lib/strtod.c
index 94eb817..64b62ff 100644
--- a/lib/strtod.c
+++ b/lib/strtod.c
@@ -200,7 +200,8 @@ strtod (const char *nptr, char **endptr)
   double num;
 
   const char *s = nptr;
-  char *end;
+  const char *end;
+  char *endbuf;
 
   /* Eat whitespace.  */
   while (locale_isspace (*s))
@@ -211,7 +212,8 @@ strtod (const char *nptr, char **endptr)
   if (*s == '-' || *s == '+')
     ++s;
 
-  num = underlying_strtod (s, &end);
+  num = underlying_strtod (s, &endbuf);
+  end = endbuf;
 
   if (c_isdigit (s[*s == '.']))
     {
@@ -224,7 +226,10 @@ strtod (const char *nptr, char **endptr)
           if (! c_isxdigit (s[2 + (s[2] == '.')]))
             end = s + 1;
           else if (end <= s + 2)
-            num = parse_number (s + 2, 16, 2, 4, 'p', &end);
+            {
+              num = parse_number (s + 2, 16, 2, 4, 'p', &endbuf);
+              end = endbuf;
+            }
           else
             {
               const char *p = s + 2;
-- 
1.7.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]