diff options
author | Neil <nyamatongwe@gmail.com> | 2015-03-29 10:13:37 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2015-03-29 10:13:37 +1100 |
commit | f9ef981fa18225a3e3eb120258fe8919dd37a635 (patch) | |
tree | 8b14e9f9c496621c92ae96f5e3e14948bf58e202 /lexers/LexSQL.cxx | |
parent | c802cf38ea379ca318183f03004d6333ef1756e5 (diff) | |
download | scintilla-mirror-f9ef981fa18225a3e3eb120258fe8919dd37a635.tar.gz |
Fix handling of '+' and '-' in numbers.
From Michael Staszewski.
Diffstat (limited to 'lexers/LexSQL.cxx')
-rw-r--r-- | lexers/LexSQL.cxx | 9 |
1 files changed, 5 insertions, 4 deletions
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); |