diff options
-rw-r--r-- | lexlib/CharacterSet.cxx | 8 | ||||
-rw-r--r-- | lexlib/CharacterSet.h | 9 | ||||
-rw-r--r-- | lexlib/StyleContext.cxx | 17 | ||||
-rw-r--r-- | lexlib/StyleContext.h | 23 |
4 files changed, 30 insertions, 27 deletions
diff --git a/lexlib/CharacterSet.cxx b/lexlib/CharacterSet.cxx index 0ab2cc0cc..55602af30 100644 --- a/lexlib/CharacterSet.cxx +++ b/lexlib/CharacterSet.cxx @@ -25,8 +25,8 @@ namespace Scintilla { int CompareCaseInsensitive(const char *a, const char *b) { while (*a && *b) { if (*a != *b) { - char upperA = MakeUpperCase(*a); - char upperB = MakeUpperCase(*b); + char upperA = static_cast<char>(MakeUpperCase(*a)); + char upperB = static_cast<char>(MakeUpperCase(*b)); if (upperA != upperB) return upperA - upperB; } @@ -40,8 +40,8 @@ int CompareCaseInsensitive(const char *a, const char *b) { int CompareNCaseInsensitive(const char *a, const char *b, size_t len) { while (*a && *b && len) { if (*a != *b) { - char upperA = MakeUpperCase(*a); - char upperB = MakeUpperCase(*b); + char upperA = static_cast<char>(MakeUpperCase(*a)); + char upperB = static_cast<char>(MakeUpperCase(*b)); if (upperA != upperB) return upperA - upperB; } diff --git a/lexlib/CharacterSet.h b/lexlib/CharacterSet.h index a0c45b2fb..183fbe421 100644 --- a/lexlib/CharacterSet.h +++ b/lexlib/CharacterSet.h @@ -160,13 +160,20 @@ inline bool isoperator(int ch) { // Simple case functions for ASCII. -inline char MakeUpperCase(char ch) { +inline int MakeUpperCase(int ch) { if (ch < 'a' || ch > 'z') return ch; else return static_cast<char>(ch - 'a' + 'A'); } +inline int MakeLowerCase(int ch) { + if (ch < 'A' || ch > 'Z') + return ch; + else + return ch - 'A' + 'a'; +} + int CompareCaseInsensitive(const char *a, const char *b); int CompareNCaseInsensitive(const char *a, const char *b, size_t len); diff --git a/lexlib/StyleContext.cxx b/lexlib/StyleContext.cxx index 5bcacb018..f9f15be2e 100644 --- a/lexlib/StyleContext.cxx +++ b/lexlib/StyleContext.cxx @@ -16,11 +16,28 @@ #include "LexAccessor.h" #include "Accessor.h" #include "StyleContext.h" +#include "CharacterSet.h" #ifdef SCI_NAMESPACE using namespace Scintilla; #endif +bool StyleContext::MatchIgnoreCase(const char *s) { + if (MakeLowerCase(ch) != static_cast<unsigned char>(*s)) + return false; + s++; + if (MakeLowerCase(chNext) != static_cast<unsigned char>(*s)) + return false; + s++; + for (int n = 2; *s; n++) { + if (static_cast<unsigned char>(*s) != + MakeLowerCase(static_cast<unsigned char>(styler.SafeGetCharAt(currentPos + n, 0)))) + return false; + s++; + } + return true; +} + static void getRange(Sci_PositionU start, Sci_PositionU end, LexAccessor &styler, diff --git a/lexlib/StyleContext.h b/lexlib/StyleContext.h index c8aa4ab02..6cbda358e 100644 --- a/lexlib/StyleContext.h +++ b/lexlib/StyleContext.h @@ -12,13 +12,6 @@ namespace Scintilla { #endif -static inline int MakeLowerCase(int ch) { - if (ch < 'A' || ch > 'Z') - return ch; - else - return ch - 'A' + 'a'; -} - // All languages handled so far can treat all characters >= 0x80 as one class // which just continues the current token or starts an identifier if in default. // DBCS treated specially as the second character can be < 0x80 and hence @@ -204,22 +197,8 @@ public: } return true; } - bool MatchIgnoreCase(const char *s) { - if (MakeLowerCase(ch) != static_cast<unsigned char>(*s)) - return false; - s++; - if (MakeLowerCase(chNext) != static_cast<unsigned char>(*s)) - return false; - s++; - for (int n=2; *s; n++) { - if (static_cast<unsigned char>(*s) != - MakeLowerCase(static_cast<unsigned char>(styler.SafeGetCharAt(currentPos+n, 0)))) - return false; - s++; - } - return true; - } // Non-inline + bool MatchIgnoreCase(const char *s); void GetCurrent(char *s, Sci_PositionU len); void GetCurrentLowered(char *s, Sci_PositionU len); }; |