[PATCH 2/3] parser: Merge first and last chkeofmark branches in parsesub

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

 



Elminate the first chkeofmark branch by moving the CTLVAR to the
end of the parsesub block and always doing STADJUST.

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

diff --git a/src/parser.c b/src/parser.c
index b711d6c..2517721 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1293,10 +1293,9 @@ parseredir: {
  */
 
 parsesub: {
-	int subtype;
-	int typeloc;
-	char *p;
 	static const char types[] = "}-+?=";
+	int subtype;
+	char *p;
 
 	USTPUTC('$', out);
 
@@ -1310,13 +1309,10 @@ parsesub: {
 			PARSEBACKQNEW();
 		}
 	} else if (c == '{' || is_name(c) || is_special(c)) {
+		int typeloc = out - (char *)stackblock();
 		const char *newsyn = synstack->syntax;
 
-		typeloc = out - (char *)stackblock();
-		if (!chkeofmark) {
-			out[-1] = CTLVAR;
-			STADJUST(1, out);
-		}
+		STADJUST(!chkeofmark, out);
 		subtype = VSNORMAL;
 		if (likely(c == '{')) {
 			if (chkeofmark)
@@ -1432,7 +1428,10 @@ badsub:
 				synstack->dqvarnest++;
 		}
 		if (!chkeofmark) {
-			*((char *)stackblock() + typeloc) = subtype | VSBIT;
+			char *p = stackblock();
+
+			p[typeloc - 1] = CTLVAR;
+			p[typeloc] = subtype | VSBIT;
 			STPUTC('=', out);
 		}
 	} else
-- 
2.39.2





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

  Powered by Linux