X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/da2fd5acd884129f58a5b394994ace8c22b55b6d..a8cc3ad1b0964273f932661a4a1145d1007e9a45:/src/common/filename.cpp?ds=sidebyside diff --git a/src/common/filename.cpp b/src/common/filename.cpp index 91318e43bf..086598ef3b 100644 --- a/src/common/filename.cpp +++ b/src/common/filename.cpp @@ -512,7 +512,10 @@ void wxFileName::SplitPath(const wxString& fullpath, } } - if ( (posLastDot != wxString::npos) && (posLastDot < posLastSlash) ) + // if we do have a dot and a slash, check that the dot is in the name part + if ( (posLastDot != wxString::npos) && + (posLastSlash != wxString::npos) && + (posLastDot < posLastSlash) ) { // the dot is part of the path, not the start of the extension posLastDot = wxString::npos; @@ -535,9 +538,23 @@ void wxFileName::SplitPath(const wxString& fullpath, if ( pstrName ) { + // take all characters starting from the one after the last slash and + // up to, but excluding, the last dot size_t nStart = posLastSlash == wxString::npos ? 0 : posLastSlash + 1; - size_t count = posLastDot == wxString::npos ? wxString::npos - : posLastDot - posLastSlash; + size_t count; + if ( posLastDot == wxString::npos ) + { + // take all until the end + count = wxString::npos; + } + else if ( posLastSlash == wxString::npos ) + { + count = posLastDot; + } + else // have both dot and slash + { + count = posLastDot - posLastSlash - 1; + } *pstrName = fullpath.Mid(nStart, count); }