Revision: 1761 http://geany.svn.sourceforge.net/geany/?rev=1761&view=rev Author: eht16 Date: 2007-07-29 07:06:35 -0700 (Sun, 29 Jul 2007)
Log Message: ----------- Backport of LexHTML from Scintilla CVS to fix #1759166. Disable debug build of Scintilla and use -Os.
Modified Paths: -------------- trunk/ChangeLog trunk/scintilla/LexHTML.cxx trunk/scintilla/Makefile.am
Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-07-28 18:01:27 UTC (rev 1760) +++ trunk/ChangeLog 2007-07-29 14:06:35 UTC (rev 1761) @@ -1,3 +1,10 @@ +2007-07-29 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> + + * scintilla/LexHTML.cxx, scintilla/Makefile.am: + Backport of LexHTML from Scintilla CVS to fix #1759166. + Disable debug build of Scintilla and use -Os. + + 2007-07-28 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/editor.c, src/editor.h, src/keybindings.c:
Modified: trunk/scintilla/LexHTML.cxx =================================================================== --- trunk/scintilla/LexHTML.cxx 2007-07-28 18:01:27 UTC (rev 1760) +++ trunk/scintilla/LexHTML.cxx 2007-07-29 14:06:35 UTC (rev 1761) @@ -40,6 +40,20 @@ return (ch < 0x80) && (isalnum(ch) || ch == '_'); }
+inline bool IsOperator(int ch) { + if (isascii(ch) && isalnum(ch)) + return false; + // '.' left out as it is used to make up numbers + if (ch == '%' || ch == '^' || ch == '&' || ch == '*' || + ch == '(' || ch == ')' || ch == '-' || ch == '+' || + ch == '=' || ch == '|' || ch == '{' || ch == '}' || + ch == '[' || ch == ']' || ch == ':' || ch == ';' || + ch == '<' || ch == '>' || ch == ',' || ch == '/' || + ch == '?' || ch == '!' || ch == '.' || ch == '~') + return true; + return false; +} + static inline int MakeLowerCase(int ch) { if (ch < 'A' || ch > 'Z') return ch; @@ -71,8 +85,15 @@ return eScriptJS; if (strstr(s, "php")) return eScriptPHP; - if (strstr(s, "xml")) + if (strstr(s, "xml")) { + const char *xml = strstr(s, "xml"); + for (const char *t=s; t<xml; t++) { + if (!IsASpace(*t)) { + return prevValue; + } + } return eScriptXML; + }
return prevValue; } @@ -397,21 +418,21 @@ return Result; }
-static inline bool ishtmlwordchar(char ch) { +static inline bool ishtmlwordchar(int ch) { return !isascii(ch) || (isalnum(ch) || ch == '.' || ch == '-' || ch == '_' || ch == ':' || ch == '!' || ch == '#'); }
-static inline bool issgmlwordchar(char ch) { +static inline bool issgmlwordchar(int ch) { return !isascii(ch) || (isalnum(ch) || ch == '.' || ch == '_' || ch == ':' || ch == '!' || ch == '#' || ch == '['); }
-static inline bool IsPhpWordStart(const unsigned char ch) { +static inline bool IsPhpWordStart(int ch) { return (isascii(ch) && (isalpha(ch) || (ch == '_'))) || (ch >= 0x7f); }
-static inline bool IsPhpWordChar(char ch) { +static inline bool IsPhpWordChar(int ch) { return IsADigit(ch) || IsPhpWordStart(ch); }
@@ -432,11 +453,11 @@ state == SCE_HJA_COMMENTLINE || state == SCE_HB_COMMENTLINE || state == SCE_HBA_COMMENTLINE; }
-static bool isLineEnd(char ch) { +static bool isLineEnd(int ch) { return ch == '\r' || ch == '\n'; }
-static bool isOKBeforeRE(char ch) { +static bool isOKBeforeRE(int ch) { return (ch == '(') || (ch == '=') || (ch == ','); }
@@ -472,8 +493,8 @@ WordList &keywords5 = *keywordlists[4]; WordList &keywords6 = *keywordlists[5]; // SGML (DTD) keywords
- // Lexer for HTML requires more lexical states (7 bits worth) than most lexers - styler.StartAt(startPos, STYLE_MAX); + // Lexer for HTML requires more lexical states (8 bits worth) than most lexers + styler.StartAt(startPos, static_cast<char>(STYLE_MAX)); char prevWord[200]; prevWord[0] = '\0'; char phpStringDelimiter[200]; // PHP is not limited in length, we are @@ -495,7 +516,7 @@ length++; state = styler.StyleAt(startPos); } - styler.StartAt(startPos, STYLE_MAX); + styler.StartAt(startPos, static_cast<char>(STYLE_MAX));
int lineCurrent = styler.GetLine(startPos); int lineState; @@ -530,9 +551,9 @@ int levelCurrent = levelPrev; int visibleChars = 0;
- char chPrev = ' '; - char ch = ' '; - char chPrevNonWhite = ' '; + int chPrev = ' '; + int ch = ' '; + int chPrevNonWhite = ' '; // look back to set chPrevNonWhite properly for better regex colouring if (scriptLanguage == eScriptJS && startPos > 0) { int back = startPos; @@ -551,23 +572,23 @@ styler.StartSegment(startPos); const int lengthDoc = startPos + length; for (int i = startPos; i < lengthDoc; i++) { - const char chPrev2 = chPrev; + const int chPrev2 = chPrev; chPrev = ch; - if (!isspacechar(ch) && state != SCE_HJ_COMMENT && + if (!IsASpace(ch) && state != SCE_HJ_COMMENT && state != SCE_HJ_COMMENTLINE && state != SCE_HJ_COMMENTDOC) chPrevNonWhite = ch; - ch = styler[i]; - char chNext = styler.SafeGetCharAt(i + 1); - const char chNext2 = styler.SafeGetCharAt(i + 2); + ch = static_cast<unsigned char>(styler[i]); + int chNext = static_cast<unsigned char>(styler.SafeGetCharAt(i + 1)); + const int chNext2 = static_cast<unsigned char>(styler.SafeGetCharAt(i + 2));
// Handle DBCS codepages - if (styler.IsLeadByte(ch)) { + if (styler.IsLeadByte(static_cast<char>(ch))) { chPrev = ' '; i += 1; continue; }
- if ((!isspacechar(ch) || !foldCompact) && fold) + if ((!IsASpace(ch) || !foldCompact) && fold) visibleChars++;
// decide what is the current state to print (depending of the script tag) @@ -670,7 +691,7 @@ char chr; // current char int j=0; chr = styler.SafeGetCharAt(i+2); - while (j < 6 && !isspacechar(chr)) { + while (j < 6 && !IsASpace(chr)) { tag[j++] = static_cast<char>(MakeLowerCase(chr)); chr = styler.SafeGetCharAt(i+2+j); } @@ -1211,7 +1232,7 @@ case SCE_HJ_DEFAULT: case SCE_HJ_START: case SCE_HJ_SYMBOLS: - if (iswordstart(ch)) { + if (IsAWordStart(ch)) { styler.ColourTo(i - 1, StateToPrint); state = SCE_HJ_WORD; } else if (ch == '/' && chNext == '*') { @@ -1240,7 +1261,7 @@ styler.ColourTo(i - 1, StateToPrint); state = SCE_HJ_COMMENTLINE; i += 2; - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType)); state = SCE_HJ_DEFAULT; @@ -1252,7 +1273,7 @@ } break; case SCE_HJ_WORD: - if (!iswordchar(ch)) { + if (!IsAWordChar(ch)) { classifyWordHTJS(styler.GetStartSegment(), i - 1, keywords2, styler, inScriptType); //styler.ColourTo(i - 1, eHTJSKeyword); state = SCE_HJ_DEFAULT; @@ -1271,7 +1292,7 @@ styler.ColourTo(i - 1, StateToPrint); state = SCE_HJ_COMMENTLINE; i += 2; - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType)); state = SCE_HJ_DEFAULT; } @@ -1357,7 +1378,7 @@ break; case SCE_HB_DEFAULT: case SCE_HB_START: - if (iswordstart(ch)) { + if (IsAWordStart(ch)) { styler.ColourTo(i - 1, StateToPrint); state = SCE_HB_WORD; } else if (ch == ''') { @@ -1370,7 +1391,7 @@ styler.SafeGetCharAt(i + 3) == '-') { styler.ColourTo(i - 1, StateToPrint); state = SCE_HB_COMMENTLINE; - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i, statePrintForState(SCE_HB_DEFAULT, inScriptType)); state = SCE_HB_DEFAULT; @@ -1382,14 +1403,14 @@ } break; case SCE_HB_WORD: - if (!iswordchar(ch)) { + if (!IsAWordChar(ch)) { state = classifyWordHTVB(styler.GetStartSegment(), i - 1, keywords3, styler, inScriptType); if (state == SCE_HB_DEFAULT) { if (ch == '"') { state = SCE_HB_STRING; } else if (ch == ''') { state = SCE_HB_COMMENTLINE; - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { styler.ColourTo(i, statePrintForState(SCE_HB_DEFAULT, inScriptType)); state = SCE_HB_DEFAULT; } @@ -1422,7 +1443,7 @@ break; case SCE_HP_DEFAULT: case SCE_HP_START: - if (iswordstart(ch)) { + if (IsAWordStart(ch)) { styler.ColourTo(i - 1, StateToPrint); state = SCE_HP_WORD; } else if ((ch == '<') && (chNext == '!') && (chNext2 == '-') && @@ -1455,7 +1476,7 @@ } else { state = SCE_HP_CHARACTER; } - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { styler.ColourTo(i - 1, StateToPrint); styler.ColourTo(i, statePrintForState(SCE_HP_OPERATOR, inScriptType)); } else if ((ch == ' ') || (ch == '\t')) { @@ -1466,7 +1487,7 @@ } break; case SCE_HP_WORD: - if (!iswordchar(ch)) { + if (!IsAWordChar(ch)) { classifyWordHTPy(styler.GetStartSegment(), i - 1, keywords4, styler, prevWord, inScriptType); state = SCE_HP_DEFAULT; if (ch == '#') { @@ -1491,7 +1512,7 @@ } else { state = SCE_HP_CHARACTER; } - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { styler.ColourTo(i, statePrintForState(SCE_HP_OPERATOR, inScriptType)); } } @@ -1540,7 +1561,7 @@ break; ///////////// start - PHP state handling case SCE_HPHP_WORD: - if (!iswordchar(ch)) { + if (!IsAWordChar(ch)) { classifyWordHTPHP(styler.GetStartSegment(), i - 1, keywords5, styler); if (ch == '/' && chNext == '*') { i++; @@ -1560,7 +1581,7 @@ state = SCE_HPHP_SIMPLESTRING; } else if (ch == '$' && IsPhpWordStart(chNext)) { state = SCE_HPHP_VARIABLE; - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { state = SCE_HPHP_OPERATOR; } else { state = SCE_HPHP_DEFAULT; @@ -1573,7 +1594,7 @@ && strchr(".xXabcdefABCDEF", ch) == NULL && ((ch != '-' && ch != '+') || (chPrev != 'e' && chPrev != 'E'))) { styler.ColourTo(i - 1, SCE_HPHP_NUMBER); - if (isoperator(ch)) + if (IsOperator(ch)) state = SCE_HPHP_OPERATOR; else state = SCE_HPHP_DEFAULT; @@ -1582,7 +1603,7 @@ case SCE_HPHP_VARIABLE: if (!IsPhpWordChar(ch)) { styler.ColourTo(i - 1, SCE_HPHP_VARIABLE); - if (isoperator(ch)) + if (IsOperator(ch)) state = SCE_HPHP_OPERATOR; else state = SCE_HPHP_DEFAULT; @@ -1646,7 +1667,7 @@ styler.ColourTo(i - 1, StateToPrint); if (IsADigit(ch) || (ch == '.' && IsADigit(chNext))) { state = SCE_HPHP_NUMBER; - } else if (iswordstart(ch)) { + } else if (IsAWordStart(ch)) { state = SCE_HPHP_WORD; } else if (ch == '/' && chNext == '*') { i++; @@ -1666,9 +1687,9 @@ state = SCE_HPHP_SIMPLESTRING; } else if (ch == '$' && IsPhpWordStart(chNext)) { state = SCE_HPHP_VARIABLE; - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { state = SCE_HPHP_OPERATOR; - } else if ((state == SCE_HPHP_OPERATOR) && (isspacechar(ch))) { + } else if ((state == SCE_HPHP_OPERATOR) && (IsASpace(ch))) { state = SCE_HPHP_DEFAULT; } break; @@ -1684,9 +1705,9 @@ state = SCE_HB_STRING; } else if (ch == ''') { state = SCE_HB_COMMENTLINE; - } else if (iswordstart(ch)) { + } else if (IsAWordStart(ch)) { state = SCE_HB_WORD; - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { styler.ColourTo(i, SCE_HB_DEFAULT); } } else if (state == SCE_HBA_DEFAULT) { // One of the above succeeded @@ -1694,9 +1715,9 @@ state = SCE_HBA_STRING; } else if (ch == ''') { state = SCE_HBA_COMMENTLINE; - } else if (iswordstart(ch)) { + } else if (IsAWordStart(ch)) { state = SCE_HBA_WORD; - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { styler.ColourTo(i, SCE_HBA_DEFAULT); } } else if (state == SCE_HJ_DEFAULT) { // One of the above succeeded @@ -1711,9 +1732,9 @@ state = SCE_HJ_DOUBLESTRING; } else if ((ch == ''') && (nonEmptySegment)) { state = SCE_HJ_SINGLESTRING; - } else if (iswordstart(ch)) { + } else if (IsAWordStart(ch)) { state = SCE_HJ_WORD; - } else if (isoperator(ch)) { + } else if (IsOperator(ch)) { styler.ColourTo(i, statePrintForState(SCE_HJ_SYMBOLS, inScriptType)); } } @@ -1815,7 +1836,7 @@ sc.SetState(SCE_H_DEFAULT); } } else if (sc.state == SCE_H_TAGUNKNOWN) { - if (!ishtmlwordchar(static_cast<char>(sc.ch)) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') { + if (!ishtmlwordchar(sc.ch) && !((sc.ch == '/') && (sc.chPrev == '<')) && sc.ch != '[') { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (s[1] == '/') { @@ -1838,7 +1859,7 @@ } } } else if (sc.state == SCE_H_ATTRIBUTE) { - if (!ishtmlwordchar(static_cast<char>(sc.ch))) { + if (!ishtmlwordchar(sc.ch)) { char s[100]; sc.GetCurrentLowered(s, sizeof(s)); if (!keywordsTags.InList(s)) { @@ -1890,7 +1911,7 @@ } else if (sc.ch == '>') { sc.SetState(SCE_H_TAG); sc.ForwardSetState(SCE_H_DEFAULT); - } else if (ishtmlwordchar(static_cast<char>(sc.ch))) { + } else if (ishtmlwordchar(sc.ch)) { sc.SetState(SCE_H_ATTRIBUTE); } } @@ -1934,8 +1955,8 @@
static void ColouriseASPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { - // Lexer for HTML requires more lexical states (7 bits worth) than most lexers - StyleContext sc(startPos, length, initStyle, styler, 0x7f); + // Lexer for HTML requires more lexical states (8 bits worth) than most lexers + StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(STYLE_MAX)); for (; sc.More(); sc.Forward()) { ColouriseASPPiece(sc, keywordlists); } @@ -2018,7 +2039,7 @@ sc.SetState(SCE_HPHP_SIMPLESTRING); } else if (sc.ch == '$' && IsPhpWordStart(static_cast<char>(sc.chNext))) { sc.SetState(SCE_HPHP_VARIABLE); - } else if (isoperator(static_cast<char>(sc.ch))) { + } else if (IsOperator(static_cast<char>(sc.ch))) { sc.SetState(SCE_HPHP_OPERATOR); } } @@ -2026,8 +2047,8 @@
static void ColourisePHPDoc(unsigned int startPos, int length, int initStyle, WordList *keywordlists[], Accessor &styler) { - // Lexer for HTML requires more lexical states (7 bits worth) than most lexers - StyleContext sc(startPos, length, initStyle, styler, 0x7f); + // Lexer for HTML requires more lexical states (8 bits worth) than most lexers + StyleContext sc(startPos, length, initStyle, styler, static_cast<char>(STYLE_MAX)); for (; sc.More(); sc.Forward()) { ColourisePHPPiece(sc, keywordlists); } @@ -2060,9 +2081,9 @@ 0, };
-LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc, 7); -LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc, 7); +LexerModule lmHTML(SCLEX_HTML, ColouriseHTMLDoc, "hypertext", 0, htmlWordListDesc, 8); +LexerModule lmXML(SCLEX_XML, ColouriseXMLDoc, "xml", 0, htmlWordListDesc, 8); // SCLEX_ASP and SCLEX_PHP should not be used in new code: use SCLEX_HTML instead. -LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc, 7); -LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc, 7); -LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 7); +LexerModule lmASP(SCLEX_ASP, ColouriseASPDoc, "asp", 0, htmlWordListDesc, 8); +LexerModule lmPHP(SCLEX_PHP, ColourisePHPDoc, "php", 0, htmlWordListDesc, 8); +LexerModule lmPHPSCRIPT(SCLEX_PHPSCRIPT, ColourisePHPScriptDoc, "phpscript", 0, phpscriptWordListDesc, 8);
Modified: trunk/scintilla/Makefile.am =================================================================== --- trunk/scintilla/Makefile.am 2007-07-28 18:01:27 UTC (rev 1760) +++ trunk/scintilla/Makefile.am 2007-07-29 14:06:35 UTC (rev 1761) @@ -5,7 +5,7 @@
CC = @CC@
-AM_CXXFLAGS = -DGTK -DGTK2 -DSCI_LEXER -DG_THREADS_IMPL_NONE +AM_CXXFLAGS = -DNDEBUG -Os -DGTK -DGTK2 -DSCI_LEXER -DG_THREADS_IMPL_NONE
LEXER_SRCS= \ LexAsm.cxx \
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.