summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2000-02-12 10:10:40 +0000
committerJim Meyering <jim@meyering.net>2000-02-12 10:10:40 +0000
commit3d9c2a6c35c09cdf463358ccb2f3c7bf42cb9d15 (patch)
treef6a998d5e68974cca7542700acf5e93898eb2f05 /lib
parent282fa27b512d84dd72aa86324eb32887d2faa9cb (diff)
downloadcoreutils-3d9c2a6c35c09cdf463358ccb2f3c7bf42cb9d15.tar.xz
(ISDIGIT): Define it.
(isdigit): Remove definition. (is_number): Use ISDIGIT, not isdigit.
Diffstat (limited to 'lib')
-rw-r--r--lib/userspec.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/userspec.c b/lib/userspec.c
index cb1f8a73f..fe2596858 100644
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -1,5 +1,5 @@
/* userspec.c -- Parse a user and group string.
- Copyright (C) 1989-1992, 1997, 1998 Free Software Foundation, Inc.
+ Copyright (C) 1989-1992, 1997, 1998, 2000 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
@@ -83,7 +83,15 @@ struct group *getgrgid ();
} \
while (0)
-#define isdigit(c) ((c) >= '0' && (c) <= '9')
+/* ISDIGIT differs from isdigit, as follows:
+ - Its arg may be any int or unsigned int; it need not be an unsigned char.
+ - It's guaranteed to evaluate its argument exactly once.
+ - It's typically faster.
+ Posix 1003.2-1992 section 2.5.2.1 page 50 lines 1556-1558 says that
+ only '0' through '9' are digits. Prefer ISDIGIT to isdigit unless
+ it's important to use the locale's definition of `digit' even when the
+ host does not conform to Posix. */
+#define ISDIGIT(c) ((unsigned) (c) - '0' <= 9)
#ifndef strdup
char *strdup ();
@@ -96,7 +104,7 @@ static int
is_number (const char *str)
{
for (; *str; str++)
- if (!isdigit (*str))
+ if (!ISDIGIT (*str))
return 0;
return 1;
}