From c2c0e752e0ceffad06d51a472838d18eedc6ed4f Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 4 Sep 2010 11:42:59 +1000 Subject: Fix for bug #3058924 wrong highlighting for float literals containing +/-. Tests added for example numeric literals. --- lexers/LexCPP.cxx | 2 +- test/examples/x.cxx | 3 +++ test/examples/x.cxx.styled | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lexers/LexCPP.cxx b/lexers/LexCPP.cxx index 6d01fb44b..0698ed920 100644 --- a/lexers/LexCPP.cxx +++ b/lexers/LexCPP.cxx @@ -513,7 +513,7 @@ void SCI_METHOD LexerCPP::Lex(unsigned int startPos, int length, int initStyle, break; case SCE_C_NUMBER: // We accept almost anything because of hex. and number suffixes - if (!setWord.Contains(sc.ch)) { + if (!(setWord.Contains(sc.ch) || ((sc.ch == '+' || sc.ch == '-') && (sc.chPrev == 'e' || sc.chPrev == 'E')))) { sc.SetState(SCE_C_DEFAULT|activitySet); } break; diff --git a/test/examples/x.cxx b/test/examples/x.cxx index 255a70e7c..fee6893a6 100644 --- a/test/examples/x.cxx +++ b/test/examples/x.cxx @@ -1,4 +1,7 @@ // A demonstration program +#include int main() { + double x[] = {3.14159,6.02e23,1.6e-19,1.0+1}; + int y[] = {75,0113,0x4b}; printf("hello world %d\n", 9); } diff --git a/test/examples/x.cxx.styled b/test/examples/x.cxx.styled index 223ee0760..9b9caf87d 100644 --- a/test/examples/x.cxx.styled +++ b/test/examples/x.cxx.styled @@ -1,4 +1,7 @@ {2}// A demonstration program +{9}#include {5}int{0} {11}main{10}(){0} {10}{{0} + {11}double{0} {11}x{10}[]{0} {10}={0} {10}{{4}3.14159{10},{4}6.02e23{10},{4}1.6e-19{10},{4}1.0{10}+{4}1{10}};{0} + {5}int{0} {11}y{10}[]{0} {10}={0} {10}{{4}75{10},{4}0113{10},{4}0x4b{10}};{0} {11}printf{10}({6}"hello world %d\n"{10},{0} {4}9{10});{0} {10}}{0} -- cgit v1.2.3