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>
This commit is contained in:
parent
350e686f3b
commit
3df1410a00
17
shell/ash.c
17
shell/ash.c
@ -11701,7 +11701,6 @@ parseredir: {
|
|||||||
parsesub: {
|
parsesub: {
|
||||||
unsigned char subtype;
|
unsigned char subtype;
|
||||||
int typeloc;
|
int typeloc;
|
||||||
int flags = 0;
|
|
||||||
|
|
||||||
c = pgetc_eatbnl();
|
c = pgetc_eatbnl();
|
||||||
if (c > 255 /* PEOA or PEOF */
|
if (c > 255 /* PEOA or PEOF */
|
||||||
@ -11730,19 +11729,19 @@ parsesub: {
|
|||||||
/* $VAR, $<specialchar>, ${...}, or PEOA/PEOF */
|
/* $VAR, $<specialchar>, ${...}, or PEOA/PEOF */
|
||||||
USTPUTC(CTLVAR, out);
|
USTPUTC(CTLVAR, out);
|
||||||
typeloc = out - (char *)stackblock();
|
typeloc = out - (char *)stackblock();
|
||||||
USTPUTC(VSNORMAL, out);
|
STADJUST(1, out);
|
||||||
subtype = VSNORMAL;
|
subtype = VSNORMAL;
|
||||||
if (c == '{') {
|
if (c == '{') {
|
||||||
c = pgetc_eatbnl();
|
c = pgetc_eatbnl();
|
||||||
subtype = 0;
|
subtype = 0;
|
||||||
}
|
}
|
||||||
varname:
|
varname:
|
||||||
if (c <= 255 /* not PEOA or PEOF */ && is_name(c)) {
|
if (is_name(c)) {
|
||||||
/* $[{[#]]NAME[}] */
|
/* $[{[#]]NAME[}] */
|
||||||
do {
|
do {
|
||||||
STPUTC(c, out);
|
STPUTC(c, out);
|
||||||
c = pgetc_eatbnl();
|
c = pgetc_eatbnl();
|
||||||
} while (c <= 255 /* not PEOA or PEOF */ && is_in_name(c));
|
} while (is_in_name(c));
|
||||||
} else if (isdigit(c)) {
|
} else if (isdigit(c)) {
|
||||||
/* $[{[#]]NUM[}] */
|
/* $[{[#]]NUM[}] */
|
||||||
do {
|
do {
|
||||||
@ -11776,7 +11775,6 @@ parsesub: {
|
|||||||
goto badsub;
|
goto badsub;
|
||||||
}
|
}
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
if (subtype == 0) {
|
if (subtype == 0) {
|
||||||
static const char types[] ALIGN1 = "}-+?=";
|
static const char types[] ALIGN1 = "}-+?=";
|
||||||
/* ${VAR...} but not $VAR or ${#VAR} */
|
/* ${VAR...} but not $VAR or ${#VAR} */
|
||||||
@ -11795,13 +11793,13 @@ parsesub: {
|
|||||||
break; /* "goto badsub" is bigger (!) */
|
break; /* "goto badsub" is bigger (!) */
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
flags = VSNUL;
|
subtype = VSNUL;
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
default: {
|
default: {
|
||||||
const char *p = strchr(types, c);
|
const char *p = strchr(types, c);
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
break;
|
break;
|
||||||
subtype = p - types + VSNORMAL;
|
subtype |= p - types + VSNORMAL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '%':
|
case '%':
|
||||||
@ -11831,12 +11829,11 @@ parsesub: {
|
|||||||
badsub:
|
badsub:
|
||||||
pungetc();
|
pungetc();
|
||||||
}
|
}
|
||||||
((unsigned char *)stackblock())[typeloc] = subtype | flags;
|
((unsigned char *)stackblock())[typeloc] = subtype;
|
||||||
if (subtype != VSNORMAL) {
|
if (subtype != VSNORMAL) {
|
||||||
varnest++;
|
varnest++;
|
||||||
if (dblquote) {
|
if (dblquote)
|
||||||
dqvarnest++;
|
dqvarnest++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
STPUTC('=', out);
|
STPUTC('=', out);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user