[klibc] [klibc:update-dash] parser: Fix incorrect eating of backslash newlines

klibc-bot for Herbert Xu herbert at gondor.apana.org.au
Thu Jan 24 19:16:02 PST 2019


Commit-ID:  5485646761fe402c332fe07abc973060af57ee59
Gitweb:     http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=5485646761fe402c332fe07abc973060af57ee59
Author:     Herbert Xu <herbert at gondor.apana.org.au>
AuthorDate: Fri, 11 May 2018 23:41:25 +0800
Committer:  Ben Hutchings <ben at decadent.org.uk>
CommitDate: Fri, 25 Jan 2019 02:57:21 +0000

[klibc] parser: Fix incorrect eating of backslash newlines

With the introduction of synstack->syntax, a number of references
to the syntax variable was missed during the conversion.  This
causes backslash newlines to be incorrectly removed in single
quote context.

This patch also combines these calls into a new helper function
pgetc_top.

Fixes: ab1cecb40478 ("parser: Add syntax stack for recursive...")
Reported-by: Leah Neukirchen <leah at vuxu.org>
Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au>
Signed-off-by: Ben Hutchings <ben at decadent.org.uk>

---
 usr/dash/parser.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/usr/dash/parser.c b/usr/dash/parser.c
index 8e407816..8bd3db44 100644
--- a/usr/dash/parser.c
+++ b/usr/dash/parser.c
@@ -853,6 +853,11 @@ static int pgetc_eatbnl(void)
 	return c;
 }
 
+static int pgetc_top(struct synstack *stack)
+{
+	return stack->syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+}
+
 static void synstack_push(struct synstack **stack, struct synstack *next,
 			  const char *syntax)
 {
@@ -915,7 +920,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
 			attyline();
 			if (synstack->syntax == BASESYNTAX)
 				return readtoken();
-			c = syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+			c = pgetc_top(synstack);
 			goto loop;
 		}
 #endif
@@ -929,7 +934,7 @@ readtoken1(int firstc, char const *syntax, char *eofmark, int striptabs)
 					goto endword;	/* exit outer loop */
 				USTPUTC(c, out);
 				nlprompt();
-				c = syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+				c = pgetc_top(synstack);
 				goto loop;		/* continue outer loop */
 			case CWORD:
 				USTPUTC(c, out);
@@ -1056,7 +1061,7 @@ toggledq:
 					USTPUTC(c, out);
 				}
 			}
-			c = syntax == SQSYNTAX ? pgetc() : pgetc_eatbnl();
+			c = pgetc_top(synstack);
 		}
 	}
 endword:


More information about the klibc mailing list