mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-18 15:11:51 +00:00
Fix wildmatch(), resolves errors matching things like "*.zip" with "duke3d.hrp.zip" for example.
git-svn-id: https://svn.eduke32.com/eduke32@4922 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
4c883f81b6
commit
b3358a90b2
2 changed files with 30 additions and 8 deletions
|
@ -685,7 +685,6 @@ char *Bstrtolower(char *str)
|
|||
|
||||
|
||||
//Brute-force case-insensitive, slash-insensitive, * and ? wildcard matcher
|
||||
//Given: string i and string j. string j can have wildcards
|
||||
//Returns: 1:matches, 0:doesn't match
|
||||
#ifndef WITHKPLIB
|
||||
extern char toupperlookup[256];
|
||||
|
@ -703,14 +702,26 @@ static int32_t wildmatch(const char *match, const char *wild)
|
|||
return 1;
|
||||
else if (*wild == '*')
|
||||
{
|
||||
while (*wild == '*') wild++;
|
||||
if (*wild == '\0') return 1;
|
||||
while (*match && toupperlookup[*match] != toupperlookup[*wild]) match++;
|
||||
do { wild++; } while (*wild == '*');
|
||||
do
|
||||
{
|
||||
if (*wild == '\0')
|
||||
return 1;
|
||||
while (*match && toupperlookup[*match] != toupperlookup[*wild]) match++;
|
||||
if (*match && *(match+1) && toupperlookup[*(match+1)] != toupperlookup[*(wild+1)])
|
||||
{
|
||||
match++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
if (toupperlookup[*match] == toupperlookup[*wild])
|
||||
continue;
|
||||
}
|
||||
return 0;
|
||||
} while (1);
|
||||
}
|
||||
while (1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2419,9 +2419,20 @@ int32_t wildmatch(const char *match, const char *wild)
|
|||
return 1;
|
||||
else if (*wild == '*')
|
||||
{
|
||||
while (*wild == '*') wild++;
|
||||
if (*wild == '\0') return 1;
|
||||
while (*match && toupperlookup[*match] != toupperlookup[*wild]) match++;
|
||||
do { wild++; } while (*wild == '*');
|
||||
do
|
||||
{
|
||||
if (*wild == '\0')
|
||||
return 1;
|
||||
while (*match && toupperlookup[*match] != toupperlookup[*wild]) match++;
|
||||
if (*match && *(match+1) && toupperlookup[*(match+1)] != toupperlookup[*(wild+1)])
|
||||
{
|
||||
match++;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
while (1);
|
||||
if (toupperlookup[*match] == toupperlookup[*wild])
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue