From 476e1b59644cdea22051305b8b3d9963f94deec4 Mon Sep 17 00:00:00 2001 From: jtc Date: Tue, 20 Jul 1993 00:29:41 +0000 Subject: 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. --- bin/expr/expr.y | 12 +++++------- 1 file 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 #include @@ -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); -- cgit