Various changes for Salford C++, and commited fileconf.h/fileconf.cpp changes

to take out nested classes


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1414 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1999-01-16 00:13:58 +00:00
parent 130f49d78c
commit a3ef5bf504
19 changed files with 237 additions and 131 deletions

View File

@@ -46,6 +46,15 @@
# pragma warning(disable:4100) // unreferenced formal parameter # pragma warning(disable:4100) // unreferenced formal parameter
#endif #endif
// suppress some Salford C++ warnings
#ifdef __SALFORDC__
# pragma suppress 353 // Possible nested comments
# pragma suppress 593 // Define not used
# pragma suppress 61 // enum has no name (doesn't suppress!)
# pragma suppress 106 // unnamed, unused parameter
# pragma suppress 571 // Virtual function hiding
#endif
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
// Currently Only MS-Windows/NT, XView and Motif are supported // Currently Only MS-Windows/NT, XView and Motif are supported
// //
@@ -109,6 +118,8 @@
#endif #endif
#elif defined(__SC__) #elif defined(__SC__)
typedef unsigned int bool; typedef unsigned int bool;
#elif defined(__SALFORDC__)
typedef unsigned int bool;
#elif defined(_MSC_VER) && (_MSC_VER <= 1000) #elif defined(_MSC_VER) && (_MSC_VER <= 1000)
typedef unsigned int bool; typedef unsigned int bool;
#elif defined(_MSC_VER) && (_MSC_VER == 1020) #elif defined(_MSC_VER) && (_MSC_VER == 1020)

View File

