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. Basic definitions and types.
------------------------------------------------------------------ ------------------------------------------------------------------
*/ */
#ifndef __goldall_h #ifndef __gdefs_h
#define __goldall_h #define __gdefs_h
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
#include <gcmpall.h> #include <gcmpall.h>
#ifdef __WIN32__
#include <tchar.h> #include <tchar.h>
#define G_HAS_VSNPRINTF
#else
typedef char TCHAR;
#endif
#ifdef __cplusplus #ifdef __cplusplus
# include <cstddef> # include <cstddef>
#endif #endif

View File

@ -25,8 +25,8 @@
// File I/O class. // File I/O class.
// ------------------------------------------------------------------ // ------------------------------------------------------------------
#ifndef __gfilbase_h #ifndef __gfile_h
#define __gfilbase_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) #if defined(_taccess_s)
inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (_taccess_s(filename, R_OK)) && !is_dir(filename)) : false; } inline bool fexist(const TCHAR *filename) { return *filename ? (0 == (_taccess_s(filename, R_OK)) && !is_dir(filename)) : false; }
#else #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 #endif
inline bool fexist(const std::string& filename) { return fexist(filename.c_str()); } 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 char* MapPath(char* map, bool reverse = false); // gcarea.cpp
inline char* ReMapPath(char* map) { return MapPath(map, true); } 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 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 record, long recordsize) { return lseek(fh, record*recordsize, SEEK_SET); }
int gchdir(const char* dir); 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 char* strbtrim(char* st) { return strtrim(strltrim(st)); }
inline bool streql (const TCHAR *str1, const TCHAR *str2) { return (0 == _tcscmp (str1, str2)); } 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 == _tcsicmp (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 == _tcsncmp (str1, str2, n)); } 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 == _tcsnicmp(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 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); } 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 *First(TCHAR *buf) { token = _tcstok_s(buf, separator, &next_token); return token; }
TCHAR *Next() { token = _tcstok_s(NULL, separator, &next_token); return token; } TCHAR *Next() { token = _tcstok_s(NULL, separator, &next_token); return token; }
#else #else
TCHAR *First(TCHAR *buf) { token = _tcstok(buf, separator); return token; } TCHAR *First(TCHAR *buf) { token = strtok(buf, separator); return token; }
TCHAR *Next() { token = _tcstok(NULL, separator); return token; } TCHAR *Next() { token = strtok(NULL, separator); return token; }
#endif #endif
TCHAR *Token() { return token; } 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 *next_token;
TCHAR *token = _tcstok_s(tmp, delim, &next_token); TCHAR *token = _tcstok_s(tmp, delim, &next_token);
#else #else
TCHAR *token = _tcstok(tmp, delim); TCHAR *token = strtok(tmp, delim);
#endif #endif
while (NULL != token) while (NULL != token)
@ -61,7 +61,7 @@ inline void tokenize(gstrarray &array, const TCHAR* str, const TCHAR *delim = NU
#if defined(_tcstok_s) #if defined(_tcstok_s)
token = _tcstok_s(NULL, delim, &next_token); token = _tcstok_s(NULL, delim, &next_token);
#else #else
token = _tcstok(NULL, delim); token = strtok(NULL, delim);
#endif #endif
} }

View File

@ -573,7 +573,7 @@ TCHAR *strxcpy(TCHAR *d, const TCHAR *s, size_t n)
#else #else
if (n) if (n)
{ {
_tcsncpy(d, s, n-1); strncpy(d, s, n-1);
d[n-1] = NUL; d[n-1] = NUL;
} }
else else
@ -636,7 +636,11 @@ int gsprintf(TCHAR* buffer, size_t sizeOfBuffer, const TCHAR* __file, int __line
if (ret < 0) if (ret < 0)
#else #else
buffer[sizeOfBuffer-1] = 0; 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]) if ((ret < 0) || buffer[sizeOfBuffer-1])
#endif #endif
{ {

View File

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

View File

@ -193,7 +193,7 @@ init_syntax_once ()
for (c = 0; c < 256; c++) for (c = 0; c < 256; c++)
re_syntax_table[c] = isxalnum(c) ? Sword : 0; re_syntax_table[c] = isxalnum(c) ? Sword : 0;
re_syntax_table['_'] = Sword; re_syntax_table[int('_')] = Sword;
done = 1; done = 1;
} }

