diff options
author | jtc <jtc@FreeBSD.org> | 1993-09-14 22:49:52 +0000 |
---|---|---|
committer | jtc <jtc@FreeBSD.org> | 1993-09-14 22:49:52 +0000 |
commit | d3452ecc7d759965fa10b867ca2f154dfe961b5e (patch) | |
tree | 8bb29816af975d51014410bf7a08d8aa612a6aa7 /bin/expr | |
parent | d2e9340b8954aa350394e2128166756e8d0a4f7d (diff) | |
download | FreeBSD-src-d3452ecc7d759965fa10b867ca2f154dfe961b5e.zip FreeBSD-src-d3452ecc7d759965fa10b867ca2f154dfe961b5e.tar.gz |
Fix grammar to eliminate support for unary minus expressions -- they
weren't supported, they aren't standard, and they caused expr to dump
core.
Diffstat (limited to 'bin/expr')
-rw-r--r-- | bin/expr/expr.y | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/bin/expr/expr.y b/bin/expr/expr.y index b22bffb..e7a0a5a 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 <stdio.h> #include <stdlib.h> #include <string.h> +#include <locale.h> #include <ctype.h> #include <err.h> @@ -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 <regex.h> -#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); |