diff options
author | stefanf <stefanf@FreeBSD.org> | 2005-08-13 15:47:13 +0000 |
---|---|---|
committer | stefanf <stefanf@FreeBSD.org> | 2005-08-13 15:47:13 +0000 |
commit | d7c6f147cb721cf5c23b029b3d3bdaffb3909af4 (patch) | |
tree | 85dd677e248473e0c5871b6775faa03857417f5e /bin/sh | |
parent | e4a640448d3528aef497b7d29e3caaff29c8b2e2 (diff) | |
download | FreeBSD-src-d7c6f147cb721cf5c23b029b3d3bdaffb3909af4.zip FreeBSD-src-d7c6f147cb721cf5c23b029b3d3bdaffb3909af4.tar.gz |
Put the comparison with PEOF into a new macro is_eof(). Don't use it if the
character comes from a string.
Diffstat (limited to 'bin/sh')
-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 { |