From f526f7526bfe458ec15ef1bd7abafd66caaf79c2 Mon Sep 17 00:00:00 2001 From: Mattia Barbon Date: Wed, 2 Jul 2003 17:11:19 +0000 Subject: [PATCH] Quick and dirty fix for building with COMPATIBILITY_2_4 off. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21580 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/list.h | 10 ++-------- include/wx/utils.h | 2 ++ src/common/docview.cpp | 16 ++++++++++++++-- src/common/filefn.cpp | 22 +++++++++++++++++----- src/common/list.cpp | 29 +++++++++++++++++++++++++---- src/common/utilscmn.cpp | 4 +++- 6 files changed, 63 insertions(+), 20 deletions(-) diff --git a/include/wx/list.h b/include/wx/list.h index bfd500d..e3c8284 100644 --- a/include/wx/list.h +++ b/include/wx/list.h @@ -37,10 +37,6 @@ #include "wx/object.h" #include "wx/string.h" -// due to circular header dependencies this function has to be declared here -// (normally it's found in utils.h which includes itself list.h...) -extern WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s); - class WXDLLIMPEXP_BASE wxObjectListNode; typedef wxObjectListNode wxNode; @@ -568,12 +564,10 @@ public: // operations // makes a copy of the string - wxNode *Add(const wxChar *s) - { return (wxNode *)wxStringListBase::Append(copystring(s)); } + wxNode *Add(const wxChar *s); // Append to beginning of list - wxNode *Prepend(const wxChar *s) - { return (wxNode *)wxStringListBase::Insert(copystring(s)); } + wxNode *Prepend(const wxChar *s); bool Delete(const wxChar *s); diff --git a/include/wx/utils.h b/include/wx/utils.h index 0880439..8d41542 100644 --- a/include/wx/utils.h +++ b/include/wx/utils.h @@ -57,7 +57,9 @@ class WXDLLIMPEXP_BASE wxPoint; // ---------------------------------------------------------------------------- // Make a copy of this string using 'new' +#if WXWIN_COMPATIBILITY_2_4 WXDLLIMPEXP_BASE wxChar* copystring(const wxChar *s); +#endif #if WXWIN_COMPATIBILITY_2 // Matches string one within string two regardless of case diff --git a/src/common/docview.cpp b/src/common/docview.cpp index 17fcf47..8714a27 100644 --- a/src/common/docview.cpp +++ b/src/common/docview.cpp @@ -1988,6 +1988,18 @@ void wxDocPrintout::GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, in // File history processor // ---------------------------------------------------------------------------- +static inline wxChar* MYcopystring(const wxString& s) +{ + wxChar* copy = new wxChar[s.length() + 1]; + return wxStrcpy(copy, s.c_str()); +} + +static inline wxChar* MYcopystring(const wxChar* s) +{ + wxChar* copy = new wxChar[wxStrlen(s) + 1]; + return wxStrcpy(copy, s); +} + wxFileHistory::wxFileHistory(size_t maxFiles, wxWindowID idBase) { m_fileMaxFiles = maxFiles; @@ -2058,7 +2070,7 @@ void wxFileHistory::AddFileToHistory(const wxString& file) { m_fileHistory[i] = m_fileHistory[i-1]; } - m_fileHistory[0] = copystring(file); + m_fileHistory[0] = MYcopystring(file); // this is the directory of the last opened file wxString pathCurrent; @@ -2187,7 +2199,7 @@ void wxFileHistory::Load(wxConfigBase& config) wxString historyFile; while ((m_fileHistoryN < m_fileMaxFiles) && config.Read(buf, &historyFile) && (historyFile != wxT(""))) { - m_fileHistory[m_fileHistoryN] = copystring((const wxChar*) historyFile); + m_fileHistory[m_fileHistoryN] = MYcopystring((const wxChar*) historyFile); m_fileHistoryN ++; buf.Printf(wxT("file%d"), (int)m_fileHistoryN+1); historyFile = wxT(""); diff --git a/src/common/filefn.cpp b/src/common/filefn.cpp index 3e6489a..6080ca0 100644 --- a/src/common/filefn.cpp +++ b/src/common/filefn.cpp @@ -215,6 +215,18 @@ WXDLLEXPORT int wxOpen( const wxChar *pathname, int flags, mode_t mode ) IMPLEMENT_DYNAMIC_CLASS(wxPathList, wxStringList) +static inline wxChar* MYcopystring(const wxString& s) +{ + wxChar* copy = new wxChar[s.length() + 1]; + return wxStrcpy(copy, s.c_str()); +} + +static inline wxChar* MYcopystring(const wxChar* s) +{ + wxChar* copy = new wxChar[wxStrlen(s) + 1]; + return wxStrcpy(copy, s); +} + void wxPathList::Add (const wxString& path) { wxStringList::Add (WXSTRINGCAST path); @@ -239,7 +251,7 @@ void wxPathList::AddEnvList (const wxString& envVariable) wxChar *val = wxGetenv (WXSTRINGCAST envVariable); if (val && *val) { - wxChar *s = copystring (val); + wxChar *s = MYcopystring (val); wxChar *save_ptr, *token = wxStrtok (s, PATH_TOKS, &save_ptr); if (token) @@ -502,9 +514,9 @@ wxChar *wxCopyAbsolutePath(const wxString& filename) wxStrcat(buf, wxT("/")); #endif wxStrcat(buf, wxFileFunctionsBuffer); - return copystring( wxRealPath(buf) ); + return MYcopystring( wxRealPath(buf) ); } - return copystring( wxFileFunctionsBuffer ); + return MYcopystring( wxFileFunctionsBuffer ); } /*- @@ -553,7 +565,7 @@ wxChar *wxExpandPath(wxChar *buf, const wxChar *name) buf[0] = wxT('\0'); if (name == NULL || *name == wxT('\0')) return buf; - nm = copystring(name); // Make a scratch copy + nm = MYcopystring(name); // Make a scratch copy wxChar *nm_tmp = nm; /* Skip leading whitespace and cr */ @@ -1385,7 +1397,7 @@ wxChar *wxGetTempFileName(const wxString& prefix, wxChar *buf) if ( buf ) wxStrcpy(buf, filename); else - buf = copystring(filename); + buf = MYcopystring(filename); return buf; } diff --git a/src/common/list.cpp b/src/common/list.cpp index b9c9e06..fed64c5 100644 --- a/src/common/list.cpp +++ b/src/common/list.cpp @@ -35,7 +35,6 @@ #ifndef WX_PRECOMP #include "wx/defs.h" #include "wx/list.h" - #include "wx/utils.h" // for copystring() (beurk...) #endif // ============================================================================= @@ -572,9 +571,21 @@ void wxObjectListNode::DeleteData() delete (wxObject *)GetData(); } -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- // wxStringList -// ----------------------------------------------------------------------------- +// ---------------------------------------------------------------------------- + +static inline wxChar* MYcopystring(const wxString& s) +{ + wxChar* copy = new wxChar[s.length() + 1]; + return wxStrcpy(copy, s.c_str()); +} + +static inline wxChar* MYcopystring(const wxChar* s) +{ + wxChar* copy = new wxChar[wxStrlen(s) + 1]; + return wxStrcpy(copy, s); +} IMPLEMENT_DYNAMIC_CLASS(wxStringList, wxObject) @@ -656,7 +667,7 @@ wxChar **wxStringList::ListToArray(bool new_copies) const { wxChar *s = node->GetData(); if ( new_copies ) - string_array[i] = copystring(s); + string_array[i] = MYcopystring(s); else string_array[i] = s; node = node->GetNext(); @@ -709,5 +720,15 @@ void wxStringList::Sort() delete [] array; } +wxNode *wxStringList::Add(const wxChar *s) +{ + return (wxNode *)wxStringListBase::Append(MYcopystring(s)); +} + +wxNode *wxStringList::Prepend(const wxChar *s) +{ + return (wxNode *)wxStringListBase::Insert(MYcopystring(s)); +} + #endif // wxLIST_COMPATIBILITY diff --git a/src/common/utilscmn.cpp b/src/common/utilscmn.cpp index 03deb79..4b732fd 100644 --- a/src/common/utilscmn.cpp +++ b/src/common/utilscmn.cpp @@ -557,7 +557,9 @@ wxChar *wxStripMenuCodes(const wxChar *in, wxChar *out) } else { - out = copystring(s); + // MYcopystring - for easier search... + out = new wxChar[s.length() + 1]; + wxStrcpy(out, s.c_str()); } return out; -- 2.7.4