diff --git a/golded3/gealst.cpp b/golded3/gealst.cpp index 4a4613f..8612b81 100644 --- a/golded3/gealst.cpp +++ b/golded3/gealst.cpp @@ -24,10 +24,6 @@ // Arealist functions. // ------------------------------------------------------------------ -#if defined(__MINGW32__) || defined(_MSC_VER) -#include -#endif - #if defined(_MSC_VER) /* C4786: 'identifier' : identifier was truncated to 'number' characters in the debug information @@ -37,6 +33,10 @@ #include #include +#if defined(__USE_ALLOCA__) +#include +#endif + // ------------------------------------------------------------------ @@ -481,7 +481,7 @@ void SelMaskPick::close() { void SelMaskPick::print_line(uint idx, uint pos, bool isbar) { -#if defined(__WIN32__) +#if defined(__USE_ALLOCA__) char *buf = (char*)alloca(DESC_LEN+3); #else __extension__ char buf[DESC_LEN+3]; diff --git a/golded3/geedit2.cpp b/golded3/geedit2.cpp index 300ac58..0dd01dd 100644 --- a/golded3/geedit2.cpp +++ b/golded3/geedit2.cpp @@ -24,15 +24,15 @@ // The Internal Editor (IE), part 2. // ------------------------------------------------------------------ -#if defined(__MINGW32__) || defined(_MSC_VER) -#include -#endif - #include #include #include #include +#if defined(__USE_ALLOCA__) +#include +#endif + // ------------------------------------------------------------------ // Constructor @@ -1090,7 +1090,7 @@ void IEclass::editimport(Line* __line, char* __filename, bool imptxt) { else { int tabsz = CFG->disptabsize ? CFG->disptabsize : 1; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__USE_ALLOCA__) char *spaces = (char*)alloca(tabsz+1); #else __extension__ char spaces[tabsz+1]; diff --git a/golded3/geedit3.cpp b/golded3/geedit3.cpp index 25c127c..ee8fb0a 100644 --- a/golded3/geedit3.cpp +++ b/golded3/geedit3.cpp @@ -24,14 +24,15 @@ // OS/2 clipboard to/from edit paste buffer. // ------------------------------------------------------------------ -#if defined(__MINGW32__) || defined(_MSC_VER) -#include -#endif - #include #include #include +#if defined(__USE_ALLOCA__) +#include +#endif + + void IEclass::Clip2Buf() { gclipbrd clipbrd; @@ -40,7 +41,7 @@ void IEclass::Clip2Buf() { return; int tabsz = CFG->disptabsize ? CFG->disptabsize : 1; -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(__USE_ALLOCA__) char *spaces = (char*)alloca(tabsz+1); #else __extension__ char spaces[tabsz+1]; diff --git a/golded3/gefile.cpp b/golded3/gefile.cpp index 6779797..8dee245 100644 --- a/golded3/gefile.cpp +++ b/golded3/gefile.cpp @@ -24,15 +24,15 @@ // File handling. // ------------------------------------------------------------------ -#if defined(__MINGW32__) || defined(_MSC_VER) -#include -#endif - #include #include #include #include +#if defined(__USE_ALLOCA__) +#include +#endif + // ------------------------------------------------------------------ @@ -777,7 +777,7 @@ void FileRequest(GMsg* msg) { else ptr1 = ptr2; ptr2 = strskip_txt(ptr1); -#if defined(_MSC_VER) +#if defined(__USE_ALLOCA__) char *tmpbuf = (char*)alloca(ptr2-ptr1+1); #else __extension__ char tmpbuf[ptr2-ptr1+1]; @@ -819,7 +819,7 @@ void FileRequest(GMsg* msg) { if(txtptr[16] == '/' and txtptr[19] == '/' and txtptr[24] == '(' /*)*/) { ptr1 = strskip_wht(txtptr); ptr2 = strskip_txt(ptr1); -#if defined(_MSC_VER) +#if defined(__USE_ALLOCA__) char *tmpbuf = (char*)alloca(ptr2-ptr1+1); #else __extension__ char tmpbuf[ptr2-ptr1+1]; @@ -955,7 +955,7 @@ void FileRequest(GMsg* msg) { msg->attr.frq1(); ptr = freqfile[n]+1; // 01234567890123456 ptr2 = strskip_txt(ptr); -#if defined(_MSC_VER) +#if defined(__USE_ALLOCA__) char *tmpbuf = (char*)alloca(ptr2-ptr+1); #else __extension__ char tmpbuf[ptr2-ptr+1]; @@ -978,7 +978,7 @@ void FileRequest(GMsg* msg) { msg->attr.frq1(); ptr = freqfile[crsr]+1; // 01234567890123456 ptr2 = strskip_txt(ptr); -#if defined(_MSC_VER) +#if defined(__USE_ALLOCA__) char *tmpbuf = (char*)alloca(ptr2-ptr+1); #else __extension__ char tmpbuf[ptr2-ptr+1]; diff --git a/golded3/gehdre.cpp b/golded3/gehdre.cpp index 58365e4..ce62aae 100644 --- a/golded3/gehdre.cpp +++ b/golded3/gehdre.cpp @@ -24,13 +24,13 @@ // Header edit. // ------------------------------------------------------------------ -#if defined(__MINGW32__) || defined(_MSC_VER) -#include -#endif - #include #include +#if defined(__USE_ALLOCA__) +#include +#endif + // ------------------------------------------------------------------ @@ -322,7 +322,7 @@ bool GMsgHeaderEdit::validate() { bool res = set_to_address(msg, &toname, &toaddr, &fromaddr, &subj, 0, LNG->SelectDestNode, lookup); vcurshow(); -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__USE_ALLOCA__) size_t bot2size = EDIT->HdrNodeLen()+1; char *bot2 = (char*)alloca(bot2size); MakeAttrStr(bot2, bot2size, &msg->attr); diff --git a/golded3/geline.cpp b/golded3/geline.cpp index 9234e96..709aa3e 100644 --- a/golded3/geline.cpp +++ b/golded3/geline.cpp @@ -24,16 +24,17 @@ // Conversion of a raw message to a linked list of lines. // ------------------------------------------------------------------ -#if defined(_MSC_VER) || defined(__MINGW32__) - #include -#endif - #include #include #include #include #include +#if defined(__USE_ALLOCA__) + #include +#endif + + // ------------------------------------------------------------------ #ifdef __UNIX__ @@ -1391,7 +1392,7 @@ int ScanLine(GMsg* msg, Line* line, const char* ptr, int getvalue, int mask) { ptr++; char endchar = *ptr; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__USE_ALLOCA__) char *kludge = (char*)alloca(ptr-kludge1+1); #else __extension__ char kludge[ptr-kludge1+1]; diff --git a/golded3/gemlst.cpp b/golded3/gemlst.cpp index 9953991..8c6e2fd 100644 --- a/golded3/gemlst.cpp +++ b/golded3/gemlst.cpp @@ -24,15 +24,16 @@ // Message lister. // ------------------------------------------------------------------ -#if defined(_MSC_VER) || defined(__MINGW32__) - #include -#endif - #include #include #include #include +#if defined(__USE_ALLOCA__) + #include +#endif + + // ------------------------------------------------------------------ extern GMsg* reader_msg; @@ -841,7 +842,7 @@ void GThreadlist::print_line(uint idx, uint pos, bool isbar) { char buf[256]; ulong maxlev = (100*window.width()+h_offset+1)/2; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__USE_ALLOCA__) char *buf2 = (char*)alloca(maxlev*2+2); #else __extension__ char buf2[maxlev*2+2]; diff --git a/golded3/gemsgs.cpp b/golded3/gemsgs.cpp index 5b9a1f5..82e5d4b 100644 --- a/golded3/gemsgs.cpp +++ b/golded3/gemsgs.cpp @@ -24,14 +24,15 @@ // Misc. msg handling. // ------------------------------------------------------------------ -#if defined(_MSC_VER) || defined(__MINGW32__) - #include -#endif - #include #include #include +#if defined(__USE_ALLOCA__) + #include +#endif + + // ------------------------------------------------------------------ static bool tokenxchg(char*& dst, char* tok, const char* src, int len = 0, int cnt = 0, ...) { @@ -488,7 +489,7 @@ void LoadText(GMsg* msg, const char* textfile) { buf = (char*)throw_malloc(PBUFSIZE); int tabsz = CFG->disptabsize ? CFG->disptabsize : 1; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__USE_ALLOCA__) char *spaces = (char*)alloca(tabsz+1); #else __extension__ char spaces[tabsz+1]; diff --git a/golded3/getpls.cpp b/golded3/getpls.cpp index 9cb5158..4e57334 100644 --- a/golded3/getpls.cpp +++ b/golded3/getpls.cpp @@ -24,10 +24,6 @@ // Template handling. // ------------------------------------------------------------------ -#if defined(__MINGW32__) || defined(_MSC_VER) -#include -#endif - #if defined(_MSC_VER) /* C4786: 'identifier' : identifier was truncated to 'number' characters in the debug information @@ -37,6 +33,10 @@ #include #include +#if defined(__USE_ALLOCA__) +#include +#endif + // ------------------------------------------------------------------ @@ -87,7 +87,7 @@ int TemplateToText(int mode, GMsg* msg, GMsg* oldmsg, const char* tpl, int origa uint ctrlinfo; char textfile[GMAXPATH]; char indexfile[GMAXPATH]; -#if defined(__MINGW32__) || defined(_MSC_VER) +#if defined(__USE_ALLOCA__) size_t sizeofbuf = CFG->quotemargin + 256; char *buf = (char*)alloca(sizeofbuf); #else diff --git a/golded3/geview.cpp b/golded3/geview.cpp index 190bfc5..4ded54c 100644 --- a/golded3/geview.cpp +++ b/golded3/geview.cpp @@ -24,12 +24,13 @@ // Message viewer class implementation. // ------------------------------------------------------------------ -#if defined(_MSC_VER) || defined(__MINGW32__) +#include +#include + +#if defined(__USE_ALLOCA__) #include #endif -#include -#include // ------------------------------------------------------------------ @@ -111,7 +112,7 @@ void GMsgHeaderView::Paint() { else *buf1 = NUL; -#if defined(_MSC_VER) || defined(__MINGW32__) +#if defined(__USE_ALLOCA__) char *top = (char*)alloca(width+1); #else __extension__ char top[width+1]; diff --git a/goldlib/gall/gcmpall.h b/goldlib/gall/gcmpall.h index 2d8b787..e5fa928 100644 --- a/goldlib/gall/gcmpall.h +++ b/goldlib/gall/gcmpall.h @@ -110,6 +110,9 @@ #define __HAVE_DRIVES__ #endif +#if defined(_MSC_VER) || defined(__MINGW32__) +#define __USE_ALLOCA__ +#endif /* --------------------------------------------------------------- */ /* System-wide constants */ diff --git a/goldlib/gall/gwildmat.cpp b/goldlib/gall/gwildmat.cpp index 022d6f0..e94b1c6 100644 --- a/goldlib/gall/gwildmat.cpp +++ b/goldlib/gall/gwildmat.cpp @@ -26,8 +26,9 @@ #include #include -#ifdef _MSC_VER -#include + +#if defined(__USE_ALLOCA__) + #include #endif @@ -45,9 +46,9 @@ ** ** Special thanks to Lars Mathiesen for the ABORT code. ** This can greatly speed up failing wildcard patterns. For example: -** pattern: -*-*-*-*-*-*-12-*-*-*-m-*-*-* -** text 1: -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1 -** text 2: -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1 +** pattern: -*-*-*-*-*-*-12-*-*-*-m-*-*-* +** text 1: -adobe-courier-bold-o-normal--12-120-75-75-m-70-iso8859-1 +** text 2: -adobe-courier-bold-o-normal--12-120-75-75-X-70-iso8859-1 ** Text 1 matches with 51 calls, while text 2 fails with 54 calls. Without ** the ABORT code, it takes 22310 calls to fail. Ugh. The following ** explanation is from Lars: @@ -167,7 +168,7 @@ bool strwild(const char* str, const char* wild) { if(wild[1] == NUL) return true; else { -#ifdef _MSC_VER +#if defined(__USE_ALLOCA__) char *buf = (char *)alloca(strlen(wild)); #else __extension__ char buf[strlen(wild)];