X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fxstrtol.c;h=f4ba50ba2836322029a1b9eee915c1cb1616c59a;hb=c98e50278baa2c19aee3f16d13716f29ae41fdc6;hp=cd85a3f93d78a57f9b26f692faf454d305712e4c;hpb=6ce9913b3b6bc149bbb38834e9ce5af4558b2a2a;p=gnulib.git diff --git a/lib/xstrtol.c b/lib/xstrtol.c index cd85a3f93..f4ba50ba2 100644 --- a/lib/xstrtol.c +++ b/lib/xstrtol.c @@ -21,6 +21,8 @@ # include #endif +/* Some pre-ANSI implementations (e.g. SunOS 4) + need stderr defined if assertion checking is enabled. */ #include #if STDC_HEADERS @@ -36,12 +38,6 @@ # endif #endif -/* Some pre-ANSI implementations (e.g. SunOS 4) - need stderr defined if assertion checking is enabled. */ -#ifndef NDEBUG -# include -#endif - #include #include @@ -73,6 +69,18 @@ extern int errno; # define LONG_MAX TYPE_MAXIMUM (long int) #endif +#if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) +# define IN_CTYPE_DOMAIN(c) 1 +#else +# define IN_CTYPE_DOMAIN(c) isascii(c) +#endif + +#ifdef isblank +# define ISBLANK(c) (IN_CTYPE_DOMAIN (c) && isblank (c)) +#else +# define ISBLANK(c) ((c) == ' ' || (c) == '\t') +#endif + #include "xstrtol.h" __unsigned long int __strtol (); @@ -111,6 +119,18 @@ __xstrtol (const char *s, char **ptr, int strtol_base, p = (ptr ? ptr : &t_ptr); +#if STRING_TO_UNSIGNED + { + const char *q = s; + while (ISBLANK (*q)) + { + ++q; + } + if (*q == '-') + return LONGINT_INVALID; + } +#endif + errno = 0; tmp = __strtol (s, p, strtol_base); if (errno != 0)