Fix DJGPP build
This commit is contained in:
parent
717827510e
commit
b322344dae
@ -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
|
||||
|
@ -25,8 +25,8 @@
|
||||
// File I/O class.
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
#ifndef __gfilbase_h
|
||||
#define __gfilbase_h
|
||||
#ifndef __gfile_h
|
||||
#define __gfile_h
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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; }
|
||||
};
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -193,7 +193,7 @@ init_syntax_once ()
|
||||
for (c = 0; c < 256; c++)
|
||||
re_syntax_table[c] = isxalnum(c) ? Sword : 0;
|
||||
|
||||
re_syntax_table['_'] = Sword;
|
||||
re_syntax_table[int('_')] = Sword;
|
||||
|
||||
done = 1;
|
||||
}
|
||||
|
@ -157,8 +157,16 @@ struct HudsToIdx {
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
typedef word HudsLast[HUDS_MAXBOARD] __attribute__((packed));
|
||||
typedef word GoldLast[GOLD_MAXBOARD] __attribute__((packed));
|
||||
typedef word HudsLast[HUDS_MAXBOARD]
|
||||
#ifndef __DJGPP__
|
||||
__attribute__((packed))
|
||||
#endif
|
||||
;
|
||||
typedef word GoldLast[GOLD_MAXBOARD]
|
||||
#ifndef __DJGPP__
|
||||
__attribute__((packed))
|
||||
#endif
|
||||
;
|
||||
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
@ -3684,7 +3684,9 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag
|
||||
int i = 0;
|
||||
|
||||
// checking lines with bad syntax
|
||||
#if DEBUG
|
||||
int basefieldnum = 0;
|
||||
#endif
|
||||
|
||||
// split affix header line into pieces
|
||||
|
||||
|
@ -308,10 +308,10 @@ hentry * Hunspell::spellsharps(char * base, char * pos, int n, int repnum, char
|
||||
hentry * h;
|
||||
*pos = 'Ã';
|
||||
*(pos + 1) = 'Ÿ';
|
||||
if (h = spellsharps(base, pos + 2, n + 1, repnum + 1, tmp)) return h;
|
||||
if ((h = spellsharps(base, pos + 2, n + 1, repnum + 1, tmp))) return h;
|
||||
*pos = 's';
|
||||
*(pos + 1) = 's';
|
||||
if (h = spellsharps(base, pos + 2, n + 1, repnum, tmp)) return h;
|
||||
if ((h = spellsharps(base, pos + 2, n + 1, repnum, tmp))) return h;
|
||||
} else if (repnum > 0) {
|
||||
if (utf8) return check(base);
|
||||
return check(sharps_u8_l1(tmp, base));
|
||||
@ -347,7 +347,7 @@ int Hunspell::spell(const char * word)
|
||||
char wspace[MAXWORDUTF8LEN + 4];
|
||||
w_char unicw[MAXWORDLEN + 1];
|
||||
int nc = strlen(word);
|
||||
int wl2;
|
||||
int wl2=0;
|
||||
if (utf8) {
|
||||
if (nc >= MAXWORDUTF8LEN) return 0;
|
||||
} else {
|
||||
@ -458,7 +458,7 @@ int Hunspell::spell(const char * word)
|
||||
char * s;
|
||||
char r;
|
||||
for (int i = 0; i < pAMgr->get_numbreak(); i++) {
|
||||
if (s=(char *) strstr(cw, wordbreak[i])) {
|
||||
if ((s=(char *) strstr(cw, wordbreak[i]))) {
|
||||
r = *s;
|
||||
*s = '\0';
|
||||
// examine 2 sides of the break point
|
||||
@ -664,7 +664,7 @@ int Hunspell::suggest(char*** slst, const char * word)
|
||||
// aNew -> "a New" (instead of "a new")
|
||||
for (int j = prevns; j < ns; j++) {
|
||||
char * space;
|
||||
if (space = strchr((*slst)[j],' ')) {
|
||||
if ( (space = strchr((*slst)[j],' ')) ) {
|
||||
int slen = strlen(space + 1);
|
||||
// different case after space (need capitalisation)
|
||||
if ((slen < wl) && strcmp(cw + wl - slen, space + 1)) {
|
||||
@ -696,12 +696,12 @@ int Hunspell::suggest(char*** slst, const char * word)
|
||||
if (pAMgr && pAMgr->get_checksharps()) {
|
||||
char * pos;
|
||||
if (utf8) {
|
||||
while (pos = strstr((*slst)[j], "ß")) {
|
||||
while ( (pos = strstr((*slst)[j], "ß")) ) {
|
||||
*pos = 'S';
|
||||
*(pos+1) = 'S';
|
||||
}
|
||||
} else {
|
||||
while (pos = strchr((*slst)[j], 'ß')) {
|
||||
while ( (pos = strchr((*slst)[j], 'ß')) ) {
|
||||
(*slst)[j] = (char *) realloc((*slst)[j], strlen((*slst)[j]) + 2);
|
||||
mystrrep((*slst)[j], "ß", "SS");
|
||||
}
|
||||
@ -790,13 +790,13 @@ int Hunspell::suggest(char*** slst, const char * word)
|
||||
strcpy(s, (*slst)[j]);
|
||||
len = strlen(s);
|
||||
}
|
||||
int wl = mkallsmall2(s, w, len);
|
||||
mkallsmall2(s, w, len);
|
||||
free((*slst)[j]);
|
||||
if (spell(s)) {
|
||||
(*slst)[l] = mystrdup(s);
|
||||
l++;
|
||||
} else {
|
||||
int wl = mkinitcap2(s, w, len);
|
||||
mkinitcap2(s, w, len);
|
||||
if (spell(s)) {
|
||||
(*slst)[l] = mystrdup(s);
|
||||
l++;
|
||||
|
@ -79,7 +79,7 @@ int SuggestMgr::suggest(char*** slst, const char * w, int nsug)
|
||||
int nocompoundtwowords = 0;
|
||||
char ** wlst;
|
||||
w_char word_utf[MAXSWL];
|
||||
int wl;
|
||||
int wl=0;
|
||||
|
||||
char w2[MAXWORDUTF8LEN];
|
||||
const char * word = w;
|
||||
|
@ -72,6 +72,9 @@
|
||||
#define SMB_VERSION 0x0121 /* SMB format version */
|
||||
/* High byte major, low byte minor */
|
||||
|
||||
#define U_MODE 777 /* permitions for the new files (real: U_MODE XOR UMASK) */
|
||||
/* This is required for sopen(,,,) */
|
||||
|
||||
#ifndef __gtimall_h
|
||||
time32_t gtime(time32_t *timep)
|
||||
{
|
||||
@ -109,7 +112,7 @@ int SMBCALL smb_open(smb_t* smb)
|
||||
smb->shd_fp=smb->sdt_fp=smb->sid_fp=NULL;
|
||||
smb->last_error[0]=0;
|
||||
sprintf(str,"%s.shd",smb->file);
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO))==-1) {
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO,U_MODE))==-1) {
|
||||
sprintf(smb->last_error,"%d opening %s",errno,str);
|
||||
return(2);
|
||||
}
|
||||
@ -156,7 +159,7 @@ int SMBCALL smb_open(smb_t* smb)
|
||||
setvbuf(smb->shd_fp,smb->shd_buf,_IOFBF,SHD_BLOCK_LEN);
|
||||
|
||||
sprintf(str,"%s.sdt",smb->file);
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO))==-1) {
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO,U_MODE))==-1) {
|
||||
sprintf(smb->last_error,"%d opening %s",errno,str);
|
||||
smb_close(smb);
|
||||
return(1);
|
||||
@ -172,7 +175,7 @@ int SMBCALL smb_open(smb_t* smb)
|
||||
setvbuf(smb->sdt_fp,NULL,_IOFBF,2*1024);
|
||||
|
||||
sprintf(str,"%s.sid",smb->file);
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO))==-1) {
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYNO,U_MODE))==-1) {
|
||||
sprintf(smb->last_error,"%d opening %s",errno,str);
|
||||
smb_close(smb);
|
||||
return(3);
|
||||
@ -219,7 +222,7 @@ int SMBCALL smb_open_da(smb_t* smb)
|
||||
|
||||
sprintf(str,"%s.sda",smb->file);
|
||||
while(1) {
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW))!=-1)
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW,U_MODE))!=-1)
|
||||
break;
|
||||
if(errno!=EACCES && errno!=EAGAIN) {
|
||||
sprintf(smb->last_error,"%d opening %s",errno,str);
|
||||
@ -264,7 +267,7 @@ int SMBCALL smb_open_ha(smb_t* smb)
|
||||
|
||||
sprintf(str,"%s.sha",smb->file);
|
||||
while(1) {
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW))!=-1)
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW,U_MODE))!=-1)
|
||||
break;
|
||||
if(errno!=EACCES && errno!=EAGAIN) {
|
||||
sprintf(smb->last_error,"%d opening %s",errno,str);
|
||||
@ -1010,7 +1013,7 @@ int SMBCALL smb_addcrc(smb_t* smb, uint32_t crc)
|
||||
|
||||
sprintf(str,"%s.sch",smb->file);
|
||||
while(1) {
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW))!=-1)
|
||||
if((file=sopen(str,O_RDWR|O_CREAT|O_BINARY,SH_DENYRW,U_MODE))!=-1)
|
||||
break;
|
||||
if(errno!=EACCES && errno!=EAGAIN) {
|
||||
sprintf(smb->last_error,"%d opening %s", errno, str);
|
||||
|
Reference in New Issue
Block a user