diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-08-02 22:56:56 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-08-02 22:56:56 +0000 |
commit | eb32ddf3c0710c3a94bc08b3a4f93856b46cb0c1 (patch) | |
tree | ea6b5bcfb6d53e2491f6c3420322d8ade069e552 /lib | |
parent | a4e2377f602256dae6ec39c8bbf3971f35322882 (diff) | |
download | coreutils-eb32ddf3c0710c3a94bc08b3a4f93856b46cb0c1.tar.xz |
(errno): Remove decl; we now assume C89 or better.
(__xstrtol): Rewrite to avoid casts.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/xstrtol.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/xstrtol.c b/lib/xstrtol.c index d0aa0a968..906e4a1cc 100644 --- a/lib/xstrtol.c +++ b/lib/xstrtol.c @@ -1,6 +1,6 @@ /* A more useful interface to strtol. - Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003 Free + Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -37,15 +37,10 @@ #include <assert.h> #include <ctype.h> -#include <stdlib.h> -#include <string.h> - #include <errno.h> -#ifndef errno -extern int errno; -#endif - #include <limits.h> +#include <stdlib.h> +#include <string.h> /* The extra casts work around common compiler bugs. */ #define TYPE_SIGNED(t) (! ((t) 0 < (t) -1)) @@ -121,9 +116,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; } |