pointless whitespace/comment fixes, no code changes
[oweals/busybox.git] / shell / ash.c
index 0d3ab0ff51a871a488c8b21fb62fccb455ffbc91..4acc30110b99ba1765813ddf7c6316a760712536 100644 (file)
@@ -185,10 +185,6 @@ struct globals_misc {
 #define debug optlist[15]
 #endif
 
-#if ENABLE_SH_MATH_SUPPORT
-       arith_eval_hooks_t math_hooks;
-#endif
-
        /* trap handler commands */
        /*
         * Sigmode records the current value of the signal handlers for the various
@@ -238,7 +234,6 @@ extern struct globals_misc *const ash_ptr_to_globals_misc;
 #define random_LCG         (G_misc.random_LCG        )
 #define backgndpid  (G_misc.backgndpid )
 #define job_warning (G_misc.job_warning)
-#define math_hooks  (G_misc.math_hooks )
 #define INIT_G_misc() do { \
        (*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \
        barrier(); \
@@ -354,39 +349,25 @@ raise_interrupt(void)
 } while (0)
 #endif
 
-#if ENABLE_ASH_OPTIMIZE_FOR_SIZE
-static void
+static USE_ASH_OPTIMIZE_FOR_SIZE(inline) void
 int_on(void)
 {
+       xbarrier();
        if (--suppressint == 0 && intpending) {
                raise_interrupt();
        }
 }
 #define INT_ON int_on()
-static void
+static USE_ASH_OPTIMIZE_FOR_SIZE(inline) void
 force_int_on(void)
 {
+       xbarrier();
        suppressint = 0;
        if (intpending)
                raise_interrupt();
 }
 #define FORCE_INT_ON force_int_on()
 
-#else /* !ASH_OPTIMIZE_FOR_SIZE */
-
-#define INT_ON do { \
-       xbarrier(); \
-       if (--suppressint == 0 && intpending) \
-               raise_interrupt(); \
-} while (0)
-#define FORCE_INT_ON do { \
-       xbarrier(); \
-       suppressint = 0; \
-       if (intpending) \
-               raise_interrupt(); \
-} while (0)
-#endif /* !ASH_OPTIMIZE_FOR_SIZE */
-
 #define SAVE_INT(v) ((v) = suppressint)
 
 #define RESTORE_INT(v) do { \
@@ -1117,6 +1098,14 @@ ash_msg_and_raise_error(const char *msg, ...)
        va_end(ap);
 }
 
+static void raise_error_syntax(const char *) NORETURN;
+static void
+raise_error_syntax(const char *msg)
+{
+       ash_msg_and_raise_error("syntax error: %s", msg);
+       /* NOTREACHED */
+}
+
 static void ash_msg_and_raise(int, const char *, ...) NORETURN;
 static void
 ash_msg_and_raise(int cond, const char *msg, ...)
@@ -2700,23 +2689,26 @@ SIT(int c, int syntax)
        const char *s;
        int indx;
 
-       if (c == PEOF)          /* 2^8+2 */
+       if (c == PEOF) {         /* 2^8+2 */
                return CENDFILE;
+       }
 #if ENABLE_ASH_ALIAS
