Fix DJGPP build

This commit is contained in:
Stas Degteff
2006-05-14 18:37:26 +00:00
parent 717827510e
commit b322344dae
13 changed files with 452 additions and 430 deletions

View File

@@ -27,13 +27,18 @@
Basic definitions and types.
------------------------------------------------------------------
*/
#ifndef __goldall_h
#define __goldall_h
#ifndef __gdefs_h
#define __gdefs_h
/* ------------------------------------------------------------------ */
#include <gcmpall.h>
#ifdef __WIN32__
#include <tchar.h>
#define G_HAS_VSNPRINTF
#else
typedef char TCHAR;
#endif
#ifdef __cplusplus
# include <cstddef>
#endif

View File

@@ -25,8 +25,8 @@
// File I/O class.
// ------------------------------------------------------------------
#ifndef __gfilbase_h
#define __gfilbase_h
#ifndef __gfile_h
#define __gfile_h
// ------------------------------------------------------------------

View File

@@ -155,7 +155,7 @@ inline bool is_dir(const std::string &path) { return is_dir(path.c_str()); }
#if defined(_taccess_s)
inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (_taccess_s(filename, R_OK)) && !is_dir(filename)) : false; }
#else
inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (_taccess(filename, R_OK)) && !is_dir(filename)) : false; }
inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (access(filename, R_OK)) && !is_dir(filename)) : false; }
#endif
inline bool fexist(const std::string& filename) { return fexist(filename.c_str()); }
@@ -197,8 +197,8 @@ int strschg_environ(std::string& s);
char* MapPath(char* map, bool reverse = false); // gcarea.cpp
inline char* ReMapPath(char* map) { return MapPath(map, true); }
inline long lseekset(int fh, long offset) { return _lseek(fh, offset, SEEK_SET); }
inline long lseekset(int fh, long record, long recordsize) { return _lseek(fh, record*recordsize, SEEK_SET); }
inline long lseekset(int fh, long offset) { return lseek(fh, offset, SEEK_SET); }
inline long lseekset(int fh, long record, long recordsize) { return lseek(fh, record*recordsize, SEEK_SET); }
int gchdir(const char* dir);

View File

@@ -105,10 +105,10 @@ char* strunrevname(char* unreversedname, const char* name);
inline char* strbtrim(char* st) { return strtrim(strltrim(st)); }
inline bool streql (const TCHAR *str1, const TCHAR *str2) { return (0 == _tcscmp (str1, str2)); }
inline bool strieql (const TCHAR *str1, const TCHAR *str2) { return (0 == _tcsicmp (str1, str2)); }
inline bool strneql (const TCHAR *str1, const TCHAR *str2, int n) { return (0 == _tcsncmp (str1, str2, n)); }
inline bool strnieql(const TCHAR *str1, const TCHAR *str2, int n) { return (0 == _tcsnicmp(str1, str2, n)); }
inline bool streql (const TCHAR *str1, const TCHAR *str2) { return (0 == strcmp (str1, str2)); }
inline bool strieql (const TCHAR *str1, const TCHAR *str2) { return (0 == stricmp (str1, str2)); }
inline bool strneql (const TCHAR *str1, const TCHAR *str2, int n) { return (0 == strncmp (str1, str2, n)); }
inline bool strnieql(const TCHAR *str1, const TCHAR *str2, int n) { return (0 == strnicmp(str1, str2, n)); }
inline const char* strskip_to(const char* p, char* s) { return p+strcspn(p, s); }
inline char* strskip_to(char* p, char* s) { return p+strcspn(p, s); }
@@ -163,8 +163,8 @@ public:
TCHAR *First(TCHAR *buf) { token = _tcstok_s(buf, separator, &next_token); return token; }
TCHAR *Next() { token = _tcstok_s(NULL, separator, &next_token); return token; }
#else
TCHAR *First(TCHAR *buf) { token = _tcstok(buf, separator); return token; }
TCHAR *Next() { token = _tcstok(NULL, separator); return token; }
TCHAR *First(TCHAR *buf) { token = strtok(buf, separator); return token; }
TCHAR *Next() { token = strtok(NULL, separator); return token; }
#endif
TCHAR *Token() { return token; }
};

View File

@@ -52,7 +52,7 @@ inline void tokenize(gstrarray &array, const TCHAR* str, const TCHAR *delim = NU
TCHAR *next_token;
TCHAR *token = _tcstok_s(tmp, delim, &next_token);
#else
TCHAR *token = _tcstok(tmp, delim);
TCHAR *token = strtok(tmp, delim);
#endif
while (NULL != token)
@@ -61,7 +61,7 @@ inline void tokenize(gstrarray &array, const TCHAR* str, const TCHAR *delim = NU
#if defined(_tcstok_s)
token = _tcstok_s(NULL, delim, &next_token);
#else
token = _tcstok(NULL, delim);
token = strtok(NULL, delim);
#endif
}

View File

@@ -573,7 +573,7 @@ TCHAR *strxcpy(TCHAR *d, const TCHAR *s, size_t n)
#else
if (n)
{
_tcsncpy(d, s, n-1);
strncpy(d, s, n-1);
d[n-1] = NUL;
}
else
@@ -636,7 +636,11 @@ int gsprintf(TCHAR* buffer, size_t sizeOfBuffer, const TCHAR* __file, int __line
if (ret < 0)
#else
buffer[sizeOfBuffer-1] = 0;
ret = _vsntprintf(buffer, sizeOfBuffer, format, argptr);
#if defined( G_HAS_VSNPRINTF )
ret = _vsnprintf(buffer, sizeOfBuffer, format, argptr);
#else
ret = vsprintf(buffer, format, argptr);
#endif
if ((ret < 0) || buffer[sizeOfBuffer-1])
#endif
{

View File

@@ -181,7 +181,7 @@ inline void gctime(TCHAR *buffer, size_t sizeInChars, const time32_t *timep)
_tctime_s(buffer, sizeInChars, &zero);
}
#else
const char *time = _tctime(&temp);
const char *time = ctime(&temp);
#if defined(__WIN32__)
if (NULL == time)
{