@@ -162,6 +162,9 @@ private:
// types of sizeof()<=sizeof(long) or pointers if sizeof(pointer)<=sizeof(long) // types of sizeof()<=sizeof(long) or pointers if sizeof(pointer)<=sizeof(long)
// //
// NB: it has only inline functions => takes no space at all // NB: it has only inline functions => takes no space at all
// Mod by JACS: Salford C++ doesn't like 'var->operator=' syntax, as in:
// { ((wxBaseArray *)this)->operator=((const wxBaseArray&)src);
// so using a temporary variable instead.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#define _WX_DEFINE_ARRAY(T, name) \ #define _WX_DEFINE_ARRAY(T, name) \
typedef int (CMPFUNC_CONV *CMPFUNC##T)(T *pItem1, T *pItem2); \ typedef int (CMPFUNC_CONV *CMPFUNC##T)(T *pItem1, T *pItem2); \
@@ -172,7 +175,8 @@ public: \
{ wxASSERT( sizeof(T) <= sizeof(long) ); } \ { wxASSERT( sizeof(T) <= sizeof(long) ); } \
\ \
name& operator=(const name& src) \ name& operator=(const name& src) \
{ ((wxBaseArray *)this)->operator=((const wxBaseArray&)src); \ { wxBaseArray* temp = (wxBaseArray*) this; \
(*temp) = ((const wxBaseArray&)src); \
return *this; } \ return *this; } \
\ \
T& operator[](size_t uiIndex) const \ T& operator[](size_t uiIndex) const \
@@ -216,6 +220,9 @@ public: \
// the normal arrays otherwise. // the normal arrays otherwise.
// //
// NB: it has only inline functions => takes no space at all // NB: it has only inline functions => takes no space at all
// Mod by JACS: Salford C++ doesn't like 'var->operator=' syntax, as in:
// { ((wxBaseArray *)this)->operator=((const wxBaseArray&)src);
// so using a temporary variable instead.
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#define _WX_DEFINE_SORTED_ARRAY(T, name) \ #define _WX_DEFINE_SORTED_ARRAY(T, name) \
typedef int (CMPFUNC_CONV *SCMPFUNC##T)(T pItem1, T pItem2); \ typedef int (CMPFUNC_CONV *SCMPFUNC##T)(T pItem1, T pItem2); \
@@ -226,7 +233,8 @@ public: \
{ wxASSERT( sizeof(T) <= sizeof(long) ); m_fnCompare = fn; } \ { wxASSERT( sizeof(T) <= sizeof(long) ); m_fnCompare = fn; } \
\ \
name& operator=(const name& src) \ name& operator=(const name& src) \
{ ((wxBaseArray *)this)->operator=((const wxBaseArray&)src); \ { wxBaseArray* temp = (wxBaseArray*) this; \
(*temp) = ((const wxBaseArray&)src); \
m_fnCompare = src.m_fnCompare; \ m_fnCompare = src.m_fnCompare; \
return *this; } \ return *this; } \
\ \

View File

@@ -18,13 +18,17 @@
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
#ifdef wxUSE_CONFIG
#include "wx/confbase.h"
#include "wx/textfile.h" #include "wx/textfile.h"
#include "wx/string.h" #include "wx/string.h"
// ----------------------------------------------------------------------------
// compile options
// ----------------------------------------------------------------------------
// it won't compile without it anyhow
#ifndef wxUSE_CONFIG
#error "Please define wxUSE_CONFIG or remove fileconf.cpp from your makefile"
#endif // wxUSE_CONFIG
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxFileConfig // wxFileConfig
@@ -94,8 +98,37 @@
(it's on by default, the current status can be retrieved with (it's on by default, the current status can be retrieved with
IsExpandingEnvVars function). IsExpandingEnvVars function).
*/ */
class wxFileConfig; //linea nueva
class ConfigGroup;
class ConfigEntry;
class WXDLLEXPORT wxFileConfig : public wxConfigBase // we store all lines of the local config file as a linked list in memory
class LineList
{
public:
void SetNext(LineList *pNext) { m_pNext = pNext; }
void SetPrev(LineList *pPrev) { m_pPrev = pPrev; }
// ctor
LineList(const wxString& str, LineList *pNext = (LineList *) NULL) : m_strLine(str)
{ SetNext(pNext); SetPrev((LineList *) NULL); }
//
LineList *Next() const { return m_pNext; }
LineList *Prev() const { return m_pPrev; }
//
void SetText(const wxString& str) { m_strLine = str; }
const wxString& Text() const { return m_strLine; }
private:
wxString m_strLine; // line contents
LineList *m_pNext, // next node
*m_pPrev; // previous one
};
class wxFileConfig : public wxConfigBase
{ {
public: public:
// construct the "standard" full name for global (system-wide) and // construct the "standard" full name for global (system-wide) and
@@ -182,33 +215,6 @@ public:
public: public:
// fwd decl // fwd decl
class ConfigGroup;
class ConfigEntry;
// we store all lines of the local config file as a linked list in memory
class LineList
{
public:
void SetNext(LineList *pNext) { m_pNext = pNext; }
void SetPrev(LineList *pPrev) { m_pPrev = pPrev; }
// ctor
LineList(const wxString& str, LineList *pNext = (LineList *) NULL) : m_strLine(str)
{ SetNext(pNext); SetPrev((LineList *) NULL); }
//
LineList *Next() const { return m_pNext; }
LineList *Prev() const { return m_pPrev; }
//
void SetText(const wxString& str) { m_strLine = str; }
const wxString& Text() const { return m_strLine; }
private:
wxString m_strLine; // line contents
LineList *m_pNext, // next node
*m_pPrev; // previous one
};
// functions to work with this list // functions to work with this list
LineList *LineListAppend(const wxString& str); LineList *LineListAppend(const wxString& str);
@@ -253,6 +259,8 @@ public:
WX_DEFINE_SORTED_ARRAY(ConfigEntry *, ArrayEntries); WX_DEFINE_SORTED_ARRAY(ConfigEntry *, ArrayEntries);
WX_DEFINE_SORTED_ARRAY(ConfigGroup *, ArrayGroups); WX_DEFINE_SORTED_ARRAY(ConfigGroup *, ArrayGroups);
};
class ConfigEntry class ConfigEntry
{ {
private: private:
@@ -289,8 +297,8 @@ public:
private: private:
wxFileConfig *m_pConfig; // config object we belong to wxFileConfig *m_pConfig; // config object we belong to
ConfigGroup *m_pParent; // parent group (NULL for root group) ConfigGroup *m_pParent; // parent group (NULL for root group)
ArrayEntries m_aEntries; // entries in this group wxFileConfig::ArrayEntries m_aEntries; // entries in this group
ArrayGroups m_aSubgroups; // subgroups wxFileConfig::ArrayGroups m_aSubgroups; // subgroups
wxString m_strName; // group's name wxString m_strName; // group's name
bool m_bDirty; // if FALSE => all subgroups are not dirty bool m_bDirty; // if FALSE => all subgroups are not dirty
LineList *m_pLine; // pointer to our line in the linked list LineList *m_pLine; // pointer to our line in the linked list
@@ -313,8 +321,8 @@ public:
wxFileConfig *Config() const { return m_pConfig; } wxFileConfig *Config() const { return m_pConfig; }
bool IsDirty() const { return m_bDirty; } bool IsDirty() const { return m_bDirty; }
const ArrayEntries& Entries() const { return m_aEntries; } const wxFileConfig::ArrayEntries& Entries() const { return m_aEntries; }
const ArrayGroups& Groups() const { return m_aSubgroups; } const wxFileConfig::ArrayGroups& Groups() const { return m_aSubgroups; }
bool IsEmpty() const { return Entries().IsEmpty() && Groups().IsEmpty(); } bool IsEmpty() const { return Entries().IsEmpty() && Groups().IsEmpty(); }
// find entry/subgroup (NULL if not found) // find entry/subgroup (NULL if not found)
@@ -345,11 +353,11 @@ public:
void SetLastEntry(ConfigEntry *pEntry) { m_pLastEntry = pEntry; } void SetLastEntry(ConfigEntry *pEntry) { m_pLastEntry = pEntry; }
void SetLastGroup(ConfigGroup *pGroup) { m_pLastGroup = pGroup; } void SetLastGroup(ConfigGroup *pGroup) { m_pLastGroup = pGroup; }
}; };
};
#endif #endif //_FILECONF_H
// wxUSE_CONFIG
#endif
//_FILECONF_H

View File

@@ -217,6 +217,7 @@ public:
{ wxASSERT( m_count==0 ); m_keyType = keyType; } { wxASSERT( m_count==0 ); m_keyType = keyType; }
protected: protected:
// all methods here are "overloaded" in derived classes to provide compile // all methods here are "overloaded" in derived classes to provide compile
// time type checking // time type checking
@@ -225,12 +226,18 @@ protected:
void *data, void *data,
const wxListKey& key = wxDefaultListKey) = 0; const wxListKey& key = wxDefaultListKey) = 0;
// Can't access these from derived classes otherwise (bug in Salford C++?)
#ifdef __SALFORDC__
public:
#endif
// ctors // ctors
// from an array // from an array
wxListBase(size_t count, void *elements[]); wxListBase(size_t count, void *elements[]);
// from a sequence of objects // from a sequence of objects
wxListBase(void *object, ... /* terminate with NULL */); wxListBase(void *object, ... /* terminate with NULL */);
protected:
// copy ctor and assignment operator // copy ctor and assignment operator
wxListBase(const wxListBase& list) wxListBase(const wxListBase& list)
{ DoCopy(list); } { DoCopy(list); }

View File

@@ -18,6 +18,7 @@
#include "wx/defs.h" #include "wx/defs.h"
#include "wx/object.h" #include "wx/object.h"
#include "wx/event.h"
class WXDLLEXPORT wxFrame; class WXDLLEXPORT wxFrame;
class WXDLLEXPORT wxWindow; class WXDLLEXPORT wxWindow;

View File

