From 23717034757c259cd578b6f72d74857e61e79817 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 5 Nov 2011 11:23:51 +0000 Subject: [PATCH] Fix format string in wxLog::LogLastRepeatIfNeeded(). We used a format string without any format specifiers in it in a call to wxString::Printf() which always had a parameter resulting in an assert failure about a mismatch between the string and parameter count. Fix this by using a separate Printf() call for this case. Closes #13613. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69678 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/common/log.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/common/log.cpp b/src/common/log.cpp index c30b582075..8335dcfd17 100644 --- a/src/common/log.cpp +++ b/src/common/log.cpp @@ -216,12 +216,24 @@ unsigned wxLog::LogLastRepeatIfNeeded() { wxString msg; #if wxUSE_INTL - msg.Printf(wxPLURAL("The previous message repeated once.", - "The previous message repeated %lu times.", - gs_prevLog.numRepeated), - gs_prevLog.numRepeated); + if ( gs_prevLog.numRepeated == 1 ) + { + // We use a separate message for this case as "repeated 1 time" + // looks somewhat strange. + msg = _("The previous message repeated once."); + } + else + { + // Notice that we still use wxPLURAL() to ensure that multiple + // numbers of times are correctly formatted, even though we never + // actually use the singular string. + msg.Printf(wxPLURAL("The previous message repeated %lu time.", + "The previous message repeated %lu times.", + gs_prevLog.numRepeated), + gs_prevLog.numRepeated); + } #else - msg.Printf(wxS("The previous message was repeated %lu times."), + msg.Printf(wxS("The previous message was repeated %lu time(s)."), gs_prevLog.numRepeated); #endif gs_prevLog.numRepeated = 0; -- 2.45.2