mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 03:06:29 +00:00
huge cleanup and conversion of most string handling (especially paths) to unicode
please note: format strings must be %hs for char* arguments and %ls for wchar_t* This was SVN commit r7161.
This commit is contained in:
+1
-50
@@ -26,56 +26,7 @@
|
||||
#include "precompiled.h"
|
||||
|
||||
|
||||
int match_wildcard(const char* s, const char* w)
|
||||
{
|
||||
if(!w)
|
||||
return 1;
|
||||
|
||||
// saved position in both strings, used to expand '*':
|
||||
// s2 is advanced until match.
|
||||
// initially 0 - we abort on mismatch before the first '*'.
|
||||
const char* s2 = 0;
|
||||
const char* w2 = 0;
|
||||
|
||||
while(*s)
|
||||
{
|
||||
const int wc = *w;
|
||||
if(wc == '*')
|
||||
{
|
||||
// wildcard string ended with * => match.
|
||||
if(*++w == '\0')
|
||||
return 1;
|
||||
|
||||
w2 = w;
|
||||
s2 = s+1;
|
||||
}
|
||||
// match one character
|
||||
else if(toupper(wc) == toupper(*s) || wc == '?')
|
||||
{
|
||||
w++;
|
||||
s++;
|
||||
}
|
||||
// mismatched character
|
||||
else
|
||||
{
|
||||
// no '*' found yet => mismatch.
|
||||
if(!s2)
|
||||
return 0;
|
||||
|
||||
// resume at previous position+1
|
||||
w = w2;
|
||||
s = s2++;
|
||||
}
|
||||
}
|
||||
|
||||
// strip trailing * in wildcard string
|
||||
while(*w == '*')
|
||||
w++;
|
||||
|
||||
return (*w == '\0');
|
||||
}
|
||||
|
||||
int match_wildcardw(const wchar_t* s, const wchar_t* w)
|
||||
int match_wildcard(const wchar_t* s, const wchar_t* w)
|
||||
{
|
||||
if(!w)
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user