From 934a4502901903091641b02df2931616fc4804e3 Mon Sep 17 00:00:00 2001 From: meep-eep Date: Sat, 4 Dec 2004 18:51:09 +0000 Subject: [PATCH] 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 --- sc2/src/sc2code/libs/file.h | 6 ++++++ sc2/src/sc2code/libs/file/dirs.c | 4 ++-- sc2/src/sc2code/libs/uio/stdio/stdio.c | 2 +- sc2/src/sc2code/libs/uio/stdio/stdio.h | 6 ++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/sc2/src/sc2code/libs/file.h b/sc2/src/sc2code/libs/file.h index 96fc2a2a7..98441395b 100644 --- a/sc2/src/sc2code/libs/file.h +++ b/sc2/src/sc2code/libs/file.h @@ -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 */ diff --git a/sc2/src/sc2code/libs/file/dirs.c b/sc2/src/sc2code/libs/file/dirs.c index 982268ce0..4533dea04 100644 --- a/sc2/src/sc2code/libs/file/dirs.c +++ b/sc2/src/sc2code/libs/file/dirs.c @@ -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 diff --git a/sc2/src/sc2code/libs/uio/stdio/stdio.c b/sc2/src/sc2code/libs/uio/stdio/stdio.c index 5e7e01bfc..eafb93080 100644 --- a/sc2/src/sc2code/libs/uio/stdio/stdio.c +++ b/sc2/src/sc2code/libs/uio/stdio/stdio.c @@ -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] = ':'; diff --git a/sc2/src/sc2code/libs/uio/stdio/stdio.h b/sc2/src/sc2code/libs/uio/stdio/stdio.h index a5a16735b..3efba576a 100644 --- a/sc2/src/sc2code/libs/uio/stdio/stdio.h +++ b/sc2/src/sc2code/libs/uio/stdio/stdio.h @@ -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