[PATCH 1/3] parser: Move non-variable case in parsesub to end

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Move the rare case of a literal dollar sign to the end of the
parsesub block.  This eliminates a duplicate USTPUTC call.

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>
---
 src/parser.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/src/parser.c b/src/parser.c
index 3d21894..b711d6c 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1298,15 +1298,9 @@ parsesub: {
 	char *p;
 	static const char types[] = "}-+?=";
 
-	c = pgetc_eatbnl();
-	if (c != '(' && c != '{' && !is_name(c) && !is_special(c)) {
-		USTPUTC('$', out);
-		pungetc();
-		goto parsesub_return;
-	}
-
 	USTPUTC('$', out);
 
+	c = pgetc_eatbnl();
 	if (c == '(') {		/* $(command) or $((arith)) */
 		USTPUTC(c, out);
 		if (pgetc_eatbnl() == '(') {
@@ -1315,7 +1309,7 @@ parsesub: {
 			pungetc();
 			PARSEBACKQNEW();
 		}
-	} else {
+	} else if (c == '{' || is_name(c) || is_special(c)) {
 		const char *newsyn = synstack->syntax;
 
 		typeloc = out - (char *)stackblock();
@@ -1441,7 +1435,9 @@ badsub:
 			*((char *)stackblock() + typeloc) = subtype | VSBIT;
 			STPUTC('=', out);
 		}
-	}
+	} else
+		pungetc();
+
 	goto parsesub_return;
 }
 
-- 
2.39.2





[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux