diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-08 13:58:55 +0200 |
---|---|---|
committer | Denys Vlasenko <dvlasenk@redhat.com> | 2010-09-08 13:58:55 +0200 |
commit | 95d48f259807c408de731f580bd48cf20dec724a (patch) | |
tree | 0ec9de0f11eb644a0535ec54192d705b1d877203 | |
parent | 5b686cb8e6db85c0080ff8747c0fef7cb326dc20 (diff) | |
download | busybox-w32-95d48f259807c408de731f580bd48cf20dec724a.tar.gz busybox-w32-95d48f259807c408de731f580bd48cf20dec724a.tar.bz2 busybox-w32-95d48f259807c408de731f580bd48cf20dec724a.zip |
hush: eliminate redundant parameter of expand_vars_to_list()
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r-- | shell/hush.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/shell/hush.c b/shell/hush.c index 05ac4096f..1ba72f0d7 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -4782,18 +4782,18 @@ static NOINLINE const char *expand_one_var(char **to_be_freed_pp, char *arg, cha | |||
4782 | * to be filled). This routine is extremely tricky: has to deal with | 4782 | * to be filled). This routine is extremely tricky: has to deal with |
4783 | * variables/parameters with whitespace, $* and $@, and constructs like | 4783 | * variables/parameters with whitespace, $* and $@, and constructs like |
4784 | * 'echo -$*-'. If you play here, you must run testsuite afterwards! */ | 4784 | * 'echo -$*-'. If you play here, you must run testsuite afterwards! */ |
4785 | static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char or_mask) | 4785 | static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg) |
4786 | { | 4786 | { |
4787 | /* or_mask is either 0 (normal case) or 0x80 - | 4787 | /* output->o_expflags & EXP_FLAG_SINGLEWORD (0x80) if we are in |
4788 | * expansion of right-hand side of assignment == 1-element expand. | 4788 | * expansion of right-hand side of assignment == 1-element expand. |
4789 | * It will also do no globbing, and thus we must not backslash-quote! | ||
4790 | */ | 4789 | */ |
4791 | char ored_ch; | 4790 | char ored_ch; |
4792 | char *p; | 4791 | char *p; |
4793 | 4792 | ||
4794 | ored_ch = 0; | 4793 | ored_ch = 0; |
4795 | 4794 | ||
4796 | debug_printf_expand("expand_vars_to_list: arg:'%s' or_mask:%x\n", arg, or_mask); | 4795 | debug_printf_expand("expand_vars_to_list: arg:'%s' singleword:%x\n", arg, |
4796 | !!(output->o_expflags & EXP_FLAG_SINGLEWORD)); | ||
4797 | debug_print_list("expand_vars_to_list", output, n); | 4797 | debug_print_list("expand_vars_to_list", output, n); |
4798 | n = o_save_ptr(output, n); | 4798 | n = o_save_ptr(output, n); |
4799 | debug_print_list("expand_vars_to_list[0]", output, n); | 4799 | debug_print_list("expand_vars_to_list[0]", output, n); |
@@ -4813,7 +4813,7 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char | |||
4813 | arg = ++p; | 4813 | arg = ++p; |
4814 | p = strchr(p, SPECIAL_VAR_SYMBOL); | 4814 | p = strchr(p, SPECIAL_VAR_SYMBOL); |
4815 | 4815 | ||
4816 | first_ch = arg[0] | or_mask; /* forced to "quoted" if or_mask = 0x80 */ | 4816 | first_ch = arg[0] | (output->o_expflags & EXP_FLAG_SINGLEWORD); |
4817 | /* "$@" is special. Even if quoted, it can still | 4817 | /* "$@" is special. Even if quoted, it can still |
4818 | * expand to nothing (not even an empty string) */ | 4818 | * expand to nothing (not even an empty string) */ |
4819 | if ((first_ch & 0x7f) != '@') | 4819 | if ((first_ch & 0x7f) != '@') |
@@ -4846,9 +4846,11 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char | |||
4846 | } | 4846 | } |
4847 | output->o_expflags = sv; | 4847 | output->o_expflags = sv; |
4848 | } else | 4848 | } else |
4849 | /* If or_mask is nonzero, we handle assignment 'a=....$@.....' | 4849 | /* If EXP_FLAG_SINGLEWORD, we handle assignment 'a=....$@.....' |
4850 | * and in this case should treat it like '$*' - see 'else...' below */ | 4850 | * and in this case should treat it like '$*' - see 'else...' below */ |
4851 | if (first_ch == ('@'|0x80) && !or_mask) { /* quoted $@ */ | 4851 | if (first_ch == ('@'|0x80) /* quoted $@ */ |
4852 | && !(output->o_expflags & EXP_FLAG_SINGLEWORD) | ||
4853 | ) { | ||
4852 | while (1) { | 4854 | while (1) { |
4853 | o_addQstr(output, G.global_argv[i]); | 4855 | o_addQstr(output, G.global_argv[i]); |
4854 | if (++i >= G.global_argc) | 4856 | if (++i >= G.global_argc) |
@@ -4972,17 +4974,17 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg, char | |||
4972 | return n; | 4974 | return n; |
4973 | } | 4975 | } |
4974 | 4976 | ||
4975 | static char **expand_variables(char **argv, unsigned or_mask) | 4977 | static char **expand_variables(char **argv, unsigned expflags) |
4976 | { | 4978 | { |
4977 | int n; | 4979 | int n; |
4978 | char **list; | 4980 | char **list; |
4979 | o_string output = NULL_O_STRING; | 4981 | o_string output = NULL_O_STRING; |
4980 | 4982 | ||
4981 | output.o_expflags = or_mask; | 4983 | output.o_expflags = expflags; |
4982 | 4984 | ||
4983 | n = 0; | 4985 | n = 0; |
4984 | while (*argv) { | 4986 | while (*argv) { |
4985 | n = expand_vars_to_list(&output, n, *argv, (unsigned char)or_mask); | 4987 | n = expand_vars_to_list(&output, n, *argv); |
4986 | argv++; | 4988 | argv++; |
4987 | } | 4989 | } |
4988 | debug_print_list("expand_variables", &output, n); | 4990 | debug_print_list("expand_variables", &output, n); |