From 0d1f6a54f7be96a409a28d12da6ec48caf514e0b Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Thu, 14 Aug 2025 20:08:19 +0200 Subject: hush: allow faster parsing for "./:@" characters function old new delta parse_stream 2513 2514 +1 Signed-off-by: Denys Vlasenko --- shell/hush.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/shell/hush.c b/shell/hush.c index 35d44f07b..9f7d0d751 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -5605,8 +5605,13 @@ static struct pipe *parse_stream(char **pstring, debug_printf_parse(": ch:%c (%d) globprotect:%d\n", ch, ch, !!(ctx.word.o_expflags & EXP_FLAG_GLOBPROTECT_CHARS)); # if ENABLE_HUSH_NEED_FOR_SPEED - if (isalnum(ch)) { - /* 0-9A-Za-z are never special and just go into the current word */ + if ((ch >= '.' && ch <= ':') /* ASCII "./0123456789:" */ + /* can't include preceding "+,-" above: "-" needs glob-escaping (example?) */ + || (ch >= '@' && ch <= 'Z') /* ASCII "@A..Z" */ + || (ch >= 'a' && ch <= 'z') /* ASCII "a..Z" */ + /* can't include preceding "^_`" above because of "`". Pity. "_" is relatively common */ + ) { + /* These are never special and just go into the current word */ /* ~5% faster parsing of typical shell scripts */ INLINED_o_addchr(&ctx.word, ch); continue; -- cgit v1.2.3