From 4d198a2a3c3c36c5a716af376e5fd0a797c58948 Mon Sep 17 00:00:00 2001 From: conklin Date: Wed, 21 Jul 1993 22:56:14 +0000 Subject: Update to my latest expr (fixes bugs with comparison and matching operators) Add man page I wrote. --- bin/expr/expr.y | 49 +++++++------------------------------------------ 1 file changed, 7 insertions(+), 42 deletions(-) (limited to 'bin/expr/expr.y') diff --git a/bin/expr/expr.y b/bin/expr/expr.y index d267094..0789483 100644 --- a/bin/expr/expr.y +++ b/bin/expr/expr.y @@ -2,7 +2,7 @@ /* Written by Pace Willisson (pace@blitz.com) * and placed in the public domain * - * /b/source/CVS/src/bin/expr/expr.y,v 1.6 1993/06/14 19:59:07 jtc Exp + * $Header: /b/source/CVS/src/bin/expr/expr.y,v 1.9 1993/07/20 01:10:55 jtc Exp $ */ #include #include @@ -219,13 +219,10 @@ int is_zero_or_null (vp) struct val *vp; { - /* Like most other versions of expr, this version will return - false for a string value of multiple zeros.*/ - if (vp->type == integer) { return (vp->u.i == 0); } else { - return (*vp->u.s == 0 || strcmp (vp->u.s, "0") == 0); + return (*vp->u.s == 0 || (to_integer (vp) && vp->u.i == 0)); } /* NOTREACHED */ } @@ -292,12 +289,6 @@ struct val *a, *b; { struct val *r; - /* attempt to coerce both arguments to integers */ - (void) to_integer (a); - (void) to_integer (b); - - /* But if either one of them really is a string, do - a string comparison */ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); @@ -317,12 +308,6 @@ struct val *a, *b; { struct val *r; - /* attempt to coerce both arguments to integers */ - (void) to_integer (a); - (void) to_integer (b); - - /* But if either one of them really is a string, do - a string comparison */ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); @@ -342,12 +327,6 @@ struct val *a, *b; { struct val *r; - /* attempt to coerce both arguments to integers */ - (void) to_integer (a); - (void) to_integer (b); - - /* But if either one of them really is a string, do - a string comparison */ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); @@ -367,12 +346,6 @@ struct val *a, *b; { struct val *r; - /* attempt to coerce both arguments to integers */ - (void) to_integer (a); - (void) to_integer (b); - - /* But if either one of them really is a string, do - a string comparison */ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); @@ -392,12 +365,6 @@ struct val *a, *b; { struct val *r; - /* attempt to coerce both arguments to integers */ - (void) to_integer (a); - (void) to_integer (b); - - /* But if either one of them really is a string, do - a string comparison */ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); @@ -417,12 +384,6 @@ struct val *a, *b; { struct val *r; - /* attempt to coerce both arguments to integers */ - (void) to_integer (a); - (void) to_integer (b); - - /* But if either one of them really is a string, do - a string comparison */ if (isstring (a) || isstring (b)) { to_string (a); to_string (b); @@ -542,8 +503,12 @@ struct val *a, *b; regmatch_t rm[SE_MAX]; char errbuf[256]; int eval; - char *newpat; struct val *v; + char *newpat; + + /* coerce to both arguments to strings */ + to_string(a); + to_string(b); /* patterns are anchored to the beginning of the line */ newpat = malloc (strlen (b->u.s) + 2); -- cgit v1.1