(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'.
}
}
-/* 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
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;