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
This commit is contained in:
Mattia Barbon 2003-07-02 17:11:19 +00:00
parent c04b9739f6
commit f526f7526b
6 changed files with 63 additions and 20 deletions

View File

@ -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);

View File

@ -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

View File

@ -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("");

View File

@ -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;
}

View File

@ -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

View File

@ -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;