aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-08-13 23:20:10 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-08-13 23:20:10 +0200
commit438b92efdd73d0552ecaa938aa33de7f445bb87f (patch)
tree53344882139e546bbb5c748223aa74266d2b2e81 /shell
parentf29ab91763acc2a43975540971d88f962e1a5cbc (diff)
downloadbusybox-w32-438b92efdd73d0552ecaa938aa33de7f445bb87f.tar.gz
busybox-w32-438b92efdd73d0552ecaa938aa33de7f445bb87f.tar.bz2
busybox-w32-438b92efdd73d0552ecaa938aa33de7f445bb87f.zip
hush: optimize decoding of $'str' - avoid extra function call if we can
function old new delta parse_stream 2565 2572 +7 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/shell/hush.c b/shell/hush.c
index 85f49c844..808adf7b1 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -5125,10 +5125,11 @@ static int parse_dollar_squote(o_string *as_string, o_string *dest, struct in_st
5125{ 5125{
5126 int start; 5126 int start;
5127 int ch = i_peek_and_eat_bkslash_nl(input); /* first character after the $ */ 5127 int ch = i_peek_and_eat_bkslash_nl(input); /* first character after the $ */
5128 debug_printf_parse("parse_dollar_squote entered: ch='%c'\n", ch); 5128
5129 if (ch != '\'') 5129 if (ch != '\'')
5130 return 0; 5130 return 0;
5131 5131
5132 debug_printf_parse("parse_dollar_squote entered: ch='%c'\n", ch);
5132 dest->has_quoted_part = 1; 5133 dest->has_quoted_part = 1;
5133 start = dest->length; 5134 start = dest->length;
5134 5135
@@ -5537,8 +5538,6 @@ static int encode_string(o_string *as_string,
5537 goto again; 5538 goto again;
5538 } 5539 }
5539 if (ch == '$') { 5540 if (ch == '$') {
5540 //if (parse_dollar_squote(as_string, dest, input))
5541 // goto again;
5542 if (!parse_dollar(as_string, dest, input, /*quote_mask:*/ 0x80)) { 5541 if (!parse_dollar(as_string, dest, input, /*quote_mask:*/ 0x80)) {
5543 debug_printf_parse("encode_string return 0: " 5542 debug_printf_parse("encode_string return 0: "
5544 "parse_dollar returned 0 (error)\n"); 5543 "parse_dollar returned 0 (error)\n");
@@ -5977,8 +5976,8 @@ static struct pipe *parse_stream(char **pstring,
5977 o_addchr(&ctx.word, ch); 5976 o_addchr(&ctx.word, ch);
5978 continue; /* get next char */ 5977 continue; /* get next char */
5979 case '$': 5978 case '$':
5980 if (parse_dollar_squote(&ctx.as_string, &ctx.word, input)) 5979 if (next == '\'' && parse_dollar_squote(&ctx.as_string, &ctx.word, input))
5981 continue; /* get next char */ 5980 continue; /* ate $'...', get next char */
5982 if (!parse_dollar(&ctx.as_string, &ctx.word, input, /*quote_mask:*/ 0)) { 5981 if (!parse_dollar(&ctx.as_string, &ctx.word, input, /*quote_mask:*/ 0)) {
5983 debug_printf_parse("parse_stream parse error: " 5982 debug_printf_parse("parse_stream parse error: "
5984 "parse_dollar returned 0 (error)\n"); 5983 "parse_dollar returned 0 (error)\n");