216913c290
This closes 10821. Upstream patch: From: Herbert Xu <herbert@gondor.apana.org.au> Date: Fri, 9 Mar 2018 00:14:02 +0800 parser: Add syntax stack for recursive parsing Without a stack of syntaxes we cannot correctly these two cases together: "${a#'$$'}" "${a#"${b-'$$'}"}" A recursive parser also helps in some other corner cases such as nested arithmetic expansion with paratheses. This patch adds a syntax stack allocated from the stack using alloca. As a side-effect this allows us to remove the naked backslashes for patterns within double-quotes, which means that EXP_QPAT also has to go. This patch also fixes removes any backslashes that precede right braces when they are present within a parameter expansion context, and backslashes that precede double quotes within inner double quotes inside a parameter expansion in a here-document context. The idea of a recursive parser is based on a patch by Harald van Dijk. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> var_bash3, var_bash4 and var_bash6 tests are updated with the output given by bash-4.3.43 With this patch, the following tests now pass for ash: dollar_repl_slash_bash2.tests squote_in_varexp2.tests squote_in_varexp.tests var_bash4.tests function old new delta readtoken1 2615 2874 +259 synstack_push - 54 +54 evalvar 574 571 -3 rmescapes 330 310 -20 subevalvar 1279 1258 -21 argstr 1146 1107 -39 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 1/4 up/down: 313/-83) Total: 230 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com> |
||
---|---|---|
.. | ||
empty.right | ||
empty.tests | ||
glob_and_vars.right | ||
glob_and_vars.tests | ||
param_expand_alt.right | ||
param_expand_alt.tests | ||
param_expand_assign.right | ||
param_expand_assign.tests | ||
param_expand_bash_substring.right | ||
param_expand_bash_substring.tests | ||
param_expand_default.right | ||
param_expand_default.tests | ||
param_expand_indicate_error.right | ||
param_expand_indicate_error.tests | ||
param_expand_len1.right | ||
param_expand_len1.tests | ||
param_expand_len.right | ||
param_expand_len.tests | ||
param_glob.right | ||
param_glob.tests | ||
param_subshell.right | ||
param_subshell.tests | ||
readonly0.right | ||
readonly0.tests | ||
readonly1.right | ||
readonly1.tests | ||
star.right | ||
star.tests | ||
unset.right | ||
unset.tests | ||
var1.right | ||
var1.tests | ||
var2.right | ||
var2.tests | ||
var3.right | ||
var3.tests | ||
var4.right | ||
var4.tests | ||
var5.right | ||
var5.tests | ||
var_bash1.right | ||
var_bash1.tests | ||
var_bash1a.right | ||
var_bash1a.tests | ||
var_bash1b.right | ||
var_bash1b.tests | ||
var_bash2.right | ||
var_bash2.tests | ||
var_bash3.right | ||
var_bash3.tests | ||
var_bash4.right | ||
var_bash4.tests | ||
var_bash5.right | ||
var_bash5.tests | ||
var_bash6.right | ||
var_bash6.tests | ||
var_bash7.right | ||
var_bash7.tests | ||
var_bash_repl_empty_pattern.right | ||
var_bash_repl_empty_pattern.tests | ||
var_bash_repl_empty_var.right | ||
var_bash_repl_empty_var.tests | ||
var_expand_in_assign.right | ||
var_expand_in_assign.tests | ||
var_expand_in_redir.right | ||
var_expand_in_redir.tests | ||
var_expand_on_ifs.right | ||
var_expand_on_ifs.tests | ||
var_in_pipes.right | ||
var_in_pipes.tests | ||
var_leak.right | ||
var_leak.tests | ||
var_leaks.right | ||
var_leaks.tests | ||
var_LINENO1.right | ||
var_LINENO1.tests | ||
var_posix1.right | ||
var_posix1.tests | ||
var_serial.right | ||
var_serial.tests | ||
var_subst_in_for.right | ||
var_subst_in_for.tests | ||
var_unbackslash1.right | ||
var_unbackslash1.tests | ||
var_unbackslash.right | ||
var_unbackslash.tests | ||
var_wordsplit_ifs1.right | ||
var_wordsplit_ifs1.tests | ||
var_wordsplit_ifs2.right | ||
var_wordsplit_ifs2.tests | ||
var_wordsplit_ifs3.right | ||
var_wordsplit_ifs3.tests | ||
var-do-not-collapse-arithmetic-expansion-at-parse-time.right | ||
var-do-not-collapse-arithmetic-expansion-at-parse-time.tests | ||
var-do-not-expand-tilde-in-parameter-expansion-in-quotes.right | ||
var-do-not-expand-tilde-in-parameter-expansion-in-quotes.tests | ||
var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.right | ||
var-do-not-quote-backslashes-in-parameter-expansions-outside-quotes.tests | ||
var-expand-tilde-in-parameter-expansion.right | ||
var-expand-tilde-in-parameter-expansion.tests | ||
var-pattern-replacement-in-parameter-expansion-1.right | ||
var-pattern-replacement-in-parameter-expansion-1.tests | ||
var-pattern-replacement-in-parameter-expansion-2.right | ||
var-pattern-replacement-in-parameter-expansion-2.tests | ||
var-pattern-replacement-in-parameter-expansion-3.right | ||
var-pattern-replacement-in-parameter-expansion-3.tests | ||
var-pattern-replacement-in-parameter-expansion-4.right | ||
var-pattern-replacement-in-parameter-expansion-4.tests | ||
var-pattern-replacement-in-parameter-expansion-5.right | ||
var-pattern-replacement-in-parameter-expansion-5.tests | ||
var-runtime-quote-detection.right | ||
var-runtime-quote-detection.tests | ||
var-utf8-length.right | ||
var-utf8-length.tests |