diff --git a/lexilla/lexers_x/LexAHK.cxx b/lexilla/lexers_x/LexAHK.cxx index 5f65f0eb7..b9e30fae7 100644 --- a/lexilla/lexers_x/LexAHK.cxx +++ b/lexilla/lexers_x/LexAHK.cxx @@ -27,7 +27,6 @@ #include "WordList.h" // #include "CharSetX.h" -#include "StringUtils.h" #include "SciXLexer.h" @@ -205,8 +204,8 @@ Sci_Position SCI_METHOD LexerAHK::WordListSet(int n, const char *wl) int firstModification = -1; if (wordListN) { // AHK is fully case-insensitive for keywords/commands/directives/etc. - // Load each wordlist lowercased; callers must lowercase currentWord - // before InList() (see Lexilla::ToLowerAscii in StringUtils.h). + // Load each wordlist lowercased; callers use sc.GetCurrentLowered() + // (Lexilla idiom — see LexVB, LexSQL, LexAU3 for the same pattern). if (wordListN->Set(wl, true)) { firstModification = 0; } @@ -217,9 +216,8 @@ Sci_Position SCI_METHOD LexerAHK::WordListSet(int n, const char *wl) void LexerAHK::HighlightKeyword(char currentWord[], StyleContext& sc) { - // Wordlists are stored lowercase (see WordListSet) — canonicalize lookup. - ToLowerAscii(currentWord); - + // Wordlists are stored lowercase (see WordListSet); callers MUST pass an + // already-lowercased buffer (use sc.GetCurrentLowered() at the call site). if (controlFlow.InList(currentWord)) { sc.ChangeState(SCE_AHK_WORD_CF); } @@ -399,8 +397,7 @@ void SCI_METHOD LexerAHK::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, in // Hotkey F2:: or remapping a::b bIsHotkey = true; // Check if it is a known key - sc.GetCurrent(currentWord, sizeof(currentWord)); - ToLowerAscii(currentWord); + sc.GetCurrentLowered(currentWord, sizeof(currentWord)); if (keysButtons.InList(currentWord)) { sc.ChangeState(SCE_AHK_WORD_KB); } @@ -496,7 +493,7 @@ void SCI_METHOD LexerAHK::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, in } else if (sc.state == SCE_AHK_IDENTIFIER) { if (!WordChar.Contains(sc.ch)) { - sc.GetCurrent(currentWord, sizeof(currentWord)); + sc.GetCurrentLowered(currentWord, sizeof(currentWord)); HighlightKeyword(currentWord, sc); // AHK_L user-function call: unknown identifier immediately followed by `(` if (sc.state == SCE_AHK_DEFAULT && sc.ch == '(') { @@ -527,8 +524,7 @@ void SCI_METHOD LexerAHK::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, in else if (sc.state == SCE_AHK_VARREF) { if (sc.ch == '%') { // End of variable reference - sc.GetCurrent(currentWord, sizeof(currentWord)); - ToLowerAscii(currentWord); + sc.GetCurrentLowered(currentWord, sizeof(currentWord)); if (variables.InList(currentWord)) { sc.ChangeState(SCE_AHK_VARREFKW); } @@ -694,7 +690,7 @@ void SCI_METHOD LexerAHK::Lex(Sci_PositionU startPos, Sci_Position lengthDoc, in } // End of file: complete any pending changeState if (sc.state == SCE_AHK_IDENTIFIER) { - sc.GetCurrent(currentWord, sizeof(currentWord)); + sc.GetCurrentLowered(currentWord, sizeof(currentWord)); HighlightKeyword(currentWord, sc); } else if (sc.state == SCE_AHK_STRING && bInExprString) { diff --git a/lexilla/lexers_x/StringUtils.h b/lexilla/lexers_x/StringUtils.h index 7cc42c90b..94d186720 100644 --- a/lexilla/lexers_x/StringUtils.h +++ b/lexilla/lexers_x/StringUtils.h @@ -34,17 +34,6 @@ inline bool StrHasSuffix(const char *s, size_t length, const char (&suffix)[N]) return length >= N - 1 && strcmp(s + (length + 1 - N), suffix) == 0; } -// In-place ASCII lowercase. Intended for canonicalizing identifiers before -// case-insensitive WordList::InList lookups in case-insensitive languages -// (AHK, etc.). Non-ASCII bytes are left untouched. -inline void ToLowerAscii(char *s) noexcept { - for (; *s; ++s) { - if (*s >= 'A' && *s <= 'Z') { - *s = static_cast(*s + 32); - } - } -} - #if defined(__clang__) || defined(__GNUC__) || !defined(_MSC_BUILD)// || (_MSC_VER >= 1920) template