Update Scintilla to 4.0.4
[TortoiseGit.git] / ext / scintilla / lexlib / CharacterSet.cxx
blob7f73005f7e744605156dcf6e078a0b800cf19410
1 // Scintilla source code edit control
2 /** @file CharacterSet.cxx
3 ** Simple case functions for ASCII.
4 ** Lexer infrastructure.
5 **/
6 // Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
7 // The License.txt file describes the conditions under which this software may be distributed.
9 #include <cstdlib>
10 #include <cassert>
12 #include "CharacterSet.h"
14 using namespace Scintilla;
16 namespace Scintilla {
18 int CompareCaseInsensitive(const char *a, const char *b) {
19 while (*a && *b) {
20 if (*a != *b) {
21 const char upperA = static_cast<char>(MakeUpperCase(*a));
22 const char upperB = static_cast<char>(MakeUpperCase(*b));
23 if (upperA != upperB)
24 return upperA - upperB;
26 a++;
27 b++;
29 // Either *a or *b is nul
30 return *a - *b;
33 int CompareNCaseInsensitive(const char *a, const char *b, size_t len) {
34 while (*a && *b && len) {
35 if (*a != *b) {
36 const char upperA = static_cast<char>(MakeUpperCase(*a));
37 const char upperB = static_cast<char>(MakeUpperCase(*b));
38 if (upperA != upperB)
39 return upperA - upperB;
41 a++;
42 b++;
43 len--;
45 if (len == 0)
46 return 0;
47 else
48 // Either *a or *b is nul
49 return *a - *b;