X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=coreutils%2Fexpr.c;h=b247f08db10801fdaaad5e8e7f98f638c8e3cedc;hb=eb1395147ae98e56b455d0f3f9406725fe189822;hp=5d2fbf2f76513a4fd6aa771d8ff96e5ffc5a0ee4;hpb=af3f42011628585cd5c8f5c1fd4b43f2e370a23d;p=oweals%2Fbusybox.git diff --git a/coreutils/expr.c b/coreutils/expr.c index 5d2fbf2f7..b247f08db 100644 --- a/coreutils/expr.c +++ b/coreutils/expr.c @@ -23,22 +23,22 @@ * provided they all associate ((x op x) op x). */ //config:config EXPR -//config: bool "expr" +//config: bool "expr (6.6 kb)" //config: default y //config: help -//config: expr is used to calculate numbers and print the result -//config: to standard output. +//config: expr is used to calculate numbers and print the result +//config: to standard output. //config: //config:config EXPR_MATH_SUPPORT_64 //config: bool "Extend Posix numbers support to 64 bit" //config: default y //config: depends on EXPR //config: help -//config: Enable 64-bit math support in the expr applet. This will make -//config: the applet slightly larger, but will allow computation with very -//config: large numbers. +//config: Enable 64-bit math support in the expr applet. This will make +//config: the applet slightly larger, but will allow computation with very +//config: large numbers. -//applet:IF_EXPR(APPLET(expr, BB_DIR_USR_BIN, BB_SUID_DROP)) +//applet:IF_EXPR(APPLET_NOEXEC(expr, expr, BB_DIR_USR_BIN, BB_SUID_DROP, expr)) //kbuild:lib-$(CONFIG_EXPR) += expr.o @@ -118,7 +118,10 @@ struct globals { char **args; } FIX_ALIASING; #define G (*(struct globals*)bb_common_bufsiz1) -#define INIT_G() do { setup_common_bufsiz(); } while (0) +#define INIT_G() do { \ + setup_common_bufsiz(); \ + /* NB: noexec applet - globals not zeroed */ \ +} while (0) /* forward declarations */ static VALUE *eval(void); @@ -246,7 +249,7 @@ static arith_t arithmetic_common(VALUE *l, VALUE *r, int op) arith_t li, ri; if (!toarith(l) || !toarith(r)) - bb_error_msg_and_die("non-numeric argument"); + bb_simple_error_msg_and_die("non-numeric argument"); li = l->u.i; ri = r->u.i; if (op == '+') @@ -256,7 +259,7 @@ static arith_t arithmetic_common(VALUE *l, VALUE *r, int op) if (op == '*') return li * ri; if (ri == 0) - bb_error_msg_and_die("division by zero"); + bb_simple_error_msg_and_die("division by zero"); if (op == '/') return li / ri; return li % ri; @@ -316,19 +319,19 @@ static VALUE *eval7(void) VALUE *v; if (!*G.args) - bb_error_msg_and_die("syntax error"); + bb_simple_error_msg_and_die("syntax error"); if (nextarg("(")) { G.args++; v = eval(); if (!nextarg(")")) - bb_error_msg_and_die("syntax error"); + bb_simple_error_msg_and_die("syntax error"); G.args++; return v; } if (nextarg(")")) - bb_error_msg_and_die("syntax error"); + bb_simple_error_msg_and_die("syntax error"); return str_value(*G.args++); } @@ -350,7 +353,7 @@ static VALUE *eval6(void) G.args++; /* We have a valid token, so get the next argument. */ if (key == 1) { /* quote */ if (!*G.args) - bb_error_msg_and_die("syntax error"); + bb_simple_error_msg_and_die("syntax error"); return str_value(*G.args++); } if (key == 2) { /* length */ @@ -543,11 +546,11 @@ int expr_main(int argc UNUSED_PARAM, char **argv) xfunc_error_retval = 2; /* coreutils compat */ G.args = argv + 1; if (*G.args == NULL) { - bb_error_msg_and_die("too few arguments"); + bb_simple_error_msg_and_die("too few arguments"); } v = eval(); if (*G.args) - bb_error_msg_and_die("syntax error"); + bb_simple_error_msg_and_die("syntax error"); if (v->type == INTEGER) printf("%" PF_REZ "d\n", PF_REZ_TYPE v->u.i); else