diff options
author | Kein-Hong Man <unknown> | 2015-12-10 13:07:42 +1100 |
---|---|---|
committer | Kein-Hong Man <unknown> | 2015-12-10 13:07:42 +1100 |
commit | c47c131ac48d22044f787c384958ec2fc7bb6a40 (patch) | |
tree | e0da403a059b0cbee6cd13700bef99afac88d2af | |
parent | d01c7c9be2aac0c1de277119c68a31191e0c8a63 (diff) | |
download | scintilla-mirror-c47c131ac48d22044f787c384958ec2fc7bb6a40.tar.gz |
Flag incomplete here doc delimiters as syntax errors, matching bash 4.3.
Avoid heap allocations for here delimiter and quote stack.
-rw-r--r-- | cppcheck.suppress | 2 | ||||
-rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
-rw-r--r-- | lexers/LexBash.cxx | 26 |
3 files changed, 15 insertions, 17 deletions
diff --git a/cppcheck.suppress b/cppcheck.suppress index aea0ad98f..46e814ddc 100644 --- a/cppcheck.suppress +++ b/cppcheck.suppress @@ -15,7 +15,7 @@ unusedPrivateFunction:scintilla/win32/PlatWin.cxx // Suppress most lexer warnings since the lexers are maintained by others
useInitializationList:scintilla/lexers/LexAsm.cxx
useInitializationList:scintilla/lexers/LexBasic.cxx
-noCopyConstructor:scintilla/lexers/LexBash.cxx
+uninitMemberVar:scintilla/lexers/LexBash.cxx
variableScope:scintilla/lexers/LexBash.cxx
variableScope:scintilla/lexers/LexBatch.cxx
variableScope:scintilla/lexers/LexCmake.cxx
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index fa2ae5acf..4b1b43f2a 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -504,6 +504,10 @@ the document is already styled when the user scrolls to it. </li> <li> + Bash lexer flags incomplete here doc delimiters as syntax errors. + <a href="http://sourceforge.net/p/scintilla/bugs/1789/">Bug #1789</a>. + </li> + <li> Send SCN_UPDATEUI with SC_UPDATE_SELECTION when the application changes multiple selection. </li> diff --git a/lexers/LexBash.cxx b/lexers/LexBash.cxx index 21c47e577..f9d4d2a25 100644 --- a/lexers/LexBash.cxx +++ b/lexers/LexBash.cxx @@ -126,14 +126,13 @@ static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int in bool Quoted; // true if Quote in ('\'','"','`') bool Indent; // indented delimiter (for <<-) int DelimiterLength; // strlen(Delimiter) - char *Delimiter; // the Delimiter, 256: sizeof PL_tokenbuf + char Delimiter[HERE_DELIM_MAX]; // the Delimiter HereDocCls() { State = 0; Quote = 0; Quoted = false; Indent = 0; DelimiterLength = 0; - Delimiter = new char[HERE_DELIM_MAX]; Delimiter[0] = '\0'; } void Append(int ch) { @@ -141,7 +140,6 @@ static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int in Delimiter[DelimiterLength] = '\0'; } ~HereDocCls() { - delete []Delimiter; } }; HereDocCls HereDoc; @@ -173,18 +171,15 @@ static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int in int Up, Down; int Style; int Depth; // levels pushed - int *CountStack; - int *UpStack; - int *StyleStack; + int CountStack[BASH_DELIM_STACK_MAX]; + int UpStack [BASH_DELIM_STACK_MAX]; + int StyleStack[BASH_DELIM_STACK_MAX]; QuoteStackCls() { Count = 0; Up = '\0'; Down = '\0'; Style = 0; Depth = 0; - CountStack = new int[BASH_DELIM_STACK_MAX]; - UpStack = new int[BASH_DELIM_STACK_MAX]; - StyleStack = new int[BASH_DELIM_STACK_MAX]; } void Start(int u, int s) { Count = 1; @@ -214,9 +209,6 @@ static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int in Down = opposite(Up); } ~QuoteStackCls() { - delete []CountStack; - delete []UpStack; - delete []StyleStack; } }; QuoteStackCls QuoteStack; @@ -584,12 +576,14 @@ static void ColouriseBashDoc(Sci_PositionU startPos, Sci_Position length, int in HereDoc.State = 2; if (HereDoc.Quoted) { if (sc.state == SCE_SH_HERE_DELIM) { - // Missing quote at end of string! We are stricter than bash. - // Colour here-doc anyway while marking this bit as an error. + // Missing quote at end of string! Syntax error in bash 4.3 + // Mark this bit as an error, do not colour any here-doc sc.ChangeState(SCE_SH_ERROR); + sc.SetState(SCE_SH_DEFAULT); + } else { + // HereDoc.Quote always == '\'' + sc.SetState(SCE_SH_HERE_Q); } - // HereDoc.Quote always == '\'' - sc.SetState(SCE_SH_HERE_Q); } else if (HereDoc.DelimiterLength == 0) { // no delimiter, illegal (but '' and "" are legal) sc.ChangeState(SCE_SH_ERROR); |