Do not use isalpha() for drive letters. That doesn't necessarilly work
for all locales. git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1426 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
@@ -64,6 +64,12 @@ int copyFile (uio_DirHandle *srcDir, const char *srcName,
|
||||
bool fileExists (const char *name);
|
||||
bool fileExists2(uio_DirHandle *dir, const char *fileName);
|
||||
|
||||
#ifdef WIN32
|
||||
static inline int isDriveLetter(int c)
|
||||
{
|
||||
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _FILE_H */
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ mkdirhier (const char *path)
|
||||
|
||||
#ifdef WIN32
|
||||
// driveletter + semicolon on Windows.
|
||||
if (isalpha(pathstart[0]) && pathstart[1] == ':')
|
||||
if (isDriveLetter(pathstart[0]) && pathstart[1] == ':')
|
||||
{
|
||||
*(ptr++) = *(pathstart++);
|
||||
*(ptr++) = *(pathstart++);
|
||||
@@ -439,7 +439,7 @@ expandPathAbsolute (char *dest, size_t destLen, const char *src, int what)
|
||||
{
|
||||
if (src[0] == '/' || ((what & EP_SLASHES) && src[0] == '\\')
|
||||
#ifdef WIN32
|
||||
|| (isalpha(src[0]) && (src[1] == ':'))
|
||||
|| (isDriveLetter(src[0]) && (src[1] == ':'))
|
||||
#endif
|
||||
) {
|
||||
// Path is already absolute; nothing to do
|
||||
|
||||
@@ -345,7 +345,7 @@ stdio_getPDirEntryHandle(const uio_PDirHandle *pDirHandle, const char *name) {
|
||||
#ifdef WIN32
|
||||
if (pDirHandle->extra->extra->upDir == NULL) {
|
||||
// Top dir. Contains only drive letters.
|
||||
if (!isalpha(name[0]) || name[1] != ':' || name[2] != '\0')
|
||||
if (!isDriveLetter(name[0]) || name[1] != ':' || name[2] != '\0')
|
||||
return NULL;
|
||||
driveName[0] = tolower(name[0]);
|
||||
driveName[1] = ':';
|
||||
|
||||
@@ -107,5 +107,11 @@ void stdio_EntriesIterator_delete(stdio_EntriesIterator *iterator);
|
||||
uio_PDirEntryHandle *stdio_getPDirEntryHandle(
|
||||
const uio_PDirHandle *pDirHandle, const char *name);
|
||||
|
||||
#ifdef WIN32
|
||||
static inline int isDriveLetter(int c)
|
||||
{
|
||||
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user