diff options
author | Colomban Wendling <ban@herbesfolles.org> | 2013-07-22 11:15:02 +0200 |
---|---|---|
committer | Colomban Wendling <ban@herbesfolles.org> | 2013-07-22 11:15:02 +0200 |
commit | 945e829c5feb9122f15ffe43d8ff5b8f6512b79e (patch) | |
tree | 502da0e6c02f532beacc65277547211ecbe6c671 | |
parent | bc1d4eb9737091681cfc3a3161280d4ecd1853f9 (diff) | |
download | scintilla-mirror-945e829c5feb9122f15ffe43d8ff5b8f6512b79e.tar.gz |
Bash: Fix handling of quoted HereDoc delimiters
-rw-r--r-- | lexers/LexBash.cxx | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lexers/LexBash.cxx b/lexers/LexBash.cxx index 2dc8707e5..5f582e401 100644 --- a/lexers/LexBash.cxx +++ b/lexers/LexBash.cxx @@ -437,12 +437,22 @@ static void ColouriseBashDoc(unsigned int startPos, int length, int initStyle, HereDoc.State = 1; } } else if (HereDoc.State == 1) { // collect the delimiter - if (setHereDoc2.Contains(sc.ch) || sc.chPrev == '\\') { + // * if single quoted, there's no escape + // * if double quoted, there are \\ and \" escapes + if ((HereDoc.Quote == '\'' && sc.ch != HereDoc.Quote) || + (HereDoc.Quoted && sc.ch != HereDoc.Quote && sc.ch != '\\') || + (HereDoc.Quote != '\'' && sc.chPrev == '\\') || + (setHereDoc2.Contains(sc.ch))) { HereDoc.Append(sc.ch); } else if (HereDoc.Quoted && sc.ch == HereDoc.Quote) { // closing quote => end of delimiter sc.ForwardSetState(SCE_SH_DEFAULT); } else if (sc.ch == '\\') { - // skip escape prefix + if (HereDoc.Quoted && sc.chNext != HereDoc.Quote && sc.chNext != '\\') { + // in quoted prefixes only \ and the quote eat the escape + HereDoc.Append(sc.ch); + } else { + // skip escape prefix + } } else if (!HereDoc.Quoted) { sc.SetState(SCE_SH_DEFAULT); } |