~ubuntu-branches/ubuntu/natty/geany/natty

« back to all changes in this revision

Viewing changes to scintilla/CharClassify.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Chow Loong Jin
  • Date: 2010-08-07 03:23:12 UTC
  • mfrom: (1.4.3 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20100807032312-ot70ac9d50cn79we
Tags: upstream-0.19
ImportĀ upstreamĀ versionĀ 0.19

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
// Copyright 2006 by Neil Hodgson <neilh@scintilla.org>
6
6
// The License.txt file describes the conditions under which this software may be distributed.
7
7
 
 
8
#include <stdlib.h>
8
9
#include <ctype.h>
9
10
 
10
11
#include "CharClassify.h"
41
42
                }
42
43
        }
43
44
}
 
45
 
 
46
int CompareCaseInsensitive(const char *a, const char *b) {
 
47
        while (*a && *b) {
 
48
                if (*a != *b) {
 
49
                        char upperA = MakeUpperCase(*a);
 
50
                        char upperB = MakeUpperCase(*b);
 
51
                        if (upperA != upperB)
 
52
                                return upperA - upperB;
 
53
                }
 
54
                a++;
 
55
                b++;
 
56
        }
 
57
        // Either *a or *b is nul
 
58
        return *a - *b;
 
59
}
 
60
 
 
61
int CompareNCaseInsensitive(const char *a, const char *b, size_t len) {
 
62
        while (*a && *b && len) {
 
63
                if (*a != *b) {
 
64
                        char upperA = MakeUpperCase(*a);
 
65
                        char upperB = MakeUpperCase(*b);
 
66
                        if (upperA != upperB)
 
67
                                return upperA - upperB;
 
68
                }
 
69
                a++;
 
70
                b++;
 
71
                len--;
 
72
        }
 
73
        if (len == 0)
 
74
                return 0;
 
75
        else
 
76
                // Either *a or *b is nul
 
77
                return *a - *b;
 
78
}