diff options
author | Jim Meyering <jim@meyering.net> | 2001-08-18 16:39:33 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2001-08-18 16:39:33 +0000 |
commit | 92b78195a1a7c95615add80678b87a6a3f762f48 (patch) | |
tree | 7268ca5b50c06a4a137cd7b782056fb854ee363e | |
parent | bc70df09bb771b1a86a4759be94504510f28c09e (diff) | |
download | coreutils-92b78195a1a7c95615add80678b87a6a3f762f48.tar.xz |
(toarith): Don't accept plain "-" as a valid integer.
-rw-r--r-- | src/expr.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/expr.c b/src/expr.c index 50930d289..8702dd19c 100644 --- a/src/expr.c +++ b/src/expr.c @@ -320,19 +320,19 @@ toarith (VALUE *v) case string: i = 0; cp = v->u.s; - /* Don't interpret the empty string as an integer. */ - if (*cp == 0) - return 0; neg = (*cp == '-'); if (neg) cp++; - for (; *cp; cp++) + + do { if (ISDIGIT (*cp)) i = i * 10 + *cp - '0'; else return 0; } + while (*++cp); + free (v->u.s); v->u.i = i * (neg ? -1 : 1); v->type = integer; |