X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fstrtol.c;h=6d5f4ac4d492e7c6de9d67ffae2611a115aad2a7;hb=f755ca1568887fb854b2362855096cb9ff3f3e00;hp=025287a3f8bd58bb8e438f225678a0f21fbf4538;hpb=9502a06a475a2a334ae724a77df1e0c23d5226b6;p=gnulib.git diff --git a/lib/strtol.c b/lib/strtol.c index 025287a3f..6d5f4ac4d 100644 --- a/lib/strtol.c +++ b/lib/strtol.c @@ -1,5 +1,5 @@ /* strtol - Convert string representation of a number into an integer value. - Copyright (C) 1991, 92, 94, 95, 96 Free Software Foundation, Inc. + Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc. NOTE: The canonical source of this file is maintained with the GNU C Library. Bugs can be reported to bug-glibc@prep.ai.mit.edu. @@ -129,12 +129,17 @@ extern int errno; # define ISALPHA(Ch) iswalpha (Ch) # define TOUPPER(Ch) towupper (Ch) #else +# if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +# else +# define IN_CTYPE_DOMAIN(c) isascii(c) +# endif # define L_(Ch) Ch # define UCHAR_TYPE unsigned char # define STRING_TYPE char -# define ISSPACE(Ch) isspace (Ch) -# define ISALPHA(Ch) isalpha (Ch) -# define TOUPPER(Ch) toupper (Ch) +# define ISSPACE(Ch) (IN_CTYPE_DOMAIN (Ch) && isspace (Ch)) +# define ISALPHA(Ch) (IN_CTYPE_DOMAIN (Ch) && isalpha (Ch)) +# define TOUPPER(Ch) (IN_CTYPE_DOMAIN (Ch) ? toupper (Ch) : (Ch)) #endif #ifdef __STDC__ @@ -201,7 +206,10 @@ INTERNAL (strtol) (nptr, endptr, base, group) #endif if (base < 0 || base == 1 || base > 36) - base = 10; + { + __set_errno (EINVAL); + return 0; + } save = s = nptr; @@ -309,6 +317,8 @@ INTERNAL (strtol) (nptr, endptr, base, group) ? -((unsigned LONG int) (LONG_MIN + 1)) + 1 : (unsigned LONG int) LONG_MAX)) overflow = 1; +#else + overflow |= negative; #endif if (overflow)