From 0919f1df552ddf022ce4508cbf40e04eae5ef896 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 23 Aug 2016 15:11:20 +0200 Subject: prevent C++ locale number formatting in text APIs (try 3) This time it is the formatting of floating numbers in progress reporting with a radix charater potentially not being dot. Followup of 7303e11ff28f920a6277c159aa46f80c007350bb. Regression of b58e2c7c56b1416a343e81f9f80cb1f02c128e25 in so far as it exchanging very effected with slightly less effected code. LP: 1611010 --- apt-pkg/acquire.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'apt-pkg/acquire.cc') diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 29362fb40..1efb772b4 100644 --- a/apt-pkg/acquire.cc +++ b/apt-pkg/acquire.cc @@ -1258,8 +1258,11 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner) snprintf(msg,sizeof(msg), _("Retrieving file %li of %li"), i, TotalItems); // build the status str - std::string dlstatus; - strprintf(dlstatus, "dlstatus:%ld:%.4f:%s\n", i, Percent, msg); + std::ostringstream str; + str.imbue(std::locale("C.UTF-8")); + str.precision(4); + str << "dlstatus" << ':' << std::fixed << i << ':' << Percent << ':' << msg << '\n'; + auto const dlstatus = str.str(); FileFd::Write(fd, dlstatus.data(), dlstatus.size()); } -- cgit v1.2.3