aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-05-11 23:41:25 +0800
committerBen Hutchings <ben@decadent.org.uk>2020-03-28 21:42:55 +0000
commitc3b0fa9573b914694612b7a2bbf658928b5fb097 (patch)
tree56d94115ed0866f12c30c12baee3f91570a23e04
parentdfe960aa216a4495cf926fac099caacabc5684e3 (diff)
downloadklibc-c3b0fa9573b914694612b7a2bbf658928b5fb097.tar.gz
[klibc] dash: parser: Fix incorrect eating of backslash newlines
[ dash commit 469c5fd4f57622b1a6571172898ab29430319d4a ] 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@vuxu.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--usr/dash/parser.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/usr/dash/parser.c b/usr/dash/parser.c
index 8e4078162b85d..8bd3db44ff3d0 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: