Merge pull request #3948 from techee/warning_fix2
[geany-mirror.git] / scintilla / src / CharacterType.cxx
blob2991ac3c4ef30373cbb9f9c7eba33b38732da991
1 // Scintilla source code edit control
2 /** @file CharacterType.cxx
3 ** Tests for character type and case-insensitive comparisons.
4 **/
5 // Copyright 1998-2010 by Neil Hodgson <neilh@scintilla.org>
6 // The License.txt file describes the conditions under which this software may be distributed.
8 #include <cstdlib>
9 #include <cassert>
11 #include "CharacterType.h"
13 using namespace Scintilla::Internal;
15 namespace Scintilla::Internal {
17 int CompareCaseInsensitive(const char *a, const char *b) noexcept {
18 while (*a && *b) {
19 if (*a != *b) {
20 const char upperA = MakeUpperCase(*a);
21 const char upperB = MakeUpperCase(*b);
22 if (upperA != upperB)
23 return upperA - upperB;
25 a++;
26 b++;
28 // Either *a or *b is nul
29 return *a - *b;
32 int CompareNCaseInsensitive(const char *a, const char *b, size_t len) noexcept {
33 while (*a && *b && len) {
34 if (*a != *b) {
35 const char upperA = MakeUpperCase(*a);
36 const char upperB = MakeUpperCase(*b);
37 if (upperA != upperB)
38 return upperA - upperB;
40 a++;
41 b++;
42 len--;
44 if (len == 0)
45 return 0;
46 else
47 // Either *a or *b is nul
48 return *a - *b;