diff options
| author | jtc <jtc@NetBSD.org> | 1993-07-20 00:29:41 +0000 |
|---|---|---|
| committer | jtc <jtc@NetBSD.org> | 1993-07-20 00:29:41 +0000 |
| commit | 476e1b59644cdea22051305b8b3d9963f94deec4 (patch) | |
| tree | 7a6c1f9b195a17d42aaaa8fe7828f836b2f516fe /bin/expr/expr.y | |
| parent | 0a08244e8ce4551cb447b78b650cc495746df545 (diff) | |
integer arguments were not coerced to strings for the `:' operator.
bad things: core dumps, etc. will happen if integer values make it
up the parse tree.
Diffstat (limited to 'bin/expr/expr.y')
| -rw-r--r-- | bin/expr/expr.y | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/bin/expr/expr.y b/bin/expr/expr.y index d76cd46b480..324923ddee0 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 * - * $Header: /cvsroot/src/bin/expr/expr.y,v 1.6 1993/06/14 19:59:07 jtc Exp $ + * $Header: /cvsroot/src/bin/expr/expr.y,v 1.7 1993/07/20 00:29:41 jtc Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -542,16 +542,14 @@ struct val *a, *b; regmatch_t rm[SE_MAX]; char errbuf[256]; int eval; - char *newpat; struct val *v; - /* patterns are anchored to the beginning of the line */ - newpat = malloc (strlen (b->u.s) + 2); - strcpy (newpat, "^"); - strcat (newpat, b->u.s); + /* coerce to both arguments to strings */ + to_string(a); + to_string(b); /* compile regular expression */ - if ((eval = regcomp (&rp, newpat, 0)) != 0) { + if ((eval = regcomp (&rp, b->u.s, 0)) != 0) { regerror (eval, &rp, errbuf, sizeof(errbuf)); fprintf (stderr, "expr: %s\n", errbuf); exit (2); |
