From 30a0a3fa7fa13af938d41b9a4118dfbcc7273315 Mon Sep 17 00:00:00 2001 From: leo Date: Wed, 30 Jul 2003 16:33:40 +0000 Subject: Added new string comparison function. git-svn-id: http://svn.leocad.org/trunk@341 c7d43263-9d01-0410-8a33-9dba5d9f93d6 --- common/str.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'common/str.cpp') 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) -- cgit v1.2.3