From d3452ecc7d759965fa10b867ca2f154dfe961b5e Mon Sep 17 00:00:00 2001 From: jtc Date: Tue, 14 Sep 1993 22:49:52 +0000 Subject: [PATCH] Fix grammar to eliminate support for unary minus expressions -- they weren't supported, they aren't standard, and they caused expr to dump core. --- bin/expr/expr.y | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/expr/expr.y b/bin/expr/expr.y index b22bffbbe29..e7a0a5a7c47 100644 --- a/bin/expr/expr.y +++ b/bin/expr/expr.y @@ -4,11 +4,13 @@ * * Largely rewritten by J.T. Conklin (jtc@wimsey.com) * - * $Header: /b/source/CVS/src/bin/expr/expr.y,v 1.11 1993/08/17 16:01:23 jtc Exp $ + * $Id : /b/source/CVS/src/bin/expr/expr.y,v 1.11 1993/08/17 16:01:23 jtc Exp $ */ + #include #include #include +#include #include #include @@ -79,7 +81,6 @@ expr: TOKEN | expr '/' expr { $$ = op_div ($1, $3); } | expr '%' expr { $$ = op_rem ($1, $3); } | expr ':' expr { $$ = op_colon ($1, $3); } - | '-' expr %prec UNARY { $$ = op_minus (NULL, $2); } ; @@ -232,6 +233,8 @@ main (argc, argv) int argc; char **argv; { + setlocale (LC_ALL, ""); + av = argv + 1; yyparse (); @@ -241,10 +244,7 @@ char **argv; else printf ("%s\n", result->u.s); - if (is_zero_or_null (result)) - exit (1); - else - exit (0); + exit (is_zero_or_null (result)); } int @@ -485,14 +485,13 @@ struct val *a, *b; } #include -#define SE_MAX 30 struct val * op_colon (a, b) struct val *a, *b; { regex_t rp; - regmatch_t rm[SE_MAX]; + regmatch_t rm[2]; char errbuf[256]; int eval; struct val *v; @@ -515,7 +514,7 @@ struct val *a, *b; free (newpat); /* compare string against pattern */ - if (regexec(&rp, a->u.s, SE_MAX, rm, 0) == 0) { + if (regexec(&rp, a->u.s, 2, rm, 0) == 0) { if (rm[1].rm_so >= 0) { *(a->u.s + rm[1].rm_eo) = '\0'; v = make_str (a->u.s + rm[1].rm_so); -- 2.45.2