summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-08-18 16:39:33 +0000
committerJim Meyering <jim@meyering.net>2001-08-18 16:39:33 +0000
commit92b78195a1a7c95615add80678b87a6a3f762f48 (patch)
tree7268ca5b50c06a4a137cd7b782056fb854ee363e
parentbc70df09bb771b1a86a4759be94504510f28c09e (diff)
downloadcoreutils-92b78195a1a7c95615add80678b87a6a3f762f48.tar.xz
(toarith): Don't accept plain "-" as a valid integer.
-rw-r--r--src/expr.c8
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;