X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fwildcard.cpp;h=b230ab147daf8245a1e62ad4858e56f6c21d4aa6;hb=4ca5fb1994541181f940a692bce47eb11d681e7a;hp=2df7a5bec10e769b3e3445e8ebc18132fbfaee0c;hpb=03fe9de7ac49af62e95b6dd3341b2012c9a530cf;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/wildcard.cpp b/src/wildcard.cpp index 2df7a5bec..b230ab147 100644 --- a/src/wildcard.cpp +++ b/src/wildcard.cpp @@ -11,7 +11,7 @@ * --------------------------------------------------- */ -/* $Core: libIRCDwildcard */ +/* $Core */ #include "inspircd.h" #include "hashcomp.h" @@ -41,18 +41,21 @@ CoreExport bool csmatch(const std::string &str, const std::string &mask) while ((string != str.end()) && (wild != mask.end()) && (*wild != '*')) { if ((*wild != *string) && (*wild != '?')) - return 0; + return false; wild++; string++; } + if (wild == mask.end() && string != str.end()) + return false; + while (string != str.end()) { if (wild != mask.end() && *wild == '*') { if (++wild == mask.end()) - return 1; + return true; mp = wild; cp = string; @@ -95,18 +98,25 @@ CoreExport bool match(const std::string &str, const std::string &mask) while ((string != str.end()) && (wild != mask.end()) && (*wild != '*')) { if ((lowermap[(unsigned char)*wild] != lowermap[(unsigned char)*string]) && (*wild != '?')) - return 0; + return false; wild++; string++; + //printf("Iterate first loop\n"); } + if (wild == mask.end() && string != str.end()) + return false; + while (string != str.end()) { + //printf("outer\n %c", *string); if (wild != mask.end() && *wild == '*') { + + //printf("inner %c\n", *wild); if (++wild == mask.end()) - return 1; + return true; mp = wild; cp = string; @@ -118,8 +128,11 @@ CoreExport bool match(const std::string &str, const std::string &mask) else if ((string != str.end() && wild != mask.end()) && ((lowermap[(unsigned char)*wild] == lowermap[(unsigned char)*string]) || (*wild == '?'))) { - wild++; - string++; + if (wild != mask.end()) + wild++; + + if (string != str.end()) + string++; } else {