summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorleo2003-07-30 16:33:40 +0000
committerleo2003-07-30 16:33:40 +0000
commit30a0a3fa7fa13af938d41b9a4118dfbcc7273315 (patch)
tree19d313e9cfcdb90c826d10ee8be101c8ef7d42c8 /common
parentfd2913d40bcd329236025a84c0509d897b8ee2e0 (diff)
Added new string comparison function.
git-svn-id: http://svn.leocad.org/trunk@341 c7d43263-9d01-0410-8a33-9dba5d9f93d6
Diffstat (limited to 'common')
-rw-r--r--common/str.cpp20
-rw-r--r--common/str.h1
2 files changed, 21 insertions, 0 deletions
diff --git a/common/str.cpp b/common/str.cpp
index cb82ada..304cd88 100644
--- a/common/str.cpp
+++ b/common/str.cpp
@@ -194,6 +194,26 @@ int String::CompareNoCase (const char *string) const
return (((int)*ch) - ((int)*string));
}
+int String::CompareNoCase(const char *string, int count) const
+{
+ char c1, c2, *ch = m_pData;
+
+ while (*ch && *string && count)
+ {
+ c1 = tolower (*ch);
+ c2 = tolower (*string);
+
+ if (c1 != c2)
+ return (c1 - c2);
+
+ ch++;
+ string++;
+ count--;
+ }
+
+ return (((int)*ch) - ((int)*string));
+}
+
void String::MakeUpper ()
{
for (char *cp = m_pData; *cp; ++cp)
diff --git a/common/str.h b/common/str.h
index cc6d474..23e6f1a 100644
--- a/common/str.h
+++ b/common/str.h
@@ -43,6 +43,7 @@ class String
int Compare (const char *string) const
{ return strcmp (m_pData, string); }
int CompareNoCase (const char *string) const;
+ int CompareNoCase (const char *string, int count) const;
// simple sub-string extraction
String& Mid (int first, int count) const;