summaryrefslogtreecommitdiff
path: root/src/wildcard.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-12 15:59:57 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-05-12 15:59:57 +0000
commit03fe9de7ac49af62e95b6dd3341b2012c9a530cf (patch)
tree52022dfcc3dd5441f837d498a85502269f2b8b41 /src/wildcard.cpp
parent30044376c1ce94fcda65765d448e7cad6b8f3001 (diff)
Fix wildcard matching in win32, seems that incrementing an iterator dereferences it internally on win32, so iter++ when iter == container.end() drops an assert. YES, an assert. No fucking throw, making it a fucking pain to debug (no bt on assert, program exits)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9706 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/wildcard.cpp')
-rw-r--r--src/wildcard.cpp27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/wildcard.cpp b/src/wildcard.cpp
index 3a91e8350..2df7a5bec 100644
--- a/src/wildcard.cpp
+++ b/src/wildcard.cpp
@@ -49,17 +49,19 @@ CoreExport bool csmatch(const std::string &str, const std::string &mask)
while (string != str.end())
{
- if (*wild == '*')
+ if (wild != mask.end() && *wild == '*')
{
if (++wild == mask.end())
return 1;
mp = wild;
cp = string;
- cp++;
+
+ if (cp != str.end())
+ cp++;
}
else
- if ((*wild == *string) || (*wild == '?'))
+ if ((string != str.end() && wild != mask.end()) && ((*wild == *string) || (*wild == '?')))
{
wild++;
string++;
@@ -67,7 +69,10 @@ CoreExport bool csmatch(const std::string &str, const std::string &mask)
else
{
wild = mp;
- string = cp++;
+ if (cp == str.end())
+ cp = str.end();
+ else
+ string = cp++;
}
}
@@ -98,17 +103,20 @@ CoreExport bool match(const std::string &str, const std::string &mask)
while (string != str.end())
{
- if (*wild == '*')
+ if (wild != mask.end() && *wild == '*')
{
if (++wild == mask.end())
return 1;
mp = wild;
cp = string;
- cp++;
+
+ if (cp != str.end())
+ cp++;
+
}
else
- if ((lowermap[(unsigned char)*wild] == lowermap[(unsigned char)*string]) || (*wild == '?'))
+ if ((string != str.end() && wild != mask.end()) && ((lowermap[(unsigned char)*wild] == lowermap[(unsigned char)*string]) || (*wild == '?')))
{
wild++;
string++;
@@ -116,7 +124,10 @@ CoreExport bool match(const std::string &str, const std::string &mask)
else
{
wild = mp;
- string = cp++;
+ if (cp == str.end())
+ string = str.end();
+ else
+ string = cp++;
}
}