From 3f4a0c5be34be837210768501c13dbcff81e533c Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 3 Feb 1999 16:48:12 +0000 Subject: [PATCH] _MSC_VER => __VISUALC__ change git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1580 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/defs.h | 202 ++++---- include/wx/docview.h | 4 +- include/wx/filefn.h | 16 +- include/wx/ioswrap.h | 20 + include/wx/log.h | 12 +- include/wx/memory.h | 30 +- include/wx/msw/msvcrt.h | 17 +- include/wx/msw/ole/oleutils.h | 16 +- include/wx/object.h | 27 +- include/wx/string.h | 34 +- include/wx/utils.h | 11 +- include/wx/variant.h | 17 +- include/wx/wxchar.h | 18 +- include/wx/wxexpr.h | 9 +- include/wx/wxprec.h | 12 +- src/common/docmdi.cpp | 2 +- src/common/docview.cpp | 13 +- src/common/file.cpp | 72 ++- src/common/filefn.cpp | 836 +++++++++++++++++----------------- src/common/log.cpp | 2 +- src/common/memory.cpp | 231 +++++----- src/common/object.cpp | 17 +- src/common/odbc.cpp | 10 +- src/common/resourc2.cpp | 4 +- src/common/resource.cpp | 4 +- src/common/socket.cpp | 12 +- src/common/string.cpp | 48 +- src/common/time.cpp | 169 ++++--- src/common/utilscmn.cpp | 381 ++++++++-------- src/common/variant.cpp | 7 +- src/common/wxexpr.cpp | 9 +- src/generic/helpxlp.cpp | 24 +- src/msw/app.cpp | 12 +- src/msw/dibutils.cpp | 265 +++++------ src/msw/dummy.cpp | 14 +- src/msw/dummydll.cpp | 16 +- src/msw/ole/dataobj.cpp | 8 +- src/msw/ole/oleutils.cpp | 8 +- src/msw/pnghand.cpp | 515 +++++++++++---------- src/msw/textctrl.cpp | 7 +- src/msw/utils.cpp | 300 ++++++------ src/msw/utilsexc.cpp | 8 +- 42 files changed, 1662 insertions(+), 1777 deletions(-) create mode 100644 include/wx/ioswrap.h diff --git a/include/wx/defs.h b/include/wx/defs.h index eefebd53ed..fd5cd7c644 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DEFS_H_ @@ -21,27 +21,54 @@ #include "wx/setup.h" #include "wx/version.h" -// Helps SGI compilation, apparently -#if defined(__SGI__) -#if defined(__GNUG__) -#define __need_wchar_t -#else -/* Note I use the term __SGI_CC__ for both cc and CC, its not a good idea to - * mix gcc and cc/CC, the name mangling is different */ -#define __SGI_CC__ -#endif -#endif +// ---------------------------------------------------------------------------- +// compiler and OS identification +// ---------------------------------------------------------------------------- -#if defined(sun) || defined(__SUN__) -# if !defined(__GNUG__) -# ifndef __SUNCC__ -# define __SUNCC__ -# endif -# endif -#endif +// OS +#if defined(__HPUX__) || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi ) || defined(__unix__) + #ifndef __UNIX__ + #define __UNIX__ + #endif // Unix + + // Helps SGI compilation, apparently + #ifdef __SGI__ + #ifdef __GNUG__ + #define __need_wchar_t + #else // !gcc + // Note I use the term __SGI_CC__ for both cc and CC, its not a good + // idea to mix gcc and cc/CC, the name mangling is different + #define __SGI_CC__ + #endif // gcc/!gcc + #endif // SGI + + #if defined(sun) || defined(__SUN__) + #ifndef __GNUG__ + #ifndef __SUNCC__ + #define __SUNCC__ + #endif // Sun CC + #endif + #endif // Sun +#else // Windows + #ifndef __WINDOWS__ + #define __WINDOWS__ + #endif // Windows + + // define another standard symbol for Microsoft Visual C++: the standard one + // (_MSC_VER) is also defined by Metrowerks compiler + #if defined(_MSC_VER) && !defined(__MWERKS__) + #define __VISUALC__ + #elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__) + #define __BORLANDC__ + #elif defined(__WATCOMC__) + //#define __WATCOMC__ + #elif defined(__SC__) + #define __SYMANTECC__ + #endif // compiler +#endif // OS // suppress some Visual C++ warnings -#ifdef _MSC_VER +#ifdef __VISUALC__ # pragma warning(disable:4244) // cobversion from double to float # pragma warning(disable:4100) // unreferenced formal parameter #endif @@ -124,9 +151,9 @@ typedef unsigned int bool; #elif defined(__SALFORDC__) typedef unsigned int bool; -#elif defined(_MSC_VER) && (_MSC_VER <= 1000) +#elif defined(__VISUALC__) && (__VISUALC__ <= 1000) typedef unsigned int bool; -#elif defined(_MSC_VER) && (_MSC_VER == 1020) +#elif defined(__VISUALC__) && (__VISUALC__ == 1020) #define bool unsigned int #elif defined(__BORLANDC__) && (__BORLANDC__ < 0x500) typedef unsigned int bool; @@ -144,7 +171,7 @@ #endif // Sun CC #endif -#if ( defined(_MSC_VER) && (_MSC_VER <= 800) ) || defined(__GNUWIN32__) || (defined(__BORLANDC__) && defined(__WIN16__)) || defined(__SC__) || defined(__SALFORDC__) +#if ( defined(__VISUALC__) && (__VISUALC__ <= 800) ) || defined(__GNUWIN32__) || (defined(__BORLANDC__) && defined(__WIN16__)) || defined(__SC__) || defined(__SALFORDC__) // Not a good idea, because later system files (e.g. windows.h) // may try to define it. Use wxByte instead. // #define byte unsigned char @@ -281,30 +308,6 @@ enum ErrCode WXDLLEXPORT_DATA(extern const bool) wxTrue; WXDLLEXPORT_DATA(extern const bool) wxFalse; -// ---------------------------------------------------------------------------- -// compiler and OS identification -// ---------------------------------------------------------------------------- - -// OS -#if defined(__HPUX__) || defined(____SVR4____) || defined(__LINUX__) || defined(__sgi ) || defined(__unix__) - #ifndef __UNIX__ - #define __UNIX__ - #endif -#endif - -#ifndef __UNIX__ // Windows - #if defined(_MSC_VER) - #define __VISUALC__ - #elif defined(__BCPLUSPLUS__) && !defined(__BORLANDC__) - #define __BORLANDC__ - #elif defined(__WATCOMC__) - //#define __WATCOMC__ - #elif defined(__SC__) - #define __SYMANTECC__ - #endif // compiler - -#endif // OS - // ---------------------------------------------------------------------------- // compiler specific settings // ---------------------------------------------------------------------------- @@ -315,25 +318,18 @@ WXDLLEXPORT_DATA(extern const bool) wxFalse; #pragma warning(disable: 4514) // unreferenced inline func has been removed /* you might be tempted to disable this one also: triggered by CHECK and FAIL - macros in debug.h, but it's, overall, is a rather useful one, so I leave it - and will try to find some way to disable this warning just for CHECK/FAIL. - Anyone? + macros in debug.h, but it's, overall, a rather useful one, so I leave it and + will try to find some way to disable this warning just for CHECK/FAIL. Anyone? */ #pragma warning(disable: 4127) // conditional expression is constant - #endif // VC++ -#if _MSC_VER > 1010 -#undef try -#undef except -#undef finally -#define except(x) catch(...) -#elif defined(__MWERKS__) -#undef try -#undef except -#undef finally -#define except(x) catch(...) -#endif +#if defined(__MWERKS__) + #undef try + #undef except + #undef finally + #define except(x) catch(...) +#endif // Metrowerks // where should i put this? we need to make sure of this as it breaks // the code. @@ -402,20 +398,20 @@ typedef void (*wxFunction) (wxObject&, wxEvent&); /* * Frame/dialog style flags */ -#define wxSTAY_ON_TOP 0x8000 -#define wxICONIZE 0x4000 -#define wxMINIMIZE wxICONIZE -#define wxMAXIMIZE 0x2000 -#define wxTHICK_FRAME 0x1000 -#define wxSYSTEM_MENU 0x0800 -#define wxMINIMIZE_BOX 0x0400 -#define wxMAXIMIZE_BOX 0x0200 -#define wxTINY_CAPTION_HORIZ 0x0100 -#define wxTINY_CAPTION_VERT 0x0080 -#define wxRESIZE_BOX wxMAXIMIZE_BOX -#define wxRESIZE_BORDER 0x0040 -#define wxDIALOG_MODAL 0x0020 -#define wxDIALOG_MODELESS 0x0000 +#define wxSTAY_ON_TOP 0x8000 +#define wxICONIZE 0x4000 +#define wxMINIMIZE wxICONIZE +#define wxMAXIMIZE 0x2000 +#define wxTHICK_FRAME 0x1000 +#define wxSYSTEM_MENU 0x0800 +#define wxMINIMIZE_BOX 0x0400 +#define wxMAXIMIZE_BOX 0x0200 +#define wxTINY_CAPTION_HORIZ 0x0100 +#define wxTINY_CAPTION_VERT 0x0080 +#define wxRESIZE_BOX wxMAXIMIZE_BOX +#define wxRESIZE_BORDER 0x0040 +#define wxDIALOG_MODAL 0x0020 +#define wxDIALOG_MODELESS 0x0000 #define wxDEFAULT_FRAME_STYLE (wxRESIZE_BORDER | wxMINIMIZE_BOX | wxMAXIMIZE_BOX | wxTHICK_FRAME | wxSYSTEM_MENU | wxCAPTION | wxCLIP_CHILDREN) @@ -423,7 +419,7 @@ typedef void (*wxFunction) (wxObject&, wxEvent&); #define wxDEFAULT_FRAME wxDEFAULT_FRAME_STYLE #endif -#define wxDEFAULT_DIALOG_STYLE (wxSYSTEM_MENU|wxCAPTION|wxTHICK_FRAME) +#define wxDEFAULT_DIALOG_STYLE (wxSYSTEM_MENU|wxCAPTION|wxTHICK_FRAME) /* * Subwindow style flags @@ -671,7 +667,7 @@ enum { wxCROSS_HATCH, wxHORIZONTAL_HATCH, wxVERTICAL_HATCH, -#define IS_HATCH(s) ((s)>=wxBDIAGONAL_HATCH && (s)<=wxVERTICAL_HATCH) +#define IS_HATCH(s) ((s)>=wxBDIAGONAL_HATCH && (s)<=wxVERTICAL_HATCH) wxJOIN_BEVEL = 120, wxJOIN_MITER, @@ -684,7 +680,7 @@ enum { // Logical ops -typedef enum +typedef enum { wxCLEAR, // 0 wxXOR, // src XOR dst @@ -715,10 +711,10 @@ typedef enum #define wxWINDING_RULE 2 // ToolPanel in wxFrame -#define wxTOOL_TOP 1 -#define wxTOOL_BOTTOM 2 -#define wxTOOL_LEFT 3 -#define wxTOOL_RIGHT 4 +#define wxTOOL_TOP 1 +#define wxTOOL_BOTTOM 2 +#define wxTOOL_LEFT 3 +#define wxTOOL_RIGHT 4 // Dialog specifiers/return values @@ -784,13 +780,13 @@ enum wxDataFormat /* Virtual keycodes */ -enum wxKeyCode +enum wxKeyCode { WXK_BACK = 8, WXK_TAB = 9, - WXK_RETURN = 13, - WXK_ESCAPE = 27, - WXK_SPACE = 32, + WXK_RETURN = 13, + WXK_ESCAPE = 27, + WXK_SPACE = 32, WXK_DELETE = 127, WXK_START = 300, @@ -866,25 +862,25 @@ enum wxKeyCode /* OS mnemonics -- Identify the running OS (useful for Windows) * [Not all platforms are currently available or supported] */ -enum +enum { wxUNKNOWN_PLATFORM, - wxCURSES, /* Text-only CURSES */ - wxXVIEW_X, /* Sun's XView OpenLOOK toolkit */ - wxMOTIF_X, /* OSF Motif 1.x.x */ - wxCOSE_X, /* OSF Common Desktop Environment */ - wxNEXTSTEP, /* NeXTStep */ - wxMACINTOSH, /* Apple System 7 */ - wxGTK, /* GTK */ - wxQT, /* Qt */ - wxGEOS, /* GEOS */ - wxOS2_PM, /* OS/2 Workplace */ - wxWINDOWS, /* Windows or WfW */ - wxPENWINDOWS, /* Windows for Pen Computing */ - wxWINDOWS_NT, /* Windows NT */ - wxWIN32S, /* Windows 32S API */ - wxWIN95, /* Windows 95 */ - wxWIN386 /* Watcom 32-bit supervisor modus */ + wxCURSES, // Text-only CURSES + wxXVIEW_X, // Sun's XView OpenLOOK toolkit + wxMOTIF_X, // OSF Motif 1.x.x + wxCOSE_X, // OSF Common Desktop Environment + wxNEXTSTEP, // NeXTStep + wxMACINTOSH, // Apple System 7 + wxGTK, // GTK + wxQT, // Qt + wxGEOS, // GEOS + wxOS2_PM, // OS/2 Workplace + wxWINDOWS, // Windows or WfW + wxPENWINDOWS, // Windows for Pen Computing + wxWINDOWS_NT, // Windows NT + wxWIN32S, // Windows 32S API + wxWIN95, // Windows 95 + wxWIN386 // Watcom 32-bit supervisor modus }; /* Printing */ diff --git a/include/wx/docview.h b/include/wx/docview.h index ba1b413a12..d38e19be92 100644 --- a/include/wx/docview.h +++ b/include/wx/docview.h @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_DOCH__ @@ -44,7 +44,7 @@ class WXDLLEXPORT wxConfigBase; #else # include # include -# ifdef _MSC_VER +# ifdef __VISUALC__ using namespace std; # endif #endif diff --git a/include/wx/filefn.h b/include/wx/filefn.h index 3c78364288..1067e88f5e 100644 --- a/include/wx/filefn.h +++ b/include/wx/filefn.h @@ -29,16 +29,12 @@ typedef long off_t; #endif -#ifdef _MSC_VER - #define off_t _off_t -#endif - -#if defined(__BORLANDC__) && defined(__WIN16__) -typedef long off_t; -#endif - -#if defined(__SC__) -typedef long off_t; +#if defined(__VISUALC__) || defined(__MWERKS__) + typedef _off_t off_t; +#elif defined(__BORLANDC__) && defined(__WIN16__) + typedef long off_t; +#elif defined(__SC__) + typedef long off_t; #endif const off_t wxInvalidOffset = (off_t)-1; diff --git a/include/wx/ioswrap.h b/include/wx/ioswrap.h new file mode 100644 index 0000000000..ce0b15357c --- /dev/null +++ b/include/wx/ioswrap.h @@ -0,0 +1,20 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: ioswrap.h +// Purpose: includes the correct iostream headers for current compiler +// Author: Vadim Zeitlin +// Modified by: +// Created: 03.02.99 +// RCS-ID: $Id$ +// Copyright: (c) 1998 Vadim Zeitlin +// Licence: wxWindows license +/////////////////////////////////////////////////////////////////////////////// + +#if wxUSE_IOSTREAMH + // N.B. BC++ doesn't have istream.h, ostream.h +# include +#else +# include +# if defined(__VISUALC__) || defined(__MWERKS__) + using namespace std; +# endif +#endif diff --git a/include/wx/log.h b/include/wx/log.h index ec849d8df9..db595e7664 100644 --- a/include/wx/log.h +++ b/include/wx/log.h @@ -57,13 +57,13 @@ class WXDLLEXPORT wxLogFrame; class WXDLLEXPORT wxFrame; #if wxUSE_IOSTREAMH -// N.B. BC++ doesn't have istream.h, ostream.h -# include + // N.B. BC++ doesn't have istream.h, ostream.h +# include #else -# include -# ifdef _MSC_VER - using namespace std; -# endif +# include +# if defined(__VISUALC__) || defined(__MWERKS__) + using namespace std; +# endif #endif // ---------------------------------------------------------------------------- diff --git a/include/wx/memory.h b/include/wx/memory.h index 841ea9e410..f9977849b5 100644 --- a/include/wx/memory.h +++ b/include/wx/memory.h @@ -6,7 +6,7 @@ // Created: 29/01/98 // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_MEMORYH__ @@ -29,13 +29,13 @@ #include #if wxUSE_IOSTREAMH -// N.B. BC++ doesn't have istream.h, ostream.h -# include + // N.B. BC++ doesn't have istream.h, ostream.h +# include #else -# include -# ifdef _MSC_VER - using namespace std; -# endif +# include +# if defined(__VISUALC__) || defined(__MWERKS__) + using namespace std; +# endif #endif #ifdef __WXDEBUG__ @@ -49,15 +49,15 @@ void wxDebugFree(void * buf, bool isVect = FALSE); // Undefine temporarily (new is #defined in object.h) because we want to // declare some new operators. #ifdef new -#undef new + #undef new #endif #if defined(__SUNCC__) -#define wxUSE_ARRAY_MEMORY_OPERATORS 0 -#elif !( defined (_MSC_VER) && (_MSC_VER <= 1020) ) || defined( __MWERKS__) -#define wxUSE_ARRAY_MEMORY_OPERATORS 1 + #define wxUSE_ARRAY_MEMORY_OPERATORS 0 +#elif !( defined (__VISUALC__) && (__VISUALC__ <= 1020) ) || defined( __MWERKS__) + #define wxUSE_ARRAY_MEMORY_OPERATORS 1 #else -#define wxUSE_ARRAY_MEMORY_OPERATORS 0 + #define wxUSE_ARRAY_MEMORY_OPERATORS 0 #endif // Added JACS 25/11/98: needed for some compilers @@ -76,9 +76,9 @@ void operator delete[] (void * buf); #endif // VC++ 6.0 -#if _MSC_VER >= 1200 -void operator delete(void *buf, char*, int); -void operator delete[](void *buf, char*, int); +#if defined(__VISUALC__) && (__VISUALC__ >= 1200) + void operator delete(void *buf, char*, int); + void operator delete[](void *buf, char*, int); #endif #endif diff --git a/include/wx/msw/msvcrt.h b/include/wx/msw/msvcrt.h index 289756e3fe..ee7db39355 100644 --- a/include/wx/msw/msvcrt.h +++ b/include/wx/msw/msvcrt.h @@ -19,12 +19,14 @@ #ifndef _MSW_MSVCRT_H_ #define _MSW_MSVCRT_H_ -// use debug CRT functions for memory leak detections in VC++ if we're not -// using wxWindows own methods -#if defined(__WXDEBUG__) && defined(_MSC_VER) && !wxUSE_GLOBAL_MEMORY_OPERATORS && !defined(__NO_VC_CRTDBG__) - #define wxUSE_VC_CRTDBG -#else - #undef wxUSE_VC_CRTDBG +// use debug CRT functions for memory leak detections in VC++ 5.0+ in debug +// builds +#undef wxUSE_VC_CRTDBG +#if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ >= 1000) + // it doesn't combine well with wxWin own memory debugging methods + #if !wxUSE_GLOBAL_MEMORY_OPERATORS && !defined(__NO_VC_CRTDBG__) + #define wxUSE_VC_CRTDBG + #endif #endif #ifdef wxUSE_VC_CRTDBG @@ -46,4 +48,5 @@ #define wxCrtSetDbgFlag(flag) #endif // wxUSE_VC_CRTDBG -#endif // _MSW_MSVCRT_H_ \ No newline at end of file +#endif // _MSW_MSVCRT_H_ + diff --git a/include/wx/msw/ole/oleutils.h b/include/wx/msw/ole/oleutils.h index 2335dd5468..9809d398e0 100644 --- a/include/wx/msw/ole/oleutils.h +++ b/include/wx/msw/ole/oleutils.h @@ -2,7 +2,7 @@ // Name: oleutils.h // Purpose: OLE helper routines, OLE debugging support &c // Author: Vadim Zeitlin -// Modified by: +// Modified by: // Created: 19.02.1998 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin @@ -44,7 +44,7 @@ bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount); // ============================================================================ /* - The most dumb implementation of IUnknown methods. We don't support + The most dumb implementation of IUnknown methods. We don't support aggregation nor containment, but for 99% of cases this simple implementation is quite enough. @@ -121,11 +121,10 @@ bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount); // Debugging support // ============================================================================ -#if defined(__WXDEBUG__) && defined(_MSC_VER) && (_MSC_VER > 1000) -// ---------------------------------------------------------------------------- -// -// ---------------------------------------------------------------------------- - +// VZ: I don't know it's not done for compilers other than VC++ but I leave it +// as is. Please note, though, that tracing OLE interface calls may be +// incredibly useful when debugging OLE programs. +#if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ >= 1000) // ---------------------------------------------------------------------------- // All OLE specific log functions have DebugTrace level (as LogTrace) // ---------------------------------------------------------------------------- @@ -143,4 +142,5 @@ void wxLogRelease(const char *szInterface, ULONG cRef); #define wxLogRelease(szInterface, cRef) #endif //WXDEBUG -#endif //_WX_OLEUTILS_H \ No newline at end of file +#endif //_WX_OLEUTILS_H + diff --git a/include/wx/object.h b/include/wx/object.h index b914b190dc..abd725a3f2 100644 --- a/include/wx/object.h +++ b/include/wx/object.h @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_OBJECTH__ @@ -40,13 +40,13 @@ class WXDLLEXPORT wxHashTable; class WXDLLEXPORT wxObject_Serialize; #if wxUSE_IOSTREAMH -// N.B. BC++ doesn't have istream.h, ostream.h -# include + // N.B. BC++ doesn't have istream.h, ostream.h +# include #else -# include -# ifdef _MSC_VER - using namespace std; -# endif +# include +# if defined(__VISUALC__) || defined(__MWERKS__) + using namespace std; +# endif #endif /* @@ -61,7 +61,7 @@ class WXDLLEXPORT wxClassInfo wxClassInfo(char *cName, char *baseName1, char *baseName2, int sz, wxObjectConstructorFn fn); wxObject *CreateObject(void); - + inline char *GetClassName(void) const { return m_className; } inline char *GetBaseClassName1(void) const { return m_baseClassName1; } inline char *GetBaseClassName2(void) const { return m_baseClassName2; } @@ -87,7 +87,7 @@ public: char* m_baseClassName2; int m_objectSize; wxObjectConstructorFn m_objectConstructor; - + // Pointers to base wxClassInfos: set in InitializeClasses // called from wx_main.cc wxClassInfo* m_baseInfo1; @@ -198,13 +198,12 @@ class WXDLLEXPORT wxObject void operator delete (void * buf); // VC++ 6.0 -#if _MSC_VER >= 1200 +#if defined(__VISUALC__) && (__VISUALC__ >= 1200) void operator delete(void *buf, char*, int); #endif - // Cause problems for VC++ -// #ifndef _MSC_VER -#if !defined(_MSC_VER) && wxUSE_ARRAY_MEMORY_OPERATORS + // Causes problems for VC++ +#if wxUSE_ARRAY_MEMORY_OPERATORS && !defined(__VISUALC__) void * operator new[] (size_t size, char * fileName = NULL, int lineNum = 0); void operator delete[] (void * buf); #endif @@ -216,7 +215,7 @@ class WXDLLEXPORT wxObject #endif */ -#endif +#endif // Debug & memory tracing #if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT virtual void Dump(ostream& str); diff --git a/include/wx/string.h b/include/wx/string.h index 541332d4ae..d385f10b61 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -16,15 +16,10 @@ #pragma interface "string.h" #endif -/* Dependencies (should be included before this header): - * string.h - * stdio.h - * stdarg.h - * limits.h - */ #ifdef __WXMAC__ -#include + #include #endif + #include #include #include @@ -32,11 +27,12 @@ #include #ifndef WX_PRECOMP - #include "wx/defs.h" // Robert Roebling + #include "wx/defs.h" + #ifdef WXSTRING_IS_WXOBJECT #include "wx/object.h" #endif -#endif +#endif // !PCH #include "wx/debug.h" @@ -83,7 +79,7 @@ inline size_t WXDLLEXPORT Strlen(const char *psz) // portable strcasecmp/_stricmp inline int WXDLLEXPORT Stricmp(const char *psz1, const char *psz2) { -#if defined(_MSC_VER) +#if defined(__VISUALC__) || defined(__MWERKS__) return _stricmp(psz1, psz2); #elif defined(__SC__) return _stricmp(psz1, psz2); @@ -645,7 +641,7 @@ public: size_t find(const wxString& str, size_t nStart = 0) const; // VC++ 1.5 can't cope with this syntax. -#if !(defined(_MSC_VER) && !defined(__WIN32__)) +#if !defined(__VISUALC__) || defined(__WIN32__) // find first n characters of sz size_t find(const char* sz, size_t nStart = 0, size_t n = npos) const; #endif @@ -661,7 +657,7 @@ public: size_t rfind(const wxString& str, size_t nStart = npos) const; // VC++ 1.5 can't cope with this syntax. -#if ! (defined(_MSC_VER) && !defined(__WIN32__)) +#if !defined(__VISUALC__) || defined(__WIN32__) // as find, but from the end size_t rfind(const char* sz, size_t nStart = npos, size_t n = npos) const; @@ -854,19 +850,7 @@ wxString WXDLLEXPORT operator+(const char *psz, const wxString& string); #ifdef wxSTD_STRING_COMPATIBILITY -// forward declare iostream -// Known not to work with wxUSE_IOSTREAMH set to 0, so -// replacing with includes (on advice of ungod@pasdex.com.au) -// class WXDLLEXPORT istream; -#if wxUSE_IOSTREAMH -// N.B. BC++ doesn't have istream.h, ostream.h -#include -#else -#include -# ifdef _MSC_VER - using namespace std; -# endif -#endif +#include "wx/ioswrap.h" WXDLLEXPORT istream& operator>>(istream& is, wxString& str); diff --git a/include/wx/utils.h b/include/wx/utils.h index 483e0caf07..037cfc61b2 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -6,7 +6,7 @@ // Created: 29/01/98 // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_UTILSH__ @@ -23,14 +23,7 @@ #include "wx/filefn.h" #include "wx/process.h" -#if wxUSE_IOSTREAMH -#include -#else -#include -# ifdef _MSC_VER - using namespace std; -# endif -#endif +#include "wx/ioswrap.h" #ifdef __X__ #ifndef __VMS__ diff --git a/include/wx/variant.h b/include/wx/variant.h index 4956e3283a..a52b72239c 100644 --- a/include/wx/variant.h +++ b/include/wx/variant.h @@ -6,7 +6,7 @@ // Created: 10/09/98 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifndef _WX_VARIANT_H_ @@ -22,18 +22,11 @@ #include "wx/list.h" #if wxUSE_TIMEDATE -#include "wx/time.h" -#include "wx/date.h" -#endif + #include "wx/time.h" + #include "wx/date.h" +#endif // time/date -#if wxUSE_IOSTREAMH -#include -#else -#include -# ifdef _MSC_VER - using namespace std; -# endif -#endif +#include "wx/ioswrap.h" /* * wxVariantData stores the actual data in a wxVariant object, diff --git a/include/wx/wxchar.h b/include/wx/wxchar.h index 9083a4c7bf..b2e27e2796 100644 --- a/include/wx/wxchar.h +++ b/include/wx/wxchar.h @@ -22,11 +22,11 @@ #endif // only do Unicode for Windows (VC++), for now -#if defined(_MSC_VER) && defined(__WIN32__) +#if defined(__VISUALC__) && defined(__WIN32__) #include typedef _TCHAR wxChar; -typedef _TSCHAR wxSChar; +typedef _TSCHAR wxSChar; typedef _TUCHAR wxUChar; // ctype.h functions @@ -120,11 +120,11 @@ typedef _TUCHAR wxUChar; #error "Please define your compiler's Unicode conventions in wxChar.h" #endif -typedef char wxChar; -typedef signed char wxSChar; -typedef unsigned char wxUChar; +typedef char wxChar; +typedef signed char wxSChar; +typedef unsigned char wxUChar; -#define _T(x) x +#define _T(x) x // ctype.h functions #define wxIsalnum isalnum @@ -212,7 +212,7 @@ inline bool WXDLLEXPORT wxIsEmpty(const wxChar *p) { return !p || !*p; } /// safe version of strlen() (returns 0 if passed NULL pointer) inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz) -#if defined(_MSC_VER) +#if defined(__VISUALC__) { return psz ? _tcslen(psz) : 0; } #else { return psz ? strlen(psz) : 0; } @@ -220,7 +220,7 @@ inline size_t WXDLLEXPORT wxStrlen(const wxChar *psz) /// portable strcasecmp/_stricmp inline int WXDLLEXPORT wxStricmp(const wxChar *, const wxChar *) -#if defined(_MSC_VER) +#if defined(__VISUALC__) { return _tcsicmp(psz1, psz2); } #elif defined(__BORLANDC__) { return stricmp(psz1, psz2); } @@ -239,7 +239,7 @@ inline int WXDLLEXPORT wxStricmp(const wxChar *, const wxChar *) return c1 - c2; */ - + #error "Please define string case-insensitive compare for your OS/compiler" #endif // OS/compiler diff --git a/include/wx/wxexpr.h b/include/wx/wxexpr.h index 76aad36b0d..613726f841 100644 --- a/include/wx/wxexpr.h +++ b/include/wx/wxexpr.h @@ -21,14 +21,7 @@ #include "wx/defs.h" #include "wx/string.h" -#if wxUSE_IOSTREAMH -#include -#else -#include -# ifdef _MSC_VER - using namespace std; -# endif -#endif +#include "wx/ioswrap.h" #include "wx/list.h" #include "wx/hash.h" diff --git a/include/wx/wxprec.h b/include/wx/wxprec.h index b1a93f2493..eff6f75395 100644 --- a/include/wx/wxprec.h +++ b/include/wx/wxprec.h @@ -6,19 +6,19 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // check if to use precompiled headers -#if (defined(__BORLANDC__) || defined(_MSC_VER) || defined(__WATCOMC__)) && defined(__WXMSW__) -#if !NOPCH -#define WX_PRECOMP -#endif +#if (defined(__BORLANDC__) || defined(__VISUALC__) || defined(__WATCOMC__)) && defined(__WXMSW__) + #if !NOPCH + #define WX_PRECOMP + #endif #endif // For some reason, this must be defined for common dialogs to work. #ifdef __WATCOMC__ -#define INCLUDE_COMMDLG_H 1 +#define INCLUDE_COMMDLG_H 1 #endif // include the wx definitions diff --git a/src/common/docmdi.cpp b/src/common/docmdi.cpp index 0379f04ff8..e188c03a12 100644 --- a/src/common/docmdi.cpp +++ b/src/common/docmdi.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ diff --git a/src/common/docview.cpp b/src/common/docview.cpp index ae846c0c8f..47fc1beea0 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -6,7 +6,7 @@ // Created: 01/02/97 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -51,15 +51,12 @@ #include #include +#include "wx/ioswrap.h" + #if wxUSE_IOSTREAMH -#include -#include + #include #else -#include -#include -# ifdef _MSC_VER - using namespace std; -# endif + #include #endif #if !USE_SHARED_LIBRARY diff --git a/src/common/file.cpp b/src/common/file.cpp index 604aaa2077..127a04feb4 100644 --- a/src/common/file.cpp +++ b/src/common/file.cpp @@ -15,7 +15,7 @@ // ---------------------------------------------------------------------------- #ifdef __GNUG__ -#pragma implementation "file.h" + #pragma implementation "file.h" #endif // For compilers that support precompilation, includes "wx.h". @@ -23,7 +23,7 @@ #include "wx/defs.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif // standard @@ -55,37 +55,34 @@ #include // for GetTempFileName #elif (defined(__UNIX__) || defined(__GNUWIN32__)) - #include -#ifdef __GNUWIN32__ - #include -#endif + #include + #ifdef __GNUWIN32__ + #include + #endif #elif (defined(__WXSTUBS__)) - // Have to ifdef this for different environments - #include + // Have to ifdef this for different environments + #include #elif (defined(__WXMAC__)) - int access( const char *path, int mode ) { return 0 ; } - char* mktemp( char * path ) { return path ;} - #include - #include - #define W_OK 2 - #define R_OK 4 + int access( const char *path, int mode ) { return 0 ; } + char* mktemp( char * path ) { return path ;} + #include + #include + #define W_OK 2 + #define R_OK 4 #else - #error "Please specify the header with file functions declarations." + #error "Please specify the header with file functions declarations." #endif //Win/UNIX #include // SEEK_xxx constants #include // O_RDONLY &c #ifndef __MWERKS__ -#include // needed for stat -#include // stat + #include // needed for stat + #include // stat #endif // Microsoft compiler loves underscores, feed them to it -#ifdef _MSC_VER - - #ifndef __MWERKS__ - +#ifdef __VISUALC__ // functions #define open _open #define close _close @@ -100,7 +97,7 @@ #define stat _stat // constants - + #define O_RDONLY _O_RDONLY #define O_WRONLY _O_WRONLY #define O_RDWR _O_RDWR @@ -110,16 +107,11 @@ #define S_IFDIR _S_IFDIR #define S_IFREG _S_IFREG - - #endif - - #define W_OK 2 - #define R_OK 4 #else #define tell(fd) lseek(fd, 0, SEEK_CUR) -#endif //_MSC_VER +#endif // VC++ -#ifdef __BORLANDC__ +#if defined(__BORLANDC__) || defined(_MSC_VER) #define W_OK 2 #define R_OK 4 #endif @@ -129,9 +121,8 @@ #define O_BINARY (0) #endif //__UNIX__ - #ifdef __SALFORDC__ -#include + #include #endif // wxWindows @@ -141,13 +132,13 @@ #include #ifndef MAX_PATH -#define MAX_PATH 512 + #define MAX_PATH 512 #endif #ifdef __WXMAC__ -char gwxMacFileName[ MAX_PATH ] ; -char gwxMacFileName2[ MAX_PATH ] ; -char gwxMacFileName3[ MAX_PATH ] ; + char gwxMacFileName[ MAX_PATH ] ; + char gwxMacFileName2[ MAX_PATH ] ; + char gwxMacFileName3[ MAX_PATH ] ; #endif // ============================================================================ @@ -213,7 +204,7 @@ bool wxFile::Create(const char *szFileName, bool bOverwrite, int accessMode) // if bOverwrite we create a new file or truncate the existing one, // otherwise we only create the new file and fail if it already exists #ifdef __SALFORDC__ - int fd = open(szFileName, O_WRONLY | O_CREAT | + int fd = open(szFileName, O_WRONLY | O_CREAT | (bOverwrite ? O_TRUNC : O_EXCL)); #else int fd = open(szFileName, O_WRONLY | O_CREAT | @@ -330,7 +321,7 @@ size_t wxFile::Write(const void *pBuf, size_t nCount) bool wxFile::Flush() { if ( IsOpened() ) { - #if (defined(_MSC_VER) && !defined(__MWERKS__)) || wxHAVE_FSYNC + #if defined(__VISUALC__) || wxHAVE_FSYNC if ( fsync(m_fd) == -1 ) { wxLogSysError(_("can't flush file descriptor %d"), m_fd); @@ -399,9 +390,9 @@ off_t wxFile::Length() const { wxASSERT( IsOpened() ); - #if defined( _MSC_VER ) && !defined( __MWERKS__ ) + #ifdef __VISUALC__ int iRc = _filelength(m_fd); - #else + #else // !VC++ int iRc = tell(m_fd); if ( iRc != -1 ) { // @ have to use const_cast :-( @@ -416,8 +407,7 @@ off_t wxFile::Length() const iRc = iLen; } - - #endif //_MSC_VER + #endif // VC++ if ( iRc == -1 ) { wxLogSysError(_("can't find length of file on file descriptor %d"), m_fd); diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index e828319ae0..c220105aba 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -6,7 +6,7 @@ // Created: 29/01/98 // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -29,7 +29,7 @@ #include // there are just too many of those... -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(disable:4706) // assignment within conditional expression #endif // VC++ @@ -38,11 +38,13 @@ #include #include #if !defined(__WATCOMC__) -#if !(defined(_MSC_VER) && (_MSC_VER > 800)) -#include -#endif + #if !(defined(_MSC_VER) && (_MSC_VER > 800)) + #include + #endif #endif + #include + #ifndef __MWERKS__ #include #include @@ -117,9 +119,9 @@ void wxPathList::AddEnvList (const wxString& envVariable) { static const char PATH_TOKS[] = #ifdef __WINDOWS__ - " ;"; // Don't seperate with colon in DOS (used for drive) + " ;"; // Don't seperate with colon in DOS (used for drive) #else - " :;"; + " :;"; #endif char *val = getenv (WXSTRINGCAST envVariable); @@ -129,14 +131,14 @@ void wxPathList::AddEnvList (const wxString& envVariable) char *token = strtok (s, PATH_TOKS); if (token) - { - Add (copystring (token)); - while (token) - { - if ((token = strtok ((char *) NULL, PATH_TOKS)) != NULL) - Add (wxString(token)); - } - } + { + Add (copystring (token)); + while (token) + { + if ((token = strtok ((char *) NULL, PATH_TOKS)) != NULL) + Add (wxString(token)); + } + } delete[]s; } } @@ -151,7 +153,7 @@ void wxPathList::EnsureFileAccessible (const wxString& path) if (path_only) { if (!Member (wxString(path_only))) - Add (wxString(path_only)); + Add (wxString(path_only)); } } @@ -163,13 +165,13 @@ bool wxPathList::Member (const wxString& path) if ( #if defined(__WINDOWS__) || defined(__VMS__) || defined (__WXMAC__) // Case INDEPENDENT - path.CompareTo (path2, wxString::ignoreCase) == 0 + path.CompareTo (path2, wxString::ignoreCase) == 0 #else - // Case sensitive File System - path.CompareTo (path2) == 0 + // Case sensitive File System + path.CompareTo (path2) == 0 #endif - ) - return TRUE; + ) + return TRUE; } return FALSE; } @@ -198,11 +200,11 @@ wxString wxPathList::FindValidPath (const wxString& file) #endif if (wxFileExists (wxBuffer)) { - return wxString(wxBuffer); // Found! + return wxString(wxBuffer); // Found! } - } // for() + } // for() - return wxString(""); // Not found + return wxString(""); // Not found } wxString wxPathList::FindAbsoluteValidPath (const wxString& file) @@ -232,7 +234,7 @@ wxString wxPathList::FindAbsoluteValidPath (const wxString& file) } } -bool +bool wxFileExists (const wxString& filename) { #ifdef __GNUWIN32__ // (fix a B20 bug) @@ -241,11 +243,11 @@ wxFileExists (const wxString& filename) else return TRUE; #elif defined(__WXMAC__) - struct stat stbuf; - strcpy( gwxMacFileName , filename ) ; - wxUnix2MacFilename( gwxMacFileName ) ; - if (gwxMacFileName && stat ((char *)(const char *)gwxMacFileName, &stbuf) == 0) - return TRUE; + struct stat stbuf; + strcpy( gwxMacFileName , filename ) ; + wxUnix2MacFilename( gwxMacFileName ) ; + if (gwxMacFileName && stat ((char *)(const char *)gwxMacFileName, &stbuf) == 0) + return TRUE; return FALSE ; #else @@ -273,7 +275,7 @@ bool wxFileExists(const char *pszFileName) } */ -bool +bool wxIsAbsolutePath (const wxString& filename) { if (filename != "") @@ -286,8 +288,8 @@ wxIsAbsolutePath (const wxString& filename) /* MSDOS */ || filename[0] == '\\' || (isalpha (filename[0]) && filename[1] == ':') #endif - ) - return TRUE; + ) + return TRUE; } return FALSE; } @@ -297,7 +299,7 @@ wxIsAbsolutePath (const wxString& filename) * IF one exists. Inserts zero into buffer. * */ - + void wxStripExtension(char *buffer) { int len = strlen(buffer); @@ -346,35 +348,35 @@ char *wxRealPath (char *path) p = &path[2]; for (; *p; p++) { - if (*p == SEP) - { - if (p[1] == '.' && p[2] == '.' && (p[3] == SEP || p[3] == '\0')) - { + if (*p == SEP) + { + if (p[1] == '.' && p[2] == '.' && (p[3] == SEP || p[3] == '\0')) + { char *q; - for (q = p - 1; q >= path && *q != SEP; q--); - if (q[0] == SEP && (q[1] != '.' || q[2] != '.' || q[3] != SEP) - && (q - 1 <= path || q[-1] != SEP)) - { - strcpy (q, p + 3); - if (path[0] == '\0') - { - path[0] = SEP; - path[1] = '\0'; - } + for (q = p - 1; q >= path && *q != SEP; q--); + if (q[0] == SEP && (q[1] != '.' || q[2] != '.' || q[3] != SEP) + && (q - 1 <= path || q[-1] != SEP)) + { + strcpy (q, p + 3); + if (path[0] == '\0') + { + path[0] = SEP; + path[1] = '\0'; + } #ifdef __WXMSW__ - /* Check that path[2] is NULL! */ - else if (path[1] == ':' && !path[2]) - { - path[2] = SEP; - path[3] = '\0'; - } -#endif - p = q - 1; - } - } - else if (p[1] == '.' && (p[2] == SEP || p[2] == '\0')) - strcpy (p, p + 2); - } + /* Check that path[2] is NULL! */ + else if (path[1] == ':' && !path[2]) + { + path[2] = SEP; + path[3] = '\0'; + } +#endif + p = q - 1; + } + } + else if (p[1] == '.' && (p[2] == SEP || p[2] == '\0')) + strcpy (p, p + 2); + } } } return path; @@ -393,10 +395,10 @@ char *wxCopyAbsolutePath(const wxString& filename) char ch = buf[strlen(buf) - 1]; #ifdef __WXMSW__ if (ch != '\\' && ch != '/') - strcat(buf, "\\"); + strcat(buf, "\\"); #else if (ch != '/') - strcat(buf, "/"); + strcat(buf, "/"); #endif strcat(buf, wxBuffer); return copystring( wxRealPath(buf) ); @@ -410,19 +412,19 @@ char *wxCopyAbsolutePath(const wxString& filename) ~user/ => user's home dir If the environment variable a = "foo" and b = "bar" then: Unix: - $a => foo - $a$b => foobar - $a.c => foo.c - xxx$a => xxxfoo - ${a}! => foo! - $(b)! => bar! - \$a => \$a + $a => foo + $a$b => foobar + $a.c => foo.c + xxx$a => xxxfoo + ${a}! => foo! + $(b)! => bar! + \$a => \$a MSDOS: - $a ==> $a - $(a) ==> foo - $(a)$b ==> foo$b - $(a)$(b)==> foobar - test.$$ ==> test.$$ + $a ==> $a + $(a) ==> foo + $(a)$b ==> foo$b + $(a)$(b)==> foobar + test.$$ ==> test.$$ */ /* input name in name, pathname output to buf. */ @@ -431,7 +433,7 @@ char *wxExpandPath(char *buf, const char *name) { register char *d, *s, *nm; char lnm[_MAXPATHLEN]; - int q; + int q; // Some compilers don't like this line. // const char trimchars[] = "\n \t"; @@ -449,17 +451,17 @@ char *wxExpandPath(char *buf, const char *name) #endif buf[0] = '\0'; if (name == NULL || *name == '\0') - return buf; + return buf; nm = copystring(name); // Make a scratch copy char *nm_tmp = nm; /* Skip leading whitespace and cr */ while (strchr((char *)trimchars, *nm) != NULL) - nm++; + nm++; /* And strip off trailing whitespace and cr */ s = nm + (q = strlen(nm)) - 1; while (q-- && strchr((char *)trimchars, *s) != NULL) - *s = '\0'; + *s = '\0'; s = nm; d = lnm; @@ -472,37 +474,37 @@ char *wxExpandPath(char *buf, const char *name) /* Expand inline environment variables */ while ((*d++ = *s)) { #ifndef __WXMSW__ - if (*s == '\\') { - if ((*(d - 1) = *++s)) { - s++; - continue; - } else - break; - } else + if (*s == '\\') { + if ((*(d - 1) = *++s)) { + s++; + continue; + } else + break; + } else #endif #ifdef __WXMSW__ - if (*s++ == '$' && (*s == '{' || *s == ')')) + if (*s++ == '$' && (*s == '{' || *s == ')')) #else - if (*s++ == '$') -#endif - { - register char *start = d; - register int braces = (*s == '{' || *s == '('); - register char *value; - while ((*d++ = *s)) - if (braces ? (*s == '}' || *s == ')') : !(isalnum(*s) || *s == '_') ) - break; - else - s++; - *--d = 0; - value = getenv(braces ? start + 1 : start); - if (value) { - for ((d = start - 1); (*d++ = *value++);); - d--; - if (braces && *s) - s++; - } - } + if (*s++ == '$') +#endif + { + register char *start = d; + register int braces = (*s == '{' || *s == '('); + register char *value; + while ((*d++ = *s)) + if (braces ? (*s == '}' || *s == ')') : !(isalnum(*s) || *s == '_') ) + break; + else + s++; + *--d = 0; + value = getenv(braces ? start + 1 : start); + if (value) { + for ((d = start - 1); (*d++ = *value++);); + d--; + if (braces && *s) + s++; + } + } } /* Expand ~ and ~user */ @@ -510,41 +512,41 @@ char *wxExpandPath(char *buf, const char *name) s = ""; if (nm[0] == '~' && !q) { - /* prefix ~ */ - if (nm[1] == SEP || nm[1] == 0) - { /* ~/filename */ - if ((s = wxGetUserHome("")) != NULL) { - if (*++nm) - nm++; - } + /* prefix ~ */ + if (nm[1] == SEP || nm[1] == 0) + { /* ~/filename */ + if ((s = wxGetUserHome("")) != NULL) { + if (*++nm) + nm++; + } } else - { /* ~user/filename */ - register char *nnm; - register char *home; - for (s = nm; *s && *s != SEP; s++); - int was_sep; /* MATTHEW: Was there a separator, or NULL? */ + { /* ~user/filename */ + register char *nnm; + register char *home; + for (s = nm; *s && *s != SEP; s++); + int was_sep; /* MATTHEW: Was there a separator, or NULL? */ was_sep = (*s == SEP); - nnm = *s ? s + 1 : s; - *s = 0; - if ((home = wxGetUserHome(wxString(nm + 1))) == NULL) { + nnm = *s ? s + 1 : s; + *s = 0; + if ((home = wxGetUserHome(wxString(nm + 1))) == NULL) { if (was_sep) /* replace only if it was there: */ - *s = SEP; - s = ""; - } else { - nm = nnm; - s = home; - } - } + *s = SEP; + s = ""; + } else { + nm = nnm; + s = home; + } + } } d = buf; if (s && *s) { /* MATTHEW: s could be NULL if user '~' didn't exist */ - /* Copy home dir */ - while ('\0' != (*d++ = *s++)) - /* loop */; - // Handle root home - if (d - 1 > buf && *(d - 2) != SEP) - *(d - 1) = SEP; + /* Copy home dir */ + while ('\0' != (*d++ = *s++)) + /* loop */; + // Handle root home + if (d - 1 > buf && *(d - 2) != SEP) + *(d - 1) = SEP; } s = nm; while ((*d++ = *s++)); @@ -597,7 +599,7 @@ wxContractPath (const wxString& filename, const wxString& envname, const wxStrin { strcpy(wxBuffer, "~"); if (user != "") - strcat(wxBuffer, (const char*) user); + strcat(wxBuffer, (const char*) user); #ifdef __WXMSW__ // strcat(wxBuffer, "\\"); #else @@ -620,18 +622,18 @@ char *wxFileNameFromPath (char *path) tcp = path + strlen (path); while (--tcp >= path) - { - if (*tcp == '/' || *tcp == '\\' + { + if (*tcp == '/' || *tcp == '\\' #ifdef __VMS__ || *tcp == ':' || *tcp == ']') #else ) #endif - return tcp + 1; - } /* while */ + return tcp + 1; + } /* while */ #ifdef __WXMSW__ if (isalpha (*path) && *(path + 1) == ':') - return path + 2; + return path + 2; #endif } return path; @@ -647,18 +649,18 @@ wxString wxFileNameFromPath (const wxString& path1) tcp = path + strlen (path); while (--tcp >= path) - { - if (*tcp == '/' || *tcp == '\\' + { + if (*tcp == '/' || *tcp == '\\' #ifdef __VMS__ || *tcp == ':' || *tcp == ']') #else ) #endif - return wxString(tcp + 1); - } /* while */ + return wxString(tcp + 1); + } /* while */ #ifdef __WXMSW__ if (isalpha (*path) && *(path + 1) == ':') - return wxString(path + 2); + return wxString(path + 2); #endif } // Yes, this should return the path, not an empty string, otherwise @@ -703,12 +705,12 @@ wxPathOnly (char *path) #ifdef __WXMSW__ // Try Drive specifier if (isalpha (buf[0]) && buf[1] == ':') - { - // A:junk --> A:. (since A:.\junk Not A:\junk) - buf[2] = '.'; - buf[3] = '\0'; - return buf; - } + { + // A:junk --> A:. (since A:.\junk Not A:\junk) + buf[2] = '.'; + buf[3] = '\0'; + return buf; + } #endif } @@ -751,12 +753,12 @@ wxString wxPathOnly (const wxString& path) #ifdef __WXMSW__ // Try Drive specifier if (isalpha (buf[0]) && buf[1] == ':') - { - // A:junk --> A:. (since A:.\junk Not A:\junk) - buf[2] = '.'; - buf[3] = '\0'; - return wxString(buf); - } + { + // A:junk --> A:. (since A:.\junk Not A:\junk) + buf[2] = '.'; + buf[3] = '\0'; + return wxString(buf); + } #endif } @@ -768,74 +770,74 @@ wxString wxPathOnly (const wxString& path) // Also, convert to lower case, since case is significant in UNIX. #ifdef __WXMAC__ -void +void wxMac2UnixFilename (char *s) { - if (s) - { - memmove( s+1 , s ,strlen( s ) + 1) ; - if ( *s == ':' ) - *s = '.' ; - else - *s = '/' ; - - while (*s) - { - if (*s == ':') - *s = '/'; - else - *s = wxToLower (*s); // Case INDEPENDENT - s++; - } - } + if (s) + { + memmove( s+1 , s ,strlen( s ) + 1) ; + if ( *s == ':' ) + *s = '.' ; + else + *s = '/' ; + + while (*s) + { + if (*s == ':') + *s = '/'; + else + *s = wxToLower (*s); // Case INDEPENDENT + s++; + } + } } -void +void wxUnix2MacFilename (char *s) { - if (s) - { - if ( *s == '.' ) - { - // relative path , since it goes on with slash which is translated to a : - memmove( s , s+1 ,strlen( s ) ) ; - } - else if ( *s == '/' ) - { - // absolute path -> on mac just start with the drive name - memmove( s , s+1 ,strlen( s ) ) ; - } - else - { - wxASSERT_MSG( 1 , "unkown path beginning" ) ; - } - while (*s) - { - if (*s == '/' || *s == '\\') - *s = ':'; - - s++ ; - } - } + if (s) + { + if ( *s == '.' ) + { + // relative path , since it goes on with slash which is translated to a : + memmove( s , s+1 ,strlen( s ) ) ; + } + else if ( *s == '/' ) + { + // absolute path -> on mac just start with the drive name + memmove( s , s+1 ,strlen( s ) ) ; + } + else + { + wxASSERT_MSG( 1 , "unkown path beginning" ) ; + } + while (*s) + { + if (*s == '/' || *s == '\\') + *s = ':'; + + s++ ; + } + } } #endif -void +void wxDos2UnixFilename (char *s) { if (s) while (*s) { - if (*s == '\\') - *s = '/'; + if (*s == '\\') + *s = '/'; #ifdef __WXMSW__ - else - *s = wxToLower (*s); // Case INDEPENDENT + else + *s = wxToLower (*s); // Case INDEPENDENT #endif - s++; + s++; } } -void +void #ifdef __WXMSW__ wxUnix2DosFilename (char *s) #else @@ -847,15 +849,15 @@ wxUnix2DosFilename (char *WXUNUSED(s)) if (s) while (*s) { - if (*s == '/') - *s = '\\'; - s++; + if (*s == '/') + *s = '\\'; + s++; } #endif } // Concatenate two files to form third -bool +bool wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& file3) { char *outfile = wxGetTempFileName("cat"); @@ -865,12 +867,12 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil FILE *fp3 = (FILE *) NULL; // Open the inputs and outputs #ifdef __WXMAC__ - strcpy( gwxMacFileName , file1 ) ; - wxUnix2MacFilename( gwxMacFileName ) ; - strcpy( gwxMacFileName2 , file2) ; - wxUnix2MacFilename( gwxMacFileName2 ) ; - strcpy( gwxMacFileName3 , outfile) ; - wxUnix2MacFilename( gwxMacFileName3 ) ; + strcpy( gwxMacFileName , file1 ) ; + wxUnix2MacFilename( gwxMacFileName ) ; + strcpy( gwxMacFileName2 , file2) ; + wxUnix2MacFilename( gwxMacFileName2 ) ; + strcpy( gwxMacFileName3 , outfile) ; + wxUnix2MacFilename( gwxMacFileName3 ) ; if ((fp1 = fopen (gwxMacFileName, "rb")) == NULL || (fp2 = fopen (gwxMacFileName2, "rb")) == NULL || @@ -882,11 +884,11 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil #endif { if (fp1) - fclose (fp1); + fclose (fp1); if (fp2) - fclose (fp2); + fclose (fp2); if (fp3) - fclose (fp3); + fclose (fp3); return FALSE; } @@ -906,7 +908,7 @@ wxConcatFiles (const wxString& file1, const wxString& file2, const wxString& fil } // Copy files -bool +bool wxCopyFile (const wxString& file1, const wxString& file2) { FILE *fd1; @@ -914,10 +916,10 @@ wxCopyFile (const wxString& file1, const wxString& file2) int ch; #ifdef __WXMAC__ - strcpy( gwxMacFileName , file1 ) ; - wxUnix2MacFilename( gwxMacFileName ) ; - strcpy( gwxMacFileName2 , file2) ; - wxUnix2MacFilename( gwxMacFileName2 ) ; + strcpy( gwxMacFileName , file1 ) ; + wxUnix2MacFilename( gwxMacFileName ) ; + strcpy( gwxMacFileName2 , file2) ; + wxUnix2MacFilename( gwxMacFileName2 ) ; if ((fd1 = fopen (gwxMacFileName, "rb")) == NULL) return FALSE; @@ -940,14 +942,14 @@ wxCopyFile (const wxString& file1, const wxString& file2) return TRUE; } -bool +bool wxRenameFile (const wxString& file1, const wxString& file2) { #ifdef __WXMAC__ - strcpy( gwxMacFileName , file1 ) ; - wxUnix2MacFilename( gwxMacFileName ) ; - strcpy( gwxMacFileName2 , file2) ; - wxUnix2MacFilename( gwxMacFileName2 ) ; + strcpy( gwxMacFileName , file1 ) ; + wxUnix2MacFilename( gwxMacFileName ) ; + strcpy( gwxMacFileName2 , file2) ; + wxUnix2MacFilename( gwxMacFileName2 ) ; if (0 == rename (gwxMacFileName, gwxMacFileName2)) return TRUE; @@ -967,11 +969,11 @@ wxRenameFile (const wxString& file1, const wxString& file2) bool wxRemoveFile(const wxString& file) { -#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__) +#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) int flag = remove(WXSTRINGCAST file); #elif defined( __WXMAC__ ) - strcpy( gwxMacFileName , file ) ; - wxUnix2MacFilename( gwxMacFileName ) ; + strcpy( gwxMacFileName , file ) ; + wxUnix2MacFilename( gwxMacFileName ) ; int flag = unlink(gwxMacFileName); #else int flag = unlink(WXSTRINGCAST file); @@ -984,7 +986,7 @@ bool wxMkdir(const wxString& dir) #if defined(__WXSTUBS__) return FALSE; #elif defined(__VMS__) - return FALSE; + return FALSE; #elif defined( __WXMAC__ ) strcpy( gwxMacFileName , dir ) ; wxUnix2MacFilename( gwxMacFileName ) ; @@ -1001,8 +1003,8 @@ bool wxRmdir(const wxString& dir, int WXUNUSED(flags)) #ifdef __VMS__ return FALSE; #elif defined( __WXMAC__ ) - strcpy( gwxMacFileName , dir ) ; - wxUnix2MacFilename( gwxMacFileName ) ; + strcpy( gwxMacFileName , dir ) ; + wxUnix2MacFilename( gwxMacFileName ) ; return (rmdir(WXSTRINGCAST gwxMacFileName) == 0); #else @@ -1037,14 +1039,14 @@ bool wxDirExists(const wxString& dir) #endif #if defined(__WIN32__) - HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo); - - if (h==INVALID_HANDLE_VALUE) - return FALSE; - else { - FindClose(h); - return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY); - } + HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo); + + if (h==INVALID_HANDLE_VALUE) + return FALSE; + else { + FindClose(h); + return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY); + } #else // In Borland findfirst has a different argument // ordering from _dos_findfirst. But _dos_findfirst @@ -1084,7 +1086,7 @@ char *wxGetTempFileName(const wxString& prefix, char *buf) { #ifdef __WINDOWS__ -#ifndef __WIN32__ +#ifndef __WIN32__ char tmp[144]; ::GetTempFileName(0, WXSTRINGCAST prefix, 0, tmp); #else @@ -1098,7 +1100,7 @@ char *wxGetTempFileName(const wxString& prefix, char *buf) return buf; #else - static short last_temp = 0; // cache last to speed things a bit + static short last_temp = 0; // cache last to speed things a bit // At most 1000 temp files to a process! We use a ring count. char tmp[100]; // FIXME static buffer @@ -1106,18 +1108,18 @@ char *wxGetTempFileName(const wxString& prefix, char *buf) { sprintf (tmp, "/tmp/%s%d.%03x", WXSTRINGCAST prefix, (int) getpid (), (int) suffix); if (!wxFileExists( tmp )) - { - // Touch the file to create it (reserve name) - FILE *fd = fopen (tmp, "w"); - if (fd) - fclose (fd); - last_temp = suffix; + { + // Touch the file to create it (reserve name) + FILE *fd = fopen (tmp, "w"); + if (fd) + fclose (fd); + last_temp = suffix; if (buf) - strcpy( buf, tmp); - else - buf = copystring( tmp ); - return buf; - } + strcpy( buf, tmp); + else + buf = copystring( tmp ); + return buf; + } } wxLogError( _("wxWindows: error finding temporary file name.\n") ); if (buf) buf[0] = 0; @@ -1160,7 +1162,7 @@ char *wxFindFirstFile(const char *spec, int flags) /* MATTHEW: p is NULL => Local directory */ if (!p) p = "."; - + if ((wxDirStream=opendir(p))==NULL) return (char *) NULL; @@ -1208,17 +1210,17 @@ char *wxFindNextFile(void) strcat(buf, nextDir->d_name); if ((strcmp(nextDir->d_name, ".") == 0) || - (strcmp(nextDir->d_name, "..") == 0)) { - if (wxFindFileFlags && !(wxFindFileFlags & wxDIR)) - continue; - isdir = TRUE; + (strcmp(nextDir->d_name, "..") == 0)) { + if (wxFindFileFlags && !(wxFindFileFlags & wxDIR)) + continue; + isdir = TRUE; } else - isdir = wxDirExists(buf); - + isdir = wxDirExists(buf); + if (!wxFindFileFlags - || ((wxFindFileFlags & wxDIR) && isdir) - || ((wxFindFileFlags & wxFILE) && !isdir)) - return buf; + || ((wxFindFileFlags & wxDIR) && isdir) + || ((wxFindFileFlags & wxFILE) && !isdir)) + return buf; } } closedir(wxDirStream); @@ -1254,28 +1256,28 @@ char *wxFindFirstFile(const char *spec, int flags) wxString path1(wxFileSpec); char *p = wxPathOnly(WXSTRINGCAST path1); if (p && (strlen(p) > 0)) - strcpy(wxBuffer, p); + strcpy(wxBuffer, p); else - wxBuffer[0] = 0; + wxBuffer[0] = 0; #ifdef __WIN32__ if (wxFileStrucHandle != INVALID_HANDLE_VALUE) - FindClose(wxFileStrucHandle); + FindClose(wxFileStrucHandle); wxFileStrucHandle = ::FindFirstFile(WXSTRINGCAST spec, &wxFileStruc); if (wxFileStrucHandle == INVALID_HANDLE_VALUE) - return NULL; + return NULL; bool isdir = !!(wxFileStruc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); if (isdir && !(flags & wxDIR)) - return wxFindNextFile(); + return wxFindNextFile(); else if (!isdir && flags && !(flags & wxFILE)) - return wxFindNextFile(); + return wxFindNextFile(); if (wxBuffer[0] != 0) - strcat(wxBuffer, "\\"); + strcat(wxBuffer, "\\"); strcat(wxBuffer, wxFileStruc.cFileName); return wxBuffer; #else @@ -1301,19 +1303,19 @@ char *wxFindFirstFile(const char *spec, int flags) if (attrib & _A_SUBDIR) { if (!(wxFindFileFlags & wxDIR)) - return wxFindNextFile(); + return wxFindNextFile(); } else if (wxFindFileFlags && !(wxFindFileFlags & wxFILE)) - return wxFindNextFile(); + return wxFindNextFile(); - if (wxBuffer[0] != 0) - strcat(wxBuffer, "\\"); + if (wxBuffer[0] != 0) + strcat(wxBuffer, "\\"); #ifdef __BORLANDC__ - strcat(wxBuffer, wxFileStruc.ff_name); + strcat(wxBuffer, wxFileStruc.ff_name); #else - strcat(wxBuffer, wxFileStruc.name); + strcat(wxBuffer, wxFileStruc.name); #endif - return wxBuffer; + return wxBuffer; } else return NULL; @@ -1327,21 +1329,21 @@ char *wxFindNextFile(void) wxString p2(wxFileSpec); char *p = wxPathOnly(WXSTRINGCAST p2); if (p && (strlen(p) > 0)) - strcpy(wxBuffer, p); + strcpy(wxBuffer, p); else - wxBuffer[0] = 0; - + wxBuffer[0] = 0; + try_again: #ifdef __WIN32__ if (wxFileStrucHandle == INVALID_HANDLE_VALUE) - return NULL; + return NULL; bool success = (FindNextFile(wxFileStrucHandle, &wxFileStruc) != 0); if (!success) { - FindClose(wxFileStrucHandle); + FindClose(wxFileStrucHandle); wxFileStrucHandle = INVALID_HANDLE_VALUE; - return NULL; + return NULL; } bool isdir = !!(wxFileStruc.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY); @@ -1349,12 +1351,12 @@ char *wxFindNextFile(void) if (isdir && !(wxFindFileFlags & wxDIR)) goto try_again; else if (!isdir && wxFindFileFlags && !(wxFindFileFlags & wxFILE)) - goto try_again; + goto try_again; if (wxBuffer[0] != 0) strcat(wxBuffer, "\\"); strcat(wxBuffer, wxFileStruc.cFileName); - return wxBuffer; + return wxBuffer; #else #ifdef __BORLANDC__ @@ -1374,19 +1376,19 @@ char *wxFindNextFile(void) if (attrib & _A_SUBDIR) { if (!(wxFindFileFlags & wxDIR)) - goto try_again; + goto try_again; } else if (wxFindFileFlags && !(wxFindFileFlags & wxFILE)) goto try_again; - if (wxBuffer[0] != 0) + if (wxBuffer[0] != 0) strcat(wxBuffer, "\\"); #ifdef __BORLANDC__ - strcat(wxBuffer, wxFileStruc.ff_name); + strcat(wxBuffer, wxFileStruc.ff_name); #else - strcat(wxBuffer, wxFileStruc.name); + strcat(wxBuffer, wxFileStruc.name); #endif - return wxBuffer; + return wxBuffer; } else return NULL; @@ -1403,7 +1405,7 @@ char *wxGetWorkingDirectory(char *buf, int sz) { if (!buf) buf = new char[sz+1]; -#ifdef _MSC_VER +#ifdef _MSC_VER if (_getcwd(buf, sz) == NULL) { #else if (getcwd(buf, sz) == NULL) { @@ -1462,7 +1464,7 @@ bool wxEndsWithPathSeparator(const char *pszFileName) bool wxFindFileInPath(wxString *pStr, const char *pszPath, const char *pszFile) { // we assume that it's not empty - wxCHECK_MSG( !IsEmpty(pszFile), FALSE, + wxCHECK_MSG( !IsEmpty(pszFile), FALSE, _("empty file name in wxFindFileInPath")); // skip path separator in the beginning of the file name if present @@ -1537,13 +1539,13 @@ bool wxIsWild( const wxString& pattern ) wxString tmp = pattern; char *pat = WXSTRINGCAST(tmp); while (*pat) { - switch (*pat++) { - case '?': case '*': case '[': case '{': - return TRUE; - case '\\': - if (!*pat++) - return FALSE; - } + switch (*pat++) { + case '?': case '*': case '[': case '{': + return TRUE; + case '\\': + if (!*pat++) + return FALSE; + } } return FALSE; }; @@ -1577,129 +1579,129 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) // dot_special means '.' only matches '.' if (dot_special && *str == '.' && *pattern != *str) - return FALSE; + return FALSE; while ((*pattern != '\0') && (!done) && (((*str=='\0')&&((*pattern==OB)||(*pattern=='*')))||(*str!='\0'))) { - switch (*pattern) { - case '\\': - pattern++; - if (*pattern != '\0') - pattern++; - break; - case '*': - pattern++; - ret_code = FALSE; - while ((*str!='\0') - && (!(ret_code=wxMatchWild(pattern, str++, FALSE)))) - /*loop*/; - if (ret_code) { - while (*str != '\0') - str++; - while (*pattern != '\0') - pattern++; - } - break; - case '[': - pattern++; - repeat: - if ((*pattern == '\0') || (*pattern == ']')) { - done = TRUE; - break; - } - if (*pattern == '\\') { - pattern++; - if (*pattern == '\0') { - done = TRUE; - break; - } - } - if (*(pattern + 1) == '-') { - c = *pattern; - pattern += 2; - if (*pattern == ']') { - done = TRUE; - break; - } - if (*pattern == '\\') { - pattern++; - if (*pattern == '\0') { - done = TRUE; - break; - } - } - if ((*str < c) || (*str > *pattern)) { - pattern++; - goto repeat; - } - } else if (*pattern != *str) { - pattern++; - goto repeat; - } - pattern++; - while ((*pattern != ']') && (*pattern != '\0')) { - if ((*pattern == '\\') && (*(pattern + 1) != '\0')) - pattern++; - pattern++; - } - if (*pattern != '\0') { - pattern++, str++; - } - break; - case '?': - pattern++; - str++; - break; - case OB: - pattern++; - while ((*pattern != CB) && (*pattern != '\0')) { - cp = str; - ok = TRUE; - while (ok && (*cp != '\0') && (*pattern != '\0') - && (*pattern != ',') && (*pattern != CB)) { - if (*pattern == '\\') - pattern++; - ok = (*pattern++ == *cp++); - } - if (*pattern == '\0') { - ok = FALSE; - done = TRUE; - break; - } else if (ok) { - str = cp; - while ((*pattern != CB) && (*pattern != '\0')) { - if (*++pattern == '\\') { - if (*++pattern == CB) - pattern++; - } - } - } else { - while (*pattern!=CB && *pattern!=',' && *pattern!='\0') { - if (*++pattern == '\\') { + switch (*pattern) { + case '\\': + pattern++; + if (*pattern != '\0') + pattern++; + break; + case '*': + pattern++; + ret_code = FALSE; + while ((*str!='\0') + && (!(ret_code=wxMatchWild(pattern, str++, FALSE)))) + /*loop*/; + if (ret_code) { + while (*str != '\0') + str++; + while (*pattern != '\0') + pattern++; + } + break; + case '[': + pattern++; + repeat: + if ((*pattern == '\0') || (*pattern == ']')) { + done = TRUE; + break; + } + if (*pattern == '\\') { + pattern++; + if (*pattern == '\0') { + done = TRUE; + break; + } + } + if (*(pattern + 1) == '-') { + c = *pattern; + pattern += 2; + if (*pattern == ']') { + done = TRUE; + break; + } + if (*pattern == '\\') { + pattern++; + if (*pattern == '\0') { + done = TRUE; + break; + } + } + if ((*str < c) || (*str > *pattern)) { + pattern++; + goto repeat; + } + } else if (*pattern != *str) { + pattern++; + goto repeat; + } + pattern++; + while ((*pattern != ']') && (*pattern != '\0')) { + if ((*pattern == '\\') && (*(pattern + 1) != '\0')) + pattern++; + pattern++; + } + if (*pattern != '\0') { + pattern++, str++; + } + break; + case '?': + pattern++; + str++; + break; + case OB: + pattern++; + while ((*pattern != CB) && (*pattern != '\0')) { + cp = str; + ok = TRUE; + while (ok && (*cp != '\0') && (*pattern != '\0') + && (*pattern != ',') && (*pattern != CB)) { + if (*pattern == '\\') + pattern++; + ok = (*pattern++ == *cp++); + } + if (*pattern == '\0') { + ok = FALSE; + done = TRUE; + break; + } else if (ok) { + str = cp; + while ((*pattern != CB) && (*pattern != '\0')) { + if (*++pattern == '\\') { + if (*++pattern == CB) + pattern++; + } + } + } else { + while (*pattern!=CB && *pattern!=',' && *pattern!='\0') { + if (*++pattern == '\\') { if (*++pattern == CB || *pattern == ',') - pattern++; - } - } - } - if (*pattern != '\0') - pattern++; - } - break; - default: - if (*str == *pattern) { - str++, pattern++; - } else { - done = TRUE; - } - } + pattern++; + } + } + } + if (*pattern != '\0') + pattern++; + } + break; + default: + if (*str == *pattern) { + str++, pattern++; + } else { + done = TRUE; + } + } } while (*pattern == '*') - pattern++; + pattern++; return ((*str == '\0') && (*pattern == '\0')); }; #endif -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(default:4706) // assignment within conditional expression #endif // VC++ diff --git a/src/common/log.cpp b/src/common/log.cpp index 8708f2debc..03267bf2d3 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -986,7 +986,7 @@ void wxOnAssert(const char *szFile, int nLine, const char *szMsg) // make life easier for people using VC++ IDE: clicking on the message will // take us immediately to the place of the failed assert -#ifdef _MSC_VER +#ifdef __VISUALC__ sprintf(szBuf, _("%s(%d): assert failed"), szFile, nLine); #else // !VC++ // make the error message more clear for all the others diff --git a/src/common/memory.cpp b/src/common/memory.cpp index 81245b504f..7cac322e8d 100644 --- a/src/common/memory.cpp +++ b/src/common/memory.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -38,15 +38,12 @@ #include #include +#include "wx/ioswrap.h" + #if wxUSE_IOSTREAMH -#include -#include + #include #else -#include -#include -# ifdef _MSC_VER - using namespace std; -# endif + #include #endif #if !defined(__WATCOMC__) && !defined(__VMS__) && !defined( __MWERKS__ ) && !defined(__SALFORDC__) @@ -78,8 +75,8 @@ // wxDebugContext wxTheDebugContext; /* Redefine new and delete so that we can pick up situations where: - - we overwrite or underwrite areas of malloc'd memory. - - we use uninitialise variables + - we overwrite or underwrite areas of malloc'd memory. + - we use uninitialise variables Only do this in debug mode. We change new to get enough memory to allocate a struct, followed @@ -116,7 +113,7 @@ void wxMemStruct::ErrorMsg (const char * mesg) wxLogDebug("wxWindows memory checking error: %s", mesg); PrintNode (); -// << m_fileName << ' ' << m_lineNum << endl; +// << m_fileName << ' ' << m_lineNum << endl; } /* @@ -126,7 +123,7 @@ void wxMemStruct::ErrorMsg () { wxLogDebug("wxWindows over/underwrite memory error:"); PrintNode (); - + // cerr << m_fileName << ' ' << m_lineNum << endl; } @@ -141,9 +138,9 @@ void wxMemStruct::ErrorMsg () int wxMemStruct::AssertList () { if (wxDebugContext::GetHead () != 0 && ! (wxDebugContext::GetHead ())->AssertIt () || - wxDebugContext::GetTail () != 0 && ! wxDebugContext::GetTail ()->AssertIt ()) { - ErrorMsg ("Head or tail pointers trashed"); - return 0; + wxDebugContext::GetTail () != 0 && ! wxDebugContext::GetTail ()->AssertIt ()) { + ErrorMsg ("Head or tail pointers trashed"); + return 0; } return 1; } @@ -163,8 +160,8 @@ int wxMemStruct::AssertList () int wxMemStruct::AssertIt () { return (m_id == MemStructId && - (m_prev == 0 || m_prev->m_id == MemStructId) && - (m_next == 0 || m_next->m_id == MemStructId)); + (m_prev == 0 || m_prev->m_id == MemStructId) && + (m_next == 0 || m_next->m_id == MemStructId)); } @@ -175,19 +172,19 @@ int wxMemStruct::AssertIt () int wxMemStruct::Append () { if (! AssertList ()) - return 0; + return 0; if (wxDebugContext::GetHead () == 0) { - if (wxDebugContext::GetTail () != 0) { - ErrorMsg ("Null list should have a null tail pointer"); - return 0; - } - (void) wxDebugContext::SetHead (this); - (void) wxDebugContext::SetTail (this); + if (wxDebugContext::GetTail () != 0) { + ErrorMsg ("Null list should have a null tail pointer"); + return 0; + } + (void) wxDebugContext::SetHead (this); + (void) wxDebugContext::SetTail (this); } else { - wxDebugContext::GetTail ()->m_next = this; - this->m_prev = wxDebugContext::GetTail (); - (void) wxDebugContext::SetTail (this); + wxDebugContext::GetTail ()->m_next = this; + this->m_prev = wxDebugContext::GetTail (); + (void) wxDebugContext::SetTail (this); } return 1; } @@ -201,51 +198,51 @@ int wxMemStruct::Append () int wxMemStruct::Unlink () { if (! AssertList ()) - return 0; + return 0; if (wxDebugContext::GetHead () == 0 || wxDebugContext::GetTail () == 0) { - ErrorMsg ("Trying to remove node from empty list"); - return 0; + ErrorMsg ("Trying to remove node from empty list"); + return 0; } // Handle the part of the list before this node. if (m_prev == 0) { - if (this != wxDebugContext::GetHead ()) { - ErrorMsg ("No previous node for non-head node"); - return 0; - } - (void) wxDebugContext::SetHead (m_next); + if (this != wxDebugContext::GetHead ()) { + ErrorMsg ("No previous node for non-head node"); + return 0; + } + (void) wxDebugContext::SetHead (m_next); } else { - if (! m_prev->AssertIt ()) { - ErrorMsg ("Trashed previous pointer"); - return 0; - } - - if (m_prev->m_next != this) { - ErrorMsg ("List is inconsistent"); - return 0; - } - m_prev->m_next = m_next; + if (! m_prev->AssertIt ()) { + ErrorMsg ("Trashed previous pointer"); + return 0; + } + + if (m_prev->m_next != this) { + ErrorMsg ("List is inconsistent"); + return 0; + } + m_prev->m_next = m_next; } // Handle the part of the list after this node. if (m_next == 0) { - if (this != wxDebugContext::GetTail ()) { - ErrorMsg ("No next node for non-tail node"); - return 0; - } - (void) wxDebugContext::SetTail (m_prev); + if (this != wxDebugContext::GetTail ()) { + ErrorMsg ("No next node for non-tail node"); + return 0; + } + (void) wxDebugContext::SetTail (m_prev); } else { - if (! m_next->AssertIt ()) { - ErrorMsg ("Trashed next pointer"); - return 0; - } - - if (m_next->m_prev != this) { - ErrorMsg ("List is inconsistent"); - return 0; - } - m_next->m_prev = m_prev; + if (! m_next->AssertIt ()) { + ErrorMsg ("Trashed next pointer"); + return 0; + } + + if (m_next->m_prev != this) { + ErrorMsg ("List is inconsistent"); + return 0; + } + m_next->m_prev = m_prev; } return 1; @@ -262,22 +259,22 @@ int wxMemStruct::CheckBlock () int nFailures = 0; if (m_firstMarker != MemStartCheck) { - nFailures++; - ErrorMsg (); + nFailures++; + ErrorMsg (); } - + char * pointer = wxDebugContext::MidMarkerPos ((char *) this); if (* (wxMarkerType *) pointer != MemMidCheck) { - nFailures++; - ErrorMsg (); + nFailures++; + ErrorMsg (); } - + pointer = wxDebugContext::EndMarkerPos ((char *) this, RequestSize ()); if (* (wxMarkerType *) pointer != MemEndCheck) { - nFailures++; - ErrorMsg (); + nFailures++; + ErrorMsg (); } - + return nFailures; } @@ -288,12 +285,12 @@ int wxMemStruct::CheckBlock () int wxMemStruct::CheckAllPrevious () { int nFailures = 0; - + for (wxMemStruct * st = this->m_prev; st != 0; st = st->m_prev) { - if (st->AssertIt ()) - nFailures += st->CheckBlock (); - else - return -1; + if (st->AssertIt ()) + nFailures += st->CheckBlock (); + else + return -1; } return nFailures; @@ -366,7 +363,7 @@ void wxMemStruct::PrintNode () void wxMemStruct::Dump () { if (!ValidateNode()) return; - + if (m_isObject) { wxObject *obj = (wxObject *)m_actualData; @@ -416,15 +413,15 @@ int wxMemStruct::ValidateNode () { char * startPointer = (char *) this; if (!AssertIt ()) { - if (IsDeleted ()) - ErrorMsg ("Object already deleted"); - else { - // Can't use the error routines as we have no recognisable object. + if (IsDeleted ()) + ErrorMsg ("Object already deleted"); + else { + // Can't use the error routines as we have no recognisable object. #ifndef __WXGTK__ - wxLogDebug("Can't verify memory struct - all bets are off!"); + wxLogDebug("Can't verify memory struct - all bets are off!"); #endif - } - return 0; + } + return 0; } /* @@ -438,20 +435,20 @@ int wxMemStruct::ValidateNode () if (* (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) != MemMidCheck) ErrorMsg (); if (* (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer, - RequestSize ()) != - MemEndCheck) + RequestSize ()) != + MemEndCheck) ErrorMsg (); // Back to before the extra buffer and check that // we can still read what we originally wrote. if (Marker () != MemStartCheck || - * (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) - != MemMidCheck || - * (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer, - RequestSize ()) != MemEndCheck) + * (wxMarkerType *) wxDebugContext::MidMarkerPos (startPointer) + != MemMidCheck || + * (wxMarkerType *) wxDebugContext::EndMarkerPos (startPointer, + RequestSize ()) != MemEndCheck) { - ErrorMsg (); - return 0; + ErrorMsg (); + return 0; } return 1; @@ -588,7 +585,7 @@ char * wxDebugContext::EndMarkerPos (const char * buf, const size_t size) char * wxDebugContext::StartPos (const char * caller) { return ((char *) (caller - wxDebugContext::PaddedSize (sizeof(wxMarkerType)) - - wxDebugContext::PaddedSize (sizeof (wxMemStruct)))); + wxDebugContext::PaddedSize (sizeof (wxMemStruct)))); } /* @@ -620,7 +617,7 @@ size_t wxDebugContext::PaddedSize (const size_t size) size_t wxDebugContext::TotSize (const size_t reqSize) { return (PaddedSize (sizeof (wxMemStruct)) + PaddedSize (reqSize) + - 2 * sizeof(wxMarkerType)); + 2 * sizeof(wxMarkerType)); } @@ -631,7 +628,7 @@ void wxDebugContext::TraverseList (PmSFV func, wxMemStruct *from) { if (!from) from = wxDebugContext::GetHead (); - + for (wxMemStruct * st = from; st != 0; st = st->m_next) { void* data = st->GetActualData(); @@ -683,7 +680,7 @@ bool wxDebugContext::Dump(void) } } TraverseList ((PmSFV)&wxMemStruct::Dump, (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL)); - + wxLogDebug( "" ); wxLogDebug( "" ); @@ -739,10 +736,10 @@ bool wxDebugContext::PrintStatistics(bool detailed) wxLogDebug( "----- Memory statistics -----" ); } } - + bool currentMode = GetDebugMode(); SetDebugMode(FALSE); - + long noNonObjectNodes = 0; long noObjectNodes = 0; long totalSize = 0; @@ -753,7 +750,7 @@ bool wxDebugContext::PrintStatistics(bool detailed) if (!from) from = wxDebugContext::GetHead (); - wxMemStruct *st; + wxMemStruct *st; for (st = from; st != 0; st = st->m_next) { void* data = st->GetActualData(); @@ -803,7 +800,7 @@ bool wxDebugContext::PrintStatistics(bool detailed) } wxLogDebug(""); } - + SetDebugMode(currentMode); wxLogDebug("Number of object items: %ld", noObjectNodes); @@ -816,7 +813,7 @@ bool wxDebugContext::PrintStatistics(bool detailed) #else return FALSE; #endif -} +} bool wxDebugContext::PrintClasses(void) { @@ -874,7 +871,7 @@ bool wxDebugContext::PrintClasses(void) wxLogDebug(""); wxLogDebug(""); return TRUE; -} +} void wxDebugContext::SetCheckpoint(bool all) { @@ -888,7 +885,7 @@ void wxDebugContext::SetCheckpoint(bool all) int wxDebugContext::Check(bool checkAll) { int nFailures = 0; - + wxMemStruct *from = (checkPoint ? checkPoint->m_next : (wxMemStruct*)NULL ); if (!from || checkAll) from = wxDebugContext::GetHead (); @@ -942,7 +939,7 @@ int wxDebugContext::CountObjectsLeft(bool sinceCheckpoint) #endif // Seems OK all of a sudden. Maybe to do with linking with multithreaded library? -#if 0 // def _MSC_VER +#if 0 // def __VISUALC__ #define NO_DEBUG_ALLOCATION #endif @@ -1001,7 +998,7 @@ void operator delete (void * buf) } // VC++ 6.0 -#if _MSC_VER >= 1200 +#if defined(__VISUALC__) && (__VISUALC__ >= 1200) void operator delete(void* pData, char* /* fileName */, int /* lineNum */) { // ::operator delete(pData); @@ -1039,12 +1036,12 @@ void * wxDebugAlloc(size_t size, char * fileName, int lineNum, bool isObject, bo { return (void *)malloc(size); } - + int totSize = wxDebugContext::TotSize (size); char * buf = (char *) malloc(totSize); if (!buf) { - wxLogDebug("Call to malloc (%ld) failed.", (long)size); - return 0; + wxLogDebug("Call to malloc (%ld) failed.", (long)size); + return 0; } wxMemStruct * st = (wxMemStruct *)buf; st->m_firstMarker = MemStartCheck; @@ -1058,15 +1055,15 @@ void * wxDebugAlloc(size_t size, char * fileName, int lineNum, bool isObject, bo // Errors from Append() shouldn't really happen - but just in case! if (st->Append () == 0) { - st->ErrorMsg ("Trying to append new node"); + st->ErrorMsg ("Trying to append new node"); } - + if (wxDebugContext::GetCheckPrevious ()) { - if (st->CheckAllPrevious () < 0) { - st->ErrorMsg ("Checking previous nodes"); - } + if (st->CheckAllPrevious () < 0) { + st->ErrorMsg ("Checking previous nodes"); + } } - + // Set up the extra markers at the middle and end. char * ptr = wxDebugContext::MidMarkerPos (buf); * (wxMarkerType *) ptr = MemMidCheck; @@ -1086,7 +1083,7 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) ) { if (!buf) return; - + // If not in debugging allocation mode, do the normal thing // so we don't leave any trace of ourselves in the node list. if (!wxDebugContext::GetDebugMode()) @@ -1101,7 +1098,7 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) ) wxMemStruct * st = (wxMemStruct *) wxDebugContext::StructPos (startPointer); if (! st->ValidateNode ()) - return; + return; // If this is the current checkpoint, we need to // move the checkpoint back so it points to a valid @@ -1113,12 +1110,12 @@ void wxDebugFree(void * buf, bool WXUNUSED(isVect) ) { st->ErrorMsg ("Unlinking deleted node"); } - + // Now put in the fill char into the id slot and the caller requested // memory locations. st->SetDeleted (); (void) memset (wxDebugContext::CallerMemPos (startPointer), MemFillChar, - st->RequestSize ()); + st->RequestSize ()); // Don't allow delayed freeing of memory in this version // if (!wxDebugContext::GetDelayFree()) @@ -1160,7 +1157,7 @@ void wxTraceLevel(int level, const char *fmt ...) { if (wxDebugContext::GetLevel() < level) return; - + va_list ap; static char buffer[512]; diff --git a/src/common/object.cpp b/src/common/object.cpp index 4ac78acc23..acebb41729 100644 --- a/src/common/object.cpp +++ b/src/common/object.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -40,15 +40,8 @@ #endif #if defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT - // for wxObject::Dump -#if wxUSE_IOSTREAMH -# include -#else -# include -# ifdef _MSC_VER - using namespace std; -# endif -#endif + // for wxObject::Dump + #include "wx/ioswrap.h" #endif #if !USE_SHARED_LIBRARY @@ -121,7 +114,7 @@ void wxObject::operator delete (void * buf) } // VC++ 6.0 -#if _MSC_VER >= 1200 +#if defined(__VISUALC__) && (__VISUALC__ >= 1200) void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum */) { ::operator delete(pData); @@ -129,7 +122,7 @@ void wxObject::operator delete(void* pData, char* /* fileName */, int /* lineNum #endif // Cause problems for VC++ - crashes -#if !defined(_MSC_VER) && wxUSE_ARRAY_MEMORY_OPERATORS +#if !defined(__VISUALC__) && wxUSE_ARRAY_MEMORY_OPERATORS void * wxObject::operator new[] (size_t size, char * fileName, int lineNum) { return wxDebugAlloc(size, fileName, lineNum, TRUE, TRUE); diff --git a/src/common/odbc.cpp b/src/common/odbc.cpp index 576ee3a487..f82a986409 100644 --- a/src/common/odbc.cpp +++ b/src/common/odbc.cpp @@ -2,12 +2,12 @@ // Name: odbc.cpp // Purpose: ODBC implementation // Author: Julian Smart, Olaf Klein (oklein@smallo.ruhr.de), -// Patrick Halke (patrick@zaphod.ruhr.de) -// Modified by: +// Patrick Halke (patrick@zaphod.ruhr.de) +// Modified by: // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -25,7 +25,7 @@ #if wxUSE_ODBC -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(disable:4706) // assignment within conditional expression #endif // VC++ @@ -1831,7 +1831,7 @@ bool wxQueryField::IsDirty(void) { return dirty; } -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(default:4706) // assignment within conditional expression #endif // VC++ diff --git a/src/common/resourc2.cpp b/src/common/resourc2.cpp index 4bee887ddb..42deac36a0 100644 --- a/src/common/resourc2.cpp +++ b/src/common/resourc2.cpp @@ -22,7 +22,7 @@ #if wxUSE_WX_RESOURCES -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(disable:4706) // assignment within conditional expression #endif // VC++ @@ -1568,7 +1568,7 @@ wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemReso return table->CreateItem((wxWindow *)this, resource, parentResource); } -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(default:4706) // assignment within conditional expression #endif // VC++ diff --git a/src/common/resource.cpp b/src/common/resource.cpp index 031a211c74..7b8918622c 100644 --- a/src/common/resource.cpp +++ b/src/common/resource.cpp @@ -22,7 +22,7 @@ #if wxUSE_WX_RESOURCES -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(disable:4706) // assignment within conditional expression #endif // VC++ @@ -2916,7 +2916,7 @@ wxControl *wxWindow::CreateItem(const wxItemResource *resource, const wxItemReso return table->CreateItem((wxWindow *)this, resource, parentResource); } -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(default:4706) // assignment within conditional expression #endif // VC++ diff --git a/src/common/socket.cpp b/src/common/socket.cpp index e4d22c8e4a..56c601c617 100644 --- a/src/common/socket.cpp +++ b/src/common/socket.cpp @@ -97,7 +97,7 @@ void wxMacProcessEvents() ; #include #include -#ifdef _MSC_VER +#ifdef __VISUALC__ #include #endif @@ -157,7 +157,7 @@ void wxMacProcessEvents() ; // implementations (such as PC-NFS) will require you to include this // or a similar routine (see appendix in WinSock doc or help file). -#if defined( NEED_WSAFDIsSet ) || defined( _MSC_VER ) +#if defined( NEED_WSAFDIsSet ) || defined( __VISUALC__ ) int PASCAL FAR __WSAFDIsSet(SOCKET fd, fd_set FAR *set) { int i = set->fd_count; @@ -440,9 +440,9 @@ wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, size_t nbytes) SockMsg msg; // warning about 'cast truncates constant value' -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(disable: 4310) -#endif // _MSC_VER +#endif // __VISUALC__ msg.sig[0] = (char) 0xad; msg.sig[1] = (char) 0xde; @@ -468,9 +468,9 @@ wxSocketBase& wxSocketBase::WriteMsg(const char *buffer, size_t nbytes) return *this; -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(default: 4310) -#endif // _MSC_VER +#endif // __VISUALC__ } wxSocketBase& wxSocketBase::Unread(const char *buffer, size_t nbytes) diff --git a/src/common/string.cpp b/src/common/string.cpp index deb0d43978..1107cc55cf 100644 --- a/src/common/string.cpp +++ b/src/common/string.cpp @@ -90,7 +90,7 @@ extern const char WXDLLEXPORT *g_szNul = &g_strEmpty.dummy; // function: for Unix this is done with configure, for Windows we test the // compiler explicitly. #ifdef __WXMSW__ - #ifdef _MSC_VER + #ifdef __VISUALC__ #define wxVsprintf _vsnprintf #endif #else // !Windows @@ -107,7 +107,7 @@ extern const char WXDLLEXPORT *g_szNul = &g_strEmpty.dummy; #ifndef __SC__ #pragma message("Using sprintf() because no snprintf()-like function defined") #endif -#endif +#endif // no vsnprintf // ---------------------------------------------------------------------------- // global functions @@ -119,46 +119,18 @@ extern const char WXDLLEXPORT *g_szNul = &g_strEmpty.dummy; // iostream ones. // // ATTN: you can _not_ use both of these in the same program! -#if wxUSE_IOSTREAMH -#include -#define NAMESPACE -#else -#include -# ifdef _MSC_VER - using namespace std; -# endif -// for msvc (bcc50+ also) you don't need these NAMESPACE defines, -// using namespace std; takes care of that. -#define NAMESPACE std:: -#endif - -#ifdef __WXMSW__ - #ifdef _MSC_VER - #define wxVsprintf _vsnprintf - #endif -#else - #if defined ( HAVE_VSNPRINTF ) - #define wxVsprintf vsnprintf - #endif -#endif -#ifndef wxVsprintf - // vsprintf() is ANSI so we can always use it, but it's unsafe! - #define wxVsprintf(buffer,len,format,argptr) vsprintf(buffer,format, argptr) - #pragma message("Using sprintf() because no snprintf()-like function defined") -#endif - -NAMESPACE istream& operator>>(NAMESPACE istream& is, wxString& WXUNUSED(str)) +istream& operator>>(istream& is, wxString& WXUNUSED(str)) { #if 0 int w = is.width(0); if ( is.ipfx(0) ) { - NAMESPACE streambuf *sb = is.rdbuf(); + streambuf *sb = is.rdbuf(); str.erase(); while ( true ) { int ch = sb->sbumpc (); if ( ch == EOF ) { - is.setstate(NAMESPACE ios::eofbit); + is.setstate(ios::eofbit); break; } else if ( isspace(ch) ) { @@ -174,7 +146,7 @@ NAMESPACE istream& operator>>(NAMESPACE istream& is, wxString& WXUNUSED(str)) is.isfx(); if ( str.length() == 0 ) - is.setstate(NAMESPACE ios::failbit); + is.setstate(ios::failbit); #endif return is; } @@ -1142,12 +1114,12 @@ size_t wxString::find(const wxString& str, size_t nStart) const } // VC++ 1.5 can't cope with the default argument in the header. -#if ! (defined(_MSC_VER) && !defined(__WIN32__)) +#if !defined(__VISUALC__) || defined(__WIN32__) size_t wxString::find(const char* sz, size_t nStart, size_t n) const { return find(wxString(sz, n == npos ? 0 : n), nStart); } -#endif +#endif // VC++ 1.5 // Gives a duplicate symbol (presumably a case-insensitivity problem) #if !defined(__BORLANDC__) @@ -1178,7 +1150,7 @@ size_t wxString::rfind(const wxString& str, size_t nStart) const } // VC++ 1.5 can't cope with the default argument in the header. -#if ! (defined(_MSC_VER) && !defined(__WIN32__)) +#if !defined(__VISUALC__) || defined(__WIN32__) size_t wxString::rfind(const char* sz, size_t nStart, size_t n) const { return rfind(wxString(sz, n == npos ? 0 : n), nStart); @@ -1192,7 +1164,7 @@ size_t wxString::rfind(char ch, size_t nStart) const return p == NULL ? npos : p - c_str(); } -#endif +#endif // VC++ 1.5 wxString wxString::substr(size_t nStart, size_t nLen) const { diff --git a/src/common/time.cpp b/src/common/time.cpp index d709f8b212..71ad2fac3a 100644 --- a/src/common/time.cpp +++ b/src/common/time.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -32,17 +32,14 @@ seconds since January 1, 1901, GMT. #include "wx/time.h" #include "wx/date.h" #include "wx/utils.h" -#include +#include "wx/intl.h" + +#include "wx/ioswrap.h" #if wxUSE_IOSTREAMH -#include -#include + #include #else -#include -#include -# ifdef _MSC_VER - using namespace std; -# endif + #include #endif #include @@ -60,8 +57,8 @@ static int DST_OBSERVED; /* flags U.S. daylight saving time observed */ static bool wxTimeInitialized = FALSE; -wxTime::tFormat wxTime::Format = wxTime::wx12h; -wxTime::tPrecision wxTime::Precision = wxTime::wxStdMinSec; +wxTime::tFormat wxTime::Format = wxTime::wx12h; +wxTime::tPrecision wxTime::Precision = wxTime::wxStdMinSec; static const unsigned long seconds_in_day = 24*60*60L; static const wxDate refDate(1,1,1901); @@ -69,19 +66,19 @@ static const wxDate refDate(1,1,1901); wxTime wxTime::GetLocalTime(const wxDate& date, hourTy h, minuteTy m, secondTy s) /* - Return a local wxTime for the specified Standard Time date, hour, minute, - and second. + Return a local wxTime for the specified Standard Time date, hour, minute, + and second. */ { if (!wxTimeInitialized) { - wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); - wxTimeInitialized = TRUE; + wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); + wxTimeInitialized = TRUE; } /* - if (!date.IsBetween(refDate,maxDate)) - setError(NIHCL_DATERANGE,DEFAULT, - date.dayOfMonth(),date.nameOfMonth(),date.year()); + if (!date.IsBetween(refDate,maxDate)) + setError(NIHCL_DATERANGE,DEFAULT, + date.dayOfMonth(),date.nameOfMonth(),date.year()); */ // The following line causes an error in GCC 2.1 // long daysBetween = date-refDate; @@ -95,13 +92,13 @@ wxTime wxTime::GetLocalTime(const wxDate& date, hourTy h, minuteTy m, secondTy s wxTime::wxTime() /* - Construct a wxTime for this instant. + Construct a wxTime for this instant. */ { if (!wxTimeInitialized) { - wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); - wxTimeInitialized = TRUE; + wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); + wxTimeInitialized = TRUE; } sec = wxGetCurrentTime(); #ifdef __SALFORDC__ @@ -113,14 +110,14 @@ wxTime::wxTime() wxTime::wxTime(hourTy h, minuteTy m, secondTy s, bool dst) /* - Construct a wxTime for today at the specified (local) hour, minute, and - second. + Construct a wxTime for today at the specified (local) hour, minute, and + second. */ { if (!wxTimeInitialized) { - wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); - wxTimeInitialized = TRUE; + wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); + wxTimeInitialized = TRUE; } sec = wxTime(wxDate(),h,m,s,dst).sec; @@ -136,7 +133,7 @@ wxTime::wxTime(const wxDate& date, hourTy h, minuteTy m, secondTy s, bool dst) if (!wxTimeInitialized) { wxGetLocalTime(&TIME_ZONE, &DST_OBSERVED); - wxTimeInitialized = TRUE; + wxTimeInitialized = TRUE; } sec = GetLocalTime(date,h,m,s).sec-3600; if (IsDST()) @@ -149,8 +146,8 @@ wxTime::wxTime(const wxDate& date, hourTy h, minuteTy m, secondTy s, bool dst) sec += 3600; /* if (IsDST()) setError(NIHCL_BADTIME,DEFAULT, - date.dayOfMonth(),date.nameOfMonth(),date.year(), - h,m,s,(dst?_("DST"):"")); + date.dayOfMonth(),date.nameOfMonth(),date.year(), + h,m,s,(dst?_("DST"):"")); */ } sec += TIME_ZONE; // adjust to GMT @@ -159,11 +156,11 @@ wxTime::wxTime(const wxDate& date, hourTy h, minuteTy m, secondTy s, bool dst) #ifndef __SALFORDC__ wxTime::operator wxDate() const /* - Convert a wxTime to a local wxDate + Convert a wxTime to a local wxDate */ { // return wxDate((int)(GetLocalTime().sec/seconds_in_day)); 4.2 cc bug - long daycount = (long)(GetLocalTime().sec/seconds_in_day); + long daycount = (long)(GetLocalTime().sec/seconds_in_day); wxDate date(1,1,1901); date += daycount; @@ -178,11 +175,11 @@ bool wxTime::IsBetween(const wxTime& a, const wxTime& b) const hourTy wxTime::GetHour() const /* - Return the hour of this wxTime in local time; i.e., adjust for + Return the hour of this wxTime in local time; i.e., adjust for time zone and Daylight Savings Time. */ { - return GetLocalTime().GetHourGMT(); + return GetLocalTime().GetHourGMT(); } hourTy wxTime::GetHourGMT() const @@ -190,12 +187,12 @@ hourTy wxTime::GetHourGMT() const Return the hour of this Time in GMT. */ { - return (hourTy)((sec % 86400) / 3600); + return (hourTy)((sec % 86400) / 3600); } wxTime wxTime::GetBeginDST(unsigned year) /* - Return the local Standard Time at which Daylight Savings Time + Return the local Standard Time at which Daylight Savings Time begins in the specified year. */ { @@ -203,8 +200,8 @@ wxTime wxTime::GetBeginDST(unsigned year) wxTime DSTtime(GetLocalTime(wxDate(3,31,year).Previous(1)+7,2)); if (year<=1986) { // Previous Sunday - DSTtime = GetLocalTime(wxDate(4,30,year).Previous(1),2); - if (year==1974) DSTtime = GetLocalTime(wxDate(1,6,1974),2); + DSTtime = GetLocalTime(wxDate(4,30,year).Previous(1),2); + if (year==1974) DSTtime = GetLocalTime(wxDate(1,6,1974),2); if (year==1975) DSTtime = GetLocalTime(wxDate(2,23,1975),2); } return DSTtime; @@ -216,8 +213,8 @@ wxTime wxTime::GetEndDST(unsigned year) ends in the specified year. */ { - wxTime STDtime(GetLocalTime(wxDate(10,31,year).Previous(1),2-1)); - return STDtime; + wxTime STDtime(GetLocalTime(wxDate(10,31,year).Previous(1),2-1)); + return STDtime; } bool wxTime::IsDST() const @@ -229,12 +226,12 @@ bool wxTime::IsDST() const long daycount = (long)(sec/seconds_in_day); // At this point, daycount is the number of days from 1/1/1901. - // Need to convert to julian date (which starts at 1/1/4713 B.C.) - wxDate date(1,1,1901); + // Need to convert to julian date (which starts at 1/1/4713 B.C.) + wxDate date(1,1,1901); date += daycount; unsigned year = date.GetYear(); - if (DST_OBSERVED) + if (DST_OBSERVED) { if (*this >= GetBeginDST(year)) if (*this < GetEndDST(year)) return TRUE; @@ -247,7 +244,7 @@ wxTime wxTime::GetLocalTime() const Adjusts this GM Time for local time zone and Daylight Savings Time. */ { - wxTime local_time(sec-TIME_ZONE); + wxTime local_time(sec-TIME_ZONE); if (local_time.IsDST()) local_time.sec += 3600; return local_time; } @@ -255,7 +252,7 @@ wxTime wxTime::GetLocalTime() const minuteTy wxTime::GetMinute() const /* Return the minute of this wxTime in local time; i.e., adjust - for time zone and Daylight Savings Time. + for time zone and Daylight Savings Time. */ { return GetLocalTime().GetMinuteGMT(); @@ -266,7 +263,7 @@ minuteTy wxTime::GetMinuteGMT() const Return the minute of this wxTime in GMT. */ { - return (minuteTy)(((sec % 86400) % 3600) / 60); + return (minuteTy)(((sec % 86400) % 3600) / 60); } secondTy wxTime::GetSecond() const @@ -274,7 +271,7 @@ secondTy wxTime::GetSecond() const Return the second of this wxTime. */ { - return (secondTy)(((sec % 86400) % 3600) % 60); + return (secondTy)(((sec % 86400) % 3600) % 60); } secondTy wxTime::GetSecondGMT() const @@ -318,7 +315,7 @@ wxTime wxTime::Max(const wxTime& t) const wxTime wxTime::Min(const wxTime& t) const { if (t > *this) return *this; - return t; + return t; } #ifndef __SALFORDC__ @@ -329,46 +326,46 @@ wxTime::operator char *(void) #endif void wxTime::SetFormat(const wxTime::tFormat lFormat, - const wxTime::tPrecision lPrecision) { + const wxTime::tPrecision lPrecision) { - wxTime::Format = lFormat; - wxTime::Precision = lPrecision; + wxTime::Format = lFormat; + wxTime::Precision = lPrecision; } char *wxTime::FormatTime() const { - static char timeBuf[30]; - unsigned hh(GetHour()); - - switch (Format) { - case wx12h: - hh -= 12; - break; - case wx24h: - break; - } - - switch (Precision) { - case wxStdMinSec: - sprintf(timeBuf,"%2d:%02d:%02d",hh,GetMinute(),GetSecond()); - break; - case wxStdMin: - sprintf(timeBuf,"%2d:%02d",hh,GetMinute()); - break; - } - - if (Format == wx12h) - if (GetHour() <= 12) - strcat(timeBuf,_("am")); - else - strcat(timeBuf,_("pm")); - - return timeBuf; + static char timeBuf[30]; + unsigned hh(GetHour()); + + switch (Format) { + case wx12h: + hh -= 12; + break; + case wx24h: + break; + } + + switch (Precision) { + case wxStdMinSec: + sprintf(timeBuf,"%2d:%02d:%02d",hh,GetMinute(),GetSecond()); + break; + case wxStdMin: + sprintf(timeBuf,"%2d:%02d",hh,GetMinute()); + break; + } + + if (Format == wx12h) + if (GetHour() <= 12) + strcat(timeBuf,_("am")); + else + strcat(timeBuf,_("pm")); + + return timeBuf; } /* int wxTime::compare(const Object& ob) const { - assertArgSpecies(ob,classDesc,"compare"); + assertArgSpecies(ob,classDesc,"compare"); register clockTy t = castdown(ob).sec; if (sec < t) return -1; if (sec > t) return 1; @@ -392,16 +389,16 @@ void wxTime::printOn(ostream& strm) const wxDate(*this).printOn(strm); strm << ' ' << ((hh <= 12) ? hh : hh-12) << ':' << setfill('0') << setw(2) << GetMinute() << ':' - << setfill('0') << setw(2) << GetSecond() << ' '; + << setfill('0') << setw(2) << GetSecond() << ' '; if (hh < 12) strm << _("am"); else strm << _("pm"); } wxTime::wxTime(OIOin& strm) - : BASE(strm) + : BASE(strm) { - unsigned long usec; - strm >> sec >> usec; + unsigned long usec; + strm >> sec >> usec; } void wxTime::storer(OIOout& strm) const @@ -412,16 +409,16 @@ void wxTime::storer(OIOout& strm) const wxTime::wxTime(OIOifd& fd) - : BASE(fd) + : BASE(fd) { - unsigned long usec; - fd >> sec >> usec; + unsigned long usec; + fd >> sec >> usec; } void wxTime::storer(OIOofd& fd) const { - BASE::storer(fd); - fd << sec << 0l; + BASE::storer(fd); + fd << sec << 0l; } */ diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 1488ca866c..57fcf3bd32 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -6,7 +6,7 @@ // Created: 29/01/98 // RCS-ID: $Id$ // Copyright: (c) 1998 Julian Smart -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -30,15 +30,12 @@ #include "wx/textdlg.h" #endif +#include "wx/ioswrap.h" + #if wxUSE_IOSTREAMH -#include -#include + #include #else -#include -#include -# ifdef _MSC_VER - using namespace std; -# endif + #include #endif #include @@ -46,9 +43,9 @@ #include #include #if !defined(__WATCOMC__) -#if !(defined(_MSC_VER) && (_MSC_VER > 800)) -#include -#endif + #if !(defined(_MSC_VER) && (_MSC_VER > 800)) + #include + #endif #endif #include #ifndef __MWERKS__ @@ -92,14 +89,14 @@ int strncasecmp(const char *str_1, const char *str_2, size_t maxchar) { register char c1, c2; - while( maxchar--) + while( maxchar--) { c1 = tolower(*str_1++); c2 = tolower(*str_2++); - + if ( !c1 || c1!=c2 ) - return c1 - c2; - + return c1 - c2; + } ; return 0 ; @@ -163,14 +160,6 @@ int strncasecmp(const char *str_1, const char *str_2, size_t maxchar) #endif #endif -#ifdef _MSC_VER -#pragma warning (disable : 4245) -#endif - -#ifdef _MSC_VER -#pragma warning (default : 4245) -#endif - #else // This declaration is missing in SunOS! // (Yes, I know it is NOT ANSI-C but its in BSD libc) @@ -181,7 +170,7 @@ extern "C" int strncasecmp (const char *, const char *, size_t); } #endif -#endif /* __WXMSW__ */ +#endif /* __WXMSW__ */ char * @@ -191,7 +180,7 @@ copystring (const char *s) size_t len = strlen (s) + 1; char *news = new char[len]; - memcpy (news, s, len); // Should be the fastest + memcpy (news, s, len); // Should be the fastest return news; } @@ -199,7 +188,7 @@ copystring (const char *s) // Id generation static long wxCurrentId = 100; -long +long wxNewId (void) { return wxCurrentId++; @@ -208,21 +197,21 @@ wxNewId (void) long wxGetCurrentId(void) { return wxCurrentId; } -void +void wxRegisterId (long id) { if (id >= wxCurrentId) wxCurrentId = id + 1; } -void +void StringToFloat (char *s, float *number) { if (s && *s && number) *number = (float) strtod (s, (char **) NULL); } -void +void StringToDouble (char *s, double *number) { if (s && *s && number) @@ -248,14 +237,14 @@ DoubleToString (double number, const char *fmt) return buf; } -void +void StringToInt (char *s, int *number) { if (s && *s && number) *number = (int) strtol (s, (char **) NULL, 10); } -void +void StringToLong (char *s, long *number) { if (s && *s && number) @@ -288,7 +277,7 @@ static char hexArray[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A' int wxHexToDec(const wxString& buf) { int firstDigit, secondDigit; - + if (buf.GetChar(0) >= 'A') firstDigit = buf.GetChar(0) - 'A' + 10; else @@ -298,7 +287,7 @@ int wxHexToDec(const wxString& buf) secondDigit = buf.GetChar(1) - 'A' + 10; else secondDigit = buf.GetChar(1) - '0'; - + return firstDigit * 16 + secondDigit; } @@ -321,7 +310,7 @@ wxString wxDecToHex(int dec) } // Match a string INDEPENDENT OF CASE -bool +bool StringMatch (char *str1, char *str2, bool subString, bool exact) { if (str1 == NULL || str2 == NULL) @@ -338,15 +327,15 @@ StringMatch (char *str1, char *str2, bool subString, bool exact) // Search for str1 in str2 // Slow .... but acceptable for short strings for (i = 0; i <= len2 - len1; i++) - { - if (strncasecmp (str1, str2 + i, len1) == 0) - return TRUE; - } + { + if (strncasecmp (str1, str2 + i, len1) == 0) + return TRUE; + } } else if (exact) { if (strcasecmp (str1, str2) == 0) - return TRUE; + return TRUE; } else { @@ -354,7 +343,7 @@ StringMatch (char *str1, char *str2, bool subString, bool exact) int len2 = strlen (str2); if (strncasecmp (str1, str2, wxMin (len1, len2)) == 0) - return TRUE; + return TRUE; } return FALSE; @@ -365,7 +354,7 @@ StringMatch (char *str1, char *str2, bool subString, bool exact) wxString wxNow( void ) { time_t now = time((time_t *) NULL); - char *date = ctime(&now); + char *date = ctime(&now); date[24] = '\0'; return wxString(date); } @@ -400,31 +389,31 @@ char *wxStripMenuCodes (char *in, char *out) { if (!in) return (char *) NULL; - + if (!out) out = copystring(in); char *tmpOut = out; - + while (*in) { if (*in == '&') - { - // Check && -> &, &x -> x - if (*++in == '&') - *out++ = *in++; - } + { + // Check && -> &, &x -> x + if (*++in == '&') + *out++ = *in++; + } else if (*in == '\t') - { + { // Remove all stuff after \t in X mode, and let the stuff as is // in Windows mode. // Accelerators are handled in wx_item.cc for Motif, and are not // YET supported in XView - break; - } + break; + } else - *out++ = *in++; - } // while + *out++ = *in++; + } // while *out = '\0'; @@ -463,12 +452,12 @@ wxFindWindowByLabel (const wxString& title, wxWindow * parent) else { for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ()) - { - wxWindow *win = (wxWindow *) node->Data (); - wxWindow *retwin = wxFindWindowByLabel1 (title, win); - if (retwin) - return retwin; - } // for() + { + wxWindow *win = (wxWindow *) node->Data (); + wxWindow *retwin = wxFindWindowByLabel1 (title, win); + if (retwin) + return retwin; + } // for() } return (wxWindow *) NULL; @@ -481,22 +470,22 @@ wxFindWindowByLabel1 (const wxString& title, wxWindow * parent) if (parent) { if (parent->GetLabel() == title) - return parent; + return parent; } if (parent) { for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ()) - { - wxWindow *win = (wxWindow *) node->Data (); - wxWindow *retwin = wxFindWindowByLabel1 (title, win); - if (retwin) - return retwin; - } // for() + { + wxWindow *win = (wxWindow *) node->Data (); + wxWindow *retwin = wxFindWindowByLabel1 (title, win); + if (retwin) + return retwin; + } // for() } - return (wxWindow *) NULL; // Not found + return (wxWindow *) NULL; // Not found } @@ -518,12 +507,12 @@ wxFindWindowByName (const wxString& title, wxWindow * parent) else { for (wxNode * node = wxTopLevelWindows.First (); node; node = node->Next ()) - { - wxWindow *win = (wxWindow *) node->Data (); - wxWindow *retwin = wxFindWindowByName1 (title, win); - if (retwin) - return retwin; - } // for() + { + wxWindow *win = (wxWindow *) node->Data (); + wxWindow *retwin = wxFindWindowByName1 (title, win); + if (retwin) + return retwin; + } // for() } // Failed? Try by label instead. @@ -536,28 +525,28 @@ wxFindWindowByName1 (const wxString& title, wxWindow * parent) { if (parent) { - if ( parent->GetName() == title ) - return parent; + if ( parent->GetName() == title ) + return parent; } if (parent) { for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ()) - { - wxWindow *win = (wxWindow *) node->Data (); - wxWindow *retwin = wxFindWindowByName1 (title, win); - if (retwin) - return retwin; - } // for() + { + wxWindow *win = (wxWindow *) node->Data (); + wxWindow *retwin = wxFindWindowByName1 (title, win); + if (retwin) + return retwin; + } // for() } - return (wxWindow *) NULL; // Not found + return (wxWindow *) NULL; // Not found } // Returns menu item id or -1 if none. -int +int wxFindMenuItemId (wxFrame * frame, const wxString& menuString, const wxString& itemString) { wxMenuBar *menuBar = frame->GetMenuBar (); @@ -572,12 +561,12 @@ On Fri, 21 Jul 1995, Paul Craven wrote: > Is there a way to find the path of running program's executable? I can get > my home directory, and the current directory, but I don't know how to get the > executable directory. -> +> The code below (warty as it is), does what you want on most Unix, DOS, and Mac platforms (it's from the ALS Prolog main). -|| Ken Bowen Applied Logic Systems, Inc. PO Box 180, +|| Ken Bowen Applied Logic Systems, Inc. PO Box 180, ||==== Voice: +1 (617)965-9191 Newton Centre, || FAX: +1 (617)965-1636 MA 02159 USA Email: ken@als.com WWW: http://www.als.com @@ -590,8 +579,8 @@ DOS, and Mac platforms (it's from the ALS Prolog main). /*--------------------------------------------------------------------* | whereami is given a filename f in the form: whereami(argv[0]) - | It returns the directory in which the executable file (containing - | this code [main.c] ) may be found. A dot will be returned to indicate + | It returns the directory in which the executable file (containing + | this code [main.c] ) may be found. A dot will be returned to indicate | the current directory. *--------------------------------------------------------------------*/ @@ -599,7 +588,7 @@ static void whereami(name) char *name; { - register char *cutoff = NULL; /* stifle -Wall */ + register char *cutoff = NULL; /* stifle -Wall */ register char *s; register char *t; int cc; @@ -612,117 +601,117 @@ whereami(name) if (access(name, R_OK) == 0) { - /*-------------------------------------------------------------* - * The file was accessible without any other work. But the current - * working directory might change on us, so if it was accessible - * through the cwd, then we should get it for later accesses. - *-------------------------------------------------------------*/ + /*-------------------------------------------------------------* + * The file was accessible without any other work. But the current + * working directory might change on us, so if it was accessible + * through the cwd, then we should get it for later accesses. + *-------------------------------------------------------------*/ - t = imagedir; - if (!absolute_pathname(name)) { + t = imagedir; + if (!absolute_pathname(name)) { #if defined(DOS) || defined(__WIN32__) - int drive; - char *newrbuf; + int drive; + char *newrbuf; - newrbuf = imagedir; + newrbuf = imagedir; #ifndef __DJGPP__ - if (*(name + 1) == ':') { - if (*name >= 'a' && *name <= 'z') - drive = (int) (*name - 'a' + 1); - else - drive = (int) (*name - 'A' + 1); - *newrbuf++ = *name; - *newrbuf++ = *(name + 1); - *newrbuf++ = DIR_SEPARATOR; - } - else { - drive = 0; - *newrbuf++ = DIR_SEPARATOR; - } - if (getcwd(newrbuf, drive) == 0) { /* } */ + if (*(name + 1) == ':') { + if (*name >= 'a' && *name <= 'z') + drive = (int) (*name - 'a' + 1); + else + drive = (int) (*name - 'A' + 1); + *newrbuf++ = *name; + *newrbuf++ = *(name + 1); + *newrbuf++ = DIR_SEPARATOR; + } + else { + drive = 0; + *newrbuf++ = DIR_SEPARATOR; + } + if (getcwd(newrbuf, drive) == 0) { /* } */ #else - if (getcwd(newrbuf, 1024) == 0) { /* } */ + if (getcwd(newrbuf, 1024) == 0) { /* } */ #endif #else /* DOS */ #ifdef HAVE_GETWD - if (getwd(imagedir) == 0) { /* } */ + if (getwd(imagedir) == 0) { /* } */ #else /* !HAVE_GETWD */ - if (getcwd(imagedir, 1024) == 0) { + if (getcwd(imagedir, 1024) == 0) { #endif /* !HAVE_GETWD */ #endif /* DOS */ - fatal_error(FE_GETCWD, 0); - } - for (; *t; t++) /* Set t to end of buffer */ - ; - if (*(t - 1) == DIR_SEPARATOR) /* leave slash if already - * last char - */ - cutoff = t - 1; - else { - cutoff = t; /* otherwise put one in */ - *t++ = DIR_SEPARATOR; - } - } + fatal_error(FE_GETCWD, 0); + } + for (; *t; t++) /* Set t to end of buffer */ + ; + if (*(t - 1) == DIR_SEPARATOR) /* leave slash if already + * last char + */ + cutoff = t - 1; + else { + cutoff = t; /* otherwise put one in */ + *t++ = DIR_SEPARATOR; + } + } #if (!defined(__MAC__) && !defined(__DJGPP__) && !defined(__GO32__) && !defined(__WIN32__)) - else - (*t++ = DIR_SEPARATOR); + else + (*t++ = DIR_SEPARATOR); #endif - /*-------------------------------------------------------------* - * Copy the rest of the string and set the cutoff if it was not - * already set. If the first character of name is a slash, cutoff - * is not presently set but will be on the first iteration of the - * loop below. - *-------------------------------------------------------------*/ + /*-------------------------------------------------------------* + * Copy the rest of the string and set the cutoff if it was not + * already set. If the first character of name is a slash, cutoff + * is not presently set but will be on the first iteration of the + * loop below. + *-------------------------------------------------------------*/ - for ((*name == DIR_SEPARATOR ? (s = name+1) : (s = name));;) { - if (*s == DIR_SEPARATOR) - cutoff = t; - if (!(*t++ = *s++)) - break; - } + for ((*name == DIR_SEPARATOR ? (s = name+1) : (s = name));;) { + if (*s == DIR_SEPARATOR) + cutoff = t; + if (!(*t++ = *s++)) + break; + } } else { - /*-------------------------------------------------------------* - * Get the path list from the environment. If the path list is - * inaccessible for any reason, leave with fatal error. - *-------------------------------------------------------------*/ + /*-------------------------------------------------------------* + * Get the path list from the environment. If the path list is + * inaccessible for any reason, leave with fatal error. + *-------------------------------------------------------------*/ #ifdef __MAC__ - if ((s = getenv("Commands")) == (char *) 0) + if ((s = getenv("Commands")) == (char *) 0) #else - if ((s = getenv("PATH")) == (char *) 0) + if ((s = getenv("PATH")) == (char *) 0) #endif - fatal_error(FE_PATH, 0); - - /* - * Copy path list into ebuf and set the source pointer to the - * beginning of this buffer. - */ - - strcpy(ebuf, s); - s = ebuf; - - for (;;) { - t = imagedir; - while (*s && *s != PATH_SEPARATOR) - *t++ = *s++; - if (t > imagedir && *(t - 1) == DIR_SEPARATOR) - ; /* do nothing -- slash already is in place */ - else - *t++ = DIR_SEPARATOR; /* put in the slash */ - cutoff = t - 1; /* set cutoff */ - strcpy(t, name); - if (access(imagedir, R_OK) == 0) - break; - - if (*s) - s++; /* advance source pointer */ - else - fatal_error(FE_INFND, 0); - } + fatal_error(FE_PATH, 0); + + /* + * Copy path list into ebuf and set the source pointer to the + * beginning of this buffer. + */ + + strcpy(ebuf, s); + s = ebuf; + + for (;;) { + t = imagedir; + while (*s && *s != PATH_SEPARATOR) + *t++ = *s++; + if (t > imagedir && *(t - 1) == DIR_SEPARATOR) + ; /* do nothing -- slash already is in place */ + else + *t++ = DIR_SEPARATOR; /* put in the slash */ + cutoff = t - 1; /* set cutoff */ + strcpy(t, name); + if (access(imagedir, R_OK) == 0) + break; + + if (*s) + s++; /* advance source pointer */ + else + fatal_error(FE_INFND, 0); + } } @@ -735,26 +724,26 @@ whereami(name) #ifdef HAVE_SYMLINK while ((cc = readlink(imagedir, ebuf, 512)) != -1) { - ebuf[cc] = 0; - s = ebuf; - if (*s == DIR_SEPARATOR) { - t = imagedir; - } - else { - t = cutoff + 1; - } - for (;;) { - if (*s == DIR_SEPARATOR) - cutoff = t; /* mark the last slash seen */ - if (!(*t++ = *s++)) /* copy the character */ - break; - } + ebuf[cc] = 0; + s = ebuf; + if (*s == DIR_SEPARATOR) { + t = imagedir; + } + else { + t = cutoff + 1; + } + for (;;) { + if (*s == DIR_SEPARATOR) + cutoff = t; /* mark the last slash seen */ + if (!(*t++ = *s++)) /* copy the character */ + break; + } } #endif /* HAVE_SYMLINK */ - strcpy(imagename, cutoff + 1); /* keep the image name */ - *(cutoff + 1) = 0; /* chop off the filename part */ + strcpy(imagename, cutoff + 1); /* keep the image name */ + *(cutoff + 1) = 0; /* chop off the filename part */ } #endif @@ -801,14 +790,14 @@ wxString wxGetTextFromUser(const wxString& message, const wxString& caption, } #ifdef __MWERKS__ -char *strdup(const char *s) +char *strdup(const char *s) { - return strcpy( (char*) malloc( strlen( s ) + 1 ) , s ) ; + return strcpy( (char*) malloc( strlen( s ) + 1 ) , s ) ; } -int isascii( int c ) +int isascii( int c ) { - return ( c >= 0 && c < 128 ) ; + return ( c >= 0 && c < 128 ) ; } #endif diff --git a/src/common/variant.cpp b/src/common/variant.cpp index 2612f8db24..ad725d2e13 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -6,7 +6,7 @@ // Created: 10/09/98 // RCS-ID: $Id$ // Copyright: (c) -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -17,16 +17,13 @@ #include "wx/wxprec.h" #ifdef __BORLANDC__ -#pragma hdrstop + #pragma hdrstop #endif #if wxUSE_IOSTREAMH # include #else # include -# ifdef _MSC_VER - using namespace std; -# endif #endif #include "wx/stream.h" diff --git a/src/common/wxexpr.cpp b/src/common/wxexpr.cpp index 5a3ace2c14..e7cabf24f0 100644 --- a/src/common/wxexpr.cpp +++ b/src/common/wxexpr.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -21,12 +21,9 @@ #endif #if wxUSE_IOSTREAMH -#include + #include #else -#include -# ifdef _MSC_VER - using namespace std; -# endif + #include #endif #include diff --git a/src/generic/helpxlp.cpp b/src/generic/helpxlp.cpp index 13d43fbb63..26bec27921 100644 --- a/src/generic/helpxlp.cpp +++ b/src/generic/helpxlp.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -67,8 +67,8 @@ IMPLEMENT_CLASS(wxXLPHelpController, wxHelpControllerBase) #endif // suppress annoying warning "'this' used in base member init list" (so what?) -#ifdef _MSC_VER -#pragma warning(disable: 4355) +#ifdef __VISUALC__ + #pragma warning(disable: 4355) #endif // Visual C++ wxXLPHelpController::wxXLPHelpController(void) @@ -78,8 +78,8 @@ wxXLPHelpController::wxXLPHelpController(void) helpRunning = FALSE; helpConnection = NULL; } -#ifdef _MSC_VER -#pragma warning(default: 4355) +#ifdef __VISUALC__ + #pragma warning(default: 4355) #endif // Visual C++ wxXLPHelpController::~wxXLPHelpController(void) @@ -118,21 +118,21 @@ bool wxXLPHelpController::LoadFile(const wxString& file) bool wxXLPHelpController::DisplayContents(void) { - if (!helpRunning) - { + if (!helpRunning) + { if (!Run()) return FALSE; } if (helpConnection) - return helpConnection->Execute("s -1"); + return helpConnection->Execute("s -1"); else - return FALSE; + return FALSE; } bool wxXLPHelpController::DisplaySection(int section) { if (!helpRunning) - { + { if (!Run()) return FALSE; } @@ -146,7 +146,7 @@ bool wxXLPHelpController::DisplaySection(int section) bool wxXLPHelpController::DisplayBlock(long block) { if (!helpRunning) - { + { if (!Run()) return FALSE; } @@ -160,7 +160,7 @@ bool wxXLPHelpController::DisplayBlock(long block) bool wxXLPHelpController::KeywordSearch(const wxString& k) { if (!helpRunning) - { + { if (!Run()) return FALSE; } diff --git a/src/msw/app.cpp b/src/msw/app.cpp index ac63e42c76..a3301a6085 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -227,7 +227,7 @@ bool wxApp::Initialize() // This is to foil optimizations in Visual C++ that throw out dummy.obj. // PLEASE DO NOT ALTER THIS. -#if defined(_MSC_VER) && !defined(WXMAKINGDLL) +#if defined(__VISUALC__) && !defined(WXMAKINGDLL) extern char wxDummyChar; if (wxDummyChar) wxDummyChar++; #endif @@ -545,7 +545,7 @@ void wxApp::CleanUp() #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL)) // temporarily disable this warning -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(disable: 4715) // not all control paths return a value #endif // Visual C++ @@ -565,10 +565,10 @@ int wxEntry(WXHINSTANCE hInstance, // FIXME other compilers must support Win32 SEH (structured exception // handling) too, just find the appropriate keyword in their docs! // Please note that it's _not_ the same as C++ exceptions! -#if !defined(__WXDEBUG__) && defined(_MSC_VER) && !defined(__MWERKS__) +#if !defined(__WXDEBUG__) && defined(__VISUALC__) #define CATCH_PROGRAM_EXCEPTIONS - __try { + __try { #else #undef CATCH_PROGRAM_EXCEPTIONS #endif @@ -656,7 +656,7 @@ int wxEntry(WXHINSTANCE hInstance, } // restore warning state -#ifdef _MSC_VER +#ifdef __VISUALC__ #pragma warning(default: 4715) // not all control paths return a value #endif // Visual C++ @@ -1123,6 +1123,6 @@ HINSTANCE wxGetInstance() // For some reason, with MSVC++ 1.5, WinMain isn't linked in properly // if in a separate file. So include it here to ensure it's linked. -#if (defined(_MSC_VER) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__TWIN32__)) +#if (defined(__VISUALC__) && !defined(__WIN32__)) || (defined(__GNUWIN32__) && !defined(__TWIN32__)) #include "main.cpp" #endif diff --git a/src/msw/dibutils.cpp b/src/msw/dibutils.cpp index 6921a92472..3ae1f94dc9 100644 --- a/src/msw/dibutils.cpp +++ b/src/msw/dibutils.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Microsoft, Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -29,13 +29,14 @@ #include #include #include -#include + +#include "wx/msw/dibutils.h" #if defined(__WIN32__) #if !defined(__MWERKS__) && !defined(__SALFORDC__) #include // for _fmemcpy() #endif - #define _huge + #define _huge #ifndef hmemcpy #define hmemcpy memcpy #endif @@ -81,7 +82,7 @@ void ClearSystemPalette(void) for(Counter = 0; Counter < 256; Counter++) { Palette.aEntries[Counter].peRed = 0; - Palette.aEntries[Counter].peGreen = 0; + Palette.aEntries[Counter].peGreen = 0; Palette.aEntries[Counter].peBlue = 0; Palette.aEntries[Counter].peFlags = PC_NOCOLLAPSE; } @@ -92,8 +93,8 @@ void ClearSystemPalette(void) if (ScreenPalette) { - ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE); - nMapped = RealizePalette(ScreenDC); + ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE); + nMapped = RealizePalette(ScreenDC); ScreenPalette = SelectPalette(ScreenDC,ScreenPalette,FALSE); bOK = DeleteObject(ScreenPalette); } @@ -114,14 +115,14 @@ void ClearSystemPalette(void) int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi) { - HFILE fh; - OFSTRUCT of; + HFILE fh; + OFSTRUCT of; - fh = OpenFile(szFile, &of, OF_WRITE | OF_CREATE); + fh = OpenFile(szFile, &of, OF_WRITE | OF_CREATE); if (!fh) { -// printf("la regamos0"); - return 0; +// printf("la regamos0"); + return 0; } long size = DibSize(lpbi); @@ -133,19 +134,19 @@ int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi) bmf.bfReserved1 = 0; bmf.bfReserved2 = 0; bmf.bfOffBits = sizeof(bmf) + (char far*)(DibPtr(lpbi)) - (char far*)lpbi; -#if defined( __WATCOMC__) || defined(_MSC_VER) || defined(__SC__) || defined(__SALFORDC__) +#if defined( __WATCOMC__) || defined(__VISUALC__) || defined(__SC__) || defined(__SALFORDC__) if (_hwrite(fh, (LPCSTR)(&bmf), sizeof(bmf))<0 || - _hwrite(fh, (LPCSTR)lpbi, size)<0) { - _lclose(fh); -// printf("la regamos1"); - return 0; + _hwrite(fh, (LPCSTR)lpbi, size)<0) { + _lclose(fh); +// printf("la regamos1"); + return 0; } #else if (_hwrite(fh, (LPBYTE)(&bmf), sizeof(bmf))<0 || - _hwrite(fh, (LPBYTE)lpbi, size)<0) { - _lclose(fh); -// printf("la regamos1"); - return 0; + _hwrite(fh, (LPBYTE)lpbi, size)<0) { + _lclose(fh); +// printf("la regamos1"); + return 0; } #endif @@ -155,50 +156,50 @@ int DibWriteFile(LPSTR szFile, LPBITMAPINFOHEADER lpbi) PDIB DibOpenFile(LPSTR szFile) { - HFILE fh; - DWORD dwLen; - DWORD dwBits; - PDIB pdib; - LPVOID p; - OFSTRUCT of; + HFILE fh; + DWORD dwLen; + DWORD dwBits; + PDIB pdib; + LPVOID p; + OFSTRUCT of; #if defined(WIN32) || defined(_WIN32) - #define GetCurrentInstance() GetModuleHandle(NULL) + #define GetCurrentInstance() GetModuleHandle(NULL) #else - #define GetCurrentInstance() (HINSTANCE)SELECTOROF((LPVOID)&of) + #define GetCurrentInstance() (HINSTANCE)SELECTOROF((LPVOID)&of) #endif - fh = OpenFile(szFile, &of, OF_READ); + fh = OpenFile(szFile, &of, OF_READ); - if (fh == -1) - { - HRSRC h; + if (fh == -1) + { + HRSRC h; // TODO: Unicode version #ifdef __WIN16__ - h = FindResource(GetCurrentInstance(), szFile, RT_BITMAP); + h = FindResource(GetCurrentInstance(), szFile, RT_BITMAP); #else - h = FindResourceA(GetCurrentInstance(), szFile, RT_BITMAP); + h = FindResourceA(GetCurrentInstance(), szFile, RT_BITMAP); #endif #if defined(__WIN32__) - //!!! can we call GlobalFree() on this? is it the right format. - //!!! can we write to this resource? - if (h) - return (PDIB)LockResource(LoadResource(GetCurrentInstance(), h)); + //!!! can we call GlobalFree() on this? is it the right format. + //!!! can we write to this resource? + if (h) + return (PDIB)LockResource(LoadResource(GetCurrentInstance(), h)); #else - if (h) - fh = AccessResource(GetCurrentInstance(), h); + if (h) + fh = AccessResource(GetCurrentInstance(), h); #endif - } + } - if (fh == -1) - return NULL; + if (fh == -1) + return NULL; - pdib = DibReadBitmapInfo(fh); + pdib = DibReadBitmapInfo(fh); - if (!pdib) - return NULL; + if (!pdib) + return NULL; /* How much memory do we need to hold the DIB */ @@ -207,11 +208,11 @@ PDIB DibOpenFile(LPSTR szFile) /* Can we get more memory? */ - p = GlobalReAllocPtr(pdib,dwLen,0); + p = GlobalReAllocPtr(pdib,dwLen,0); if (!p) { - GlobalFreePtr(pdib); + GlobalFreePtr(pdib); pdib = NULL; } else @@ -221,8 +222,8 @@ PDIB DibOpenFile(LPSTR szFile) if (pdib) { - /* read in the bits */ - _hread(fh, (LPBYTE)pdib + (UINT)pdib->biSize + DibPaletteSize(pdib), dwBits); + /* read in the bits */ + _hread(fh, (LPBYTE)pdib + (UINT)pdib->biSize + DibPaletteSize(pdib), dwBits); } _lclose(fh); @@ -468,7 +469,7 @@ PDIB DibCreate(int bits, int dx, int dy) *pdw++ = 0x00000000; // 0000 black *pdw++ = 0x00800000; // 0001 dark red *pdw++ = 0x00008000; // 0010 dark green - *pdw++ = 0x00808000; // 0011 mustard + *pdw++ = 0x00808000; // 0011 mustard *pdw++ = 0x00000080; // 0100 dark blue *pdw++ = 0x00800080; // 0101 purple *pdw++ = 0x00008080; // 0110 dark turquoise @@ -476,7 +477,7 @@ PDIB DibCreate(int bits, int dx, int dy) *pdw++ = 0x00808080; // 0111 dark gray *pdw++ = 0x00FF0000; // 1001 red *pdw++ = 0x0000FF00; // 1010 green - *pdw++ = 0x00FFFF00; // 1011 yellow + *pdw++ = 0x00FFFF00; // 1011 yellow *pdw++ = 0x000000FF; // 1100 blue *pdw++ = 0x00FF00FF; // 1101 pink (magenta) *pdw++ = 0x0000FFFF; // 1110 cyan @@ -583,69 +584,69 @@ static void hmemmove(BYTE _huge *d, BYTE _huge *s, LONG len) BOOL DibMapToPalette(PDIB pdib, HPALETTE hpal) { - LPBITMAPINFOHEADER lpbi; - PALETTEENTRY pe; - int n; - int nDibColors; - int nPalColors=0; - BYTE FAR * lpBits; - RGBQUAD FAR * lpRgb; - BYTE xlat[256]; - DWORD SizeImage; - - if (!hpal || !pdib) - return FALSE; - - lpbi = (LPBITMAPINFOHEADER)pdib; - lpRgb = DibColors(pdib); - - GetObject(hpal,sizeof(int),(LPSTR)&nPalColors); - nDibColors = DibNumColors(pdib); - - if ((SizeImage = lpbi->biSizeImage) == 0) - SizeImage = DibSizeImage(lpbi); - - // - // build a xlat table. from the current DIB colors to the given - // palette. - // - for (n=0; nbiClrUsed = nPalColors; - - // - // re-size the DIB - // - if (nPalColors > nDibColors) - { - GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0); - hmemmove((BYTE _huge *)DibPtr(lpbi), (BYTE _huge *)lpBits, SizeImage); - lpBits = (LPBYTE)DibPtr(lpbi); - } - else if (nPalColors < nDibColors) - { - hmemcpy(DibPtr(lpbi), lpBits, SizeImage); - GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0); - lpBits = (LPBYTE)DibPtr(lpbi); - } - - // - // translate the DIB bits - // - switch (lpbi->biCompression) - { - case BI_RLE8: - xlatRle8(lpBits, SizeImage, xlat); - break; - - case BI_RLE4: - xlatRle4(lpBits, SizeImage, xlat); - break; + LPBITMAPINFOHEADER lpbi; + PALETTEENTRY pe; + int n; + int nDibColors; + int nPalColors=0; + BYTE FAR * lpBits; + RGBQUAD FAR * lpRgb; + BYTE xlat[256]; + DWORD SizeImage; + + if (!hpal || !pdib) + return FALSE; + + lpbi = (LPBITMAPINFOHEADER)pdib; + lpRgb = DibColors(pdib); + + GetObject(hpal,sizeof(int),(LPSTR)&nPalColors); + nDibColors = DibNumColors(pdib); + + if ((SizeImage = lpbi->biSizeImage) == 0) + SizeImage = DibSizeImage(lpbi); + + // + // build a xlat table. from the current DIB colors to the given + // palette. + // + for (n=0; nbiClrUsed = nPalColors; + + // + // re-size the DIB + // + if (nPalColors > nDibColors) + { + GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0); + hmemmove((BYTE _huge *)DibPtr(lpbi), (BYTE _huge *)lpBits, SizeImage); + lpBits = (LPBYTE)DibPtr(lpbi); + } + else if (nPalColors < nDibColors) + { + hmemcpy(DibPtr(lpbi), lpBits, SizeImage); + GlobalReAllocPtr(lpbi, lpbi->biSize + nPalColors*sizeof(RGBQUAD) + SizeImage, 0); + lpBits = (LPBYTE)DibPtr(lpbi); + } + + // + // translate the DIB bits + // + switch (lpbi->biCompression) + { + case BI_RLE8: + xlatRle8(lpBits, SizeImage, xlat); + break; + + case BI_RLE4: + xlatRle4(lpBits, SizeImage, xlat); + break; case BI_RGB: - if (lpbi->biBitCount == 8) + if (lpbi->biBitCount == 8) xlatClut8(lpBits, SizeImage, xlat); else xlatClut4(lpBits, SizeImage, xlat); @@ -660,12 +661,12 @@ BOOL DibMapToPalette(PDIB pdib, HPALETTE hpal) GetPaletteEntries(hpal,n,1,&pe); lpRgb[n].rgbRed = pe.peRed; - lpRgb[n].rgbGreen = pe.peGreen; - lpRgb[n].rgbBlue = pe.peBlue; - lpRgb[n].rgbReserved = (BYTE)0; - } + lpRgb[n].rgbGreen = pe.peGreen; + lpRgb[n].rgbBlue = pe.peBlue; + lpRgb[n].rgbReserved = (BYTE)0; + } - return TRUE; + return TRUE; } @@ -676,21 +677,21 @@ HPALETTE MakePalette(const BITMAPINFO FAR* Info, UINT flags) WORD nColors = Info->bmiHeader.biClrUsed; if (nColors) { - LOGPALETTE* logPal = (LOGPALETTE*) - new BYTE[sizeof(LOGPALETTE) + (nColors-1)*sizeof(PALETTEENTRY)]; - - logPal->palVersion = 0x300; // Windows 3.0 version - logPal->palNumEntries = nColors; - for (short n = 0; n < nColors; n++) { - logPal->palPalEntry[n].peRed = rgb[n].rgbRed; - logPal->palPalEntry[n].peGreen = rgb[n].rgbGreen; - logPal->palPalEntry[n].peBlue = rgb[n].rgbBlue; - logPal->palPalEntry[n].peFlags = (BYTE)flags; - } - hPalette = ::CreatePalette(logPal); - delete logPal; + LOGPALETTE* logPal = (LOGPALETTE*) + new BYTE[sizeof(LOGPALETTE) + (nColors-1)*sizeof(PALETTEENTRY)]; + + logPal->palVersion = 0x300; // Windows 3.0 version + logPal->palNumEntries = nColors; + for (short n = 0; n < nColors; n++) { + logPal->palPalEntry[n].peRed = rgb[n].rgbRed; + logPal->palPalEntry[n].peGreen = rgb[n].rgbGreen; + logPal->palPalEntry[n].peBlue = rgb[n].rgbBlue; + logPal->palPalEntry[n].peFlags = (BYTE)flags; + } + hPalette = ::CreatePalette(logPal); + delete logPal; } else - hPalette = 0; + hPalette = 0; return hPalette; } diff --git a/src/msw/dummy.cpp b/src/msw/dummy.cpp index 1a2876a2b9..807c6a8b01 100644 --- a/src/msw/dummy.cpp +++ b/src/msw/dummy.cpp @@ -1,9 +1,9 @@ /* - * File: dummy.cc - * Purpose: See below - * Author: Julian Smart - * Created: 1993 - * Updated: + * File: dummy.cc + * Purpose: See below + * Author: Julian Smart + * Created: 1993 + * Updated: * Copyright: (c) 1993, AIAI, University of Edinburgh */ @@ -40,7 +40,7 @@ // Foils optimizations in Visual C++ (see also app.cpp). Without it, // dummy.obj isn't linked and we get a linker error. -#if defined(_MSC_VER) +#if defined(__VISUALC__) char wxDummyChar = 0; #endif @@ -51,7 +51,7 @@ #if !defined(APIENTRY) #define APIENTRY FAR PASCAL #endif - + int #ifdef __WATCOMC__ PASCAL diff --git a/src/msw/dummydll.cpp b/src/msw/dummydll.cpp index 94d3a94a5f..1a594077d8 100644 --- a/src/msw/dummydll.cpp +++ b/src/msw/dummydll.cpp @@ -1,13 +1,13 @@ /* - * File: dummydll.cc - * Purpose: - * Author: Julian Smart - * Created: 1993 - * Updated: + * File: dummydll.cc + * Purpose: + * Author: Julian Smart + * Created: 1993 + * Updated: * Copyright: (c) 1993, AIAI, University of Edinburgh */ -/* static const char sccsid[] = "@(#)dummydll.cc 1.2 5/9/94"; */ +/* static const char sccsid[] = "@(#)dummydll.cc 1.2 5/9/94"; */ /* * A dummy file to include wx.h. If precompiling wx.h, I @@ -19,7 +19,7 @@ // Foils optimizations in Visual C++ (see also app.cpp). Without it, // dummy.obj isn't linked and we get a linker error. -#if defined(_MSC_VER) && defined(__WIN16__) -char wxDummyChar=0; +#if defined(__VISUALC__) && defined(__WIN16__) + char wxDummyChar=0; #endif diff --git a/src/msw/ole/dataobj.cpp b/src/msw/ole/dataobj.cpp index 2d202e39eb..43f372295c 100644 --- a/src/msw/ole/dataobj.cpp +++ b/src/msw/ole/dataobj.cpp @@ -2,7 +2,7 @@ // Name: msw/ole/dataobj.cpp // Purpose: implementation of wx[I]DataObject class // Author: Vadim Zeitlin -// Modified by: +// Modified by: // Created: 10.05.98 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin @@ -313,7 +313,7 @@ STDMETHODIMP wxIDataObject::EnumFormatEtc(DWORD dwDirection, return E_NOTIMPL; } - wxIEnumFORMATETC *pEnum = + wxIEnumFORMATETC *pEnum = new wxIEnumFORMATETC(m_pDataObject->GetPreferredFormat()); pEnum->AddRef(); *ppenumFormatEtc = pEnum; @@ -359,7 +359,7 @@ const char *wxDataObject::GetFormatName(wxDataFormat format) { #ifdef __WXDEBUG__ // case 'xxx' is not a valid value for switch of enum 'wxDataFormat' - #ifdef _MSC_VER + #ifdef __VISUALC__ #pragma warning(disable:4063) #endif // VC++ @@ -386,7 +386,7 @@ const char *wxDataObject::GetFormatName(wxDataFormat format) return s_szBuf; } - #ifdef _MSC_VER + #ifdef __VISUALC__ #pragma warning(default:4063) #endif // VC++ diff --git a/src/msw/ole/oleutils.cpp b/src/msw/ole/oleutils.cpp index cb2a9e698b..e67ac95611 100644 --- a/src/msw/ole/oleutils.cpp +++ b/src/msw/ole/oleutils.cpp @@ -2,7 +2,7 @@ // Name: ole/oleutils.cpp // Purpose: implementation of OLE helper functions // Author: Vadim Zeitlin -// Modified by: +// Modified by: // Created: 19.02.98 // RCS-ID: $Id$ // Copyright: (c) 1998 Vadim Zeitlin @@ -37,8 +37,8 @@ #include #include -#if defined(_MSC_VER) && (_MSC_VER > 1000) -#include +#if defined(__VISUALC__) && (__VISUALC__ > 1000) + #include #endif // ============================================================================ @@ -62,7 +62,7 @@ bool IsIidFromList(REFIID riid, const IID *aIids[], size_t nCount) // Debug support // ---------------------------------------------------------------------------- -#if defined(__WXDEBUG__) && defined(_MSC_VER) && (_MSC_VER > 1000) +#if defined(__WXDEBUG__) && defined(__VISUALC__) && (__VISUALC__ > 1000) const char *GetIidName(REFIID riid) { // an association between symbolic name and numeric value of an IID diff --git a/src/msw/pnghand.cpp b/src/msw/pnghand.cpp index 2f82fa3e10..01309d2b84 100644 --- a/src/msw/pnghand.cpp +++ b/src/msw/pnghand.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -26,12 +26,9 @@ #include #if wxUSE_IOSTREAMH -#include +# include #else -#include -# ifdef _MSC_VER - using namespace std; -# endif +# include #endif #include @@ -70,7 +67,7 @@ ima_png_error(png_struct *png_ptr, char *message) { // wxMessageBox(message, "PNG error"); - longjmp(png_ptr->jmpbuf, 1); + longjmp(png_ptr->jmpbuf, 1); } @@ -80,15 +77,15 @@ wxPalette *wxCopyPalette(const wxPalette *cmap); wxPNGReader::wxPNGReader(void) { filetype = 0; - RawImage = NULL; // Image data + RawImage = NULL; // Image data - Width = 0; Height = 0; // Dimensions - Depth = 0; // (bits x pixel) - ColorType = 0; // Bit 1 = Palette used - // Bit 2 = Color used - // Bit 3 = Alpha used + Width = 0; Height = 0; // Dimensions + Depth = 0; // (bits x pixel) + ColorType = 0; // Bit 1 = Palette used + // Bit 2 = Color used + // Bit 3 = Alpha used - EfeWidth = 0; // Efective Width + EfeWidth = 0; // Efective Width lpbi = NULL; bgindex = -1; @@ -100,15 +97,15 @@ wxPNGReader::wxPNGReader ( char* ImageFileName ) { imageOK = FALSE; filetype = 0; - RawImage = NULL; // Image data + RawImage = NULL; // Image data - Width = 0; Height = 0; // Dimensions - Depth = 0; // (bits x pixel) - ColorType = 0; // Bit 1 = Palette used - // Bit 2 = Color used - // Bit 3 = Alpha used + Width = 0; Height = 0; // Dimensions + Depth = 0; // (bits x pixel) + ColorType = 0; // Bit 1 = Palette used + // Bit 2 = Color used + // Bit 3 = Alpha used - EfeWidth = 0; // Efective Width + EfeWidth = 0; // Efective Width lpbi = NULL; bgindex = -1; @@ -125,17 +122,17 @@ wxPNGReader::Create(int width, int height, int depth, int colortype) if (lpbi) { #ifdef __WIN16__ - GlobalFreePtr((unsigned int) lpbi); + GlobalFreePtr((unsigned int) lpbi); #else - GlobalFreePtr(lpbi); + GlobalFreePtr(lpbi); #endif -// delete Palette; +// delete Palette; } RawImage = 0; Palette = 0; if (lpbi = DibCreate(Depth, Width, Height)) { - RawImage = (ImagePointerType)DibPtr(lpbi); - EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4; + RawImage = (ImagePointerType)DibPtr(lpbi); + EfeWidth = (long)(((long)Width*Depth + 31) / 32) * 4; imageOK = TRUE; } } @@ -144,11 +141,11 @@ wxPNGReader::~wxPNGReader ( ) { if (lpbi) { #ifdef __WIN16__ - GlobalFreePtr((unsigned int) lpbi); + GlobalFreePtr((unsigned int) lpbi); #else - GlobalFreePtr(lpbi); + GlobalFreePtr(lpbi); #endif - delete Palette; + delete Palette; } } @@ -167,17 +164,17 @@ bool wxPNGReader::GetRGB(int x, int y, byte* r, byte* g, byte* b) if (!Inside(x, y)) return FALSE; if (Palette) { - return Palette->GetRGB(GetIndex(x, y), r, g, b); -/* PALETTEENTRY entry; - ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry); - *r = entry.peRed; - *g = entry.peGreen; - *b = entry.peBlue; */ + return Palette->GetRGB(GetIndex(x, y), r, g, b); +/* PALETTEENTRY entry; + ::GetPaletteEntries((HPALETTE) Palette->GetHPALETTE(), GetIndex(x, y), 1, &entry); + *r = entry.peRed; + *g = entry.peGreen; + *b = entry.peBlue; */ } else { - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - *b = ImagePointer[0]; - *g = ImagePointer[1]; - *r = ImagePointer[2]; + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + *b = ImagePointer[0]; + *g = ImagePointer[1]; + *r = ImagePointer[2]; } return TRUE; } @@ -199,14 +196,14 @@ bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b) if (ColorType & COLORTYPE_PALETTE) { - if (!Palette) return FALSE; - SetIndex(x, y, Palette->GetPixel(r, g, b)); + if (!Palette) return FALSE; + SetIndex(x, y, Palette->GetPixel(r, g, b)); } else { - ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); - ImagePointer[0] = b; - ImagePointer[1] = g; - ImagePointer[2] = r; + ImagePointerType ImagePointer = RawImage + EfeWidth*y + (x*Depth >> 3); + ImagePointer[0] = b; + ImagePointer[1] = g; + ImagePointer[2] = r; } return TRUE; @@ -215,7 +212,7 @@ bool wxPNGReader::SetRGB(int x, int y, byte r, byte g, byte b) bool wxPNGReader::SetPalette(wxPalette* colourmap) { if (!colourmap) - return FALSE; + return FALSE; ColorType |= (COLORTYPE_PALETTE | COLORTYPE_COLOR); Palette = colourmap; return (DibSetUsage(lpbi, (HPALETTE) Palette->GetHPALETTE(), WXIMA_COLORS ) != 0); @@ -226,7 +223,7 @@ wxPNGReader::SetPalette(int n, byte *r, byte *g, byte *b) { Palette = new wxPalette(); if (!Palette) - return FALSE; + return FALSE; if (!g) g = r; if (!b) b = g; @@ -240,15 +237,15 @@ wxPNGReader::SetPalette(int n, rgb_color_struct *rgb_struct) { Palette = new wxPalette(); if (!Palette) - return FALSE; + return FALSE; byte r[256], g[256], b[256]; for(int i=0; iGetHPALETTE(), FALSE); - ::RealizePalette(dc); + ::RealizePalette(dc); } - HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi, - CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS); + HBITMAP hBitmap = ::CreateDIBitmap(dc, lpbi, + CBM_INIT, RawImage, (LPBITMAPINFO) lpbi, DIB_PAL_COLORS); ::SelectPalette(dc, NULL, TRUE); ::SelectObject(dc, oldBitmap); @@ -323,16 +320,16 @@ bool wxPNGReader::InstantiateBitmap(wxBitmap *bitmap) wxMask *mask = CreateMask(); bitmap->SetMask(mask); } - return TRUE; + return TRUE; } else { return FALSE; } - } - else + } + else { - return FALSE; + return FALSE; } } @@ -341,13 +338,13 @@ wxPalette *wxCopyPalette(const wxPalette *cmap) // To get number of entries... WORD count = 0; ::GetObject((HPALETTE) cmap->GetHPALETTE(), sizeof(WORD), &count); - + LOGPALETTE* logPal = (LOGPALETTE*) - new BYTE[sizeof(LOGPALETTE) + count*sizeof(PALETTEENTRY)]; + new BYTE[sizeof(LOGPALETTE) + count*sizeof(PALETTEENTRY)]; logPal->palVersion = 0x300; logPal->palNumEntries = count; ::GetPaletteEntries((HPALETTE) cmap->GetHPALETTE(), 0, count, logPal->palPalEntry); - + HPALETTE hPalette = ::CreatePalette(logPal); delete[] logPal; @@ -360,7 +357,7 @@ wxMask *wxPNGReader::CreateMask(void) { HBITMAP hBitmap = ::CreateBitmap(GetWidth(), GetHeight(), 1, 1, NULL); - HDC dc = ::CreateCompatibleDC(NULL); + HDC dc = ::CreateCompatibleDC(NULL); HBITMAP oldBitmap = (HBITMAP) ::SelectObject(dc, hBitmap); int bgIndex = GetBGIndex(); @@ -377,7 +374,7 @@ wxMask *wxPNGReader::CreateMask(void) else ::SetPixel(dc, x, GetHeight() - y - 1, RGB(255, 255, 255)); - } + } } ::SelectObject(dc, oldBitmap); wxMask *mask = new wxMask; @@ -390,138 +387,138 @@ bool wxPNGReader::ReadFile(char * ImageFileName) int number_passes; if (ImageFileName) - strcpy(filename, ImageFileName); + strcpy(filename, ImageFileName); - FILE *fp; - png_struct *png_ptr; + FILE *fp; + png_struct *png_ptr; png_info *info_ptr; - wxPNGReaderIter iter(this); - - /* open the file */ - fp = fopen(filename, "rb"); - if (!fp) - return FALSE; - - /* allocate the necessary structures */ - png_ptr = new (png_struct); - if (!png_ptr) - { - fclose(fp); - return FALSE; - } - - info_ptr = new (png_info); - if (!info_ptr) - { - fclose(fp); - delete(png_ptr); - return FALSE; - } - /* set error handling */ - if (setjmp(png_ptr->jmpbuf)) - { - png_read_destroy(png_ptr, info_ptr, (png_info *)0); - fclose(fp); - delete(png_ptr); - delete(info_ptr); - - /* If we get here, we had a problem reading the file */ - return FALSE; - } + wxPNGReaderIter iter(this); + + /* open the file */ + fp = fopen(filename, "rb"); + if (!fp) + return FALSE; + + /* allocate the necessary structures */ + png_ptr = new (png_struct); + if (!png_ptr) + { + fclose(fp); + return FALSE; + } + + info_ptr = new (png_info); + if (!info_ptr) + { + fclose(fp); + delete(png_ptr); + return FALSE; + } + /* set error handling */ + if (setjmp(png_ptr->jmpbuf)) + { + png_read_destroy(png_ptr, info_ptr, (png_info *)0); + fclose(fp); + delete(png_ptr); + delete(info_ptr); + + /* If we get here, we had a problem reading the file */ + return FALSE; + } //png_set_error(ima_png_error, NULL); - /* initialize the structures, info first for error handling */ - png_info_init(info_ptr); - png_read_init(png_ptr); + /* initialize the structures, info first for error handling */ + png_info_init(info_ptr); + png_read_init(png_ptr); - /* set up the input control */ - png_init_io(png_ptr, fp); + /* set up the input control */ + png_init_io(png_ptr, fp); - /* read the file information */ - png_read_info(png_ptr, info_ptr); + /* read the file information */ + png_read_info(png_ptr, info_ptr); - /* allocate the memory to hold the image using the fields - of png_info. */ - png_color_16 my_background={ 0, 31, 127, 255, 0 }; + /* allocate the memory to hold the image using the fields + of png_info. */ + png_color_16 my_background={ 0, 31, 127, 255, 0 }; - if (info_ptr->valid & PNG_INFO_bKGD) + if (info_ptr->valid & PNG_INFO_bKGD) { - png_set_background(png_ptr, &(info_ptr->background), - PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); + png_set_background(png_ptr, &(info_ptr->background), + PNG_BACKGROUND_GAMMA_FILE, 1, 1.0); if ( info_ptr->num_palette > 0 ) bgindex = info_ptr->background.index; } - else { - png_set_background(png_ptr, &my_background, - PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); + else { + png_set_background(png_ptr, &my_background, + PNG_BACKGROUND_GAMMA_SCREEN, 0, 1.0); // Added by JACS: guesswork! if ( info_ptr->num_trans != 0 ) bgindex = info_ptr->num_trans - 1 ; - } + } - /* tell libpng to strip 16 bit depth files down to 8 bits */ - if (info_ptr->bit_depth == 16) - png_set_strip_16(png_ptr); + /* tell libpng to strip 16 bit depth files down to 8 bits */ + if (info_ptr->bit_depth == 16) + png_set_strip_16(png_ptr); - int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24; - Create(info_ptr->width, info_ptr->height, pixel_depth, - info_ptr->color_type); + int pixel_depth=(info_ptr->pixel_depth<24) ? info_ptr->pixel_depth: 24; + Create(info_ptr->width, info_ptr->height, pixel_depth, + info_ptr->color_type); - if (info_ptr->num_palette>0) + if (info_ptr->num_palette>0) { - SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette); + SetPalette((int)info_ptr->num_palette, (rgb_color_struct*)info_ptr->palette); + } + + int row_stride = info_ptr->width * ((pixel_depth+7)>>3); + // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride); +// printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth); + + byte *row_pointers = new byte[row_stride]; + + /* turn on interlace handling */ + if (info_ptr->interlace_type) + number_passes = png_set_interlace_handling(png_ptr); + else + number_passes = 1; +// printf("NP = %d ", number_passes); + + for (int pass=0; pass< number_passes; pass++) { + iter.upset(); + int y=0; + do { +// (unsigned char *)iter.GetRow(); + if (info_ptr->interlace_type) { + if (pass>0) + iter.GetRow(row_pointers, row_stride); + png_read_row(png_ptr, row_pointers, NULL); } + else + png_read_row(png_ptr, row_pointers, NULL); + + iter.SetRow(row_pointers, row_stride); + y++; + } while(iter.PrevRow()); +// printf("Y=%d ",y); + } + delete[] row_pointers; - int row_stride = info_ptr->width * ((pixel_depth+7)>>3); - // printf("P = %d D = %d RS= %d ", info_ptr->num_palette, info_ptr->pixel_depth,row_stride); -// printf("CT = %d TRS = %d BD= %d ", info_ptr->color_type, info_ptr->valid & PNG_INFO_tRNS,info_ptr->bit_depth); - - byte *row_pointers = new byte[row_stride]; - - /* turn on interlace handling */ - if (info_ptr->interlace_type) - number_passes = png_set_interlace_handling(png_ptr); - else - number_passes = 1; -// printf("NP = %d ", number_passes); - - for (int pass=0; pass< number_passes; pass++) { - iter.upset(); - int y=0; - do { -// (unsigned char *)iter.GetRow(); - if (info_ptr->interlace_type) { - if (pass>0) - iter.GetRow(row_pointers, row_stride); - png_read_row(png_ptr, row_pointers, NULL); - } - else - png_read_row(png_ptr, row_pointers, NULL); - - iter.SetRow(row_pointers, row_stride); - y++; - } while(iter.PrevRow()); -// printf("Y=%d ",y); - } - delete[] row_pointers; - - /* read the rest of the file, getting any additional chunks - in info_ptr */ - png_read_end(png_ptr, info_ptr); - - /* clean up after the read, and free any memory allocated */ - png_read_destroy(png_ptr, info_ptr, (png_info *)0); - - /* free the structures */ - delete(png_ptr); - delete(info_ptr); - - /* close the file */ - fclose(fp); - - /* that's it */ - return TRUE; + /* read the rest of the file, getting any additional chunks + in info_ptr */ + png_read_end(png_ptr, info_ptr); + + /* clean up after the read, and free any memory allocated */ + png_read_destroy(png_ptr, info_ptr, (png_info *)0); + + /* free the structures */ + delete(png_ptr); + delete(info_ptr); + + /* close the file */ + fclose(fp); + + /* that's it */ + return TRUE; } @@ -530,91 +527,91 @@ bool wxPNGReader::ReadFile(char * ImageFileName) bool wxPNGReader::SaveFile(char * ImageFileName) { if (ImageFileName) - strcpy(filename, ImageFileName); + strcpy(filename, ImageFileName); wxPNGReaderIter iter(this); FILE *fp; png_struct *png_ptr; - png_info *info_ptr; + png_info *info_ptr; /* open the file */ - fp = fopen(filename, "wb"); - if (!fp) - return FALSE; - - /* allocate the necessary structures */ - png_ptr = new (png_struct); - if (!png_ptr) - { - fclose(fp); - return FALSE; - } - - info_ptr = new (png_info); - if (!info_ptr) - { - fclose(fp); - delete(png_ptr); - return FALSE; - } - - /* set error handling */ - if (setjmp(png_ptr->jmpbuf)) - { - png_write_destroy(png_ptr); - fclose(fp); - delete(png_ptr); - delete(info_ptr); - - /* If we get here, we had a problem reading the file */ - return FALSE; - } + fp = fopen(filename, "wb"); + if (!fp) + return FALSE; + + /* allocate the necessary structures */ + png_ptr = new (png_struct); + if (!png_ptr) + { + fclose(fp); + return FALSE; + } + + info_ptr = new (png_info); + if (!info_ptr) + { + fclose(fp); + delete(png_ptr); + return FALSE; + } + + /* set error handling */ + if (setjmp(png_ptr->jmpbuf)) + { + png_write_destroy(png_ptr); + fclose(fp); + delete(png_ptr); + delete(info_ptr); + + /* If we get here, we had a problem reading the file */ + return FALSE; + } //png_set_error(ima_png_error, NULL); -// printf("writig pg %s ", filename); +// printf("writig pg %s ", filename); /* initialize the structures */ - png_info_init(info_ptr); - png_write_init(png_ptr); - - int row_stride = GetWidth() * ((GetDepth()+7)>>3); - /* set up the output control */ + png_info_init(info_ptr); + png_write_init(png_ptr); + + int row_stride = GetWidth() * ((GetDepth()+7)>>3); + /* set up the output control */ png_init_io(png_ptr, fp); - /* set the file information here */ - info_ptr->width = GetWidth(); - info_ptr->height = GetHeight(); - info_ptr->pixel_depth = GetDepth(); - info_ptr->channels = (GetDepth()>8) ? 3: 1; - info_ptr->bit_depth = GetDepth()/info_ptr->channels; - info_ptr->color_type = GetColorType(); - info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0; - info_ptr->valid = 0; - info_ptr->rowbytes = row_stride; + /* set the file information here */ + info_ptr->width = GetWidth(); + info_ptr->height = GetHeight(); + info_ptr->pixel_depth = GetDepth(); + info_ptr->channels = (GetDepth()>8) ? 3: 1; + info_ptr->bit_depth = GetDepth()/info_ptr->channels; + info_ptr->color_type = GetColorType(); + info_ptr->compression_type = info_ptr->filter_type = info_ptr->interlace_type=0; + info_ptr->valid = 0; + info_ptr->rowbytes = row_stride; // printf("P = %d D = %d RS= %d GD= %d CH= %d ", info_ptr->pixel_depth, info_ptr->bit_depth, row_stride, GetDepth(), info_ptr->channels); - /* set the palette if there is one */ - if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette()) - { -// printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); - info_ptr->valid |= PNG_INFO_PLTE; - info_ptr->palette = new png_color[256]; - info_ptr->num_palette = 256; - for (int i=0; i<256; i++) - GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue); - } -// printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); + /* set the palette if there is one */ + if ((GetColorType() & COLORTYPE_PALETTE) && GetPalette()) + { +// printf("writing paleta[%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); + info_ptr->valid |= PNG_INFO_PLTE; + info_ptr->palette = new png_color[256]; + info_ptr->num_palette = 256; + for (int i=0; i<256; i++) + GetPalette()->GetRGB(i, &info_ptr->palette[i].red, &info_ptr->palette[i].green, &info_ptr->palette[i].blue); + } +// printf("Paleta [%d %d %x]",GetColorType() ,COLORTYPE_PALETTE, GetPalette()); /* optional significant bit chunk */ // info_ptr->valid |= PNG_INFO_sBIT; // info_ptr->sig_bit = true_bit_depth; - /* optional gamma chunk */ + /* optional gamma chunk */ // info_ptr->valid |= PNG_INFO_gAMA; // info_ptr->gamma = gamma; - /* other optional chunks */ + /* other optional chunks */ /* write the file information */ png_write_info(png_ptr, info_ptr); @@ -622,14 +619,14 @@ bool wxPNGReader::SaveFile(char * ImageFileName) /* set up the transformations you want. Note that these are all optional. Only call them if you want them */ - /* shift the pixels up to a legal bit depth and fill in + /* shift the pixels up to a legal bit depth and fill in as appropriate to correctly scale the image */ // png_set_shift(png_ptr, &(info_ptr->sig_bit)); - /* pack pixels into bytes */ + /* pack pixels into bytes */ // png_set_packing(png_ptr); - /* flip bgr pixels to rgb */ + /* flip bgr pixels to rgb */ // png_set_bgr(png_ptr); /* swap bytes of 16 bit files to most significant bit first */ @@ -640,35 +637,35 @@ bool wxPNGReader::SaveFile(char * ImageFileName) /* If you are only writing one row at a time, this works */ - byte *row_pointers = new byte[row_stride]; - iter.upset(); - do { -// (unsigned char *)iter.GetRow(); - iter.GetRow(row_pointers, row_stride); - png_write_row(png_ptr, row_pointers); - } while(iter.PrevRow()); - + byte *row_pointers = new byte[row_stride]; + iter.upset(); + do { +// (unsigned char *)iter.GetRow(); + iter.GetRow(row_pointers, row_stride); + png_write_row(png_ptr, row_pointers); + } while(iter.PrevRow()); + delete[] row_pointers; /* write the rest of the file */ png_write_end(png_ptr, info_ptr); - /* clean up after the write, and free any memory allocated */ + /* clean up after the write, and free any memory allocated */ png_write_destroy(png_ptr); /* if you malloced the palette, free it here */ if (info_ptr->palette) - delete[] (info_ptr->palette); + delete[] (info_ptr->palette); - /* free the structures */ - delete(png_ptr); - delete(info_ptr); + /* free the structures */ + delete(png_ptr); + delete(info_ptr); - /* close the file */ - fclose(fp); + /* close the file */ + fclose(fp); - /* that's it */ - return TRUE; + /* that's it */ + return TRUE; } static int Power(int x, int y) @@ -693,7 +690,7 @@ static void DecToHex(int dec, char *buf) buf[1] = hexArray[secondDigit]; buf[2] = 0; } - + bool wxPNGReader::SaveXPM(char *filename, char *name) { diff --git a/src/msw/textctrl.cpp b/src/msw/textctrl.cpp index c6263deba8..64f4d4314e 100644 --- a/src/msw/textctrl.cpp +++ b/src/msw/textctrl.cpp @@ -39,12 +39,9 @@ #include #if wxUSE_IOSTREAMH -#include +# include #else -#include -# ifdef _MSC_VER - using namespace std; -# endif +# include #endif #include diff --git a/src/msw/utils.cpp b/src/msw/utils.cpp index a42f71bca7..e0ed4d7246 100644 --- a/src/msw/utils.cpp +++ b/src/msw/utils.cpp @@ -68,41 +68,26 @@ #include #include #ifndef __WATCOMC__ -#if !(defined(_MSC_VER) && (_MSC_VER > 800)) -#include -#endif + #if !(defined(_MSC_VER) && (_MSC_VER > 800)) + #include + #endif #endif #include //// BEGIN for console support: VC++ only -#if defined(__WXDEBUG__) && !defined(__WIN16__) && defined(_MSC_VER) && !defined(__NO_VC_CRTDBG__) - #define wxUSE_VC_CRTDBG -#else - #undef wxUSE_VC_CRTDBG -#endif +#include "wx/msw/msvcrt.h" -#ifdef wxUSE_VC_CRTDBG - // VC++ uses this macro as debug/release mode indicator - #ifndef _DEBUG - #define _DEBUG - #endif +#include - #include +#include "wx/ioswrap.h" #if wxUSE_IOSTREAMH // N.B. BC++ doesn't have istream.h, ostream.h -# include # include # include - #else -# include -# include # include -# ifdef _MSC_VER - using namespace std; -# endif #endif /* Need to undef new if including crtdbg.h */ @@ -118,8 +103,6 @@ # define new new(__FILE__,__LINE__) # endif -#endif - /// END for console support // In the WIN.INI file @@ -766,14 +749,14 @@ bool wxDirExists(const wxString& dir) #endif #if defined(__WIN32__) - HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo); - - if (h==INVALID_HANDLE_VALUE) - return FALSE; - else { - FindClose(h); - return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY); - } + HANDLE h = FindFirstFile((LPTSTR) WXSTRINGCAST dir,(LPWIN32_FIND_DATA)&fileInfo); + + if (h==INVALID_HANDLE_VALUE) + return FALSE; + else { + FindClose(h); + return ((fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY); + } #else // In Borland findfirst has a different argument // ordering from _dos_findfirst. But _dos_findfirst @@ -806,13 +789,13 @@ bool wxIsWild( const wxString& pattern ) wxString tmp = pattern; char *pat = WXSTRINGCAST(tmp); while (*pat) { - switch (*pat++) { - case '?': case '*': case '[': case '{': - return TRUE; - case '\\': - if (!*pat++) - return FALSE; - } + switch (*pat++) { + case '?': case '*': case '[': case '{': + return TRUE; + case '\\': + if (!*pat++) + return FALSE; + } } return FALSE; }; @@ -832,124 +815,124 @@ bool wxMatchWild( const wxString& pat, const wxString& text, bool dot_special ) // dot_special means '.' only matches '.' if (dot_special && *str == '.' && *pattern != *str) - return FALSE; + return FALSE; while ((*pattern != '\0') && (!done) && (((*str=='\0')&&((*pattern==OB)||(*pattern=='*')))||(*str!='\0'))) { - switch (*pattern) { - case '\\': - pattern++; - if (*pattern != '\0') - pattern++; - break; - case '*': - pattern++; - ret_code = FALSE; - while ((*str!='\0') - && (!(ret_code=wxMatchWild(pattern, str++, FALSE)))) - /*loop*/; - if (ret_code) { - while (*str != '\0') - str++; - while (*pattern != '\0') - pattern++; - } - break; - case '[': - pattern++; - repeat: - if ((*pattern == '\0') || (*pattern == ']')) { - done = TRUE; - break; - } - if (*pattern == '\\') { - pattern++; - if (*pattern == '\0') { - done = TRUE; - break; - } - } - if (*(pattern + 1) == '-') { - c = *pattern; - pattern += 2; - if (*pattern == ']') { - done = TRUE; - break; - } - if (*pattern == '\\') { - pattern++; - if (*pattern == '\0') { - done = TRUE; - break; - } - } - if ((*str < c) || (*str > *pattern)) { - pattern++; - goto repeat; - } - } else if (*pattern != *str) { - pattern++; - goto repeat; - } - pattern++; - while ((*pattern != ']') && (*pattern != '\0')) { - if ((*pattern == '\\') && (*(pattern + 1) != '\0')) - pattern++; - pattern++; - } - if (*pattern != '\0') { - pattern++, str++; - } - break; - case '?': - pattern++; - str++; - break; - case OB: - pattern++; - while ((*pattern != CB) && (*pattern != '\0')) { - cp = str; - ok = TRUE; - while (ok && (*cp != '\0') && (*pattern != '\0') - && (*pattern != ',') && (*pattern != CB)) { - if (*pattern == '\\') - pattern++; - ok = (*pattern++ == *cp++); - } - if (*pattern == '\0') { - ok = FALSE; - done = TRUE; - break; - } else if (ok) { - str = cp; - while ((*pattern != CB) && (*pattern != '\0')) { - if (*++pattern == '\\') { - if (*++pattern == CB) - pattern++; - } - } - } else { - while (*pattern!=CB && *pattern!=',' && *pattern!='\0') { - if (*++pattern == '\\') { + switch (*pattern) { + case '\\': + pattern++; + if (*pattern != '\0') + pattern++; + break; + case '*': + pattern++; + ret_code = FALSE; + while ((*str!='\0') + && (!(ret_code=wxMatchWild(pattern, str++, FALSE)))) + /*loop*/; + if (ret_code) { + while (*str != '\0') + str++; + while (*pattern != '\0') + pattern++; + } + break; + case '[': + pattern++; + repeat: + if ((*pattern == '\0') || (*pattern == ']')) { + done = TRUE; + break; + } + if (*pattern == '\\') { + pattern++; + if (*pattern == '\0') { + done = TRUE; + break; + } + } + if (*(pattern + 1) == '-') { + c = *pattern; + pattern += 2; + if (*pattern == ']') { + done = TRUE; + break; + } + if (*pattern == '\\') { + pattern++; + if (*pattern == '\0') { + done = TRUE; + break; + } + } + if ((*str < c) || (*str > *pattern)) { + pattern++; + goto repeat; + } + } else if (*pattern != *str) { + pattern++; + goto repeat; + } + pattern++; + while ((*pattern != ']') && (*pattern != '\0')) { + if ((*pattern == '\\') && (*(pattern + 1) != '\0')) + pattern++; + pattern++; + } + if (*pattern != '\0') { + pattern++, str++; + } + break; + case '?': + pattern++; + str++; + break; + case OB: + pattern++; + while ((*pattern != CB) && (*pattern != '\0')) { + cp = str; + ok = TRUE; + while (ok && (*cp != '\0') && (*pattern != '\0') + && (*pattern != ',') && (*pattern != CB)) { + if (*pattern == '\\') + pattern++; + ok = (*pattern++ == *cp++); + } + if (*pattern == '\0') { + ok = FALSE; + done = TRUE; + break; + } else if (ok) { + str = cp; + while ((*pattern != CB) && (*pattern != '\0')) { + if (*++pattern == '\\') { + if (*++pattern == CB) + pattern++; + } + } + } else { + while (*pattern!=CB && *pattern!=',' && *pattern!='\0') { + if (*++pattern == '\\') { if (*++pattern == CB || *pattern == ',') - pattern++; - } - } - } - if (*pattern != '\0') - pattern++; - } - break; - default: - if (*str == *pattern) { - str++, pattern++; - } else { - done = TRUE; - } - } + pattern++; + } + } + } + if (*pattern != '\0') + pattern++; + } + break; + default: + if (*str == *pattern) { + str++, pattern++; + } else { + done = TRUE; + } + } } while (*pattern == '*') - pattern++; + pattern++; return ((*str == '\0') && (*pattern == '\0')); }; @@ -1089,14 +1072,14 @@ void OutputDebugStringW95(const char* lpOutputString, ...) #endif -#ifdef wxUSE_VC_CRTDBG +#ifdef 0 // maximum mumber of lines the output console should have static const WORD MAX_CONSOLE_LINES = 500; BOOL WINAPI MyConsoleHandler( DWORD dwCtrlType ) { // control signal type - FreeConsole(); - return TRUE; + FreeConsole(); + return TRUE; } void wxRedirectIOToConsole() @@ -1110,10 +1093,10 @@ void wxRedirectIOToConsole() AllocConsole(); // set the screen buffer to be big enough to let us scroll text - GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo); coninfo.dwSize.Y = MAX_CONSOLE_LINES; - SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), + SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize); // redirect unbuffered STDOUT to the console @@ -1139,13 +1122,12 @@ void wxRedirectIOToConsole() fp = _fdopen( hConHandle, "w" ); *stderr = *fp; setvbuf( stderr, NULL, _IONBF, 0 ); - - // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog + + // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog // point to console as well ios::sync_with_stdio(); - SetConsoleCtrlHandler(MyConsoleHandler, TRUE); - + SetConsoleCtrlHandler(MyConsoleHandler, TRUE); } #else // Not supported diff --git a/src/msw/utilsexc.cpp b/src/msw/utilsexc.cpp index e74411c229..0b7212e2a0 100644 --- a/src/msw/utilsexc.cpp +++ b/src/msw/utilsexc.cpp @@ -6,7 +6,7 @@ // Created: 04/01/98 // RCS-ID: $Id$ // Copyright: (c) Julian Smart and Markus Holzem -// Licence: wxWindows license +// Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// #ifdef __GNUG__ @@ -59,9 +59,9 @@ #include #include #ifndef __WATCOMC__ -#if !(defined(_MSC_VER) && (_MSC_VER > 800)) -#include -#endif + #if !(defined(_MSC_VER) && (_MSC_VER > 800)) + #include + #endif #endif #include -- 2.45.2