summary refs log tree commit diff
path: root/src/expand.h
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2018-03-09 00:14:02 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2018-03-22 00:29:58 +0800
commitab1cecb4047864afb247a6ed691e7f59ce716f2c (patch)
tree4e4914acd4854f273fa7da4af24f7b86c83672fd /src/expand.h
parentparser: use pgetc_eatbnl() in more places (diff)
downloaddash-ab1cecb4047864afb247a6ed691e7f59ce716f2c.tar.gz
dash-ab1cecb4047864afb247a6ed691e7f59ce716f2c.zip
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>
Diffstat (limited to 'src/expand.h')
-rw-r--r--src/expand.h1
1 files changed, 0 insertions, 1 deletions
diff --git a/src/expand.h b/src/expand.h
index 26dc5b4..90f5328 100644
--- a/src/expand.h
+++ b/src/expand.h
@@ -55,7 +55,6 @@ struct arglist {
 #define	EXP_VARTILDE	0x4	/* expand tildes in an assignment */
 #define	EXP_REDIR	0x8	/* file glob for a redirection (1 match only) */
 #define EXP_CASE	0x10	/* keeps quotes around for CASE pattern */
-#define EXP_QPAT	0x20	/* pattern in quoted parameter expansion */
 #define EXP_VARTILDE2	0x40	/* expand tildes after colons only */
 #define EXP_WORD	0x80	/* expand word in parameter expansion */
 #define EXP_QUOTED	0x100	/* expand word in double quotes */