Skip to content

Commit

Permalink
Iteration 5 of wildcard matching. Fixes broken matching for certain c…
Browse files Browse the repository at this point in the history
…onditions reported by MacGyver.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10302 e03df62e-2008-0410-955e-edbf42e46eb7
  • Loading branch information
peavey committed Aug 26, 2008
1 parent 4b86612 commit f11b1b9
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/wildcard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@
* ZNC's, thought to be faster than ours, but it turned out that we could do better ;-)
* Iteration 4)
* Largely from work by peavey and myself (w00t) :)
*
* Iteration 5)
* peavey: Fix glob scan similar to 1.1, but scan ahead on glob in inner loop to retain speedup
* this fixes another case which we forgot to test. Add early return for obvious fail condition.
*/
static bool match_internal(const unsigned char *string, const unsigned char *wild, unsigned const char *map)
{
const unsigned char* s;
const unsigned char *s, *m; m = wild;

if (*string && !*wild)
return false;

if (!map)
map = lowermap;
Expand All @@ -44,6 +49,8 @@ static bool match_internal(const unsigned char *string, const unsigned char *wil
while (*wild && *wild == '*')
wild++;

m = wild;

if (!*wild)
return true;
else if (*wild != '?')
Expand All @@ -57,19 +64,17 @@ static bool match_internal(const unsigned char *string, const unsigned char *wil
if (*(wild+1) || !*(s+1))
{
wild++;
break;
}
break;
}
s++;
}
}
}
else if ( (map[*wild] != map[*string]) && (*wild != '?') )
{
return false;
}
else
else if ( (map[*wild] == map[*string]) || (*wild == '?') )
wild++;
else
wild = m;

string++;
}
Expand All @@ -94,7 +99,6 @@ CoreExport bool InspIRCd::Match(const char *str, const char *mask, unsigned con
return match_internal((const unsigned char *)str, (const unsigned char *)mask, map);
}


CoreExport bool InspIRCd::MatchCIDR(const std::string &str, const std::string &mask, unsigned const char *map)
{
if (irc::sockets::MatchCIDR(str, mask, true))
Expand Down

0 comments on commit f11b1b9

Please sign in to comment.