diff options
| -rw-r--r-- | doc/ScintillaHistory.html | 4 | ||||
| -rw-r--r-- | lexers/LexSQL.cxx | 9 | 
2 files changed, 9 insertions, 4 deletions
diff --git a/doc/ScintillaHistory.html b/doc/ScintillaHistory.html index e96ac73f4..7dbb3824f 100644 --- a/doc/ScintillaHistory.html +++ b/doc/ScintillaHistory.html @@ -492,6 +492,10 @@  	and SCI_GETKEYSUNICODE always returns true. These APIs are deprecated and should not be called.  	</li>  	<li> +	SQL lexer fixes handling of '+' and '-' in numbers so the '-' in '1-1' is seen as an operator and for +	'1--comment' the comment is recognized. +	</li> +	<li>  	TCL lexer reverts change to string handling.  	<a href="http://sourceforge.net/p/scintilla/bugs/1642/">Bug #1642</a>.  	</li> diff --git a/lexers/LexSQL.cxx b/lexers/LexSQL.cxx index 9e1a19748..176c92c32 100644 --- a/lexers/LexSQL.cxx +++ b/lexers/LexSQL.cxx @@ -54,12 +54,12 @@ static inline bool IsADoxygenChar(int ch) {  	        ch == '}' || ch == '[' || ch == ']');  } -static inline bool IsANumberChar(int ch) { +static inline bool IsANumberChar(int ch, int chPrev) {  	// Not exactly following number definition (several dots are seen as OK, etc.)  	// but probably enough in most cases.  	return (ch < 0x80) &&  	       (isdigit(ch) || toupper(ch) == 'E' || -	        ch == '.' || ch == '-' || ch == '+'); +	        ch == '.' || ((ch == '-' || ch == '+') && chPrev < 0x80 && toupper(chPrev) == 'E'));  }  typedef unsigned int sql_state_t; @@ -453,7 +453,7 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,  			break;  		case SCE_SQL_NUMBER:  			// We stop the number definition on non-numerical non-dot non-eE non-sign char -			if (!IsANumberChar(sc.ch)) { +			if (!IsANumberChar(sc.ch, sc.chPrev)) {  				sc.SetState(SCE_SQL_DEFAULT);  			}  			break; @@ -594,7 +594,8 @@ void SCI_METHOD LexerSQL::Lex(unsigned int startPos, int length, int initStyle,  			if (sc.Match('q', '\'') || sc.Match('Q', '\'')) {  				sc.SetState(SCE_SQL_QOPERATOR);			  				sc.Forward(); -			} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext))) { +			} else if (IsADigit(sc.ch) || (sc.ch == '.' && IsADigit(sc.chNext)) || +			          ((sc.ch == '-' || sc.ch == '+') && IsADigit(sc.chNext) && !IsADigit(sc.chPrev))) {  				sc.SetState(SCE_SQL_NUMBER);  			} else if (IsAWordStart(sc.ch)) {  				sc.SetState(SCE_SQL_IDENTIFIER);  | 