@@ -117,8 +117,11 @@ public:
void Reset(void) { m_current = 0; } void Reset(void) { m_current = 0; }
void Reset(const wxRegion& region); void Reset(const wxRegion& region);
operator bool (void) const { return m_current < m_numRects; } #ifndef __SALFORDC__
bool HaveRects(void) const { return m_current < m_numRects; } operator bool (void) const { return (m_current < m_numRects); }
#endif
bool HaveRects(void) const { return (m_current < m_numRects); }
void operator ++ (void); void operator ++ (void);
void operator ++ (int); void operator ++ (int);

View File

@@ -62,22 +62,22 @@ public:
Type_Multi_String, // Multiple Unicode strings Type_Multi_String, // Multiple Unicode strings
Type_Resource_list, // Resource list in the resource map Type_Resource_list, // Resource list in the resource map
Type_Full_resource_descriptor, // Resource list in the hardware description Type_Full_resource_descriptor, // Resource list in the hardware description
Type_Resource_requirements_list, // ??? Type_Resource_requirements_list // ???
#endif //WIN32 #endif //WIN32
}; };
// predefined registry keys // predefined registry keys
enum StdKey enum StdKey
{ {
HKCR, // classes root HKCR // classes root
#ifdef __WIN32__ #ifdef __WIN32__
HKCU, // current user , HKCU, // current user
HKLM, // local machine HKLM, // local machine
HKUSR, // users HKUSR, // users
HKPD, // performance data (@@ NT only?) HKPD // performance data (@@ NT only?)
#if WINVER >= 0x0400 #if WINVER >= 0x0400
HKCC, // current config , HKCC, // current config
HKDD, // dynamic data HKDD // dynamic data
#endif // Winver #endif // Winver
#endif // Win32/16 #endif // Win32/16
}; };

View File

@@ -247,6 +247,18 @@
#define wxUSE_NATIVE_STATUSBAR 0 #define wxUSE_NATIVE_STATUSBAR 0
#endif #endif
// Salford C++ doesn't like some of the memory operator definitions
#ifdef __SALFORDC__
#undef wxUSE_MEMORY_TRACING
#define wxUSE_MEMORY_TRACING 0
#undef wxUSE_GLOBAL_MEMORY_OPERATORS
#define wxUSE_GLOBAL_MEMORY_OPERATORS 0
#undef wxUSE_DEBUG_NEW_ALWAYS
#define wxUSE_DEBUG_NEW_ALWAYS 0
#endif
// Minimal setup e.g. for compiling small utilities // Minimal setup e.g. for compiling small utilities
#define MINIMAL_WXWINDOWS_SETUP 0 #define MINIMAL_WXWINDOWS_SETUP 0

View File

@@ -54,7 +54,9 @@
#define wxSTD_STRING_COMPATIBILITY #define wxSTD_STRING_COMPATIBILITY
// define to derive wxString from wxObject // define to derive wxString from wxObject
#ifdef WXSTRING_IS_WXOBJECT
#undef WXSTRING_IS_WXOBJECT #undef WXSTRING_IS_WXOBJECT
#endif
// maximum possible length for a string means "take all string" everywhere // maximum possible length for a string means "take all string" everywhere
// (as sizeof(StringData) is unknown here we substract 100) // (as sizeof(StringData) is unknown here we substract 100)
@@ -85,6 +87,8 @@ inline int WXDLLEXPORT Stricmp(const char *psz1, const char *psz2)
return _stricmp(psz1, psz2); return _stricmp(psz1, psz2);
#elif defined(__SC__) #elif defined(__SC__)
return _stricmp(psz1, psz2); return _stricmp(psz1, psz2);
#elif defined(__SALFORDC__)
return stricmp(psz1, psz2);
#elif defined(__BORLANDC__) #elif defined(__BORLANDC__)
return stricmp(psz1, psz2); return stricmp(psz1, psz2);
#elif defined(__WATCOMC__) #elif defined(__WATCOMC__)
@@ -801,41 +805,41 @@ private:
// wxString comparison functions: operator versions are always case sensitive // wxString comparison functions: operator versions are always case sensitive
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// //
inline bool operator==(const wxString& s1, const wxString& s2) { return s1.Cmp(s2) == 0; } inline bool operator==(const wxString& s1, const wxString& s2) { return (s1.Cmp(s2) == 0); }
// //
inline bool operator==(const wxString& s1, const char * s2) { return s1.Cmp(s2) == 0; } inline bool operator==(const wxString& s1, const char * s2) { return (s1.Cmp(s2) == 0); }
// //
inline bool operator==(const char * s1, const wxString& s2) { return s2.Cmp(s1) == 0; } inline bool operator==(const char * s1, const wxString& s2) { return (s2.Cmp(s1) == 0); }
// //
inline bool operator!=(const wxString& s1, const wxString& s2) { return s1.Cmp(s2) != 0; } inline bool operator!=(const wxString& s1, const wxString& s2) { return (s1.Cmp(s2) != 0); }
// //
inline bool operator!=(const wxString& s1, const char * s2) { return s1.Cmp(s2) != 0; } inline bool operator!=(const wxString& s1, const char * s2) { return (s1.Cmp(s2) != 0); }
// //
inline bool operator!=(const char * s1, const wxString& s2) { return s2.Cmp(s1) != 0; } inline bool operator!=(const char * s1, const wxString& s2) { return (s2.Cmp(s1) != 0); }
// //
inline bool operator< (const wxString& s1, const wxString& s2) { return s1.Cmp(s2) < 0; } inline bool operator< (const wxString& s1, const wxString& s2) { return (s1.Cmp(s2) < 0); }
// //
inline bool operator< (const wxString& s1, const char * s2) { return s1.Cmp(s2) < 0; } inline bool operator< (const wxString& s1, const char * s2) { return (s1.Cmp(s2) < 0); }
// //
inline bool operator< (const char * s1, const wxString& s2) { return s2.Cmp(s1) > 0; } inline bool operator< (const char * s1, const wxString& s2) { return (s2.Cmp(s1) > 0); }
// //
inline bool operator> (const wxString& s1, const wxString& s2) { return s1.Cmp(s2) > 0; } inline bool operator> (const wxString& s1, const wxString& s2) { return (s1.Cmp(s2) > 0); }
// //
inline bool operator> (const wxString& s1, const char * s2) { return s1.Cmp(s2) > 0; } inline bool operator> (const wxString& s1, const char * s2) { return (s1.Cmp(s2) > 0); }
// //
inline bool operator> (const char * s1, const wxString& s2) { return s2.Cmp(s1) < 0; } inline bool operator> (const char * s1, const wxString& s2) { return (s2.Cmp(s1) < 0); }
// //
inline bool operator<=(const wxString& s1, const wxString& s2) { return s1.Cmp(s2) <= 0; } inline bool operator<=(const wxString& s1, const wxString& s2) { return (s1.Cmp(s2) <= 0); }
// //
inline bool operator<=(const wxString& s1, const char * s2) { return s1.Cmp(s2) <= 0; } inline bool operator<=(const wxString& s1, const char * s2) { return (s1.Cmp(s2) <= 0); }
// //
inline bool operator<=(const char * s1, const wxString& s2) { return s2.Cmp(s1) >= 0; } inline bool operator<=(const char * s1, const wxString& s2) { return (s2.Cmp(s1) >= 0); }
// //
inline bool operator>=(const wxString& s1, const wxString& s2) { return s1.Cmp(s2) >= 0; } inline bool operator>=(const wxString& s1, const wxString& s2) { return (s1.Cmp(s2) >= 0); }
// //
inline bool operator>=(const wxString& s1, const char * s2) { return s1.Cmp(s2) >= 0; } inline bool operator>=(const wxString& s1, const char * s2) { return (s1.Cmp(s2) >= 0); }
// //
inline bool operator>=(const char * s1, const wxString& s2) { return s2.Cmp(s1) <= 0; } inline bool operator>=(const char * s1, const wxString& s2) { return (s2.Cmp(s1) <= 0); }
wxString WXDLLEXPORT operator+(const wxString& string1, const wxString& string2); wxString WXDLLEXPORT operator+(const wxString& string1, const wxString& string2);
wxString WXDLLEXPORT operator+(const wxString& string, char ch); wxString WXDLLEXPORT operator+(const wxString& string, char ch);

