summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <dvlasenk@redhat.com>2010-09-10 10:12:34 +0200
committerDenys Vlasenko <dvlasenk@redhat.com>2010-09-10 10:12:34 +0200
commita769e0225d965d7eced9f04d99c3a66b1c427ee3 (patch)
tree733f13ebc0af81c81d523537e6fd0cac9061ecce
parentbfc02a76c5c3f0c8a5de518a46951098fef1e3cb (diff)
downloadbusybox-w32-a769e0225d965d7eced9f04d99c3a66b1c427ee3.tar.gz
busybox-w32-a769e0225d965d7eced9f04d99c3a66b1c427ee3.tar.bz2
busybox-w32-a769e0225d965d7eced9f04d99c3a66b1c427ee3.zip
hush: remove useless ESC_GLOB_CHARS clears/resotres
function old new delta o_addQstr 43 165 +122 expand_on_ifs 210 189 -21 expand_vars_to_list 1122 1094 -28 o_addqblock 139 - -139 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 1/2 up/down: 122/-188) Total: -66 bytes Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
-rw-r--r--shell/hush.c19
1 files changed, 4 insertions, 15 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 9c615275c..b7aeab28c 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -4353,13 +4353,12 @@ static int expand_on_ifs(o_string *output, int n, const char *str)
4353 while (1) { 4353 while (1) {
4354 int word_len = strcspn(str, G.ifs); 4354 int word_len = strcspn(str, G.ifs);
4355 if (word_len) { 4355 if (word_len) {
4356 if (output->o_expflags & EXP_FLAG_ESC_GLOB_CHARS) 4356 if (!(output->o_expflags & EXP_FLAG_GLOB))
4357 o_addqblock(output, str, word_len);
4358 else if (!(output->o_expflags & EXP_FLAG_GLOB))
4359 o_addblock(output, str, word_len); 4357 o_addblock(output, str, word_len);
4360 else /* if (!escape && glob) */ { 4358 else {
4361 /* Protect backslashes against globbing up :) 4359 /* Protect backslashes against globbing up :)
4362 * Example: "v='\*'; echo b$v" 4360 * Example: "v='\*'; echo b$v" prints "b\*"
4361 * (and does not try to glob on "*")
4363 */ 4362 */
4364 o_addblock_duplicate_backslash(output, str, word_len); 4363 o_addblock_duplicate_backslash(output, str, word_len);
4365 /*/ Why can't we do it easier? */ 4364 /*/ Why can't we do it easier? */
@@ -4819,10 +4818,6 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg)
4819 i = 1; 4818 i = 1;
4820 cant_be_null |= first_ch; /* do it for "$@" _now_, when we know it's not empty */ 4819 cant_be_null |= first_ch; /* do it for "$@" _now_, when we know it's not empty */
4821 if (!(first_ch & 0x80)) { /* unquoted $* or $@ */ 4820 if (!(first_ch & 0x80)) { /* unquoted $* or $@ */
4822 int sv = output->o_expflags;
4823 /* unquoted var's contents should be globbed, so don't escape */
4824//TODO: make _caller_ set EXP_FLAG_ESC_GLOB_CHARS properly
4825 output->o_expflags &= ~EXP_FLAG_ESC_GLOB_CHARS;
4826 while (G.global_argv[i]) { 4821 while (G.global_argv[i]) {
4827 n = expand_on_ifs(output, n, G.global_argv[i]); 4822 n = expand_on_ifs(output, n, G.global_argv[i]);
4828 debug_printf_expand("expand_vars_to_list: argv %d (last %d)\n", i, G.global_argc - 1); 4823 debug_printf_expand("expand_vars_to_list: argv %d (last %d)\n", i, G.global_argc - 1);
@@ -4835,7 +4830,6 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg)
4835 debug_print_list("expand_vars_to_list[3]", output, n); 4830 debug_print_list("expand_vars_to_list[3]", output, n);
4836 } 4831 }
4837 } 4832 }
4838 output->o_expflags = sv;
4839 } else 4833 } else
4840 /* If EXP_FLAG_SINGLEWORD, we handle assignment 'a=....$@.....' 4834 /* If EXP_FLAG_SINGLEWORD, we handle assignment 'a=....$@.....'
4841 * and in this case should treat it like '$*' - see 'else...' below */ 4835 * and in this case should treat it like '$*' - see 'else...' below */
@@ -4917,13 +4911,8 @@ static NOINLINE int expand_vars_to_list(o_string *output, int n, char *arg)
4917 debug_printf_expand("unquoted '%s', output->o_escape:%d\n", val, 4911 debug_printf_expand("unquoted '%s', output->o_escape:%d\n", val,
4918 !!(output->o_expflags & EXP_FLAG_ESC_GLOB_CHARS)); 4912 !!(output->o_expflags & EXP_FLAG_ESC_GLOB_CHARS));
4919 if (val && val[0]) { 4913 if (val && val[0]) {
4920 /* unquoted var's contents should be globbed, so don't escape */
4921 int sv = output->o_expflags;
4922//TODO: make _caller_ set EXP_FLAG_ESC_GLOB_CHARS properly
4923 output->o_expflags &= ~EXP_FLAG_ESC_GLOB_CHARS;
4924 n = expand_on_ifs(output, n, val); 4914 n = expand_on_ifs(output, n, val);
4925 val = NULL; 4915 val = NULL;
4926 output->o_expflags = sv;
4927 } 4916 }
4928 } else { /* quoted $VAR, val will be appended below */ 4917 } else { /* quoted $VAR, val will be appended below */
4929 debug_printf_expand("quoted '%s', output->o_escape:%d\n", val, 4918 debug_printf_expand("quoted '%s', output->o_escape:%d\n", val,