summaryrefslogtreecommitdiff
path: root/src/wildcard.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-31 12:30:42 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-31 12:30:42 +0000
commit11376014e3b8395c46366c7395b0daeddef8ceda (patch)
treefec4b589282277b7c7a4d85e4125ab43c6e0693d /src/wildcard.cpp
parentcfc2715066ba2228a510bb845691b1422e3338de (diff)
Remove match/wildcmp wrapper which just casts from const char* to char*, do the cast within wildcmp and rename wildcmp to match.
Remove other casts by casting directly to unsigned char* first time around git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4607 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/wildcard.cpp')
-rw-r--r--src/wildcard.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/wildcard.cpp b/src/wildcard.cpp
index 3b95b5f75..aa9f52102 100644
--- a/src/wildcard.cpp
+++ b/src/wildcard.cpp
@@ -34,12 +34,15 @@ extern char lowermap[255];
// (unattributed to any author) all over the 'net.
// For now, we'll just consider this public domain.
-int wildcmp(char *wild, char *string)
+bool match(const char *str, const char *mask)
{
- char *cp, *mp;
+ unsigned char *cp, *mp;
+ unsigned char* string = (unsigned char*)str;
+ unsigned char* wild = (unsigned char*)mask;
+
while ((*string) && (*wild != '*'))
{
- if ((lowermap[(unsigned)*wild] != lowermap[(unsigned)*string]) && (*wild != '?'))
+ if ((lowermap[*wild] != lowermap[*string]) && (*wild != '?'))
{
return 0;
}
@@ -59,7 +62,7 @@ int wildcmp(char *wild, char *string)
cp = string+1;
}
else
- if ((lowermap[(unsigned)*wild] == lowermap[(unsigned)*string]) || (*wild == '?'))
+ if ((lowermap[*wild] == lowermap[*string]) || (*wild == '?'))
{
wild++;
string++;
@@ -80,14 +83,3 @@ int wildcmp(char *wild, char *string)
return !*wild;
}
-// This wrapper function is required to convert both
-// strings to 'scandanavian lowercase' and make copies
-// of them to a safe location. It also ensures we don't
-// bite off more than we can chew with the length of
-// the string.
-
-bool match(const char* literal, const char* mask)
-{
- return wildcmp((char*)mask, (char*)literal);
-}
-