Browse Source

Fixed a parsing bug and minor optimization.

release/0.19
JustinAJ 10 years ago
parent
commit
906af1f162
  1. 24
      Jupiter/Functions.c

24
Jupiter/Functions.c

@ -235,12 +235,11 @@ bool strmatch(const char *f, const char *s)
{ {
f++; f++;
if (*f == 0) return true; if (*f == 0) return true;
while (*s != 0) while (*f != *s)
{ {
if (*f == *s) break; if (*s == 0) return false;
s++; s++;
} }
if (*s == 0) return false;
} }
else if (*f != '?' && *f != *s) return false; else if (*f != '?' && *f != *s) return false;
f++; f++;
@ -251,18 +250,19 @@ bool strmatch(const char *f, const char *s)
bool strmatchi(const char *f, const char *s) bool strmatchi(const char *f, const char *s)
{ {
int fUpper;
while (*f != 0) while (*f != 0)
{ {
if (*f == '*') if (*f == '*')
{ {
f++; f++;
if (*f == 0) return true; if (*f == 0) return true;
while (*s != 0) fUpper = toupper(*f);
while (fUpper != toupper(*s))
{ {
if (*f == *s) break; if (*s == 0) return false;
s++; s++;
} }
if (*s == 0) return false;
} }
else if (*f != '?' && toupper(*f) != toupper(*s)) return false; else if (*f != '?' && toupper(*f) != toupper(*s)) return false;
f++; f++;
@ -279,12 +279,11 @@ bool wstrmatch(const wchar_t *f, const wchar_t *s)
{ {
f++; f++;
if (*f == 0) return true; if (*f == 0) return true;
while (*s != 0) while (*f != *s)
{ {
if (*f == *s) break; if (*s == 0) return false;
s++; s++;
} }
if (*s == 0) return false;
} }
else if (*f != L'?' && *f != *s) return false; else if (*f != L'?' && *f != *s) return false;
f++; f++;
@ -295,18 +294,19 @@ bool wstrmatch(const wchar_t *f, const wchar_t *s)
bool wstrmatchi(const wchar_t *f, const wchar_t *s) bool wstrmatchi(const wchar_t *f, const wchar_t *s)
{ {
wint_t fUpper;
while (*f != 0) while (*f != 0)
{ {
if (*f == L'*') if (*f == L'*')
{ {
f++; f++;
if (*f == 0) return true; if (*f == 0) return true;
while (*s != 0) fUpper = towupper(*f);
while (fUpper != towupper(*s))
{ {
if (*f == *s) break; if (*s == 0) return false;
s++; s++;
} }
if (*s == 0) return false;
} }
else if (*f != L'?' && towupper(*f) != towupper(*s)) return false; else if (*f != L'?' && towupper(*f) != towupper(*s)) return false;
f++; f++;

Loading…
Cancel
Save