diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Document.cxx | 27 | ||||
-rw-r--r-- | src/PosRegExp.cxx | 9 | ||||
-rw-r--r-- | src/PropSet.cxx | 2 |
3 files changed, 31 insertions, 7 deletions
diff --git a/src/Document.cxx b/src/Document.cxx index babe25bcf..ac9c381a0 100644 --- a/src/Document.cxx +++ b/src/Document.cxx @@ -747,6 +747,23 @@ char Document::DocCharAt(int pos, void *param) { return reinterpret_cast<Document*>(param)->CharAt(pos); } +// The comparison and case changing functions here assume ASCII +// or extended ASCII such as the normal Windows code page. + +static inline char MakeUpperCase(char ch) { + if (ch < 'a' || ch > 'z') + return ch; + else + return static_cast<char>(ch - 'a' + 'A'); +} + +static inline char MakeLowerCase(char ch) { + if (ch < 'A' || ch > 'Z') + return ch; + else + return static_cast<char>(ch - 'A' + 'a'); +} + // Find text in document, supporting both forward and backward // searches (just pass minPos > maxPos to do a backward search) // Has not been tested with backwards DBCS searches yet. @@ -811,7 +828,7 @@ long Document::FindText(int minPos, int maxPos, const char *s, //Platform::DebugPrintf("Find %d %d %s %d\n", startPos, endPos, ft->lpstrText, lengthFind); char firstChar = s[0]; if (!caseSensitive) - firstChar = static_cast<char>(toupper(firstChar)); + firstChar = static_cast<char>(MakeUpperCase(firstChar)); int pos = startPos; while (forward ? (pos < endSearch) : (pos >= endSearch)) { char ch = CharAt(pos); @@ -831,11 +848,11 @@ long Document::FindText(int minPos, int maxPos, const char *s, } } } else { - if (toupper(ch) == firstChar) { + if (MakeUpperCase(ch) == firstChar) { bool found = true; for (int posMatch = 1; posMatch < lengthFind && found; posMatch++) { ch = CharAt(pos + posMatch); - if (toupper(ch) != toupper(s[posMatch])) + if (MakeUpperCase(ch) != MakeUpperCase(s[posMatch])) found = false; } if (found) { @@ -869,11 +886,11 @@ void Document::ChangeCase(Range r, bool makeUpperCase) { } else { if (makeUpperCase) { if (islower(ch)) { - ChangeChar(pos, static_cast<char>(toupper(ch))); + ChangeChar(pos, static_cast<char>(MakeUpperCase(ch))); } } else { if (isupper(ch)) { - ChangeChar(pos, static_cast<char>(tolower(ch))); + ChangeChar(pos, static_cast<char>(MakeLowerCase(ch))); } } } diff --git a/src/PosRegExp.cxx b/src/PosRegExp.cxx index 01870848d..eb240e2fb 100644 --- a/src/PosRegExp.cxx +++ b/src/PosRegExp.cxx @@ -8,7 +8,14 @@ #ifdef _MSC_VER #pragma warning(disable: 4244) #endif - +#ifdef __BORLANDC__ +// Too much effort to to cean this code up so just ignore badly +// bracketed initialisers, conversions losing significant digits, +// and values assigned but not used. +#pragma warn -pin +#pragma warn -sig +#pragma warn -aus +#endif //Up: /[A-Z \x80-\x9f \xf0 ]/x //Lo: /[a-z \xa0-\xaf \xe0-\xef \xf1 ]/x //Wd: /[\d _ A-Z a-z \xa0-\xaf \xe0-\xf1 \x80-\x9f]/x diff --git a/src/PropSet.cxx b/src/PropSet.cxx index 573991870..5f4e20a1c 100644 --- a/src/PropSet.cxx +++ b/src/PropSet.cxx @@ -19,7 +19,7 @@ // The comparison and case changing functions here assume ASCII // or extended ASCII such as the normal Windows code page. -inline char MakeUpperCase(char ch) { +static inline char MakeUpperCase(char ch) { if (ch < 'a' || ch > 'z') return ch; else |