summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/parser.c16
2 files changed, 8 insertions, 9 deletions
diff --git a/ChangeLog b/ChangeLog
index 3352429..940e4b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2007-10-04  Herbert Xu <herbert@gondor.apana.org.au>
 
 	* Fix parsing of ${##1}.
+	* Size optimisations in parameter expansion parser.
 
 2007-10-04  Alexey Gladkov <legion@altlinux.org>
 
diff --git a/src/parser.c b/src/parser.c
index 9edb824..f49ee7d 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1142,7 +1142,6 @@ parseredir: {
 parsesub: {
 	int subtype;
 	int typeloc;
-	int flags;
 	char *p;
 	static const char types[] = "}-+?=";
 
@@ -1163,18 +1162,18 @@ parsesub: {
 	} else {
 		USTPUTC(CTLVAR, out);
 		typeloc = out - (char *)stackblock();
-		USTPUTC(VSNORMAL, out);
+		STADJUST(1, out);
 		subtype = VSNORMAL;
-		if (c == '{') {
+		if (likely(c == '{')) {
 			c = pgetc();
 			subtype = 0;
 		}
 varname:
-		if (c > PEOA && is_name(c)) {
+		if (is_name(c)) {
 			do {
 				STPUTC(c, out);
 				c = pgetc();
-			} while (c > PEOA && is_in_name(c));
+			} while (is_in_name(c));
 		} else if (is_digit(c)) {
 			do {
 				STPUTC(c, out);
@@ -1208,18 +1207,17 @@ varname:
 badsub:			synerror("Bad substitution");
 
 		STPUTC('=', out);
-		flags = 0;
 		if (subtype == 0) {
 			switch (c) {
 			case ':':
-				flags = VSNUL;
+				subtype = VSNUL;
 				c = pgetc();
 				/*FALLTHROUGH*/
 			default:
 				p = strchr(types, c);
 				if (p == NULL)
 					goto badsub;
-				subtype = p - types + VSNORMAL;
+				subtype |= p - types + VSNORMAL;
 				break;
 			case '%':
 			case '#':
@@ -1238,7 +1236,7 @@ badsub:			synerror("Bad substitution");
 		} else {
 			pungetc();
 		}
-		*((char *)stackblock() + typeloc) = subtype | flags;
+		*((char *)stackblock() + typeloc) = subtype;
 		if (subtype != VSNORMAL) {
 			varnest++;
 			if (dblquote)