aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-20 12:50:42 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-20 12:50:42 +0200
commita0ec4f500c7b8b2ac1c7e34c9a2ee7504c7f8914 (patch)
treec70bd0871806ae5246d42d677a38540293518b2b
parent44c86ce5d7ee7c641a2c8c392f059e19050abd11 (diff)
downloadbusybox-w32-a0ec4f500c7b8b2ac1c7e34c9a2ee7504c7f8914.tar.gz
busybox-w32-a0ec4f500c7b8b2ac1c7e34c9a2ee7504c7f8914.tar.bz2
busybox-w32-a0ec4f500c7b8b2ac1c7e34c9a2ee7504c7f8914.zip
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>
-rw-r--r--shell/ash.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 83886c610..7efd477d1 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -7547,8 +7547,10 @@ changepath(const char *new)
7547 if (*old != *new) { 7547 if (*old != *new) {
7548 firstchange = idx; 7548 firstchange = idx;
7549 if ((*old == '\0' && *new == ':') 7549 if ((*old == '\0' && *new == ':')
7550 || (*old == ':' && *new == '\0')) 7550 || (*old == ':' && *new == '\0')
7551 ) {
7551 firstchange++; 7552 firstchange++;
7553 }
7552 old = new; /* ignore subsequent differences */ 7554 old = new; /* ignore subsequent differences */
7553 } 7555 }
7554 if (*new == '\0') 7556 if (*new == '\0')
@@ -7557,7 +7559,8 @@ changepath(const char *new)
7557 idx_bltin = idx; 7559 idx_bltin = idx;
7558 if (*new == ':') 7560 if (*new == ':')
7559 idx++; 7561 idx++;
7560 new++, old++; 7562 new++;
7563 old++;
7561 } 7564 }
7562 if (builtinloc < 0 && idx_bltin >= 0) 7565 if (builtinloc < 0 && idx_bltin >= 0)
7563 builtinloc = idx_bltin; /* zap builtins */ 7566 builtinloc = idx_bltin; /* zap builtins */
@@ -7633,23 +7636,6 @@ static const char *const tokname_array[] = {
7633 "\1}", 7636 "\1}",
7634}; 7637};
7635 7638
7636static const char *
7637tokname(int tok)
7638{
7639 static char buf[16];
7640
7641//try this:
7642//if (tok < TSEMI) return tokname_array[tok] + 1;
7643//sprintf(buf, "\"%s\"", tokname_array[tok] + 1);
7644//return buf;
7645
7646 if (tok >= TSEMI)
7647 buf[0] = '"';
7648 sprintf(buf + (tok >= TSEMI), "%s%c",
7649 tokname_array[tok] + 1, (tok >= TSEMI ? '"' : 0));
7650 return buf;
7651}
7652
7653/* Wrapper around strcmp for qsort/bsearch/... */ 7639/* Wrapper around strcmp for qsort/bsearch/... */
7654static int 7640static int
7655pstrcmp(const void *a, const void *b) 7641pstrcmp(const void *a, const void *b)
@@ -10280,7 +10266,16 @@ static struct nodelist *backquotelist;
10280static union node *redirnode; 10266static union node *redirnode;
10281static struct heredoc *heredoc; 10267static struct heredoc *heredoc;
10282 10268
10283/* 10269static const char *
10270tokname(char *buf, int tok)
10271{
10272 if (tok < TSEMI)
10273 return tokname_array[tok] + 1;
10274 sprintf(buf, "\"%s\"", tokname_array[tok] + 1);
10275 return buf;
10276}
10277
10278/* raise_error_unexpected_syntax:
10284 * Called when an unexpected token is read during the parse. The argument 10279 * Called when an unexpected token is read during the parse. The argument
10285 * is the token that is expected, or -1 if more than one type of token can 10280 * is the token that is expected, or -1 if more than one type of token can
10286 * occur at this point. 10281 * occur at this point.
@@ -10290,11 +10285,12 @@ static void
10290raise_error_unexpected_syntax(int token) 10285raise_error_unexpected_syntax(int token)
10291{ 10286{
10292 char msg[64]; 10287 char msg[64];
10288 char buf[16];
10293 int l; 10289 int l;
10294 10290
10295 l = sprintf(msg, "unexpected %s", tokname(lasttoken)); 10291 l = sprintf(msg, "unexpected %s", tokname(buf, lasttoken));
10296 if (token >= 0) 10292 if (token >= 0)
10297 sprintf(msg + l, " (expecting %s)", tokname(token)); 10293 sprintf(msg + l, " (expecting %s)", tokname(buf, token));
10298 raise_error_syntax(msg); 10294 raise_error_syntax(msg);
10299 /* NOTREACHED */ 10295 /* NOTREACHED */
10300} 10296}
@@ -10682,7 +10678,7 @@ parse_command(void)
10682 n1->nbinary.ch1 = list(0); 10678 n1->nbinary.ch1 = list(0);
10683 got = readtoken(); 10679 got = readtoken();
10684 if (got != TDO) { 10680 if (got != TDO) {
10685 TRACE(("expecting DO got %s %s\n", tokname(got), 10681 TRACE(("expecting DO got '%s' %s\n", tokname_array[got] + 1,
10686 got == TWORD ? wordtext : "")); 10682 got == TWORD ? wordtext : ""));
10687 raise_error_unexpected_syntax(TDO); 10683 raise_error_unexpected_syntax(TDO);
10688 } 10684 }
@@ -11766,7 +11762,7 @@ readtoken(void)
11766 pp = findkwd(wordtext); 11762 pp = findkwd(wordtext);
11767 if (pp) { 11763 if (pp) {
11768 lasttoken = t = pp - tokname_array; 11764 lasttoken = t = pp - tokname_array;
11769 TRACE(("keyword %s recognized\n", tokname(t))); 11765 TRACE(("keyword '%s' recognized\n", tokname_array[t] + 1));
11770 goto out; 11766 goto out;
11771 } 11767 }
11772 } 11768 }
@@ -11787,9 +11783,9 @@ readtoken(void)
11787 checkkwd = 0; 11783 checkkwd = 0;
11788#if DEBUG 11784#if DEBUG
11789 if (!alreadyseen) 11785 if (!alreadyseen)
11790 TRACE(("token %s %s\n", tokname(t), t == TWORD ? wordtext : "")); 11786 TRACE(("token '%s' %s\n", tokname_array[t] + 1, t == TWORD ? wordtext : ""));
11791 else 11787 else
11792 TRACE(("reread token %s %s\n", tokname(t), t == TWORD ? wordtext : "")); 11788 TRACE(("reread token '%s' %s\n", tokname_array[t] + 1, t == TWORD ? wordtext : ""));
11793#endif 11789#endif
11794 return t; 11790 return t;
11795} 11791}