ash: eliminate 16 bytes in bss
text data bss dec hexfilename 841423 441 7572 849436 cf61cbusybox_old 841430 441 7556 849427 cf613busybox_unstripped Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
44c86ce5d7
commit
a0ec4f500c
48
shell/ash.c
48
shell/ash.c
@ -7547,8 +7547,10 @@ changepath(const char *new)
|
|||||||
if (*old != *new) {
|
if (*old != *new) {
|
||||||
firstchange = idx;
|
firstchange = idx;
|
||||||
if ((*old == '\0' && *new == ':')
|
if ((*old == '\0' && *new == ':')
|
||||||
|| (*old == ':' && *new == '\0'))
|
|| (*old == ':' && *new == '\0')
|
||||||
|
) {
|
||||||
firstchange++;
|
firstchange++;
|
||||||
|
}
|
||||||
old = new; /* ignore subsequent differences */
|
old = new; /* ignore subsequent differences */
|
||||||
}
|
}
|
||||||
if (*new == '\0')
|
if (*new == '\0')
|
||||||
@ -7557,7 +7559,8 @@ changepath(const char *new)
|
|||||||
idx_bltin = idx;
|
idx_bltin = idx;
|
||||||
if (*new == ':')
|
if (*new == ':')
|
||||||
idx++;
|
idx++;
|
||||||
new++, old++;
|
new++;
|
||||||
|
old++;
|
||||||
}
|
}
|
||||||
if (builtinloc < 0 && idx_bltin >= 0)
|
if (builtinloc < 0 && idx_bltin >= 0)
|
||||||
builtinloc = idx_bltin; /* zap builtins */
|
builtinloc = idx_bltin; /* zap builtins */
|
||||||
@ -7633,23 +7636,6 @@ static const char *const tokname_array[] = {
|
|||||||
"\1}",
|
"\1}",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const char *
|
|
||||||
tokname(int tok)
|
|
||||||
{
|
|
||||||
static char buf[16];
|
|
||||||
|
|
||||||
//try this:
|
|
||||||
//if (tok < TSEMI) return tokname_array[tok] + 1;
|
|
||||||
//sprintf(buf, "\"%s\"", tokname_array[tok] + 1);
|
|
||||||
//return buf;
|
|
||||||
|
|
||||||
if (tok >= TSEMI)
|
|
||||||
buf[0] = '"';
|
|
||||||
sprintf(buf + (tok >= TSEMI), "%s%c",
|
|
||||||
tokname_array[tok] + 1, (tok >= TSEMI ? '"' : 0));
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wrapper around strcmp for qsort/bsearch/... */
|
/* Wrapper around strcmp for qsort/bsearch/... */
|
||||||
static int
|
static int
|
||||||
pstrcmp(const void *a, const void *b)
|
pstrcmp(const void *a, const void *b)
|
||||||
@ -10280,7 +10266,16 @@ static struct nodelist *backquotelist;
|
|||||||
static union node *redirnode;
|
static union node *redirnode;
|
||||||
static struct heredoc *heredoc;
|
static struct heredoc *heredoc;
|
||||||
|
|
||||||
/*
|
static const char *
|
||||||
|
tokname(char *buf, int tok)
|
||||||
|
{
|
||||||
|
if (tok < TSEMI)
|
||||||
|
return tokname_array[tok] + 1;
|
||||||
|
sprintf(buf, "\"%s\"", tokname_array[tok] + 1);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* raise_error_unexpected_syntax:
|
||||||
* Called when an unexpected token is read during the parse. The argument
|
* Called when an unexpected token is read during the parse. The argument
|
||||||
* is the token that is expected, or -1 if more than one type of token can
|
* is the token that is expected, or -1 if more than one type of token can
|
||||||
* occur at this point.
|
* occur at this point.
|
||||||
@ -10290,11 +10285,12 @@ static void
|
|||||||
raise_error_unexpected_syntax(int token)
|
raise_error_unexpected_syntax(int token)
|
||||||
{
|
{
|
||||||
char msg[64];
|
char msg[64];
|
||||||
|
char buf[16];
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
l = sprintf(msg, "unexpected %s", tokname(lasttoken));
|
l = sprintf(msg, "unexpected %s", tokname(buf, lasttoken));
|
||||||
if (token >= 0)
|
if (token >= 0)
|
||||||
sprintf(msg + l, " (expecting %s)", tokname(token));
|
sprintf(msg + l, " (expecting %s)", tokname(buf, token));
|
||||||
raise_error_syntax(msg);
|
raise_error_syntax(msg);
|
||||||
/* NOTREACHED */
|
/* NOTREACHED */
|
||||||
}
|
}
|
||||||
@ -10682,7 +10678,7 @@ parse_command(void)
|
|||||||
n1->nbinary.ch1 = list(0);
|
n1->nbinary.ch1 = list(0);
|
||||||
got = readtoken();
|
got = readtoken();
|
||||||
if (got != TDO) {
|
if (got != TDO) {
|
||||||
TRACE(("expecting DO got %s %s\n", tokname(got),
|
TRACE(("expecting DO got '%s' %s\n", tokname_array[got] + 1,
|
||||||
got == TWORD ? wordtext : ""));
|
got == TWORD ? wordtext : ""));
|
||||||
raise_error_unexpected_syntax(TDO);
|
raise_error_unexpected_syntax(TDO);
|
||||||
}
|
}
|
||||||
@ -11766,7 +11762,7 @@ readtoken(void)
|
|||||||
pp = findkwd(wordtext);
|
pp = findkwd(wordtext);
|
||||||
if (pp) {
|
if (pp) {
|
||||||
lasttoken = t = pp - tokname_array;
|
lasttoken = t = pp - tokname_array;
|
||||||
TRACE(("keyword %s recognized\n", tokname(t)));
|
TRACE(("keyword '%s' recognized\n", tokname_array[t] + 1));
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -11787,9 +11783,9 @@ readtoken(void)
|
|||||||
checkkwd = 0;
|
checkkwd = 0;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (!alreadyseen)
|
if (!alreadyseen)
|
||||||
TRACE(("token %s %s\n", tokname(t), t == TWORD ? wordtext : ""));
|
TRACE(("token '%s' %s\n", tokname_array[t] + 1, t == TWORD ? wordtext : ""));
|
||||||
else
|
else
|
||||||
TRACE(("reread token %s %s\n", tokname(t), t == TWORD ? wordtext : ""));
|
TRACE(("reread token '%s' %s\n", tokname_array[t] + 1, t == TWORD ? wordtext : ""));
|
||||||
#endif
|
#endif
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user