From 438b92efdd73d0552ecaa938aa33de7f445bb87f Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Wed, 13 Aug 2025 23:20:10 +0200 Subject: 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 --- shell/hush.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'shell') 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 { int start; int ch = i_peek_and_eat_bkslash_nl(input); /* first character after the $ */ - debug_printf_parse("parse_dollar_squote entered: ch='%c'\n", ch); + if (ch != '\'') return 0; + debug_printf_parse("parse_dollar_squote entered: ch='%c'\n", ch); dest->has_quoted_part = 1; start = dest->length; @@ -5537,8 +5538,6 @@ static int encode_string(o_string *as_string, goto again; } if (ch == '$') { - //if (parse_dollar_squote(as_string, dest, input)) - // goto again; if (!parse_dollar(as_string, dest, input, /*quote_mask:*/ 0x80)) { debug_printf_parse("encode_string return 0: " "parse_dollar returned 0 (error)\n"); @@ -5977,8 +5976,8 @@ static struct pipe *parse_stream(char **pstring, o_addchr(&ctx.word, ch); continue; /* get next char */ case '$': - if (parse_dollar_squote(&ctx.as_string, &ctx.word, input)) - continue; /* get next char */ + if (next == '\'' && parse_dollar_squote(&ctx.as_string, &ctx.word, input)) + continue; /* ate $'...', get next char */ 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"); -- cgit v1.2.3-55-g6feb