MSVC friendly fixes [3]

This commit is contained in:
Alexander S. Aganichev 2002-09-24 14:58:44 +00:00
parent 499128809a
commit f243a59fea
3 changed files with 52 additions and 9 deletions

View File

@ -58,6 +58,8 @@
#define __WIN32__ _WIN32 #define __WIN32__ _WIN32
#elif defined(__NT__) #elif defined(__NT__)
#define __WIN32__ __NT__ #define __WIN32__ __NT__
#elif defined(WIN32)
#define __WIN32__ WIN32
#endif #endif
#endif #endif
@ -79,10 +81,11 @@
#endif #endif
#endif #endif
#ifndef __GNUC__ #ifdef _MSC_VER
#define __attribute__(A) #define __attribute__(A)
#define __inline__ static #define __inline__ __inline
#define __extension__ #define __extension__
#define __MSVCRT__
#endif #endif
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -43,20 +43,18 @@
#include <ctype.h> #include <ctype.h>
#if defined(__EMX__) #if defined(__EMX__)
#include <sys/nls.h> #include <sys/nls.h>
#define tolower(a) _nls_tolower((unsigned char)(a)) __inline__ int tolower(int a) { return _nls_tolower((unsigned char)(a)); }
#define toupper(a) _nls_toupper((unsigned char)(a)) __inline__ int toupper(int a) { return _nls_toupper((unsigned char)(a)); }
#elif defined(__WIN32__) #elif defined(__WIN32__)
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern char tl[256], tu[256]; extern char tl[256], tu[256];
__inline__ int _nls_tolower(int c) { return tl[c]; } __inline__ int tolower(int c) { return tl[c]; }
__inline__ int _nls_toupper(int c) { return tu[c]; } __inline__ int toupper(int c) { return tu[c]; }
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
#define tolower(a) _nls_tolower((unsigned char)(a))
#define toupper(a) _nls_toupper((unsigned char)(a))
#endif #endif

View File

@ -27,7 +27,11 @@
#include <gdirposx.h> #include <gdirposx.h>
#include <gstrall.h> #include <gstrall.h>
#include <gwildmat.h> #include <gwildmat.h>
#ifndef _MSC_VER
#include <dirent.h> #include <dirent.h>
#else
#include <io.h>
#endif
#ifndef __HAVE_DRIVES__ #ifndef __HAVE_DRIVES__
#include <pwd.h> #include <pwd.h>
#endif #endif
@ -72,6 +76,7 @@ gposixdir::~gposixdir()
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#ifndef _MSC_VER
void gposixdir::cd(const char *name, bool relative) void gposixdir::cd(const char *name, bool relative)
{ {
std::string ndirname; std::string ndirname;
@ -102,7 +107,44 @@ void gposixdir::cd(const char *name, bool relative)
rewind(); 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
// ------------------------------------------------------------------ // ------------------------------------------------------------------