X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=coreutils%2Fexpr.c;h=4a537bf33077d5490b6f3793a25d0a5f5ab0541e;hb=a6ce670a87ee77ccb9337ed6d87442134e1a48ed;hp=9e3c04a11e7c02900b35b089a0c58b93498743a0;hpb=1b355ebba68bdd567dd3961a18291dfd9532c2e8;p=oweals%2Fbusybox.git diff --git a/coreutils/expr.c b/coreutils/expr.c index 9e3c04a11..4a537bf33 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c @@ -33,11 +33,15 @@ * One function can handle multiple operators all of equal precedence, * provided they all associate ((x op x) op x). */ -#include "internal.h" +/* no getopt needed */ + #include +#include +#include +#include #include +#include "busybox.h" -#include /* The kinds of value we can have. */ enum valtype { @@ -74,14 +78,14 @@ int expr_main (int argc, char **argv) VALUE *v; if (argc == 1) { - fatalError("too few arguments\n"); + error_msg_and_die("too few arguments"); } args = argv + 1; v = eval (); if (*args) - fatalError ("syntax error\n"); + error_msg_and_die ("syntax error"); if (v->type == integer) printf ("%d\n", v->u.i); @@ -216,17 +220,17 @@ static \ int name (l, r) VALUE *l; VALUE *r; \ { \ if (!toarith (l) || !toarith (r)) \ - fatalError ("non-numeric argument\n"); \ + error_msg_and_die ("non-numeric argument"); \ return l->u.i op r->u.i; \ } #define arithdivf(name, op) \ -int name (l, r) VALUE *l; VALUE *r; \ +static int name (l, r) VALUE *l; VALUE *r; \ { \ if (!toarith (l) || !toarith (r)) \ - fatalError ( "non-numeric argument\n"); \ + error_msg_and_die ( "non-numeric argument"); \ if (r->u.i == 0) \ - fatalError ( "division by zero\n"); \ + error_msg_and_die ( "division by zero"); \ return l->u.i op r->u.i; \ } @@ -270,7 +274,7 @@ of a basic regular expression is not portable; it is being ignored", re_syntax_options = RE_SYNTAX_POSIX_BASIC; errmsg = re_compile_pattern (pv->u.s, len, &re_buffer); if (errmsg) { - fatalError("%s\n", errmsg); + error_msg_and_die("%s", errmsg); } len = re_match (&re_buffer, sv->u.s, strlen (sv->u.s), 0, &re_regs); @@ -301,19 +305,19 @@ static VALUE *eval7 (void) VALUE *v; if (!*args) - fatalError ( "syntax error\n"); + error_msg_and_die ( "syntax error"); if (nextarg ("(")) { args++; v = eval (); if (!nextarg (")")) - fatalError ( "syntax error\n"); + error_msg_and_die ( "syntax error"); args++; return v; } if (nextarg (")")) - fatalError ( "syntax error\n"); + error_msg_and_die ( "syntax error"); return str_value (*args++); } @@ -327,7 +331,7 @@ static VALUE *eval6 (void) if (nextarg ("quote")) { args++; if (!*args) - fatalError ( "syntax error\n"); + error_msg_and_die ( "syntax error"); return str_value (*args++); } else if (nextarg ("length")) {