OSDN Git Service

merge from gcc
[pf3gnuchains/pf3gnuchains3x.git] / libiberty / strtol.c
index 028d610..acc7882 100644 (file)
@@ -31,6 +31,7 @@
 /*
 
 @deftypefn Supplemental {long int} strtol (const char *@var{string}, char **@var{endptr}, int @var{base})
+@deftypefnx Supplemental {unsigned long int} strtoul (const char *@var{string}, char **@var{endptr}, int @var{base})
 
 The @code{strtol} function converts the string in @var{string} to a
 long integer value according to the given @var{base}, which must be
@@ -38,8 +39,9 @@ between 2 and 36 inclusive, or be the special value 0.  If @var{base}
 is 0, @code{strtol} will look for the prefixes @code{0} and @code{0x}
 to indicate bases 8 and 16, respectively, else default to base 10.
 When the base is 16 (either explicitly or implicitly), a prefix of
-@code{0x} is allowed.  The handling of endptr is as that of
-@code{strtod} above.
+@code{0x} is allowed.  The handling of @var{endptr} is as that of
+@code{strtod} above.  The @code{strtoul} function is the same, except
+that the converted value is unsigned.
 
 @end deftypefn
 
@@ -83,10 +85,7 @@ extern int errno;
  * alphabets and digits are each contiguous.
  */
 long
-strtol(nptr, endptr, base)
-       const char *nptr;
-       char **endptr;
-       register int base;
+strtol(const char *nptr, char **endptr, register int base)
 {
        register const char *s = nptr;
        register unsigned long acc;
@@ -145,7 +144,7 @@ strtol(nptr, endptr, base)
                        break;
                if (c >= base)
                        break;
-               if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
+               if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
                        any = -1;
                else {
                        any = 1;