changeset 9833:48eddbd8edd5

strtod touchups. * lib/strtod.c (strtod): Avoid compiler warnings. Reported by Jim Meyering. Signed-off-by: Eric Blake <ebb9@byu.net>
author Eric Blake <ebb9@byu.net>
date Sun, 30 Mar 2008 08:07:51 -0600
parents 85800f596ad2
children b4f1e5627265
files ChangeLog lib/strtod.c
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Mar 30 15:58:28 2008 +0200
+++ b/ChangeLog	Sun Mar 30 08:07:51 2008 -0600
@@ -1,3 +1,9 @@
+2008-03-30  Eric Blake  <ebb9@byu.net>
+
+	strtod touchups.
+	* lib/strtod.c (strtod): Avoid compiler warnings.
+	Reported by Jim Meyering.
+
 2008-03-30  Bruno Haible  <bruno@clisp.org>
 
 	* lib/unistdio/u-vsprintf.h (EOVERFLOW): Remove fallback.
--- a/lib/strtod.c	Sun Mar 30 15:58:28 2008 +0200
+++ b/lib/strtod.c	Sun Mar 30 08:07:51 2008 -0600
@@ -51,7 +51,8 @@
       goto noconv;
     }
 
-  s = nptr;
+  /* Use unsigned char for the ctype routines.  */
+  s = (unsigned char *) nptr;
 
   /* Eat whitespace.  */
   while (isspace (*s))
@@ -191,11 +192,11 @@
       /* Get the exponent specified after the `e' or `E'.  */
       int save = errno;
       char *end;
-      long int exp;
+      long int value;
 
       errno = 0;
       ++s;
-      exp = strtol (s, &end, 10);
+      value = strtol ((char *) s, &end, 10);
       if (errno == ERANGE && num)
 	{
 	  /* The exponent overflowed a `long int'.  It is probably a safe
@@ -203,7 +204,7 @@
 	     a `long int' exceeds the limits of a `double'.  */
 	  if (endptr != NULL)
 	    *endptr = end;
-	  if (exp < 0)
+	  if (value < 0)
 	    goto underflow;
 	  else
 	    goto overflow;
@@ -213,8 +214,8 @@
 	   the 'e' or 'E', so *ENDPTR will be set there.  */
 	end = (char *) s - 1;
       errno = save;
-      s = end;
-      exponent += exp;
+      s = (unsigned char *) end;
+      exponent += value;
     }
 
   if (num == 0.0)