diff options
Diffstat (limited to 'shell/ash.c')
-rw-r--r-- | shell/ash.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/shell/ash.c b/shell/ash.c index 4e80b097c..ef2121885 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -7868,8 +7868,10 @@ changepath(const char *new) | |||
7868 | if (*old != *new) { | 7868 | if (*old != *new) { |
7869 | firstchange = idx; | 7869 | firstchange = idx; |
7870 | if ((*old == '\0' && *new == ':') | 7870 | if ((*old == '\0' && *new == ':') |
7871 | || (*old == ':' && *new == '\0')) | 7871 | || (*old == ':' && *new == '\0') |
7872 | ) { | ||
7872 | firstchange++; | 7873 | firstchange++; |
7874 | } | ||
7873 | old = new; /* ignore subsequent differences */ | 7875 | old = new; /* ignore subsequent differences */ |
7874 | } | 7876 | } |
7875 | if (*new == '\0') | 7877 | if (*new == '\0') |
@@ -7878,7 +7880,8 @@ changepath(const char *new) | |||
7878 | idx_bltin = idx; | 7880 | idx_bltin = idx; |
7879 | if (*new == ':') | 7881 | if (*new == ':') |
7880 | idx++; | 7882 | idx++; |
7881 | new++, old++; | 7883 | new++; |
7884 | old++; | ||
7882 | } | 7885 | } |
7883 | if (builtinloc < 0 && idx_bltin >= 0) | 7886 | if (builtinloc < 0 && idx_bltin >= 0) |
7884 | builtinloc = idx_bltin; /* zap builtins */ | 7887 | builtinloc = idx_bltin; /* zap builtins */ |
@@ -7954,23 +7957,6 @@ static const char *const tokname_array[] = { | |||
7954 | "\1}", | 7957 | "\1}", |
7955 | }; | 7958 | }; |
7956 | 7959 | ||
7957 | static const char * | ||
7958 | tokname(int tok) | ||
7959 | { | ||
7960 | static char buf[16]; | ||
7961 | |||
7962 | //try this: | ||
7963 | //if (tok < TSEMI) return tokname_array[tok] + 1; | ||
7964 | //sprintf(buf, "\"%s\"", tokname_array[tok] + 1); | ||
7965 | //return buf; | ||
7966 | |||
7967 | if (tok >= TSEMI) | ||
7968 | buf[0] = '"'; | ||
7969 | sprintf(buf + (tok >= TSEMI), "%s%c", | ||
7970 | tokname_array[tok] + 1, (tok >= TSEMI ? '"' : 0)); | ||
7971 | return buf; | ||
7972 | } | ||
7973 | |||
7974 | /* Wrapper around strcmp for qsort/bsearch/... */ | 7960 | /* Wrapper around strcmp for qsort/bsearch/... */ |
7975 | static int | 7961 | static int |
7976 | pstrcmp(const void *a, const void *b) | 7962 | pstrcmp(const void *a, const void *b) |
@@ -10745,7 +10731,16 @@ static struct nodelist *backquotelist; | |||
10745 | static union node *redirnode; | 10731 | static union node *redirnode; |
10746 | static struct heredoc *heredoc; | 10732 | static struct heredoc *heredoc; |
10747 | 10733 | ||
10748 | /* | 10734 | static const char * |
10735 | tokname(char *buf, int tok) | ||
10736 | { | ||
10737 | if (tok < TSEMI) | ||
10738 | return tokname_array[tok] + 1; | ||
10739 | sprintf(buf, "\"%s\"", tokname_array[tok] + 1); | ||
10740 | return buf; | ||
10741 | } | ||
10742 | |||
10743 | /* raise_error_unexpected_syntax: | ||
10749 | * Called when an unexpected token is read during the parse. The argument | 10744 | * Called when an unexpected token is read during the parse. The argument |
10750 | * is the token that is expected, or -1 if more than one type of token can | 10745 | * is the token that is expected, or -1 if more than one type of token can |
10751 | * occur at this point. | 10746 | * occur at this point. |
@@ -10755,11 +10750,12 @@ static void | |||
10755 | raise_error_unexpected_syntax(int token) | 10750 | raise_error_unexpected_syntax(int token) |
10756 | { | 10751 | { |
10757 | char msg[64]; | 10752 | char msg[64]; |
10753 | char buf[16]; | ||
10758 | int l; | 10754 | int l; |
10759 | 10755 | ||
10760 | l = sprintf(msg, "unexpected %s", tokname(lasttoken)); | 10756 | l = sprintf(msg, "unexpected %s", tokname(buf, lasttoken)); |
10761 | if (token >= 0) | 10757 | if (token >= 0) |
10762 | sprintf(msg + l, " (expecting %s)", tokname(token)); | 10758 | sprintf(msg + l, " (expecting %s)", tokname(buf, token)); |
10763 | raise_error_syntax(msg); | 10759 | raise_error_syntax(msg); |
10764 | /* NOTREACHED */ | 10760 | /* NOTREACHED */ |
10765 | } | 10761 | } |
@@ -11147,7 +11143,7 @@ parse_command(void) | |||
11147 | n1->nbinary.ch1 = list(0); | 11143 | n1->nbinary.ch1 = list(0); |
11148 | got = readtoken(); | 11144 | got = readtoken(); |
11149 | if (got != TDO) { | 11145 | if (got != TDO) { |
11150 | TRACE(("expecting DO got %s %s\n", tokname(got), | 11146 | TRACE(("expecting DO got '%s' %s\n", tokname_array[got] + 1, |
11151 | got == TWORD ? wordtext : "")); | 11147 | got == TWORD ? wordtext : "")); |
11152 | raise_error_unexpected_syntax(TDO); | 11148 | raise_error_unexpected_syntax(TDO); |
11153 | } | 11149 | } |
@@ -12231,7 +12227,7 @@ readtoken(void) | |||
12231 | pp = findkwd(wordtext); | 12227 | pp = findkwd(wordtext); |
12232 | if (pp) { | 12228 | if (pp) { |
12233 | lasttoken = t = pp - tokname_array; | 12229 | lasttoken = t = pp - tokname_array; |
12234 | TRACE(("keyword %s recognized\n", tokname(t))); | 12230 | TRACE(("keyword '%s' recognized\n", tokname_array[t] + 1)); |
12235 | goto out; | 12231 | goto out; |
12236 | } | 12232 | } |
12237 | } | 12233 | } |
@@ -12252,9 +12248,9 @@ readtoken(void) | |||
12252 | checkkwd = 0; | 12248 | checkkwd = 0; |
12253 | #if DEBUG | 12249 | #if DEBUG |
12254 | if (!alreadyseen) | 12250 | if (!alreadyseen) |
12255 | TRACE(("token %s %s\n", tokname(t), t == TWORD ? wordtext : "")); | 12251 | TRACE(("token '%s' %s\n", tokname_array[t] + 1, t == TWORD ? wordtext : "")); |
12256 | else | 12252 | else |
12257 | TRACE(("reread token %s %s\n", tokname(t), t == TWORD ? wordtext : "")); | 12253 | TRACE(("reread token '%s' %s\n", tokname_array[t] + 1, t == TWORD ? wordtext : "")); |
12258 | #endif | 12254 | #endif |
12259 | return t; | 12255 | return t; |
12260 | } | 12256 | } |