View File

@ -157,8 +157,16 @@ struct HudsToIdx {
// ------------------------------------------------------------------ // ------------------------------------------------------------------
typedef word HudsLast[HUDS_MAXBOARD] __attribute__((packed)); typedef word HudsLast[HUDS_MAXBOARD]
typedef word GoldLast[GOLD_MAXBOARD] __attribute__((packed)); #ifndef __DJGPP__
__attribute__((packed))
#endif
;
typedef word GoldLast[GOLD_MAXBOARD]
#ifndef __DJGPP__
__attribute__((packed))
#endif
;
// ------------------------------------------------------------------ // ------------------------------------------------------------------

View File

@ -3684,7 +3684,9 @@ int AffixMgr::parse_affix(char * line, const char at, FILE * af, char * dupflag
int i = 0; int i = 0;
// checking lines with bad syntax // checking lines with bad syntax
#if DEBUG
int basefieldnum = 0; int basefieldnum = 0;
#endif
// split affix header line into pieces // split affix header line into pieces

View File

@ -308,10 +308,10 @@ hentry * Hunspell::spellsharps(char * base, char * pos, int n, int repnum, char
hentry * h; hentry * h;
*pos = 'Ã'; *pos = 'Ã';
*(pos + 1) = 'Ÿ'; *(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 = 's';
*(pos + 1) = '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) { } else if (repnum > 0) {
if (utf8) return check(base); if (utf8) return check(base);
return check(sharps_u8_l1(tmp, base)); return check(sharps_u8_l1(tmp, base));
@ -347,7 +347,7 @@ int Hunspell::spell(const char * word)
char wspace[MAXWORDUTF8LEN + 4]; char wspace[MAXWORDUTF8LEN + 4];
w_char unicw[MAXWORDLEN + 1]; w_char unicw[MAXWORDLEN + 1];
int nc = strlen(word); int nc = strlen(word);
int wl2; int wl2=0;
if (utf8) { if (utf8) {
if (nc >= MAXWORDUTF8LEN) return 0; if (nc >= MAXWORDUTF8LEN) return 0;
} else { } else {
@ -458,7 +458,7 @@ int Hunspell::spell(const char * word)
char * s; char * s;
char r; char r;
for (int i = 0; i < pAMgr->get_numbreak(); i++) { 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; r = *s;
*s = '\0'; *s = '\0';
// examine 2 sides of the break point // 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") // aNew -> "a New" (instead of "a new")
for (int j = prevns; j < ns; j++) { for (int j = prevns; j < ns; j++) {
char * space; char * space;
if (space = strchr((*slst)[j],' ')) { if ( (space = strchr((*slst)[j],' ')) ) {
int slen = strlen(space + 1); int slen = strlen(space + 1);
// different case after space (need capitalisation) // different case after space (need capitalisation)
if ((slen < wl) && strcmp(cw + wl - slen, space + 1)) { 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()) { if (pAMgr && pAMgr->get_checksharps()) {
char * pos; char * pos;
if (utf8) { if (utf8) {
while (pos = strstr((*slst)[j], "ß")) { while ( (pos = strstr((*slst)[j], "ß")) ) {
*pos = 'S'; *pos = 'S';
*(pos+1) = 'S'; *(pos+1) = 'S';
} }
} else { } else {
while (pos = strchr((*slst)[j], 'ß')) { while ( (pos = strchr((*slst)[j], 'ß')) ) {
(*slst)[j] = (char *) realloc((*slst)[j], strlen((*slst)[j]) + 2); (*slst)[j] = (char *) realloc((*slst)[j], strlen((*slst)[j]) + 2);
mystrrep((*slst)[j], "ß", "SS"); mystrrep((*slst)[j], "ß", "SS");
} }
@ -790,13 +790,13 @@ int Hunspell::suggest(char*** slst, const char * word)
strcpy(s, (*slst)[j]); strcpy(s, (*slst)[j]);
len = strlen(s); len = strlen(s);
} }
int wl = mkallsmall2(s, w, len); mkallsmall2(s, w, len);
free((*slst)[j]); free((*slst)[j]);
if (spell(s)) { if (spell(s)) {
(*slst)[l] = mystrdup(s); (*slst)[l] = mystrdup(s);
l++; l++;
} else { } else {
int wl = mkinitcap2(s, w, len); mkinitcap2(s, w, len);
if (spell(s)) { if (spell(s)) {
(*slst)[l] = mystrdup(s); (*slst)[l] = mystrdup(s);
l++; l++;

View File

@ -79,7 +79,7 @@ int SuggestMgr::suggest(char*** slst, const char * w, int nsug)
int nocompoundtwowords = 0; int nocompoundtwowords = 0;
char ** wlst; char ** wlst;
w_char word_utf[MAXSWL]; w_char word_utf[MAXSWL];
int wl; int wl=0;
char w2[MAXWORDUTF8LEN]; char w2[MAXWORDUTF8LEN];
const char * word = w; const char * word = w;

View File

@ -72,6 +72,9 @@
#define SMB_VERSION 0x0121 /* SMB format version */ #define SMB_VERSION 0x0121 /* SMB format version */
/* High byte major, low byte minor */ /* 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 #ifndef __gtimall_h
time32_t gtime(time32_t *timep) 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->shd_fp=smb->sdt_fp=smb->sid_fp=NULL;
smb->last_error[0]=0; smb->last_error[0]=0;
sprintf(str,"%s.shd",smb->file); 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); sprintf(smb->last_error,"%d opening %s",errno,str);
return(2); return(2);
} }
@ -156,7 +159,7 @@ int SMBCALL smb_open(smb_t* smb)
setvbuf(smb->shd_fp,smb->shd_buf,_IOFBF,SHD_BLOCK_LEN); setvbuf(smb->shd_fp,smb->shd_buf,_IOFBF,SHD_BLOCK_LEN);
sprintf(str,"%s.sdt",smb->file); 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); sprintf(smb->last_error,"%d opening %s",errno,str);
smb_close(smb); smb_close(smb);
return(1); return(1);
@ -172,7 +175,7 @@ int SMBCALL smb_open(smb_t* smb)
setvbuf(smb->sdt_fp,NULL,_IOFBF,2*1024); setvbuf(smb->sdt_fp,NULL,_IOFBF,2*1024);
sprintf(str,"%s.sid",smb->file); 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); sprintf(smb->last_error,"%d opening %s",errno,str);
smb_close(smb); smb_close(smb);
return(3); return(3);
@ -219,7 +222,7 @@ int SMBCALL smb_open_da(smb_t* smb)
sprintf(str,"%s.sda",smb->file); sprintf(str,"%s.sda",smb->file);
while(1) { 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; break;
if(errno!=EACCES && errno!=EAGAIN) { if(errno!=EACCES && errno!=EAGAIN) {
sprintf(smb->last_error,"%d opening %s",errno,str); 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); sprintf(str,"%s.sha",smb->file);
while(1) { 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; break;
if(errno!=EACCES && errno!=EAGAIN) { if(errno!=EACCES && errno!=EAGAIN) {
sprintf(smb->last_error,"%d opening %s",errno,str); 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); sprintf(str,"%s.sch",smb->file);
while(1) { 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; break;
if(errno!=EACCES && errno!=EAGAIN) { if(errno!=EACCES && errno!=EAGAIN) {
sprintf(smb->last_error,"%d opening %s", errno, str); sprintf(smb->last_error,"%d opening %s", errno, str);