From 2169593a4f2890a60923a2eb996f9e5cfa4447e2 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 18 Aug 2001 20:45:59 +0000 Subject: [PATCH] (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'. --- src/expr.c | 23 +++++------------------ 1 file 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; -- 2.34.1