diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-16 16:12:00 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-16 16:12:00 +0200 |
commit | 52e460b7440ed5b85e4125a4eccf1e665d92c0ff (patch) | |
tree | cc006dc71e4a8e7d4e579e26da9158036a7eca5d | |
parent | 0fdf2e1026bed831e3254843e27b0577c9908030 (diff) | |
download | busybox-w32-52e460b7440ed5b85e4125a4eccf1e665d92c0ff.tar.gz busybox-w32-52e460b7440ed5b85e4125a4eccf1e665d92c0ff.tar.bz2 busybox-w32-52e460b7440ed5b85e4125a4eccf1e665d92c0ff.zip |
hush: move shell_ver from globals to main's stack.
function old new delta
hush_main 995 1011 +16
pseudo_exec_argv 253 251 -2
execvp_or_die 50 48 -2
maybe_set_to_sigexit 50 47 -3
hush_exit 78 75 -3
builtin_wait 274 271 -3
check_and_run_traps 205 200 -5
init_sigmasks 214 190 -24
builtin_trap 465 441 -24
reset_traps_to_defaults 238 211 -27
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/9 up/down: 16/-93) Total: -77 bytes
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | shell/hush.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/shell/hush.c b/shell/hush.c index a888332bc..6e36078c2 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -707,8 +707,7 @@ struct globals { | |||
707 | #endif | 707 | #endif |
708 | const char *ifs; | 708 | const char *ifs; |
709 | const char *cwd; | 709 | const char *cwd; |
710 | struct variable *top_var; /* = &G.shell_ver (set in main()) */ | 710 | struct variable *top_var; |
711 | struct variable shell_ver; | ||
712 | char **expanded_assignments; | 711 | char **expanded_assignments; |
713 | #if ENABLE_HUSH_FUNCTIONS | 712 | #if ENABLE_HUSH_FUNCTIONS |
714 | struct function *top_func; | 713 | struct function *top_func; |
@@ -7337,6 +7336,7 @@ int hush_main(int argc, char **argv) | |||
7337 | unsigned builtin_argc; | 7336 | unsigned builtin_argc; |
7338 | char **e; | 7337 | char **e; |
7339 | struct variable *cur_var; | 7338 | struct variable *cur_var; |
7339 | struct variable shell_ver; | ||
7340 | 7340 | ||
7341 | INIT_G(); | 7341 | INIT_G(); |
7342 | if (EXIT_SUCCESS) /* if EXIT_SUCCESS == 0, it is already done */ | 7342 | if (EXIT_SUCCESS) /* if EXIT_SUCCESS == 0, it is already done */ |
@@ -7345,12 +7345,13 @@ int hush_main(int argc, char **argv) | |||
7345 | G.argv0_for_re_execing = argv[0]; | 7345 | G.argv0_for_re_execing = argv[0]; |
7346 | #endif | 7346 | #endif |
7347 | /* Deal with HUSH_VERSION */ | 7347 | /* Deal with HUSH_VERSION */ |
7348 | G.shell_ver.flg_export = 1; | 7348 | memset(&shell_ver, 0, sizeof(shell_ver)); |
7349 | G.shell_ver.flg_read_only = 1; | 7349 | shell_ver.flg_export = 1; |
7350 | shell_ver.flg_read_only = 1; | ||
7350 | /* Code which handles ${var<op>...} needs writable values for all variables, | 7351 | /* Code which handles ${var<op>...} needs writable values for all variables, |
7351 | * therefore we xstrdup: */ | 7352 | * therefore we xstrdup: */ |
7352 | G.shell_ver.varstr = xstrdup(hush_version_str), | 7353 | shell_ver.varstr = xstrdup(hush_version_str), |
7353 | G.top_var = &G.shell_ver; | 7354 | G.top_var = &shell_ver; |
7354 | /* Create shell local variables from the values | 7355 | /* Create shell local variables from the values |
7355 | * currently living in the environment */ | 7356 | * currently living in the environment */ |
7356 | debug_printf_env("unsetenv '%s'\n", "HUSH_VERSION"); | 7357 | debug_printf_env("unsetenv '%s'\n", "HUSH_VERSION"); |
@@ -7369,8 +7370,8 @@ int hush_main(int argc, char **argv) | |||
7369 | e++; | 7370 | e++; |
7370 | } | 7371 | } |
7371 | /* (Re)insert HUSH_VERSION into env (AFTER we scanned the env!) */ | 7372 | /* (Re)insert HUSH_VERSION into env (AFTER we scanned the env!) */ |
7372 | debug_printf_env("putenv '%s'\n", G.shell_ver.varstr); | 7373 | debug_printf_env("putenv '%s'\n", shell_ver.varstr); |
7373 | putenv(G.shell_ver.varstr); | 7374 | putenv(shell_ver.varstr); |
7374 | 7375 | ||
7375 | /* Export PWD */ | 7376 | /* Export PWD */ |
7376 | set_pwd_var(/*exp:*/ 1); | 7377 | set_pwd_var(/*exp:*/ 1); |