diff options
-rw-r--r-- | include/PropSet.h | 2 | ||||
-rw-r--r-- | src/LexCPP.cxx | 32 | ||||
-rw-r--r-- | src/LexHTML.cxx | 11 | ||||
-rw-r--r-- | src/LexVB.cxx | 26 |
4 files changed, 19 insertions, 52 deletions
diff --git a/include/PropSet.h b/include/PropSet.h index bc1599f38..2326ba5c4 100644 --- a/include/PropSet.h +++ b/include/PropSet.h @@ -168,7 +168,7 @@ public: WordList(bool onlyLineEnds_ = false) : words(0), list(0), len(0), onlyLineEnds(onlyLineEnds_) {} ~WordList() { Clear(); } - operator bool() { return list ? true : false; } + operator bool() { return (list && list[0]) ? true : false; } const char *operator[](int ind) { return words[ind]; } void Clear(); void Set(const char *s); diff --git a/src/LexCPP.cxx b/src/LexCPP.cxx index d62375e9c..cad24a773 100644 --- a/src/LexCPP.cxx +++ b/src/LexCPP.cxx @@ -46,6 +46,7 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo styler.StartAt(startPos); bool fold = styler.GetPropertyInt("fold"); + bool stylingWithinPreprocessor = styler.GetPropertyInt("styling.within.preprocessor"); int lineCurrent = styler.GetLine(startPos); int levelPrev = styler.LevelAt(lineCurrent) & SC_FOLDLEVELNUMBERMASK; int levelCurrent = levelPrev; @@ -118,15 +119,12 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo } else if (ch == '#') { styler.ColourTo(i-1, state); state = SCE_C_PREPROCESSOR; -#ifdef COLORIZE_ALL_PREPROC /* PL 2000/05/18 */ -#else /* OLD PL 2000/05/18 */ // Skip whitespace between # and preprocessor word do { i++; ch = chNext; chNext = styler.SafeGetCharAt(i + 1); } while (isspace(ch)); -#endif /* OLD PL 2000/05/18 */ } else if (isoperator(ch)) { styler.ColourTo(i-1, state); styler.ColourTo(i, SCE_C_OPERATOR); @@ -149,10 +147,6 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo state = SCE_C_STRING; } else if (ch == '\'') { state = SCE_C_CHARACTER; -#ifdef OLD /* PL 2000/05/18 -- A preprocessor symbol shouldn't start in the middle of a word! */ - } else if (ch == '#') { - state = SCE_C_PREPROCESSOR; -#endif /* OLD PL 2000/05/18 */ } else if (isoperator(ch)) { styler.ColourTo(i, SCE_C_OPERATOR); if ((ch == '{') || (ch == '}')) { @@ -162,17 +156,17 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo } } else { if (state == SCE_C_PREPROCESSOR) { -#ifdef COLORIZE_ALL_PREPROC /* PL 2000/05/18 -- Stop after the preprocessor word */ - if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) { - styler.ColourTo(i-1, state); - state = SCE_C_DEFAULT; - } -#else /* OLD PL 2000/05/18 */ - if (isspace(ch)) { - styler.ColourTo(i-1, state); - state = SCE_C_DEFAULT; + if (stylingWithinPreprocessor) { + if (isspace(ch)) { + styler.ColourTo(i-1, state); + state = SCE_C_DEFAULT; + } + } else { + if ((ch == '\r' || ch == '\n') && !(chPrev == '\\' || chPrev == '\r')) { + styler.ColourTo(i-1, state); + state = SCE_C_DEFAULT; + } } -#endif /* OLD PL 2000/05/18 */ } else if (state == SCE_C_COMMENT) { if (ch == '/' && chPrev == '*') { if (((i > styler.GetStartSegment() + 2) || ( @@ -248,10 +242,6 @@ static void ColouriseCppDoc(unsigned int startPos, int length, int initStyle, Wo state = SCE_C_STRING; } else if (ch == '\'') { state = SCE_C_CHARACTER; -#ifdef OLD /* PL 2000/05/18 -- A preprocessor symbol SHOULD be the first non-white char. of the line! */ - } else if (ch == '#') { - state = SCE_C_PREPROCESSOR; -#endif /* OLD PL 2000/05/18 */ } else if (iswordstart(ch)) { state = SCE_C_WORD; } else if (isoperator(ch)) { diff --git a/src/LexHTML.cxx b/src/LexHTML.cxx index 0b31cba39..9a9377292 100644 --- a/src/LexHTML.cxx +++ b/src/LexHTML.cxx @@ -54,6 +54,9 @@ static void classifyAttribHTML(unsigned int start, unsigned int end, WordList &k if (keywords.InList(s)) chAttr = SCE_H_ATTRIBUTE; } + if ((chAttr == SCE_H_ATTRIBUTEUNKNOWN) && !keywords) + // No keywords -> all are known + chAttr = SCE_H_ATTRIBUTE; styler.ColourTo(end, chAttr); } @@ -81,6 +84,9 @@ static int classifyTagHTML(unsigned int start, unsigned int end, chAttr = SCE_H_SCRIPT; } } + if ((chAttr == SCE_H_TAGUNKNOWN) && !keywords) + // No keywords -> all are known + chAttr = SCE_H_TAG; styler.ColourTo(end, chAttr); return chAttr; } @@ -353,13 +359,10 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty styler.ColourTo(i, state); state = SCE_H_DEFAULT; } -#ifdef OLD /* PL 2000/05/18 -- An bad entity may stop on a non-alphabetic character */ -#else /* OLD PL 2000/05/18 */ if (ch != '#' && !isalnum(ch)) { // Should check that '#' follows '&', but it is unlikely anyway... styler.ColourTo(i, SCE_H_TAGUNKNOWN); state = SCE_H_DEFAULT; } -#endif /* OLD PL 2000/05/18 */ } else if (state == SCE_H_TAGUNKNOWN) { if (!ishtmlwordchar(ch) && ch != '/' && ch != '-') { int eClass = classifyTagHTML(styler.GetStartSegment(), i - 1, keywords, styler); @@ -368,7 +371,7 @@ static void ColouriseHyperTextDoc(unsigned int startPos, int length, int initSty scriptLanguage = eScriptJS; eClass = SCE_H_TAG; } - if (ch == '>') { + if ((ch == '>') && (eClass != SCE_H_COMMENT)) { styler.ColourTo(i, SCE_H_TAG); if (lastTagWasScript) { if (scriptLanguage == eScriptVBS) diff --git a/src/LexVB.cxx b/src/LexVB.cxx index b5b3bf9ab..feb9fe24a 100644 --- a/src/LexVB.cxx +++ b/src/LexVB.cxx @@ -20,38 +20,21 @@ static int classifyWordVB(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) { char s[100]; -#ifdef OLD /* PL 2000/05/18 -- Include hexadecimal number */ - bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.'); -#else /* OLD PL 2000/05/18 */ bool wordIsNumber = isdigit(styler[start]) || (styler[start] == '.') || (styler[start] == '&' && tolower(styler[start+1]) == 'h'); -#endif /* OLD PL 2000/05/18 */ unsigned int i; for (i = 0; i < end - start + 1 && i < 30; i++) { s[i] = static_cast<char>(tolower(styler[start + i])); -#ifdef OLD /* PL 2000/05/18 -- Little optimization */ - s[i + 1] = '\0'; - } -#else /* OLD PL 2000/05/18 */ } s[i] = '\0'; -#endif /* OLD PL 2000/05/18 */ char chAttr = SCE_C_DEFAULT; if (wordIsNumber) chAttr = SCE_C_NUMBER; else { -#ifdef OLD /* PL 2000/05/18 */ - if (keywords.InList(s)) { - chAttr = SCE_C_WORD; - if (strcmp(s, "rem") == 0) - chAttr = SCE_C_COMMENTLINE; - } -#else /* OLD PL 2000/05/18 */ if (strcmp(s, "rem") == 0) chAttr = SCE_C_COMMENTLINE; else if (keywords.InList(s)) chAttr = SCE_C_WORD; -#endif /* OLD PL 2000/05/18 */ } styler.ColourTo(end, chAttr); if (chAttr == SCE_C_COMMENTLINE) @@ -91,8 +74,6 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, } else if (ch == '\"') { styler.ColourTo(i - 1, state); state = SCE_C_STRING; -#ifdef OLD /* PL 2000/05/18 */ -#else /* OLD PL 2000/05/18 */ } else if (ch == '#') { styler.ColourTo(i - 1, state); state = SCE_C_PREPROCESSOR; @@ -102,7 +83,6 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, } else if (isoperator(ch)) { styler.ColourTo(i - 1, state); styler.ColourTo(i, SCE_C_OPERATOR); -#endif /* OLD PL 2000/05/18 */ } } else if (state == SCE_C_WORD) { if (!iswordchar(ch)) { @@ -112,12 +92,9 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, state = SCE_C_COMMENTLINE; } else if (ch == '\"') { state = SCE_C_STRING; -#ifdef OLD /* PL 2000/05/18 */ -#else /* OLD PL 2000/05/18 */ } else if (isoperator(ch)) { styler.ColourTo(i - 1, state); styler.ColourTo(i, SCE_C_OPERATOR); -#endif /* OLD PL 2000/05/18 */ } } } @@ -136,14 +113,11 @@ static void ColouriseVBDoc(unsigned int startPos, int length, int initStyle, ch = chNext; chNext = styler.SafeGetCharAt(i + 1); } -#ifdef OLD /* PL 2000/05/18 */ -#else /* OLD PL 2000/05/18 */ } else if (state == SCE_C_PREPROCESSOR) { if (ch == '\r' || ch == '\n') { styler.ColourTo(i - 1, state); state = SCE_C_DEFAULT; } -#endif /* OLD PL 2000/05/18 */ } if (state == SCE_C_DEFAULT) { // One of the above succeeded if (ch == '\'') { |