From f243a59fea4ce5c2e4b2d29772da714ddf76c426 Mon Sep 17 00:00:00 2001 From: "Alexander S. Aganichev" Date: Tue, 24 Sep 2002 14:58:44 +0000 Subject: [PATCH] MSVC friendly fixes [3] --- goldlib/gall/gcmpall.h | 7 +++++-- goldlib/gall/gctype.h | 10 ++++----- goldlib/gall/gdirposx.cpp | 44 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 52 insertions(+), 9 deletions(-) diff --git a/goldlib/gall/gcmpall.h b/goldlib/gall/gcmpall.h index 0b43e21..17ae25e 100644 --- a/goldlib/gall/gcmpall.h +++ b/goldlib/gall/gcmpall.h @@ -58,6 +58,8 @@ #define __WIN32__ _WIN32 #elif defined(__NT__) #define __WIN32__ __NT__ + #elif defined(WIN32) + #define __WIN32__ WIN32 #endif #endif @@ -79,10 +81,11 @@ #endif #endif -#ifndef __GNUC__ +#ifdef _MSC_VER #define __attribute__(A) -#define __inline__ static +#define __inline__ __inline #define __extension__ +#define __MSVCRT__ #endif // ------------------------------------------------------------------ diff --git a/goldlib/gall/gctype.h b/goldlib/gall/gctype.h index 49dc9fc..829db11 100644 --- a/goldlib/gall/gctype.h +++ b/goldlib/gall/gctype.h @@ -43,20 +43,18 @@ #include #if defined(__EMX__) #include -#define tolower(a) _nls_tolower((unsigned char)(a)) -#define toupper(a) _nls_toupper((unsigned char)(a)) +__inline__ int tolower(int a) { return _nls_tolower((unsigned char)(a)); } +__inline__ int toupper(int a) { return _nls_toupper((unsigned char)(a)); } #elif defined(__WIN32__) #ifdef __cplusplus extern "C" { #endif extern char tl[256], tu[256]; -__inline__ int _nls_tolower(int c) { return tl[c]; } -__inline__ int _nls_toupper(int c) { return tu[c]; } +__inline__ int tolower(int c) { return tl[c]; } +__inline__ int toupper(int c) { return tu[c]; } #ifdef __cplusplus } #endif -#define tolower(a) _nls_tolower((unsigned char)(a)) -#define toupper(a) _nls_toupper((unsigned char)(a)) #endif diff --git a/goldlib/gall/gdirposx.cpp b/goldlib/gall/gdirposx.cpp index 2a1c117..43475af 100644 --- a/goldlib/gall/gdirposx.cpp +++ b/goldlib/gall/gdirposx.cpp @@ -27,7 +27,11 @@ #include #include #include +#ifndef _MSC_VER #include +#else +#include +#endif #ifndef __HAVE_DRIVES__ #include #endif @@ -72,6 +76,7 @@ gposixdir::~gposixdir() // ------------------------------------------------------------------ +#ifndef _MSC_VER void gposixdir::cd(const char *name, bool relative) { std::string ndirname; @@ -102,7 +107,44 @@ void gposixdir::cd(const char *name, bool relative) rewind(); } } - +#else +void gposixdir::cd(const char *name, bool relative) +{ + std::string ndirname; + if(!*name) + name = "."; + if(relative) { + dirname += "/"; + dirname += name; + } else + dirname = name; + ok = maketruepath(dirname); + entries.clear(); + ndirname = dirname; + ndirname += "/*"; + struct _finddata_t de; + long d = _findfirst(ndirname.c_str(), &de); + if(d == -1) { + if(is_dir(dirname)) + ok = true; + else + ok = false; + } + else { + do { + ndirname = de.name; +#ifdef __HAVE_DRIVES__ + if((ndirname != ".") && !((ndirname == "..") && streql(dirname.c_str()+1, ":/"))) +#else + if((ndirname != ".") && !((ndirname == "..") && (dirname == "/"))) +#endif + entries.push_back(ndirname); + } while(_findnext(d, &de) == 0); + _findclose(d); + rewind(); + } +} +#endif // ------------------------------------------------------------------