mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Added code for WildCmp()
git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@255 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
36
String.cpp
36
String.cpp
@@ -10,7 +10,41 @@ int CString::StrCmp(const CString& s) const {
|
||||
}
|
||||
|
||||
bool CString::WildCmp(const CString& sWild, const CString& sString) {
|
||||
return true; // @todo
|
||||
// Written by Jack Handy - jakkhandy@hotmail.com
|
||||
const char *wild = sWild.c_str(), *CString = sString.c_str();
|
||||
const char *cp = NULL, *mp = NULL;
|
||||
|
||||
while ((*CString) && (*wild != '*')) {
|
||||
if ((*wild != *CString) && (*wild != '?')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
wild++;
|
||||
CString++;
|
||||
}
|
||||
|
||||
while (*CString) {
|
||||
if (*wild == '*') {
|
||||
if (!*++wild) {
|
||||
return true;
|
||||
}
|
||||
|
||||
mp = wild;
|
||||
cp = CString+1;
|
||||
} else if ((*wild == *CString) || (*wild == '?')) {
|
||||
wild++;
|
||||
CString++;
|
||||
} else {
|
||||
wild = mp;
|
||||
CString = cp++;
|
||||
}
|
||||
}
|
||||
|
||||
while (*wild == '*') {
|
||||
wild++;
|
||||
}
|
||||
|
||||
return (*wild == 0);
|
||||
}
|
||||
|
||||
bool CString::WildCmp(const CString& sWild) const {
|
||||
|
||||
Reference in New Issue
Block a user