-       if (c == PEOA)          /* 2^8+1 */
+       if (c == PEOA) {         /* 2^8+1 */
                indx = 0;
-       else
+       else
 #endif
-
-       if ((unsigned char)c >= (unsigned char)(CTLESC)
-        && (unsigned char)c <= (unsigned char)(CTLQUOTEMARK)
-       ) {
-               return CCTL;
+       {
+               if ((unsigned char)c >= (unsigned char)(CTLESC)
+                && (unsigned char)c <= (unsigned char)(CTLQUOTEMARK)
+               ) {
+                       return CCTL;
+               }
+               s = strchrnul(spec_symbls, c);
+               if (*s == '\0') {
+                       return CWORD;
+               }
+               indx = syntax_index_table[s - spec_symbls];
        }
-       s = strchrnul(spec_symbls, c);
-       if (*s == '\0')
-               return CWORD;
-       indx = syntax_index_table[s - spec_symbls];
        return S_I_T[indx][syntax];
 }
 
@@ -3019,7 +3011,7 @@ static const char syntax_index_table[258] = {
        /* 257   127      */ CWORD_CWORD_CWORD_CWORD,
 };
 
-#define SIT(c, syntax) (S_I_T[(int)syntax_index_table[((int)c)+SYNBASE]][syntax])
+#define SIT(c, syntax) (S_I_T[(int)syntax_index_table[(int)(c) + SYNBASE]][syntax])
 
 #endif  /* USE_SIT_FUNCTION */
 
@@ -5252,7 +5244,32 @@ redirectsafe(union node *redir, int flags)
  */
 
 #if ENABLE_SH_MATH_SUPPORT
-static arith_t dash_arith(const char *);
+static arith_t
+ash_arith(const char *s)
+{
+       arith_eval_hooks_t math_hooks;
+       arith_t result;
+       int errcode = 0;
+
+       math_hooks.lookupvar = lookupvar;
+       math_hooks.setvar = setvar;
+       math_hooks.endofname = endofname;
+
+       INT_OFF;
+       result = arith(s, &errcode, &math_hooks);
+       if (errcode < 0) {
+               if (errcode == -3)
+                       ash_msg_and_raise_error("exponent less than 0");
+               if (errcode == -2)
+                       ash_msg_and_raise_error("divide by zero");
+               if (errcode == -5)
+                       ash_msg_and_raise_error("expression recursion loop detected");
+               raise_error_syntax(s);
+       }
+       INT_ON;
+
+       return result;
+}
 #endif
 
 /*
@@ -5731,7 +5748,7 @@ expari(int quotes)
        if (quotes)
                rmescapes(p + 2);
 
-       len = cvtnum(dash_arith(p + 2));
+       len = cvtnum(ash_arith(p + 2));
 
        if (flag != '"')
                recordregion(begoff, begoff + len, 0);
@@ -10138,14 +10155,6 @@ static struct heredoc *heredoc;
  */
 #define NEOF ((union node *)&tokpushback)
 
-static void raise_error_syntax(const char *) NORETURN;
-static void
-raise_error_syntax(const char *msg)
-{
-       ash_msg_and_raise_error("syntax error: %s", msg);
-       /* NOTREACHED */
-}
-
 /*
  * Called when an unexpected token is read during the parse.  The argument
  * is the token that is expected, or -1 if more than one type of token can
@@ -11839,7 +11848,9 @@ cmdloop(int top)
 #endif
                }
                n = parsecmd(inter);
-               /* showtree(n); DEBUG */
+#if DEBUG
+               showtree(n);
+#endif
                if (n == NEOF) {
                        if (!top || numeof >= 50)
                                break;
@@ -12221,7 +12232,9 @@ helpcmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
        unsigned col;
        unsigned i;
 
-       out1fmt("\nBuilt-in commands:\n-------------------\n");
+       out1fmt("\n"
+               "Built-in commands:\n"
+               "------------------\n");
        for (col = 0, i = 0; i < ARRAY_SIZE(builtintab); i++) {
                col += out1fmt("%c%s", ((col == 0) ? '\t' : ' '),
                                        builtintab[i].name + 1);
@@ -12364,33 +12377,11 @@ timescmd(int argc UNUSED_PARAM, char **argv UNUSED_PARAM)
 }
 
 #if ENABLE_SH_MATH_SUPPORT
-static arith_t
-dash_arith(const char *s)
-{
-       arith_t result;
-       int errcode = 0;
-
-       INT_OFF;
-       result = arith(s, &errcode, &math_hooks);
-       if (errcode < 0) {
-               if (errcode == -3)
-                       ash_msg_and_raise_error("exponent less than 0");
-               if (errcode == -2)
-                       ash_msg_and_raise_error("divide by zero");
-               if (errcode == -5)
-                       ash_msg_and_raise_error("expression recursion loop detected");
-               raise_error_syntax(s);
-       }
-       INT_ON;
-
-       return result;
-}
-
 /*
- *  The let builtin. partial stolen from GNU Bash, the Bourne Again SHell.
- *  Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
+ * The let builtin. partial stolen from GNU Bash, the Bourne Again SHell.
+ * Copyright (C) 1987, 1989, 1991 Free Software Foundation, Inc.
  *
- *  Copyright (C) 2003 Vladimir Oleynik <dzo@simtreas.ru>
+ * Copyright (C) 2003 Vladimir Oleynik <dzo@simtreas.ru>
  */
 static int
 letcmd(int argc UNUSED_PARAM, char **argv)
@@ -12401,7 +12392,7 @@ letcmd(int argc UNUSED_PARAM, char **argv)
        if (!*argv)
                ash_msg_and_raise_error("expression expected");
        do {
-               i = dash_arith(*argv);
+               i = ash_arith(*argv);
        } while (*++argv);
 
        return !i;
@@ -13130,11 +13121,6 @@ int ash_main(int argc UNUSED_PARAM, char **argv)
        INIT_G_alias();
 #endif
        INIT_G_cmdtable();
-#if ENABLE_SH_MATH_SUPPORT
-       math_hooks.lookupvar = lookupvar;
-       math_hooks.setvar = setvar;
-       math_hooks.endofname = endofname;
-#endif
 
 #if PROFILE
        monitor(4, etext, profile_buf, sizeof(profile_buf), 50);