summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-08-18 20:45:59 +0000
committerJim Meyering <jim@meyering.net>2001-08-18 20:45:59 +0000
commit2169593a4f2890a60923a2eb996f9e5cfa4447e2 (patch)
tree02931a656e1f23dc744ab25dc516dbe8fd0bc244 /src
parentbf009adc4e097f69479cdf809902c07000559c3c (diff)
downloadcoreutils-2169593a4f2890a60923a2eb996f9e5cfa4447e2.tar.xz
(isstring): Remove.
(eval2): Do comparisons as strings first, before trying to convert to integer. This avoids loss of information and wrong result, e.g. for "expr '00' '<' '0!'", where you don't want to convert '00' to '0'.
Diffstat (limited to 'src')
-rw-r--r--src/expr.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/src/expr.c b/src/expr.c
index 98f8ee49b..6222939d0 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -283,14 +283,6 @@ null (VALUE *v)
}
}
-/* Return nonzero if V is a string value. */
-
-static int
-isstring (VALUE *v)
-{
- return v->type == string;
-}
-
/* Coerce V to a string value (can't fail). */
static void
@@ -699,16 +691,11 @@ eval2 (void)
return l;
args++;
r = eval3 ();
- toarith (l);
- toarith (r);
- if (isstring (l) || isstring (r))
- {
- tostring (l);
- tostring (r);
- lval = strcoll (l->u.s, r->u.s);
- rval = 0;
- }
- else
+ tostring (l);
+ tostring (r);
+ lval = strcoll (l->u.s, r->u.s);
+ rval = 0;
+ if (toarith (l) && toarith (r))
{
lval = l->u.i;
rval = r->u.i;