summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2025-08-14 20:08:19 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2025-08-14 20:08:19 +0200
commit0d1f6a54f7be96a409a28d12da6ec48caf514e0b (patch)
treeefe79f9909afd840043684d16cff8dc8d53f4ecd
parenta8f20420a5295133105d8cb9a8437f2210558a96 (diff)
hush: allow faster parsing for "./:@" characters
function old new delta parse_stream 2513 2514 +1 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/hush.c9
1 files 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;