Correct mistakes in wxStripExtension - correct wxString::npos. Spurred by 1073642 filefn.cpp StripExtension(wxString &)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30838 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -80,16 +80,8 @@ class WXDLLIMPEXP_BASE wxString;
|
|||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__VISAGECPP__) && __IBMCPP__ >= 400
|
|
||||||
// must define this static for VA or else you get multiply defined symbols everywhere
|
|
||||||
extern const unsigned int wxSTRING_MAXLEN;
|
|
||||||
|
|
||||||
#else
|
|
||||||
// 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 subtract 100)
|
#define wxSTRING_MAXLEN wxStringBase::npos
|
||||||
const unsigned int wxSTRING_MAXLEN = UINT_MAX - 100;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// global data
|
// global data
|
||||||
|
@@ -361,17 +361,16 @@ void wxStripExtension(wxChar *buffer)
|
|||||||
|
|
||||||
void wxStripExtension(wxString& buffer)
|
void wxStripExtension(wxString& buffer)
|
||||||
{
|
{
|
||||||
size_t len = buffer.Length();
|
//RN: Be careful about the handling the case where
|
||||||
size_t i = len-1;
|
//buffer.Length() == 0
|
||||||
while (i > 0)
|
for(size_t i = buffer.Length() - 1; i != wxString::npos; --i)
|
||||||
{
|
|
||||||
if (buffer.GetChar(i) == wxT('.'))
|
|
||||||
{
|
{
|
||||||
buffer = buffer.Left(i);
|
if (buffer.GetChar(i) == wxT('.'))
|
||||||
break;
|
{
|
||||||
|
buffer = buffer.Left(i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
i --;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Destructive removal of /./ and /../ stuff
|
// Destructive removal of /./ and /../ stuff
|
||||||
|
@@ -56,14 +56,9 @@
|
|||||||
// static class variables definition
|
// static class variables definition
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
#if defined(__VISAGECPP__) && __IBMCPP__ >= 400
|
|
||||||
// must define this static for VA or else you get multiply defined symbols
|
|
||||||
// everywhere
|
|
||||||
const unsigned int wxSTRING_MAXLEN = UINT_MAX - 100;
|
|
||||||
#endif // Visual Age
|
|
||||||
|
|
||||||
#if !wxUSE_STL
|
#if !wxUSE_STL
|
||||||
const size_t wxStringBase::npos = wxSTRING_MAXLEN;
|
//According to STL _must_ be a -1 size_t
|
||||||
|
const size_t wxStringBase::npos = (size_t) -1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user