mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-04 06:00:23 +00:00
Merge pull request #440 from a740g/main
Fix case-insensitive pattern matching on Windows and _FILES behavior
This commit is contained in:
commit
5dad21acef
|
@ -499,7 +499,11 @@ static inline bool FS_IsPatternMatching(const char *fileSpec, const char *fileNa
|
||||||
case '*': // handle wildcard '*' character
|
case '*': // handle wildcard '*' character
|
||||||
any = spec;
|
any = spec;
|
||||||
spec++;
|
spec++;
|
||||||
while (*name && *name != *spec)
|
#ifdef QB64_WINDOWS
|
||||||
|
while (*name && std::toupper(*spec) != std::toupper(*name))
|
||||||
|
#else
|
||||||
|
while (*name && *spec != *name)
|
||||||
|
#endif
|
||||||
name++;
|
name++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -510,7 +514,12 @@ static inline bool FS_IsPatternMatching(const char *fileSpec, const char *fileNa
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: // compare non-wildcard characters
|
default: // compare non-wildcard characters
|
||||||
if (*spec != *name) {
|
#ifdef QB64_WINDOWS
|
||||||
|
if (std::toupper(*spec) != std::toupper(*name))
|
||||||
|
#else
|
||||||
|
if (*spec != *name)
|
||||||
|
#endif
|
||||||
|
{
|
||||||
if (any && *name)
|
if (any && *name)
|
||||||
spec = any;
|
spec = any;
|
||||||
else
|
else
|
||||||
|
@ -625,6 +634,9 @@ qbs *func__files(qbs *qbsFileSpec, int32_t passed) {
|
||||||
if (passed) {
|
if (passed) {
|
||||||
std::string fileSpec(reinterpret_cast<char *>(qbsFileSpec->chr), qbsFileSpec->len);
|
std::string fileSpec(reinterpret_cast<char *>(qbsFileSpec->chr), qbsFileSpec->len);
|
||||||
|
|
||||||
|
if (fileSpec.empty())
|
||||||
|
fileSpec = "*.*";
|
||||||
|
|
||||||
if (FS_DirectoryExists(filepath_fix_directory(fileSpec))) {
|
if (FS_DirectoryExists(filepath_fix_directory(fileSpec))) {
|
||||||
directory = fileSpec;
|
directory = fileSpec;
|
||||||
} else {
|
} else {
|
||||||
|
@ -634,13 +646,6 @@ qbs *func__files(qbs *qbsFileSpec, int32_t passed) {
|
||||||
}
|
}
|
||||||
|
|
||||||
entry = FS_GetDirectoryEntryName(fileSpec.c_str());
|
entry = FS_GetDirectoryEntryName(fileSpec.c_str());
|
||||||
|
|
||||||
if (FS_IsStringEmpty(entry)) {
|
|
||||||
// This is per MS BASIC PDS 7.1 and VBDOS 1.0 behavior
|
|
||||||
qbsFinal = qbs_new(0, 1);
|
|
||||||
error(QB_ERROR_FILE_NOT_FOUND);
|
|
||||||
return qbsFinal;
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// Check if we've been called the first time without a filespec
|
// Check if we've been called the first time without a filespec
|
||||||
if (directory.empty()) {
|
if (directory.empty()) {
|
||||||
|
|
Loading…
Reference in a new issue