brctl: tweak help text, fix comments
[oweals/busybox.git] / coreutils / expr.c
index a2bbfdd69714e99f9da9c4233dc858937d8959ad..b247f08db10801fdaaad5e8e7f98f638c8e3cedc 100644 (file)
@@ -23,7 +23,7 @@
  * provided they all associate ((x op x) op x).
  */
 //config:config EXPR
-//config:      bool "expr (6.1 kb)"
+//config:      bool "expr (6.6 kb)"
 //config:      default y
 //config:      help
 //config:      expr is used to calculate numbers and print the result
@@ -38,7 +38,7 @@
 //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