aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornyamatongwe <unknown>2005-08-06 06:16:59 +0000
committernyamatongwe <unknown>2005-08-06 06:16:59 +0000
commit10021c40317d0b445e60aa9582bbe337ef0a04a1 (patch)
treed6a36bfacebc736498fb67d6da5fae85922850c2
parent3ec2601ec7db1bd325553dc1298f9c9cb17a9195 (diff)
downloadscintilla-mirror-10021c40317d0b445e60aa9582bbe337ef0a04a1.tar.gz
Allow properties to differentiate between different case file names on
GTK+ so that .C can be treated as c++ and .c as C.
-rw-r--r--include/PropSet.h4
-rw-r--r--src/PropSet.cxx13
2 files changed, 15 insertions, 2 deletions
diff --git a/include/PropSet.h b/include/PropSet.h
index ef1faffba..e38de7dc4 100644
--- a/include/PropSet.h
+++ b/include/PropSet.h
@@ -29,6 +29,7 @@ protected:
Property *props[hashRoots];
Property *enumnext;
int enumhash;
+ static bool caseSensitiveFilenames;
static unsigned int HashString(const char *s, size_t len) {
unsigned int ret = 0;
while (len--) {
@@ -58,6 +59,9 @@ public:
char *ToString(); // Caller must delete[] the return value
bool GetFirst(char **key, char **val);
bool GetNext(char **key, char **val);
+ static void SetCaseSensitiveFilenames(bool caseSensitiveFilenames_) {
+ caseSensitiveFilenames = caseSensitiveFilenames_;
+ }
private:
// copy-value semantics not implemented
diff --git a/src/PropSet.cxx b/src/PropSet.cxx
index 287934980..b4011a04c 100644
--- a/src/PropSet.cxx
+++ b/src/PropSet.cxx
@@ -329,6 +329,8 @@ char *SContainer::StringAllocate(const char *s, lenpos_t len) {
// End SString functions
+bool PropSet::caseSensitiveFilenames = false;
+
PropSet::PropSet() {
superPS = 0;
for (int root = 0; root < hashRoots; root++)
@@ -536,16 +538,23 @@ bool isprefix(const char *target, const char *prefix) {
return true;
}
-static bool IsSuffixCaseInsensitive(const char *target, const char *suffix) {
+static bool IsSuffix(const char *target, const char *suffix, bool caseSensitive) {
size_t lentarget = strlen(target);
size_t lensuffix = strlen(suffix);
if (lensuffix > lentarget)
return false;
+ if (caseSensitive) {
+ for (int i = static_cast<int>(lensuffix) - 1; i >= 0; i--) {
+ if (target[i + lentarget - lensuffix] != suffix[i])
+ return false;
+ }
+ } else {
for (int i = static_cast<int>(lensuffix) - 1; i >= 0; i--) {
if (MakeUpperCase(target[i + lentarget - lensuffix]) !=
MakeUpperCase(suffix[i]))
return false;
}
+ }
return true;
}
@@ -577,7 +586,7 @@ SString PropSet::GetWild(const char *keybase, const char *filename) {
char delchr = *del;
*del = '\0';
if (*keyfile == '*') {
- if (IsSuffixCaseInsensitive(filename, keyfile + 1)) {
+ if (IsSuffix(filename, keyfile + 1, caseSensitiveFilenames)) {
*del = delchr;
delete []keyptr;
return p->val;