diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-22 17:50:43 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-22 17:50:43 +0200 |
commit | 8391c4800cda0eda6e64c464cc0ea85d1785a768 (patch) | |
tree | e76ddcfef6620aa7f368c2c0ca3a3de6412663f3 /shell/hush.c | |
parent | 2e48d536cee3c2fb261780eb2a01972bd936a56c (diff) | |
download | busybox-w32-8391c4800cda0eda6e64c464cc0ea85d1785a768.tar.gz busybox-w32-8391c4800cda0eda6e64c464cc0ea85d1785a768.tar.bz2 busybox-w32-8391c4800cda0eda6e64c464cc0ea85d1785a768.zip |
hush: trivial code shrink
function old new delta
static_get 26 22 -4
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/shell/hush.c b/shell/hush.c index e9d31b436..72cfb232a 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -814,10 +814,10 @@ static void xxfree(void *ptr) | |||
814 | fdprintf(2, "free %p\n", ptr); | 814 | fdprintf(2, "free %p\n", ptr); |
815 | free(ptr); | 815 | free(ptr); |
816 | } | 816 | } |
817 | #define xmalloc(s) xxmalloc(__LINE__, s) | 817 | # define xmalloc(s) xxmalloc(__LINE__, s) |
818 | #define xrealloc(p, s) xxrealloc(__LINE__, p, s) | 818 | # define xrealloc(p, s) xxrealloc(__LINE__, p, s) |
819 | #define xstrdup(s) xxstrdup(__LINE__, s) | 819 | # define xstrdup(s) xxstrdup(__LINE__, s) |
820 | #define free(p) xxfree(p) | 820 | # define free(p) xxfree(p) |
821 | #endif | 821 | #endif |
822 | 822 | ||
823 | 823 | ||
@@ -1161,9 +1161,9 @@ static void SIGCHLD_handler(int sig UNUSED_PARAM) | |||
1161 | #if ENABLE_HUSH_JOB | 1161 | #if ENABLE_HUSH_JOB |
1162 | 1162 | ||
1163 | /* After [v]fork, in child: do not restore tty pgrp on xfunc death */ | 1163 | /* After [v]fork, in child: do not restore tty pgrp on xfunc death */ |
1164 | #define disable_restore_tty_pgrp_on_exit() (die_sleep = 0) | 1164 | # define disable_restore_tty_pgrp_on_exit() (die_sleep = 0) |
1165 | /* After [v]fork, in parent: restore tty pgrp on xfunc death */ | 1165 | /* After [v]fork, in parent: restore tty pgrp on xfunc death */ |
1166 | #define enable_restore_tty_pgrp_on_exit() (die_sleep = -1) | 1166 | # define enable_restore_tty_pgrp_on_exit() (die_sleep = -1) |
1167 | 1167 | ||
1168 | /* Restores tty foreground process group, and exits. | 1168 | /* Restores tty foreground process group, and exits. |
1169 | * May be called as signal handler for fatal signal | 1169 | * May be called as signal handler for fatal signal |
@@ -1189,8 +1189,8 @@ static void sigexit(int sig) | |||
1189 | } | 1189 | } |
1190 | #else | 1190 | #else |
1191 | 1191 | ||
1192 | #define disable_restore_tty_pgrp_on_exit() ((void)0) | 1192 | # define disable_restore_tty_pgrp_on_exit() ((void)0) |
1193 | #define enable_restore_tty_pgrp_on_exit() ((void)0) | 1193 | # define enable_restore_tty_pgrp_on_exit() ((void)0) |
1194 | 1194 | ||
1195 | #endif | 1195 | #endif |
1196 | 1196 | ||
@@ -1522,8 +1522,8 @@ static void unset_vars(char **strings) | |||
1522 | } | 1522 | } |
1523 | 1523 | ||
1524 | #if ENABLE_SH_MATH_SUPPORT | 1524 | #if ENABLE_SH_MATH_SUPPORT |
1525 | #define is_name(c) ((c) == '_' || isalpha((unsigned char)(c))) | 1525 | # define is_name(c) ((c) == '_' || isalpha((unsigned char)(c))) |
1526 | #define is_in_name(c) ((c) == '_' || isalnum((unsigned char)(c))) | 1526 | # define is_in_name(c) ((c) == '_' || isalnum((unsigned char)(c))) |
1527 | static char* FAST_FUNC endofname(const char *name) | 1527 | static char* FAST_FUNC endofname(const char *name) |
1528 | { | 1528 | { |
1529 | char *p; | 1529 | char *p; |
@@ -1607,10 +1607,11 @@ static struct variable *set_vars_and_save_old(char **strings) | |||
1607 | */ | 1607 | */ |
1608 | static int FAST_FUNC static_get(struct in_str *i) | 1608 | static int FAST_FUNC static_get(struct in_str *i) |
1609 | { | 1609 | { |
1610 | int ch = *i->p++; | 1610 | int ch = *i->p; |
1611 | if (ch != '\0') | 1611 | if (ch != '\0') { |
1612 | i->p++; | ||
1612 | return ch; | 1613 | return ch; |
1613 | i->p--; | 1614 | } |
1614 | return EOF; | 1615 | return EOF; |
1615 | } | 1616 | } |
1616 | 1617 | ||
@@ -1662,7 +1663,7 @@ static void get_user_input(struct in_str *i) | |||
1662 | const char *prompt_str; | 1663 | const char *prompt_str; |
1663 | 1664 | ||
1664 | prompt_str = setup_prompt_string(i->promptmode); | 1665 | prompt_str = setup_prompt_string(i->promptmode); |
1665 | #if ENABLE_FEATURE_EDITING | 1666 | # if ENABLE_FEATURE_EDITING |
1666 | /* Enable command line editing only while a command line | 1667 | /* Enable command line editing only while a command line |
1667 | * is actually being read */ | 1668 | * is actually being read */ |
1668 | do { | 1669 | do { |
@@ -1678,7 +1679,7 @@ static void get_user_input(struct in_str *i) | |||
1678 | G.user_input_buf[0] = EOF; /* yes, it will be truncated, it's ok */ | 1679 | G.user_input_buf[0] = EOF; /* yes, it will be truncated, it's ok */ |
1679 | G.user_input_buf[1] = '\0'; | 1680 | G.user_input_buf[1] = '\0'; |
1680 | } | 1681 | } |
1681 | #else | 1682 | # else |
1682 | do { | 1683 | do { |
1683 | G.flag_SIGINT = 0; | 1684 | G.flag_SIGINT = 0; |
1684 | fputs(prompt_str, stdout); | 1685 | fputs(prompt_str, stdout); |
@@ -1688,7 +1689,7 @@ static void get_user_input(struct in_str *i) | |||
1688 | //do we need check_and_run_traps(0)? (maybe only if stdin) | 1689 | //do we need check_and_run_traps(0)? (maybe only if stdin) |
1689 | } while (G.flag_SIGINT); | 1690 | } while (G.flag_SIGINT); |
1690 | i->eof_flag = (r == EOF); | 1691 | i->eof_flag = (r == EOF); |
1691 | #endif | 1692 | # endif |
1692 | i->p = G.user_input_buf; | 1693 | i->p = G.user_input_buf; |
1693 | } | 1694 | } |
1694 | 1695 | ||
@@ -2221,7 +2222,7 @@ static int o_glob(o_string *o, int n) | |||
2221 | return n; | 2222 | return n; |
2222 | } | 2223 | } |
2223 | 2224 | ||
2224 | #else | 2225 | #else /* !HUSH_BRACE_EXP */ |
2225 | 2226 | ||
2226 | /* Helper */ | 2227 | /* Helper */ |
2227 | static int glob_needed(const char *s) | 2228 | static int glob_needed(const char *s) |
@@ -2298,7 +2299,7 @@ static int o_glob(o_string *o, int n) | |||
2298 | return n; | 2299 | return n; |
2299 | } | 2300 | } |
2300 | 2301 | ||
2301 | #endif | 2302 | #endif /* !HUSH_BRACE_EXP */ |
2302 | 2303 | ||
2303 | /* If o->o_glob == 1, glob the string so far remembered. | 2304 | /* If o->o_glob == 1, glob the string so far remembered. |
2304 | * Otherwise, just finish current list[] and start new */ | 2305 | * Otherwise, just finish current list[] and start new */ |
@@ -3033,7 +3034,7 @@ static void re_execute_shell(char ***to_free, const char *s, | |||
3033 | char *g_argv0, char **g_argv, | 3034 | char *g_argv0, char **g_argv, |
3034 | char **builtin_argv) | 3035 | char **builtin_argv) |
3035 | { | 3036 | { |
3036 | #define NOMMU_HACK_FMT ("-$%x:%x:%x:%x:%x:%llx" IF_HUSH_LOOPS(":%x")) | 3037 | # define NOMMU_HACK_FMT ("-$%x:%x:%x:%x:%x:%llx" IF_HUSH_LOOPS(":%x")) |
3037 | /* delims + 2 * (number of bytes in printed hex numbers) */ | 3038 | /* delims + 2 * (number of bytes in printed hex numbers) */ |
3038 | char param_buf[sizeof(NOMMU_HACK_FMT) + 2 * (sizeof(int)*6 + sizeof(long long)*1)]; | 3039 | char param_buf[sizeof(NOMMU_HACK_FMT) + 2 * (sizeof(int)*6 + sizeof(long long)*1)]; |
3039 | char *heredoc_argv[4]; | 3040 | char *heredoc_argv[4]; |
@@ -3078,7 +3079,7 @@ static void re_execute_shell(char ***to_free, const char *s, | |||
3078 | , empty_trap_mask | 3079 | , empty_trap_mask |
3079 | IF_HUSH_LOOPS(, G.depth_of_loop) | 3080 | IF_HUSH_LOOPS(, G.depth_of_loop) |
3080 | ); | 3081 | ); |
3081 | #undef NOMMU_HACK_FMT | 3082 | # undef NOMMU_HACK_FMT |
3082 | /* 1:hush 2:-$<pid>:<pid>:<exitcode>:<etc...> <vars...> <funcs...> | 3083 | /* 1:hush 2:-$<pid>:<pid>:<exitcode>:<etc...> <vars...> <funcs...> |
3083 | * 3:-c 4:<cmd> 5:<arg0> <argN...> 6:NULL | 3084 | * 3:-c 4:<cmd> 5:<arg0> <argN...> 6:NULL |
3084 | */ | 3085 | */ |