View File

@@ -91,7 +91,7 @@ class PropFormFrame: public wxPropertyFormFrame
public: public:
PropFormFrame(wxPropertyFormView *v, wxFrame *parent, const wxString& title, PropFormFrame(wxPropertyFormView *v, wxFrame *parent, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME, const wxString& name = "frame"): long style = wxDEFAULT_FRAME_STYLE, const wxString& name = "frame"):
wxPropertyFormFrame(v, parent, title, pos, size, style, name) wxPropertyFormFrame(v, parent, title, pos, size, style, name)
{ {
} }

View File

@@ -207,7 +207,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event))
{ {
// Make another frame, containing a canvas // Make another frame, containing a canvas
MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(10, 10), wxSize(300, 300), MyChild *subframe = new MyChild(frame, "Canvas Frame", wxPoint(10, 10), wxSize(300, 300),
wxDEFAULT_FRAME); wxDEFAULT_FRAME_STYLE);
char titleBuf[100]; char titleBuf[100];
sprintf(titleBuf, "Canvas Frame %d", winNumber); sprintf(titleBuf, "Canvas Frame %d", winNumber);

View File

@@ -38,7 +38,7 @@
#include <commdlg.h> #include <commdlg.h>
#endif #endif
#if defined(__WATCOMC__) || defined(__SC__) #if defined(__WATCOMC__) || defined(__SC__) || defined(__SALFORDC__)
#include <windowsx.h> #include <windowsx.h>
#include <commdlg.h> #include <commdlg.h>
#endif #endif

View File

@@ -30,6 +30,7 @@
#if defined(__WXMSW__) && !defined(__GNUWIN32__) #if defined(__WXMSW__) && !defined(__GNUWIN32__)
#include <io.h> #include <io.h>
#ifndef __SALFORDC__
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#define NOSERVICE #define NOSERVICE
#define NOIME #define NOIME
@@ -50,6 +51,8 @@
#define NOKANJI #define NOKANJI
#define NOCRYPT #define NOCRYPT
#define NOMCX #define NOMCX
#endif
#include <windows.h> // for GetTempFileName #include <windows.h> // for GetTempFileName
#elif (defined(__UNIX__) || defined(__GNUWIN32__)) #elif (defined(__UNIX__) || defined(__GNUWIN32__))
#include <unistd.h> #include <unistd.h>
@@ -72,6 +75,7 @@
#include <stdio.h> // SEEK_xxx constants #include <stdio.h> // SEEK_xxx constants
#include <fcntl.h> // O_RDONLY &c #include <fcntl.h> // O_RDONLY &c
#ifndef __MWERKS__ #ifndef __MWERKS__
#include <sys/types.h> // needed for stat #include <sys/types.h> // needed for stat
#include <sys/stat.h> // stat #include <sys/stat.h> // stat
@@ -125,6 +129,11 @@
#define O_BINARY (0) #define O_BINARY (0)
#endif //__UNIX__ #endif //__UNIX__
#ifdef __SALFORDC__
#include <unix.h>
#endif
// wxWindows // wxWindows
#include <wx/string.h> #include <wx/string.h>
#include <wx/intl.h> #include <wx/intl.h>
@@ -144,8 +153,13 @@
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxFile::Exists(const char *name) bool wxFile::Exists(const char *name)
{ {
#ifdef __SALFORDC__
struct _stat st;
#else
struct stat st; struct stat st;
return !access(name, 0) && !stat(name, &st) && (st.st_mode & S_IFREG); #endif
return !access(name, 0) && !stat((char*) name, &st) && (st.st_mode & S_IFREG);
} }
bool wxFile::Access(const char *name, OpenMode mode) bool wxFile::Access(const char *name, OpenMode mode)
@@ -188,12 +202,17 @@ wxFile::~wxFile()
} }
// create the file, fail if it already exists and bOverwrite // create the file, fail if it already exists and bOverwrite
bool wxFile::Create(const char *szFileName, bool bOverwrite, int access) bool wxFile::Create(const char *szFileName, bool bOverwrite, int accessMode)
{ {
// if bOverwrite we create a new file or truncate the existing one, // 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 // 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), access); (bOverwrite ? O_TRUNC : O_EXCL));
#else
int fd = open(szFileName, O_WRONLY | O_CREAT |
(bOverwrite ? O_TRUNC : O_EXCL), accessMode);
#endif
if ( fd == -1 ) { if ( fd == -1 ) {
wxLogSysError(_("can't create file '%s'"), szFileName); wxLogSysError(_("can't create file '%s'"), szFileName);
@@ -206,7 +225,7 @@ bool wxFile::Create(const char *szFileName, bool bOverwrite, int access)
} }
// open the file // open the file
bool wxFile::Open(const char *szFileName, OpenMode mode, int access) bool wxFile::Open(const char *szFileName, OpenMode mode, int accessMode)
{ {
int flags = O_BINARY; int flags = O_BINARY;
@@ -228,7 +247,11 @@ bool wxFile::Open(const char *szFileName, OpenMode mode, int access)
break; break;
} }
int fd = open(szFileName, flags, access); #ifdef __SALFORDC__
int fd = open(szFileName, flags);
#else
int fd = open(szFileName, flags, accessMode);
#endif
if ( fd == -1 ) { if ( fd == -1 ) {
wxLogSysError(_("can't open file '%s'"), szFileName); wxLogSysError(_("can't open file '%s'"), szFileName);
@@ -405,7 +428,7 @@ bool wxFile::Eof() const
int iRc; int iRc;
#if defined(__UNIX__) || defined(__GNUWIN32__) || defined( __MWERKS__ ) #if defined(__UNIX__) || defined(__GNUWIN32__) || defined( __MWERKS__ ) || defined(__SALFORDC__)
// @@ this doesn't work, of course, on unseekable file descriptors // @@ this doesn't work, of course, on unseekable file descriptors
off_t ofsCur = Tell(), off_t ofsCur = Tell(),
ofsMax = Length(); ofsMax = Length();

View File

@@ -14,21 +14,22 @@
#pragma implementation "fileconf.h" #pragma implementation "fileconf.h"
#endif #endif
// ============================================================================
// declarations
// ============================================================================
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// headers // headers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "wx/wxprec.h" #include "wx/wxprec.h"
#include "wx/fileconf.h"
#ifdef wxUSE_CONFIG
#ifdef __BORLANDC__ #ifdef __BORLANDC__
#pragma hdrstop #pragma hdrstop
#endif //__BORLANDC__ #endif //__BORLANDC__
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/wx.h" #include "wx/string.h"
#include "wx/intl.h"
#endif //WX_PRECOMP #endif //WX_PRECOMP
#include "wx/app.h" #include "wx/app.h"
@@ -37,6 +38,7 @@
#include "wx/log.h" #include "wx/log.h"
#include "wx/textfile.h" #include "wx/textfile.h"
#include "wx/config.h" #include "wx/config.h"
#include "wx/fileconf.h"
#include "wx/utils.h" // for wxGetHomeDir #include "wx/utils.h" // for wxGetHomeDir
@@ -71,10 +73,10 @@
inline bool IsValid(char c) { return isalnum(c) || strchr("@_/-!.*%", c); } inline bool IsValid(char c) { return isalnum(c) || strchr("@_/-!.*%", c); }
// compare functions for sorting the arrays // compare functions for sorting the arrays
static int CompareEntries(wxFileConfig::ConfigEntry *p1, static int CompareEntries(ConfigEntry *p1,
wxFileConfig::ConfigEntry *p2); ConfigEntry *p2);
static int CompareGroups(wxFileConfig::ConfigGroup *p1, static int CompareGroups(ConfigGroup *p1,
wxFileConfig::ConfigGroup *p2); ConfigGroup *p2);
// filter strings // filter strings
static wxString FilterIn(const wxString& str); static wxString FilterIn(const wxString& str);
@@ -95,8 +97,6 @@ wxString wxFileConfig::GetGlobalDir()
strDir = "/etc/"; strDir = "/etc/";
#elif defined(__WXSTUBS__) #elif defined(__WXSTUBS__)
wxASSERT_MSG( FALSE, "TODO" ) ; wxASSERT_MSG( FALSE, "TODO" ) ;
#elif defined(__WXMAC__)
wxASSERT_MSG( FALSE, "TODO" ) ;
#else // Windows #else // Windows
char szWinDir[MAX_PATH]; char szWinDir[MAX_PATH];
::GetWindowsDirectory(szWinDir, MAX_PATH); ::GetWindowsDirectory(szWinDir, MAX_PATH);
@@ -704,7 +704,7 @@ bool wxFileConfig::DeleteAll()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// append a new line to the end of the list // append a new line to the end of the list
wxFileConfig::LineList *wxFileConfig::LineListAppend(const wxString& str) LineList *wxFileConfig::LineListAppend(const wxString& str)
{ {
LineList *pLine = new LineList(str); LineList *pLine = new LineList(str);
@@ -723,7 +723,7 @@ wxFileConfig::LineList *wxFileConfig::LineListAppend(const wxString& str)
} }
// insert a new line after the given one or in the very beginning if !pLine // insert a new line after the given one or in the very beginning if !pLine
wxFileConfig::LineList *wxFileConfig::LineListInsert(const wxString& str, LineList *wxFileConfig::LineListInsert(const wxString& str,
LineList *pLine) LineList *pLine)
{ {
if ( pLine == m_linesTail ) if ( pLine == m_linesTail )
@@ -782,7 +782,7 @@ bool wxFileConfig::LineListIsEmpty()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ctor // ctor
wxFileConfig::ConfigGroup::ConfigGroup(wxFileConfig::ConfigGroup *pParent, ConfigGroup::ConfigGroup(ConfigGroup *pParent,
const wxString& strName, const wxString& strName,
wxFileConfig *pConfig) wxFileConfig *pConfig)
: m_aEntries(CompareEntries), : m_aEntries(CompareEntries),
@@ -799,7 +799,7 @@ wxFileConfig::ConfigGroup::ConfigGroup(wxFileConfig::ConfigGroup *pParent,
} }
// dtor deletes all children // dtor deletes all children
wxFileConfig::ConfigGroup::~ConfigGroup() ConfigGroup::~ConfigGroup()
{ {
// entries // entries
size_t n, nCount = m_aEntries.Count(); size_t n, nCount = m_aEntries.Count();
@@ -816,7 +816,7 @@ wxFileConfig::ConfigGroup::~ConfigGroup()
// line // line
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxFileConfig::ConfigGroup::SetLine(LineList *pLine) void ConfigGroup::SetLine(LineList *pLine)
{ {
wxASSERT( m_pLine == NULL ); // shouldn't be called twice wxASSERT( m_pLine == NULL ); // shouldn't be called twice
@@ -857,7 +857,7 @@ void wxFileConfig::ConfigGroup::SetLine(LineList *pLine)
// Return the line which contains "[our name]". If we're still not in the list, // Return the line which contains "[our name]". If we're still not in the list,
// add our line to it immediately after the last line of our parent group if we // add our line to it immediately after the last line of our parent group if we
// have it or in the very beginning if we're the root group. // have it or in the very beginning if we're the root group.
wxFileConfig::LineList *wxFileConfig::ConfigGroup::GetGroupLine() LineList *ConfigGroup::GetGroupLine()
{ {
if ( m_pLine == NULL ) { if ( m_pLine == NULL ) {
ConfigGroup *pParent = Parent(); ConfigGroup *pParent = Parent();
@@ -882,12 +882,12 @@ wxFileConfig::LineList *wxFileConfig::ConfigGroup::GetGroupLine()
// Return the last line belonging to the subgroups of this group (after which // Return the last line belonging to the subgroups of this group (after which
// we can add a new subgroup), if we don't have any subgroups or entries our // we can add a new subgroup), if we don't have any subgroups or entries our
// last line is the group line (m_pLine) itself. // last line is the group line (m_pLine) itself.
wxFileConfig::LineList *wxFileConfig::ConfigGroup::GetLastGroupLine() LineList *ConfigGroup::GetLastGroupLine()
{ {
// if we have any subgroups, our last line is the last line of the last // if we have any subgroups, our last line is the last line of the last
// subgroup // subgroup
if ( m_pLastGroup != NULL ) { if ( m_pLastGroup != NULL ) {
wxFileConfig::LineList *pLine = m_pLastGroup->GetLastGroupLine(); LineList *pLine = m_pLastGroup->GetLastGroupLine();
wxASSERT( pLine != NULL ); // last group must have !NULL associated line wxASSERT( pLine != NULL ); // last group must have !NULL associated line
return pLine; return pLine;
@@ -900,10 +900,10 @@ wxFileConfig::LineList *wxFileConfig::ConfigGroup::GetLastGroupLine()
// return the last line belonging to the entries of this group (after which // return the last line belonging to the entries of this group (after which
// we can add a new entry), if we don't have any entries we will add the new // we can add a new entry), if we don't have any entries we will add the new
// one immediately after the group line itself. // one immediately after the group line itself.
wxFileConfig::LineList *wxFileConfig::ConfigGroup::GetLastEntryLine() LineList *ConfigGroup::GetLastEntryLine()
{ {
if ( m_pLastEntry != NULL ) { if ( m_pLastEntry != NULL ) {
wxFileConfig::LineList *pLine = m_pLastEntry->GetLine(); LineList *pLine = m_pLastEntry->GetLine();
wxASSERT( pLine != NULL ); // last entry must have !NULL associated line wxASSERT( pLine != NULL ); // last entry must have !NULL associated line
return pLine; return pLine;
@@ -917,7 +917,7 @@ wxFileConfig::LineList *wxFileConfig::ConfigGroup::GetLastEntryLine()
// group name // group name
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxString wxFileConfig::ConfigGroup::GetFullName() const wxString ConfigGroup::GetFullName() const
{ {
if ( Parent() ) if ( Parent() )
return Parent()->GetFullName() + wxCONFIG_PATH_SEPARATOR + Name(); return Parent()->GetFullName() + wxCONFIG_PATH_SEPARATOR + Name();
@@ -930,14 +930,14 @@ wxString wxFileConfig::ConfigGroup::GetFullName() const
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// use binary search because the array is sorted // use binary search because the array is sorted
wxFileConfig::ConfigEntry * ConfigEntry *
wxFileConfig::ConfigGroup::FindEntry(const char *szName) const ConfigGroup::FindEntry(const char *szName) const
{ {
size_t i, size_t i,
lo = 0, lo = 0,
hi = m_aEntries.Count(); hi = m_aEntries.Count();
int res; int res;
wxFileConfig::ConfigEntry *pEntry; ConfigEntry *pEntry;
while ( lo < hi ) { while ( lo < hi ) {
i = (lo + hi)/2; i = (lo + hi)/2;
@@ -960,14 +960,14 @@ wxFileConfig::ConfigGroup::FindEntry(const char *szName) const
return NULL; return NULL;
} }
wxFileConfig::ConfigGroup * ConfigGroup *
wxFileConfig::ConfigGroup::FindSubgroup(const char *szName) const ConfigGroup::FindSubgroup(const char *szName) const
{ {
size_t i, size_t i,
lo = 0, lo = 0,
hi = m_aSubgroups.Count(); hi = m_aSubgroups.Count();
int res; int res;
wxFileConfig::ConfigGroup *pGroup; ConfigGroup *pGroup;
while ( lo < hi ) { while ( lo < hi ) {
i = (lo + hi)/2; i = (lo + hi)/2;
@@ -995,8 +995,8 @@ wxFileConfig::ConfigGroup::FindSubgroup(const char *szName) const
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// create a new entry and add it to the current group // create a new entry and add it to the current group
wxFileConfig::ConfigEntry * ConfigEntry *
wxFileConfig::ConfigGroup::AddEntry(const wxString& strName, int nLine) ConfigGroup::AddEntry(const wxString& strName, int nLine)
{ {
wxASSERT( FindEntry(strName) == NULL ); wxASSERT( FindEntry(strName) == NULL );
@@ -1007,8 +1007,8 @@ wxFileConfig::ConfigGroup::AddEntry(const wxString& strName, int nLine)
} }
// create a new group and add it to the current group // create a new group and add it to the current group
wxFileConfig::ConfigGroup * ConfigGroup *
wxFileConfig::ConfigGroup::AddSubgroup(const wxString& strName) ConfigGroup::AddSubgroup(const wxString& strName)
{ {
wxASSERT( FindSubgroup(strName) == NULL ); wxASSERT( FindSubgroup(strName) == NULL );
@@ -1029,7 +1029,7 @@ wxFileConfig::ConfigGroup::AddSubgroup(const wxString& strName)
delete several of them. delete several of them.
*/ */
bool wxFileConfig::ConfigGroup::DeleteSubgroupByName(const char *szName) bool ConfigGroup::DeleteSubgroupByName(const char *szName)
{ {
return DeleteSubgroup(FindSubgroup(szName)); return DeleteSubgroup(FindSubgroup(szName));
} }
@@ -1037,7 +1037,7 @@ bool wxFileConfig::ConfigGroup::DeleteSubgroupByName(const char *szName)
// doesn't delete the subgroup itself, but does remove references to it from // doesn't delete the subgroup itself, but does remove references to it from
// all other data structures (and normally the returned pointer should be // all other data structures (and normally the returned pointer should be
// deleted a.s.a.p. because there is nothing much to be done with it anyhow) // deleted a.s.a.p. because there is nothing much to be done with it anyhow)
bool wxFileConfig::ConfigGroup::DeleteSubgroup(ConfigGroup *pGroup) bool ConfigGroup::DeleteSubgroup(ConfigGroup *pGroup)
{ {
wxCHECK( pGroup != NULL, FALSE ); // deleting non existing group? wxCHECK( pGroup != NULL, FALSE ); // deleting non existing group?
@@ -1101,7 +1101,7 @@ bool wxFileConfig::ConfigGroup::DeleteSubgroup(ConfigGroup *pGroup)
return TRUE; return TRUE;
} }
bool wxFileConfig::ConfigGroup::DeleteEntry(const char *szName) bool ConfigGroup::DeleteEntry(const char *szName)
{ {
ConfigEntry *pEntry = FindEntry(szName); ConfigEntry *pEntry = FindEntry(szName);
wxCHECK( pEntry != NULL, FALSE ); // deleting non existing item? wxCHECK( pEntry != NULL, FALSE ); // deleting non existing item?
@@ -1154,7 +1154,7 @@ bool wxFileConfig::ConfigGroup::DeleteEntry(const char *szName)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// //
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxFileConfig::ConfigGroup::SetDirty() void ConfigGroup::SetDirty()
{ {
m_bDirty = TRUE; m_bDirty = TRUE;
if ( Parent() != NULL ) // propagate upwards if ( Parent() != NULL ) // propagate upwards
@@ -1168,7 +1168,7 @@ void wxFileConfig::ConfigGroup::SetDirty()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// ctor // ctor
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxFileConfig::ConfigEntry::ConfigEntry(wxFileConfig::ConfigGroup *pParent, ConfigEntry::ConfigEntry(ConfigGroup *pParent,
const wxString& strName, const wxString& strName,
int nLine) int nLine)
: m_strName(strName) : m_strName(strName)
@@ -1190,7 +1190,7 @@ wxFileConfig::ConfigEntry::ConfigEntry(wxFileConfig::ConfigGroup *pParent,
// set value // set value
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void wxFileConfig::ConfigEntry::SetLine(LineList *pLine) void ConfigEntry::SetLine(LineList *pLine)
{ {
if ( m_pLine != NULL ) { if ( m_pLine != NULL ) {
wxLogWarning(_("entry '%s' appears more than once in group '%s'"), wxLogWarning(_("entry '%s' appears more than once in group '%s'"),
@@ -1203,7 +1203,7 @@ void wxFileConfig::ConfigEntry::SetLine(LineList *pLine)
// second parameter is FALSE if we read the value from file and prevents the // second parameter is FALSE if we read the value from file and prevents the
// entry from being marked as 'dirty' // entry from being marked as 'dirty'
void wxFileConfig::ConfigEntry::SetValue(const wxString& strValue, bool bUser) void ConfigEntry::SetValue(const wxString& strValue, bool bUser)
{ {
if ( bUser && IsImmutable() ) { if ( bUser && IsImmutable() ) {
wxLogWarning(_("attempt to change immutable key '%s' ignored."), wxLogWarning(_("attempt to change immutable key '%s' ignored."),
@@ -1239,7 +1239,7 @@ void wxFileConfig::ConfigEntry::SetValue(const wxString& strValue, bool bUser)
} }
} }
void wxFileConfig::ConfigEntry::SetDirty() void ConfigEntry::SetDirty()
{ {
m_bDirty = TRUE; m_bDirty = TRUE;
Group()->SetDirty(); Group()->SetDirty();
@@ -1253,8 +1253,8 @@ void wxFileConfig::ConfigEntry::SetDirty()
// compare functions for array sorting // compare functions for array sorting
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
int CompareEntries(wxFileConfig::ConfigEntry *p1, int CompareEntries(ConfigEntry *p1,
wxFileConfig::ConfigEntry *p2) ConfigEntry *p2)
{ {
#if wxCONFIG_CASE_SENSITIVE #if wxCONFIG_CASE_SENSITIVE
return strcmp(p1->Name(), p2->Name()); return strcmp(p1->Name(), p2->Name());
@@ -1263,8 +1263,8 @@ int CompareEntries(wxFileConfig::ConfigEntry *p1,
#endif #endif
} }
int CompareGroups(wxFileConfig::ConfigGroup *p1, int CompareGroups(ConfigGroup *p1,
wxFileConfig::ConfigGroup *p2) ConfigGroup *p2)
{ {
#if wxCONFIG_CASE_SENSITIVE #if wxCONFIG_CASE_SENSITIVE
return strcmp(p1->Name(), p2->Name()); return strcmp(p1->Name(), p2->Name());
@@ -1379,6 +1379,9 @@ wxString FilterOut(const wxString& str)
return strResult; return strResult;
} }
#endif
// wxUSE_CONFIG

View File

@@ -57,7 +57,7 @@
#endif #endif
#ifdef __WINDOWS__ #ifdef __WINDOWS__
#if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) #if !defined( __GNUWIN32__ ) && !defined( __MWERKS__ ) && !defined(__SALFORDC__)
#include <direct.h> #include <direct.h>
#include <dos.h> #include <dos.h>
#endif #endif
@@ -74,6 +74,11 @@
#include <dir.h> #include <dir.h>
#endif #endif
#ifdef __SALFORDC__
#include <dir.h>
#include <unix.h>
#endif
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/log.h" #include "wx/log.h"
@@ -240,7 +245,12 @@ wxFileExists (const wxString& filename)
return TRUE; return TRUE;
return FALSE ; return FALSE ;
#else #else
#ifdef __SALFORDC__
struct _stat stbuf;
#else
struct stat stbuf; struct stat stbuf;
#endif
if ((filename != "") && stat ((char *)(const char *)filename, &stbuf) == 0) if ((filename != "") && stat ((char *)(const char *)filename, &stbuf) == 0)
return TRUE; return TRUE;
@@ -992,8 +1002,14 @@ bool wxRmdir(const wxString& dir, int WXUNUSED(flags))
wxUnix2MacFilename( gwxMacFileName ) ; wxUnix2MacFilename( gwxMacFileName ) ;
return (rmdir(WXSTRINGCAST gwxMacFileName) == 0); return (rmdir(WXSTRINGCAST gwxMacFileName) == 0);
#else #else
#ifdef __SALFORDC__
return FALSE; // What to do?
#else
return (rmdir(WXSTRINGCAST dir) == 0); return (rmdir(WXSTRINGCAST dir) == 0);
#endif #endif
#endif
} }
#if 0 #if 0
@@ -1051,8 +1067,13 @@ bool wxPathExists(const char *pszPathName)
if ( wxEndsWithPathSeparator(pszPathName) && pszPathName[1] != '\0' ) if ( wxEndsWithPathSeparator(pszPathName) && pszPathName[1] != '\0' )
strPath.Last() = '\0'; strPath.Last() = '\0';
#ifdef __SALFORDC__
struct _stat st;
#else
struct stat st; struct stat st;
return stat(strPath, &st) == 0 && (st.st_mode & S_IFDIR); #endif
return stat((char*) (const char*) strPath, &st) == 0 && (st.st_mode & S_IFDIR);
} }
// Get a temporary filename, opening and closing the file. // Get a temporary filename, opening and closing the file.

View File

@@ -30,6 +30,12 @@
#include "wx/wfstream.h" #include "wx/wfstream.h"
#include "wx/intl.h" #include "wx/intl.h"
#ifdef __SALFORDC__
#ifdef FAR
#undef FAR
#endif
#endif
#ifdef __WXMSW__ #ifdef __WXMSW__
#include <windows.h> #include <windows.h>
#endif #endif
@@ -396,6 +402,7 @@ wxImageHandler *wxImage::FindHandler( const wxString& name )
{ {
wxImageHandler *handler = (wxImageHandler*)node->Data(); wxImageHandler *handler = (wxImageHandler*)node->Data();
if (handler->GetName() == name) return handler; if (handler->GetName() == name) return handler;
node = node->Next(); node = node->Next();
} }
return (wxImageHandler *)NULL; return (wxImageHandler *)NULL;

View File

@@ -825,8 +825,6 @@ OBJ1 = adler32$(O) compress$(O) crc32$(O) gzio$(O) uncompr$(O) deflate$(O) \
OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \ OBJ2 = zutil$(O) inflate$(O) infblock$(O) inftrees$(O) infcodes$(O) \
infutil$(O) inffast$(O) infutil$(O) inffast$(O)
all: $(LIBTARGET)
adler32.obj: adler32.c zutil.h zlib.h zconf.h adler32.obj: adler32.c zutil.h zlib.h zconf.h
$(CC) -c $(CFLAGS) $*.c $(CC) -c $(CFLAGS) $*.c

View File

@@ -101,7 +101,7 @@ test: minigzip.exe example.exe
echo hello world | minigzip | minigzip -d >test echo hello world | minigzip | minigzip -d >test
type test type test
clean: clean: .SYMBOLIC
-erase *.obj -erase *.obj
-erase *.exe -erase *.exe
-erase $(LIBTARGET) -erase $(LIBTARGET)