MSVC friendly fixes [2]
This commit is contained in:
parent
dbeb60a30e
commit
499128809a
@ -79,6 +79,11 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __GNUC__
|
||||
#define __attribute__(A)
|
||||
#define __inline__ static
|
||||
#define __extension__
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Check if type "char" is unsigned or signed
|
||||
|
@ -28,6 +28,11 @@
|
||||
#define __gctype_h
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#include <gcmpall.h>
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
|
@ -59,7 +59,7 @@
|
||||
#define GAUTO 3
|
||||
#define MAYBE 4
|
||||
|
||||
#define NUL '\x00' // Common ASCII control codes
|
||||
#define NUL ((char)'\x00') // Common ASCII control codes
|
||||
#define BEL '\x07'
|
||||
#define BS '\x08'
|
||||
#define HT '\x09'
|
||||
@ -118,8 +118,13 @@ typedef int (*StdCmpCP)(const void*, const void*);
|
||||
template <class T> inline bool in_range(T a, T b, T c) { return (a >= b) and (a <= c); }
|
||||
template <class T> inline T absolute(T a) { return a < 0 ? -a : a; }
|
||||
template <class T> inline int compare_two(T a, T b) { return a < b ? -1 : a > b ? 1 : 0; }
|
||||
#ifdef __GNUC__
|
||||
template <class T> inline T minimum_of_two(T a, T b) { return __extension__ (a <? b); }
|
||||
template <class T> inline T maximum_of_two(T a, T b) { return __extension__ (a >? b); }
|
||||
#else
|
||||
template <class T> inline T minimum_of_two(T a, T b) { return (a < b) ? a : b; }
|
||||
template <class T> inline T maximum_of_two(T a, T b) { return (a > b) ? a : b; }
|
||||
#endif
|
||||
template <class T> inline int zero_or_one(T e) { return e ? 1 : 0; }
|
||||
template <class T> inline bool make_bool(T a) { return a ? true : false; }
|
||||
|
||||
|
@ -78,7 +78,7 @@ public:
|
||||
|
||||
~gfile(); // Destructor (closes file)
|
||||
|
||||
operator bool() { return isopen(); }
|
||||
operator bool() { return isopen() ? true : false; }
|
||||
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
@ -38,6 +38,7 @@
|
||||
#include <unistd.h>
|
||||
#else
|
||||
#include <cstdlib>
|
||||
#include <direct.h>
|
||||
#endif
|
||||
#include <cerrno>
|
||||
#include <cstdio>
|
||||
@ -68,6 +69,17 @@
|
||||
#define S_STDRD S_IRUSR
|
||||
#endif
|
||||
|
||||
#ifndef S_ISDIR
|
||||
#define S_ISDIR(st_mode) ((st_mode)&_S_IFDIR)
|
||||
#endif
|
||||
|
||||
#ifndef S_ISREG
|
||||
#define S_ISREG(st_mode) ((st_mode)&_S_IFREG)
|
||||
#endif
|
||||
|
||||
#ifndef R_OK
|
||||
#define R_OK 0
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
@ -138,7 +150,7 @@ inline FILE* fsopen(const std::string& path, const char* type, int shflag) { ret
|
||||
int is_dir(const char* path);
|
||||
inline int is_dir(const std::string& path) { return is_dir(path.c_str()); }
|
||||
|
||||
inline bool fexist(const char* filename) { return *filename ? ((access(filename, 0) == 0) and not is_dir(filename)) : false; }
|
||||
inline bool fexist(const char* filename) { return *filename ? ((access(filename, R_OK) == 0) and not is_dir(filename)) : false; }
|
||||
inline bool fexist(const std::string& filename) { return fexist(filename.c_str()); }
|
||||
|
||||
dword gfixstattime(time_t st_time);
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include <gtimall.h>
|
||||
#include <gstrall.h>
|
||||
#include <gfilutil.h>
|
||||
#if defined(__MINGW32__)
|
||||
#if defined(__MINGW32__) || defined(_MSC_VER)
|
||||
#include <sys/utime.h>
|
||||
#else
|
||||
#include <utime.h>
|
||||
@ -360,11 +360,10 @@ void WipeFile(const char* file, int options) {
|
||||
uint n;
|
||||
byte buf[512];
|
||||
|
||||
switch(options) {
|
||||
default:
|
||||
for(n=0; n<512; n++)
|
||||
buf[n] = (byte)(rand() % 256);
|
||||
}
|
||||
(void)options;
|
||||
|
||||
for(n=0; n<512; n++)
|
||||
buf[n] = (byte)(rand() % 256);
|
||||
|
||||
int fh = sopen(file, O_RDWR|O_BINARY, SH_DENYRW, S_STDRW);
|
||||
if(fh != -1) {
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <cstddef>
|
||||
#include <regex.h>
|
||||
#include <gregex.h>
|
||||
#include <gmemdbg.h>
|
||||
|
||||
@ -52,8 +51,8 @@ gregex::~gregex() {
|
||||
void gregex::reset() {
|
||||
|
||||
if(preg) {
|
||||
regfree((regex_t*)preg);
|
||||
throw_delete((regex_t*)preg);
|
||||
regfree(preg);
|
||||
throw_delete(preg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +71,7 @@ bool gregex::compile(const char* pattern, int cflags) {
|
||||
throw_new(preg);
|
||||
}
|
||||
|
||||
return (bool)regcomp((regex_t*)preg, pattern, cflgs);
|
||||
return regcomp(preg, pattern, cflgs) ? true : false;
|
||||
}
|
||||
|
||||
|
||||
@ -84,7 +83,7 @@ bool gregex::match(const char* str, int eflags) {
|
||||
if(eflags & notbol) eflgs |= REG_NOTBOL;
|
||||
if(eflags & noteol) eflgs |= REG_NOTEOL;
|
||||
|
||||
return not regexec((regex_t*)preg, str, 0, NULL, eflgs);
|
||||
return not regexec(preg, str, 0, NULL, eflgs);
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,6 +31,7 @@
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#include <gdefs.h>
|
||||
#include <regex.h>
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
@ -39,7 +40,7 @@ class gregex {
|
||||
|
||||
protected:
|
||||
|
||||
void* preg;
|
||||
regex_t* preg;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -57,19 +57,19 @@ extern mail_ctype mail_ctype_global;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
inline bool is_mail_char(uint c) { return mail_ctype_global.table[c] & mail_ctype::mail_char; }
|
||||
inline bool is_mail_alpha(uint c) { return mail_ctype_global.table[c] & mail_ctype::mail_alpha; }
|
||||
inline bool is_mail_ctl(uint c) { return mail_ctype_global.table[c] & mail_ctype::mail_ctl; }
|
||||
inline bool is_mail_char(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_char) ? true : false; }
|
||||
inline bool is_mail_alpha(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_alpha) ? true : false; }
|
||||
inline bool is_mail_ctl(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_ctl) ? true : false; }
|
||||
inline bool is_mail_cr(uint c) { return c == CR; }
|
||||
inline bool is_mail_lf(uint c) { return c == LF; }
|
||||
inline bool is_mail_space(uint c) { return c == ' '; }
|
||||
inline bool is_mail_htab(uint c) { return c == HT; }
|
||||
inline bool is_mail_crlf(uint c) { return is_mail_cr(c) or is_mail_lf(c); }
|
||||
inline bool is_mail_lwsp(uint c) { return mail_ctype_global.table[c] & mail_ctype::mail_lwsp; }
|
||||
inline bool is_mail_special(uint c) { return mail_ctype_global.table[c] & mail_ctype::mail_special; }
|
||||
inline bool is_mail_delimiters(uint c) { return mail_ctype_global.table[c] & mail_ctype::mail_delimiters; }
|
||||
inline bool is_mime_tspecial(uint c) { return mail_ctype_global.table[c] & mail_ctype::mime_tspecial; }
|
||||
inline bool is_mime_especial(uint c) { return mail_ctype_global.table[c] & mail_ctype::mime_especial; }
|
||||
inline bool is_mail_lwsp(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_lwsp) ? true : false; }
|
||||
inline bool is_mail_special(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_special) ? true : false; }
|
||||
inline bool is_mail_delimiters(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mail_delimiters) ? true : false; }
|
||||
inline bool is_mime_tspecial(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mime_tspecial) ? true : false; }
|
||||
inline bool is_mime_especial(uint c) { return (mail_ctype_global.table[c] & mail_ctype::mime_especial) ? true : false; }
|
||||
inline bool is_mail_atom_delimiters(uint c) { return is_mail_delimiters(c) or is_mail_ctl(c); }
|
||||
inline bool is_mime_ct_token_valid(uint c) { return not (is_mail_lwsp(c) or is_mail_ctl(c) or is_mime_tspecial(c)); }
|
||||
|
||||
|
@ -52,6 +52,13 @@
|
||||
typedef long Clock;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#if defined(GOLD_CANPACK)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// DOS "findfirst" timestamp
|
||||
|
||||
@ -65,7 +72,7 @@ struct gfiletime {
|
||||
|
||||
const char* c_str(char* buf);
|
||||
dword number() { return *(dword*)this; }
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
typedef gfiletime FFTime;
|
||||
|
||||
@ -83,11 +90,18 @@ struct gopustime {
|
||||
|
||||
const char* c_str(char* buf);
|
||||
dword number() { return *(dword*)this; }
|
||||
} __attribute__((packed));
|
||||
};
|
||||
|
||||
typedef gopustime FTime;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#if defined(GOLD_CANPACK)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// Externs for strftimei()
|
||||
|
||||
@ -129,6 +143,10 @@ inline void usleep(long duration) { DosSleep(duration); }
|
||||
inline void usleep(long duration) { Sleep(duration); }
|
||||
#endif
|
||||
|
||||
#ifndef CLK_TCK
|
||||
#define CLK_TCK CLOCKS_PER_SEC
|
||||
#endif
|
||||
|
||||
#ifdef __UNIX__
|
||||
inline Clock gclock() { struct tms z; return Clock(times(&z)*10/sysconf(_SC_CLK_TCK)); }
|
||||
#else
|
||||
|
@ -53,9 +53,9 @@ Grp::~Grp() {
|
||||
std::multimap<int, grp_stock>::iterator i;
|
||||
for(currgrp = container.begin(); currgrp != container.end(); currgrp++)
|
||||
for(i = currgrp->second.begin(); i != currgrp->second.end(); i++) {
|
||||
if(i->second.type == TYPE_OBJECT)
|
||||
if(i->second.type == grp_stock::TYPE_OBJECT)
|
||||
throw_free(i->second.data.object_item);
|
||||
else if(i->second.type == TYPE_STRING)
|
||||
else if(i->second.type == grp_stock::TYPE_STRING)
|
||||
throw_delete(i->second.data.string_item);
|
||||
}
|
||||
}
|
||||
|
@ -116,18 +116,18 @@ class Grp {
|
||||
|
||||
private:
|
||||
|
||||
enum {
|
||||
TYPE_BOOL,
|
||||
TYPE_CHAR,
|
||||
TYPE_INT,
|
||||
TYPE_STRING,
|
||||
TYPE_OBJECT
|
||||
};
|
||||
|
||||
class grp_stock {
|
||||
|
||||
public:
|
||||
|
||||
enum {
|
||||
TYPE_BOOL,
|
||||
TYPE_CHAR,
|
||||
TYPE_INT,
|
||||
TYPE_STRING,
|
||||
TYPE_OBJECT
|
||||
};
|
||||
|
||||
int type;
|
||||
union {
|
||||
bool bool_item;
|
||||
|
@ -82,7 +82,7 @@ int GMTsk::os2() {
|
||||
#if defined(__OS2__)
|
||||
detected = GMTSK_OS2;
|
||||
name = "OS/2";
|
||||
#elif !defined(__GNUC__)
|
||||
#elif !defined(__GNUC__) && !defined(_MSC_VER)
|
||||
if(_osmajor >= 10) {
|
||||
detected = GMTSK_OS2;
|
||||
name = "OS/2";
|
||||
|
@ -115,13 +115,7 @@ char tl[256] = {
|
||||
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
|
||||
};
|
||||
|
||||
WCHAR oem2unicode[256] = {
|
||||
// MB_USEGLYPHCHARS should do the same :-)
|
||||
// 0x0000, 0x263a, 0x263b, 0x2665, 0x2666, 0x2663, 0x2660, 0x2219,
|
||||
// 0x25d8, 0x25cb, 0x25d9, 0x2642, 0x2640, 0x266a, 0x266b, 0x263c,
|
||||
// 0x25ba, 0x25c4, 0x2195, 0x203c, 0x00b6, 0x00a7, 0x25a0, 0x21a8,
|
||||
// 0x2191, 0x2193, 0x2192, 0x2190, 0x221f, 0x2194, 0x25b2, 0x25bc
|
||||
};
|
||||
WCHAR oem2unicode[256];
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
// Device-independent video functions
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstdarg>
|
||||
|
@ -26,6 +26,9 @@
|
||||
|
||||
#include <gstrall.h>
|
||||
#include <gwildmat.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@ -1004,12 +1004,12 @@ bool gwinput::field::delete_word(bool left) {
|
||||
|
||||
if(entry != gwinput::entry_noedit) {
|
||||
|
||||
bool state = isspace(buf[buf_pos-((int) left)]);
|
||||
bool state = isspace(buf[buf_pos-((int) left)]) ? true : false;
|
||||
|
||||
while(left ? buf_pos > 0 : buf_pos < buf_end_pos) {
|
||||
left ? delete_left() : delete_char();
|
||||
|
||||
if(isspace(buf[buf_pos-((int) left)]) != state)
|
||||
if((isspace(buf[buf_pos-((int) left)]) ? true : false) != state)
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
@ -429,7 +429,7 @@ typedef struct
|
||||
unfortunately clutters up the declarations a bit, but I think it's
|
||||
worth it. */
|
||||
|
||||
#if __STDC__
|
||||
#if 1 /*__STDC__*/
|
||||
|
||||
# define _RE_ARGS(args) args
|
||||
|
||||
|
Reference in New Issue
Block a user