diff options
-rw-r--r-- | bin/sh/mksyntax.c | 7 | ||||
-rw-r--r-- | bin/sh/parser.c | 7 |
2 files changed, 8 insertions, 6 deletions
diff --git a/bin/sh/mksyntax.c b/bin/sh/mksyntax.c index 505c359..6966ae0 100644 --- a/bin/sh/mksyntax.c +++ b/bin/sh/mksyntax.c @@ -343,9 +343,10 @@ print(char *name) static char *macro[] = { "#define is_digit(c)\t((is_type+SYNBASE)[c] & ISDIGIT)", - "#define is_alpha(c)\t((c) != PEOF && ((c) < CTLESC || (c) > CTLQUOTEMARK) && isalpha((unsigned char) (c)))", - "#define is_name(c)\t((c) != PEOF && ((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalpha((unsigned char) (c))))", - "#define is_in_name(c)\t((c) != PEOF && ((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalnum((unsigned char) (c))))", + "#define is_eof(c)\t((c) == PEOF)", + "#define is_alpha(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && isalpha((unsigned char) (c)))", + "#define is_name(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalpha((unsigned char) (c))))", + "#define is_in_name(c)\t(((c) < CTLESC || (c) > CTLQUOTEMARK) && ((c) == '_' || isalnum((unsigned char) (c))))", "#define is_special(c)\t((is_type+SYNBASE)[c] & (ISSPECL|ISDIGIT))", NULL }; diff --git a/bin/sh/parser.c b/bin/sh/parser.c index f92f564..d40d28a 100644 --- a/bin/sh/parser.c +++ b/bin/sh/parser.c @@ -1192,7 +1192,8 @@ parsesub: { int bracketed_name = 0; /* used to handle ${[0-9]*} variables */ c = pgetc(); - if (c != '(' && c != '{' && !is_name(c) && !is_special(c)) { + if (c != '(' && c != '{' && (is_eof(c) || !is_name(c)) && + !is_special(c)) { USTPUTC('$', out); pungetc(); } else if (c == '(') { /* $(command) or $((arith)) */ @@ -1219,11 +1220,11 @@ parsesub: { else subtype = 0; } - if (is_name(c)) { + if (!is_eof(c) && is_name(c)) { do { STPUTC(c, out); c = pgetc(); - } while (is_in_name(c)); + } while (!is_eof(c) && is_in_name(c)); } else if (is_digit(c)) { if (bracketed_name) { do { |