From 2887455004fa6a3bba32f3dea2027345d8a745e4 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 24 Mar 2009 12:20:23 +0000 Subject: [PATCH] correct translation between iterators and char pointers in CallStrptime() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@59810 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/datetimefmt.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/datetimefmt.cpp b/src/common/datetimefmt.cpp index 10111e562a..d7218ac999 100644 --- a/src/common/datetimefmt.cpp +++ b/src/common/datetimefmt.cpp @@ -110,14 +110,19 @@ CallStrptime(const wxString& str, const char *fmt, tm *tm) { - const char *start = str.mb_str(); - start = wxStringOperations::AddToIter(start, p - str.begin()); + // convert from iterator to char pointer: this is simple as wxCStrData + // already supports this + const char * const start = str.c_str() + (p - str.begin()); const char * const end = strptime(start, fmt, tm); if ( !end ) return false; - p += wxStringOperations::DiffIters(end, start); + // convert back from char pointer to iterator: unfortunately we have no way + // to do it efficiently currently so create a temporary string just to + // compute the number of characters between start and end + p += wxString(start, end - start).length(); + return true; }