diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-10-19 18:20:27 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2016-10-19 18:20:27 +0000 |
commit | 7aba8e9b446901982da24c12cf28023db2701b30 (patch) | |
tree | e7e10c0cd71cbab7399325a0144aaaf3f1eb0807 /bin/expr | |
parent | 9a23494aa0d3aabacfd327dd2ccd3f4e5a015c96 (diff) |
Delete useless setlocale(3) in src/bin/.
Minor cleanup while here: return from main, static void __dead usage, etc.
Based on a patch from Jan Stary <hans at stare dot cz>.
Feedback and OK tb@, OK millert@.
Diffstat (limited to 'bin/expr')
-rw-r--r-- | bin/expr/expr.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/bin/expr/expr.c b/bin/expr/expr.c index b22268d5141..99ae1ead4e4 100644 --- a/bin/expr/expr.c +++ b/bin/expr/expr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: expr.c,v 1.25 2016/01/07 21:17:05 tedu Exp $ */ +/* $OpenBSD: expr.c,v 1.26 2016/10/19 18:20:25 schwarze Exp $ */ /* $NetBSD: expr.c,v 1.3.6.1 1996/06/04 20:41:47 cgd Exp $ */ /* @@ -11,7 +11,6 @@ #include <stdlib.h> #include <string.h> #include <limits.h> -#include <locale.h> #include <ctype.h> #include <unistd.h> #include <regex.h> @@ -174,12 +173,10 @@ to_string(struct val *vp) int is_zero_or_null(struct val *vp) { - if (vp->type == integer) { - return (vp->u.i == 0); - } else { - return (*vp->u.s == 0 || (to_integer(vp) && vp->u.i == 0)); - } - /* NOTREACHED */ + if (vp->type == integer) + return vp->u.i == 0; + else + return *vp->u.s == 0 || (to_integer(vp) && vp->u.i == 0); } void @@ -226,7 +223,6 @@ __dead void error(void) { errx(2, "syntax error"); - /* NOTREACHED */ } struct val * @@ -237,21 +233,15 @@ eval6(void) if (token == OPERAND) { nexttoken(0); return tokval; - } else if (token == RP) { nexttoken(0); v = eval0(); - - if (token != LP) { + if (token != LP) error(); - /* NOTREACHED */ - } nexttoken(0); return v; - } else { + } else error(); - } - /* NOTREACHED */ } /* Parse and evaluate match (regex) expressions */ @@ -500,8 +490,6 @@ main(int argc, char *argv[]) { struct val *vp; - (void) setlocale(LC_ALL, ""); - if (pledge("stdio", NULL) == -1) err(2, "pledge"); @@ -513,15 +501,13 @@ main(int argc, char *argv[]) nexttoken(0); vp = eval0(); - if (token != EOI) { + if (token != EOI) error(); - /* NOTREACHED */ - } if (vp->type == integer) printf("%lld\n", vp->u.i); else printf("%s\n", vp->u.s); - exit(is_zero_or_null(vp)); + return is_zero_or_null(vp); } |