summaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenys Vlasenko2016-10-26 16:41:13 +0200
committerDenys Vlasenko2016-10-26 16:41:13 +0200
commit3df1410a00a7a57f3a43373c00cdea2031d7d70c (patch)
tree39860518a919b8e52cbca84cc34eab6ef125a618 /shell
parent350e686f3b04f41f623316706094f0e18a10c1cf (diff)
downloadbusybox-3df1410a00a7a57f3a43373c00cdea2031d7d70c.zip
busybox-3df1410a00a7a57f3a43373c00cdea2031d7d70c.tar.gz
ash: [PARSER] Size optimisations in parameter expansion parser
Upstream commit: Date: Thu, 4 Oct 2007 22:20:38 +0800 [PARSER] Size optimisations in parameter expansion parser Merge flags into subtype. Do not write subtype out twice. Add likely flag on ${ vs. $NAME. Kill unnecessary (and bogus) PEOA check. function old new delta readtoken1 2891 2860 -31 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/shell/ash.c b/shell/ash.c
index e0828d4..21373b6 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -11701,7 +11701,6 @@ parseredir: {
parsesub: {
unsigned char subtype;
int typeloc;
- int flags = 0;
c = pgetc_eatbnl();
if (c > 255 /* PEOA or PEOF */
@@ -11730,19 +11729,19 @@ parsesub: {
/* $VAR, $<specialchar>, ${...}, or PEOA/PEOF */
USTPUTC(CTLVAR, out);
typeloc = out - (char *)stackblock();
- USTPUTC(VSNORMAL, out);
+ STADJUST(1, out);
subtype = VSNORMAL;
if (c == '{') {
c = pgetc_eatbnl();
subtype = 0;
}
varname:
- if (c <= 255 /* not PEOA or PEOF */ && is_name(c)) {
+ if (is_name(c)) {
/* $[{[#]]NAME[}] */
do {
STPUTC(c, out);
c = pgetc_eatbnl();
- } while (c <= 255 /* not PEOA or PEOF */ && is_in_name(c));
+ } while (is_in_name(c));
} else if (isdigit(c)) {
/* $[{[#]]NUM[}] */
do {
@@ -11776,7 +11775,6 @@ parsesub: {
goto badsub;
}
- flags = 0;
if (subtype == 0) {
static const char types[] ALIGN1 = "}-+?=";
/* ${VAR...} but not $VAR or ${#VAR} */
@@ -11795,13 +11793,13 @@ parsesub: {
break; /* "goto badsub" is bigger (!) */
}
#endif
- flags = VSNUL;
+ subtype = VSNUL;
/*FALLTHROUGH*/
default: {
const char *p = strchr(types, c);
if (p == NULL)
break;
- subtype = p - types + VSNORMAL;
+ subtype |= p - types + VSNORMAL;
break;
}
case '%':
@@ -11831,12 +11829,11 @@ parsesub: {
badsub:
pungetc();
}
- ((unsigned char *)stackblock())[typeloc] = subtype | flags;
+ ((unsigned char *)stackblock())[typeloc] = subtype;
if (subtype != VSNORMAL) {
varnest++;
- if (dblquote) {
+ if (dblquote)
dqvarnest++;
- }
}
STPUTC('=', out);
}