diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-22 00:53:32 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-05-22 00:53:32 +0200 |
commit | ddc62f64baad8abdeb587b13afe8d47fb347981c (patch) | |
tree | b6c5cb4e5eb778206fd29895818b19e7e6e7635a /shell/hush.c | |
parent | a6ad397ea92cd9c53973243728d3e52640fe63ec (diff) | |
download | busybox-w32-ddc62f64baad8abdeb587b13afe8d47fb347981c.tar.gz busybox-w32-ddc62f64baad8abdeb587b13afe8d47fb347981c.tar.bz2 busybox-w32-ddc62f64baad8abdeb587b13afe8d47fb347981c.zip |
hush: fix a nommu todo in recent commits
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush.c')
-rw-r--r-- | shell/hush.c | 62 |
1 files changed, 37 insertions, 25 deletions
diff --git a/shell/hush.c b/shell/hush.c index 32b90876f..0f0151a21 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -5767,7 +5767,9 @@ static int parse_group(o_string *dest, struct parse_context *ctx, | |||
5767 | } | 5767 | } |
5768 | 5768 | ||
5769 | { | 5769 | { |
5770 | #if !BB_MMU | 5770 | #if BB_MMU |
5771 | # define as_string NULL | ||
5772 | #else | ||
5771 | char *as_string = NULL; | 5773 | char *as_string = NULL; |
5772 | #endif | 5774 | #endif |
5773 | pipe_list = parse_stream(&as_string, input, endch); | 5775 | pipe_list = parse_stream(&as_string, input, endch); |
@@ -5778,9 +5780,8 @@ static int parse_group(o_string *dest, struct parse_context *ctx, | |||
5778 | /* empty ()/{} or parse error? */ | 5780 | /* empty ()/{} or parse error? */ |
5779 | if (!pipe_list || pipe_list == ERR_PTR) { | 5781 | if (!pipe_list || pipe_list == ERR_PTR) { |
5780 | /* parse_stream already emitted error msg */ | 5782 | /* parse_stream already emitted error msg */ |
5781 | #if !BB_MMU | 5783 | if (!BB_MMU) |
5782 | free(as_string); | 5784 | free(as_string); |
5783 | #endif | ||
5784 | debug_printf_parse("parse_group return 1: " | 5785 | debug_printf_parse("parse_group return 1: " |
5785 | "parse_stream returned %p\n", pipe_list); | 5786 | "parse_stream returned %p\n", pipe_list); |
5786 | return 1; | 5787 | return 1; |
@@ -5792,6 +5793,7 @@ static int parse_group(o_string *dest, struct parse_context *ctx, | |||
5792 | debug_printf_parse("end of group, remembering as:'%s'\n", | 5793 | debug_printf_parse("end of group, remembering as:'%s'\n", |
5793 | command->group_as_string); | 5794 | command->group_as_string); |
5794 | #endif | 5795 | #endif |
5796 | #undef as_string | ||
5795 | } | 5797 | } |
5796 | debug_printf_parse("parse_group return 0\n"); | 5798 | debug_printf_parse("parse_group return 0\n"); |
5797 | return 0; | 5799 | return 0; |
@@ -5893,7 +5895,7 @@ static void add_till_backquote(o_string *dest, struct in_str *input) | |||
5893 | * can contain arbitrary constructs, just like $(cmd). | 5895 | * can contain arbitrary constructs, just like $(cmd). |
5894 | */ | 5896 | */ |
5895 | #define DOUBLE_CLOSE_CHAR_FLAG 0x80 | 5897 | #define DOUBLE_CLOSE_CHAR_FLAG 0x80 |
5896 | static void add_till_closing_paren(o_string *dest, struct in_str *input, char end_ch) | 5898 | static void add_till_closing_bracket(o_string *dest, struct in_str *input, char end_ch) |
5897 | { | 5899 | { |
5898 | char dbl = end_ch & DOUBLE_CLOSE_CHAR_FLAG; | 5900 | char dbl = end_ch & DOUBLE_CLOSE_CHAR_FLAG; |
5899 | end_ch &= (DOUBLE_CLOSE_CHAR_FLAG-1); | 5901 | end_ch &= (DOUBLE_CLOSE_CHAR_FLAG-1); |
@@ -5915,7 +5917,7 @@ static void add_till_closing_paren(o_string *dest, struct in_str *input, char en | |||
5915 | o_addchr(dest, ch); | 5917 | o_addchr(dest, ch); |
5916 | if (ch == '(' || ch == '{') { | 5918 | if (ch == '(' || ch == '{') { |
5917 | ch = (ch == '(' ? ')' : '}'); | 5919 | ch = (ch == '(' ? ')' : '}'); |
5918 | add_till_closing_paren(dest, input, ch); | 5920 | add_till_closing_bracket(dest, input, ch); |
5919 | o_addchr(dest, ch); | 5921 | o_addchr(dest, ch); |
5920 | continue; | 5922 | continue; |
5921 | } | 5923 | } |
@@ -5952,6 +5954,7 @@ static void add_till_closing_paren(o_string *dest, struct in_str *input, char en | |||
5952 | #if BB_MMU | 5954 | #if BB_MMU |
5953 | #define handle_dollar(as_string, dest, input) \ | 5955 | #define handle_dollar(as_string, dest, input) \ |
5954 | handle_dollar(dest, input) | 5956 | handle_dollar(dest, input) |
5957 | #define as_string NULL | ||
5955 | #endif | 5958 | #endif |
5956 | static int handle_dollar(o_string *as_string, | 5959 | static int handle_dollar(o_string *as_string, |
5957 | o_string *dest, | 5960 | o_string *dest, |
@@ -6013,12 +6016,14 @@ static int handle_dollar(o_string *as_string, | |||
6013 | } | 6016 | } |
6014 | ch |= quote_mask; | 6017 | ch |= quote_mask; |
6015 | 6018 | ||
6016 | /* It's possible to just call add_till_closing_paren() at this point. | 6019 | /* It's possible to just call add_till_closing_bracket() at this point. |
6017 | * However, this regresses some of our testsuite cases | 6020 | * However, this regresses some of our testsuite cases |
6018 | * which check invalid constructs like ${%}. | 6021 | * which check invalid constructs like ${%}. |
6019 | * Oh well... let's check that the var name part is fine... */ | 6022 | * Oh well... let's check that the var name part is fine... */ |
6020 | 6023 | ||
6021 | while (1) { | 6024 | while (1) { |
6025 | unsigned pos; | ||
6026 | |||
6022 | o_addchr(dest, ch); | 6027 | o_addchr(dest, ch); |
6023 | debug_printf_parse(": '%c'\n", ch); | 6028 | debug_printf_parse(": '%c'\n", ch); |
6024 | 6029 | ||
@@ -6035,8 +6040,15 @@ static int handle_dollar(o_string *as_string, | |||
6035 | goto bad_dollar_syntax; | 6040 | goto bad_dollar_syntax; |
6036 | /* Eat everything until closing '}' */ | 6041 | /* Eat everything until closing '}' */ |
6037 | o_addchr(dest, ch); | 6042 | o_addchr(dest, ch); |
6038 | //TODO: add nommu_addchr hack here | 6043 | if (!BB_MMU) |
6039 | add_till_closing_paren(dest, input, '}'); | 6044 | pos = dest->length; |
6045 | add_till_closing_bracket(dest, input, '}'); | ||
6046 | #if !BB_MMU | ||
6047 | if (as_string) { | ||
6048 | o_addstr(as_string, dest->data + pos); | ||
6049 | o_addchr(as_string, '}'); | ||
6050 | } | ||
6051 | #endif | ||
6040 | break; | 6052 | break; |
6041 | } | 6053 | } |
6042 | } | 6054 | } |
@@ -6045,9 +6057,8 @@ static int handle_dollar(o_string *as_string, | |||
6045 | } | 6057 | } |
6046 | #if ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_TICK | 6058 | #if ENABLE_SH_MATH_SUPPORT || ENABLE_HUSH_TICK |
6047 | case '(': { | 6059 | case '(': { |
6048 | # if !BB_MMU | 6060 | unsigned pos; |
6049 | int pos; | 6061 | |
6050 | # endif | ||
6051 | ch = i_getch(input); | 6062 | ch = i_getch(input); |
6052 | nommu_addchr(as_string, ch); | 6063 | nommu_addchr(as_string, ch); |
6053 | # if ENABLE_SH_MATH_SUPPORT | 6064 | # if ENABLE_SH_MATH_SUPPORT |
@@ -6056,17 +6067,16 @@ static int handle_dollar(o_string *as_string, | |||
6056 | nommu_addchr(as_string, ch); | 6067 | nommu_addchr(as_string, ch); |
6057 | o_addchr(dest, SPECIAL_VAR_SYMBOL); | 6068 | o_addchr(dest, SPECIAL_VAR_SYMBOL); |
6058 | o_addchr(dest, /*quote_mask |*/ '+'); | 6069 | o_addchr(dest, /*quote_mask |*/ '+'); |
6059 | # if !BB_MMU | 6070 | if (!BB_MMU) |
6060 | pos = dest->length; | 6071 | pos = dest->length; |
6061 | # endif | 6072 | add_till_closing_bracket(dest, input, ')' | DOUBLE_CLOSE_CHAR_FLAG); |
6062 | add_till_closing_paren(dest, input, ')' | DOUBLE_CLOSE_CHAR_FLAG); | 6073 | #if !BB_MMU |
6063 | # if !BB_MMU | ||
6064 | if (as_string) { | 6074 | if (as_string) { |
6065 | o_addstr(as_string, dest->data + pos); | 6075 | o_addstr(as_string, dest->data + pos); |
6066 | o_addchr(as_string, ')'); | 6076 | o_addchr(as_string, ')'); |
6067 | o_addchr(as_string, ')'); | 6077 | o_addchr(as_string, ')'); |
6068 | } | 6078 | } |
6069 | # endif | 6079 | #endif |
6070 | o_addchr(dest, SPECIAL_VAR_SYMBOL); | 6080 | o_addchr(dest, SPECIAL_VAR_SYMBOL); |
6071 | break; | 6081 | break; |
6072 | } | 6082 | } |
@@ -6074,16 +6084,15 @@ static int handle_dollar(o_string *as_string, | |||
6074 | # if ENABLE_HUSH_TICK | 6084 | # if ENABLE_HUSH_TICK |
6075 | o_addchr(dest, SPECIAL_VAR_SYMBOL); | 6085 | o_addchr(dest, SPECIAL_VAR_SYMBOL); |
6076 | o_addchr(dest, quote_mask | '`'); | 6086 | o_addchr(dest, quote_mask | '`'); |
6077 | # if !BB_MMU | 6087 | if (!BB_MMU) |
6078 | pos = dest->length; | 6088 | pos = dest->length; |
6079 | # endif | 6089 | add_till_closing_bracket(dest, input, ')'); |
6080 | add_till_closing_paren(dest, input, ')'); | 6090 | #if !BB_MMU |
6081 | # if !BB_MMU | ||
6082 | if (as_string) { | 6091 | if (as_string) { |
6083 | o_addstr(as_string, dest->data + pos); | 6092 | o_addstr(as_string, dest->data + pos); |
6084 | o_addchr(as_string, ')'); | 6093 | o_addchr(as_string, ')'); |
6085 | } | 6094 | } |
6086 | # endif | 6095 | #endif |
6087 | o_addchr(dest, SPECIAL_VAR_SYMBOL); | 6096 | o_addchr(dest, SPECIAL_VAR_SYMBOL); |
6088 | # endif | 6097 | # endif |
6089 | break; | 6098 | break; |
@@ -6108,11 +6117,13 @@ static int handle_dollar(o_string *as_string, | |||
6108 | } | 6117 | } |
6109 | debug_printf_parse("handle_dollar return 0\n"); | 6118 | debug_printf_parse("handle_dollar return 0\n"); |
6110 | return 0; | 6119 | return 0; |
6120 | #undef as_string | ||
6111 | } | 6121 | } |
6112 | 6122 | ||
6113 | #if BB_MMU | 6123 | #if BB_MMU |
6114 | #define parse_stream_dquoted(as_string, dest, input, dquote_end) \ | 6124 | #define parse_stream_dquoted(as_string, dest, input, dquote_end) \ |
6115 | parse_stream_dquoted(dest, input, dquote_end) | 6125 | parse_stream_dquoted(dest, input, dquote_end) |
6126 | #define as_string NULL | ||
6116 | #endif | 6127 | #endif |
6117 | static int parse_stream_dquoted(o_string *as_string, | 6128 | static int parse_stream_dquoted(o_string *as_string, |
6118 | o_string *dest, | 6129 | o_string *dest, |
@@ -6176,7 +6187,7 @@ static int parse_stream_dquoted(o_string *as_string, | |||
6176 | } | 6187 | } |
6177 | #if ENABLE_HUSH_TICK | 6188 | #if ENABLE_HUSH_TICK |
6178 | if (ch == '`') { | 6189 | if (ch == '`') { |
6179 | //int pos = dest->length; | 6190 | //unsigned pos = dest->length; |
6180 | o_addchr(dest, SPECIAL_VAR_SYMBOL); | 6191 | o_addchr(dest, SPECIAL_VAR_SYMBOL); |
6181 | o_addchr(dest, 0x80 | '`'); | 6192 | o_addchr(dest, 0x80 | '`'); |
6182 | add_till_backquote(dest, input); | 6193 | add_till_backquote(dest, input); |
@@ -6194,6 +6205,7 @@ static int parse_stream_dquoted(o_string *as_string, | |||
6194 | dest->o_assignment = DEFINITELY_ASSIGNMENT; | 6205 | dest->o_assignment = DEFINITELY_ASSIGNMENT; |
6195 | } | 6206 | } |
6196 | goto again; | 6207 | goto again; |
6208 | #undef as_string | ||
6197 | } | 6209 | } |
6198 | 6210 | ||
6199 | /* | 6211 | /* |