X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fxstrtol.c;h=c4557a00640a70f9d420edc72ad099204ac283bf;hb=bbdcfead98c6d3536215c3f0f603e4f92a28d26b;hp=32149397c28d9981507362522c3dc0313d308017;hpb=790855e18a1dc027c0fb770de72a28081bc677fb;p=gnulib.git diff --git a/lib/xstrtol.c b/lib/xstrtol.c index 32149397c..c4557a006 100644 --- a/lib/xstrtol.c +++ b/lib/xstrtol.c @@ -1,7 +1,7 @@ /* A more useful interface to strtol. - Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003 Free - Software Foundation, Inc. + Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006 + Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -15,14 +15,10 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Written by Jim Meyering. */ -#if HAVE_CONFIG_H -# include -#endif - #ifndef __strtol # define __strtol strtol # define __strtol_t long int @@ -31,51 +27,22 @@ # define STRTOL_T_MAXIMUM LONG_MAX #endif +#include + +#include "xstrtol.h" + /* Some pre-ANSI implementations (e.g. SunOS 4) need stderr defined if assertion checking is enabled. */ #include #include #include -#include -#include - #include -#ifndef errno -extern int errno; -#endif - #include +#include +#include -/* The extra casts work around common compiler bugs. */ -#define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) -#define TYPE_MINIMUM(t) ((t) (TYPE_SIGNED (t) \ - ? ~ (t) 0 << (sizeof (t) * CHAR_BIT - 1) \ - : (t) 0)) -#define TYPE_MAXIMUM(t) ((t) (~ (t) 0 - TYPE_MINIMUM (t))) - -#ifndef STRTOL_T_MINIMUM -# define STRTOL_T_MINIMUM TYPE_MINIMUM (__strtol_t) -# define STRTOL_T_MAXIMUM TYPE_MAXIMUM (__strtol_t) -#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 - -#define ISSPACE(c) (IN_CTYPE_DOMAIN (c) && isspace (c)) - -#include "xstrtol.h" - -#if !HAVE_DECL_STRTOIMAX && !defined strtoimax -intmax_t strtoimax (); -#endif - -#if !HAVE_DECL_STRTOUMAX && !defined strtoumax -uintmax_t strtoumax (); -#endif +#include "intprops.h" static strtol_error bkm_scale (__strtol_t *x, int scale_factor) @@ -121,9 +88,10 @@ __xstrtol (const char *s, char **ptr, int strtol_base, if (! TYPE_SIGNED (__strtol_t)) { const char *q = s; - while (ISSPACE ((unsigned char) *q)) - ++q; - if (*q == '-') + unsigned char ch = *q; + while (isspace (ch)) + ch = *++q; + if (ch == '-') return LONGINT_INVALID; } @@ -248,7 +216,6 @@ __xstrtol (const char *s, char **ptr, int strtol_base, default: *val = tmp; return err | LONGINT_INVALID_SUFFIX_CHAR; - break; } err |= overflow;