diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2018-07-20 14:45:12 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2018-07-20 16:27:26 +0200 |
commit | 57235beb696a7dbdb48751b9721c4c025127ae96 (patch) | |
tree | 04b5ce752fea69cae5158b13298a5929610b813c | |
parent | 18e8b6129298c02f7b5ccc17fee6bccc01a8968f (diff) | |
download | busybox-w32-57235beb696a7dbdb48751b9721c4c025127ae96.tar.gz busybox-w32-57235beb696a7dbdb48751b9721c4c025127ae96.tar.bz2 busybox-w32-57235beb696a7dbdb48751b9721c4c025127ae96.zip |
hush: expand_vars_to_list() should not assume it starts new word
function old new delta
expand_variables 112 115 +3
expand_vars_to_list 1117 1108 -9
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/1 up/down: 3/-9) Total: -6 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/hush.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/shell/hush.c b/shell/hush.c index fca67dc17..b8af1b088 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -3343,7 +3343,6 @@ static char **o_finalize_list(o_string *o, int n) | |||
3343 | char **list; | 3343 | char **list; |
3344 | int string_start; | 3344 | int string_start; |
3345 | 3345 | ||
3346 | n = o_save_ptr(o, n); /* force growth for list[n] if necessary */ | ||
3347 | if (DEBUG_EXPAND) | 3346 | if (DEBUG_EXPAND) |
3348 | debug_print_list("finalized", o, n); | 3347 | debug_print_list("finalized", o, n); |
3349 | debug_printf_expand("finalized n:%d\n", n); | 3348 | debug_printf_expand("finalized n:%d\n", n); |
@@ -6334,12 +6333,8 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg) | |||
6334 | char cant_be_null = 0; /* only bit 0x80 matters */ | 6333 | char cant_be_null = 0; /* only bit 0x80 matters */ |
6335 | char *p; | 6334 | char *p; |
6336 | 6335 | ||
6337 | output->ended_in_ifs = 0; /* did last unquoted expansion end with IFS chars? */ | ||
6338 | |||
6339 | debug_printf_expand("expand_vars_to_list: arg:'%s' singleword:%x\n", arg, | 6336 | debug_printf_expand("expand_vars_to_list: arg:'%s' singleword:%x\n", arg, |
6340 | !!(output->o_expflags & EXP_FLAG_SINGLEWORD)); | 6337 | !!(output->o_expflags & EXP_FLAG_SINGLEWORD)); |
6341 | debug_print_list("expand_vars_to_list", output, n); | ||
6342 | n = o_save_ptr(output, n); | ||
6343 | debug_print_list("expand_vars_to_list[0]", output, n); | 6338 | debug_print_list("expand_vars_to_list[0]", output, n); |
6344 | 6339 | ||
6345 | while ((p = strchr(arg, SPECIAL_VAR_SYMBOL)) != NULL) { | 6340 | while ((p = strchr(arg, SPECIAL_VAR_SYMBOL)) != NULL) { |
@@ -6512,9 +6507,16 @@ static char **expand_variables(char **argv, unsigned expflags) | |||
6512 | output.o_expflags = expflags; | 6507 | output.o_expflags = expflags; |
6513 | 6508 | ||
6514 | n = 0; | 6509 | n = 0; |
6515 | while (*argv) { | 6510 | for (;;) { |
6516 | n = expand_vars_to_list(&output, n, *argv); | 6511 | /* go to next list[n] */ |
6517 | argv++; | 6512 | output.ended_in_ifs = 0; |
6513 | n = o_save_ptr(&output, n); | ||
6514 | |||
6515 | if (!*argv) | ||
6516 | break; | ||
6517 | |||
6518 | /* expand argv[i] */ | ||
6519 | n = expand_vars_to_list(&output, n, *argv++); | ||
6518 | } | 6520 | } |
6519 | debug_print_list("expand_variables", &output, n); | 6521 | debug_print_list("expand_variables", &output, n); |
6520 | 6522 | ||