From 874d29390f6db64b045b7952cc0331e40f25d325 Mon Sep 17 00:00:00 2001 From: T-Bonhagen <75760084+T-Bonhagen@users.noreply.github.com> Date: Sun, 21 Feb 2021 10:16:24 +0100 Subject: fix Program freeze Volume Creation Wizard linux (#726) --- src/Main/LanguageStrings.cpp | 2 -- src/Main/StringFormatter.cpp | 13 ++++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src/Main') diff --git a/src/Main/LanguageStrings.cpp b/src/Main/LanguageStrings.cpp index 3591255b..33aaf6a9 100644 --- a/src/Main/LanguageStrings.cpp +++ b/src/Main/LanguageStrings.cpp @@ -51,7 +51,6 @@ namespace VeraCrypt { wxString text = node.InnerText; text.Replace (L"\\n", L"\n"); - text.Replace (L"%s", L"{0}"); Map[StringConverter::ToSingle (wstring (node.Attributes[L"key"]))] = text; } #endif @@ -59,7 +58,6 @@ namespace VeraCrypt { wxString text = node.InnerText; text.Replace (L"\\n", L"\n"); - text.Replace (L"%s", L"{0}"); Map[StringConverter::ToSingle (wstring (node.Attributes[L"key"]))] = text; } } diff --git a/src/Main/StringFormatter.cpp b/src/Main/StringFormatter.cpp index 4f8c2cc6..e64f85c3 100644 --- a/src/Main/StringFormatter.cpp +++ b/src/Main/StringFormatter.cpp @@ -20,7 +20,18 @@ namespace VeraCrypt { bool numberExpected = false; bool endTagExpected = false; - foreach (wchar_t c, wstring (format)) + + //TODO replace this workaround for %s, %d, %c for printf + wxString text(format); + text.Replace (L"%s", L"{}",true); + text.Replace (L"%d", L"{}",true); + text.Replace (L"%c", L"{}",true); + int i=0; + while (text.find(L"{}") != (size_t) wxNOT_FOUND){ + text.Replace(L"{}",L"{"+wxString::Format(wxT("%i"),i++)+L"}",false); + } + + foreach (wchar_t c, wstring (text)) { if (numberExpected) { -- cgit v1.2.3