.
[gnulib.git] / lib / xstrtol.c
index dec0ec7..ad2bcdb 100644 (file)
    along with this program; if not, write to the Free Software Foundation,
    Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
-/* Jim Meyering (meyering@na-net.ornl.gov) */
+/* Written by Jim Meyering. */
 
-#ifdef HAVE_CONFIG_H
-#include <config.h>
+#if HAVE_CONFIG_H
+# include <config.h>
 #endif
 
-#ifdef STDC_HEADERS
-#include <stdlib.h>
+#if STDC_HEADERS
+# include <stdlib.h>
 #endif
 
-#ifdef HAVE_STRING_H
+#if HAVE_STRING_H
 # include <string.h>
 #else
 # include <strings.h>
@@ -91,15 +91,14 @@ __xstrtol (s, ptr, base, val, valid_suffixes)
     return LONGINT_OVERFLOW;
   if (*p == s)
     return LONGINT_INVALID;
+
+  /* Let valid_suffixes == NULL mean `allow any suffix'.  */
+  /* FIXME: update all callers except the one in tail.c changing
+     last parameter NULL to `""'.  */
   if (!valid_suffixes)
     {
-      if (**p == '\0')
-       {
-         *val = tmp;
-         return LONGINT_OK;
-       }
-      else
-       return LONGINT_INVALID_SUFFIX_CHAR;
+      *val = tmp;
+      return LONGINT_OK;
     }
 
   if (**p != '\0')
@@ -146,8 +145,8 @@ __xstrtol (s, ptr, base, val, valid_suffixes)
 
 #ifdef TESTING_XSTRTO
 
-#include <stdio.h>
-#include "error.h"
+# include <stdio.h>
+# include "error.h"
 
 char *program_name;
 
@@ -175,4 +174,5 @@ main (int argc, char** argv)
     }
   exit (0);
 }
+
 #endif /* TESTING_XSTRTO */