summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2018-04-10 13:13:10 +0200
committerDenys Vlasenko2018-04-10 14:23:49 +0200
commite8b1bc0481828d84cea2862eab0ad13a73b0caca (patch)
tree802d2103a8374f6b3d3be0370c9263e69caf8fc4
parent1c57269b5d1891aef5093e7a5824f1adfbb33847 (diff)
downloadbusybox-e8b1bc0481828d84cea2862eab0ad13a73b0caca.zip
busybox-e8b1bc0481828d84cea2862eab0ad13a73b0caca.tar.gz
hush: simplify \<newline> code, part 2
function old new delta parse_stream 2787 2780 -7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c60
1 files changed, 30 insertions, 30 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 94ab450..3c67186 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -5364,7 +5364,7 @@ static struct pipe *parse_stream(char **pstring,
case '#':
/* non-comment #: "echo a#b" etc */
o_addchr(&ctx.word, ch);
- break;
+ continue; /* get next char */
case '\\':
if (next == EOF) {
//TODO: in ". FILE" containing "cmd\" (no newline) bash ignores last "\"
@@ -5380,51 +5380,51 @@ static struct pipe *parse_stream(char **pstring,
/* Example: echo Hello \2>file
* we need to know that word 2 is quoted */
ctx.word.has_quoted_part = 1;
- break;
+ continue; /* get next char */
case '$':
if (!parse_dollar(&ctx.as_string, &ctx.word, input, /*quote_mask:*/ 0)) {
debug_printf_parse("parse_stream parse error: "
"parse_dollar returned 0 (error)\n");
goto parse_error;
}
- break;
+ continue; /* get next char */
case '\'':
ctx.word.has_quoted_part = 1;
- if (next == '\'' && !ctx.pending_redirect) {
+ if (next == '\'' && !ctx.pending_redirect)
+ goto insert_empty_quoted_str_marker;
+ while (1) {
+ ch = i_getch(input);
+ if (ch == EOF) {
+ syntax_error_unterm_ch('\'');
+ goto parse_error;
+ }
+ nommu_addchr(&ctx.as_string, ch);
+ if (ch == '\'')
+ break;
+ if (ch == SPECIAL_VAR_SYMBOL) {
+ /* Convert raw ^C to corresponding special variable reference */
+ o_addchr(&ctx.word, SPECIAL_VAR_SYMBOL);
+ o_addchr(&ctx.word, SPECIAL_VAR_QUOTED_SVS);
+ }
+ o_addqchr(&ctx.word, ch);
+ }
+ continue; /* get next char */
+ case '"':
+ ctx.word.has_quoted_part = 1;
+ if (next == '"' && !ctx.pending_redirect) {
insert_empty_quoted_str_marker:
nommu_addchr(&ctx.as_string, next);
i_getch(input); /* eat second ' */
o_addchr(&ctx.word, SPECIAL_VAR_SYMBOL);
o_addchr(&ctx.word, SPECIAL_VAR_SYMBOL);
- } else {
- while (1) {
- ch = i_getch(input);
- if (ch == EOF) {
- syntax_error_unterm_ch('\'');
- goto parse_error;
- }
- nommu_addchr(&ctx.as_string, ch);
- if (ch == '\'')
- break;
- if (ch == SPECIAL_VAR_SYMBOL) {
- /* Convert raw ^C to corresponding special variable reference */
- o_addchr(&ctx.word, SPECIAL_VAR_SYMBOL);
- o_addchr(&ctx.word, SPECIAL_VAR_QUOTED_SVS);
- }
- o_addqchr(&ctx.word, ch);
- }
+ continue; /* get next char */
}
- break;
- case '"':
- ctx.word.has_quoted_part = 1;
- if (next == '"' && !ctx.pending_redirect)
- goto insert_empty_quoted_str_marker;
if (ctx.is_assignment == NOT_ASSIGNMENT)
ctx.word.o_expflags |= EXP_FLAG_ESC_GLOB_CHARS;
if (!encode_string(&ctx.as_string, &ctx.word, input, '"', /*process_bkslash:*/ 1))
goto parse_error;
ctx.word.o_expflags &= ~EXP_FLAG_ESC_GLOB_CHARS;
- break;
+ continue; /* get next char */
#if ENABLE_HUSH_TICK
case '`': {
USE_FOR_NOMMU(unsigned pos;)
@@ -5440,7 +5440,7 @@ static struct pipe *parse_stream(char **pstring,
# endif
o_addchr(&ctx.word, SPECIAL_VAR_SYMBOL);
//debug_printf_subst("SUBST RES3 '%s'\n", ctx.word.data + pos);
- break;
+ continue; /* get next char */
}
#endif
case ';':
@@ -5472,7 +5472,7 @@ static struct pipe *parse_stream(char **pstring,
* with an assignment */
ctx.is_assignment = MAYBE_ASSIGNMENT;
debug_printf_parse("ctx.is_assignment='%s'\n", assignment_flag[ctx.is_assignment]);
- break;
+ continue; /* get next char */
case '&':
if (done_word(&ctx)) {
goto parse_error;
@@ -5512,7 +5512,7 @@ static struct pipe *parse_stream(char **pstring,
&& ctx.word.length == 0 /* not word(... */
&& ctx.word.has_quoted_part == 0 /* not ""(... */
) {
- continue;
+ continue; /* get next char */
}
#endif
case '{':