]> git.saurik.com Git - apt.git/commitdiff
Use C locale instead of C.UTF-8 for protocol strings
authorJulian Andres Klode <jak@debian.org>
Tue, 23 Aug 2016 18:19:11 +0000 (20:19 +0200)
committerJulian Andres Klode <jak@debian.org>
Mon, 14 Nov 2016 14:10:03 +0000 (15:10 +0100)
The C.UTF-8 locale is not portable, so we need to use C, otherwise
we crash on other systems. We can use std::locale::classic() for
that, which might also be a bit cheaper than using locale("C").

(cherry picked from commit 0fb16c3e678044d6d06ba8a6199b1e96487ee0d8)

apt-pkg/acquire-item.cc
apt-pkg/acquire.cc
apt-pkg/contrib/strutl.cc
apt-pkg/install-progress.cc

index 334ed63a6aa89c3e9a2e86721e1fe1af65f00ca5..906ed9d8e8fdb7711b5903c0af7466c2796d073e 100644 (file)
@@ -1836,7 +1836,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile) /*{{{*/
    HashStringList ServerHashes;
    unsigned long long ServerSize = 0;
 
-   auto const &posix = std::locale("C.UTF-8");
+   auto const &posix = std::locale::classic();
    for (char const * const * type = HashString::SupportedHashes(); *type != NULL; ++type)
    {
       std::string tagname = *type;
index 3ce2e0d5a384916c15a180dfed30732f80745eba..145cbd56df3e5476bc52ba487bf9b718611907b1 100644 (file)
@@ -1248,7 +1248,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
 
       // build the status str
       std::ostringstream str;
-      str.imbue(std::locale("C.UTF-8"));
+      str.imbue(std::locale::classic());
       str.precision(4);
       str << "dlstatus" << ':' << std::fixed << i << ':' << Percent << ':' << msg << '\n';
       auto const dlstatus = str.str();
index ca924e578a299be7ac04b8a0b868ebc7117e634d..61a86a4797a25cd70f42fc5e98248503f0a3655e 100644 (file)
@@ -754,7 +754,7 @@ string TimeRFC1123(time_t Date)
    if (gmtime_r(&Date, &Conv) == NULL)
       return "";
 
-   auto const posix = std::locale("C.UTF-8");
+   auto const posix = std::locale::classic();
    std::ostringstream datestr;
    datestr.imbue(posix);
    datestr << std::put_time(&Conv, "%a, %d %b %Y %H:%M:%S GMT");
@@ -934,7 +934,7 @@ bool RFC1123StrToTime(const char* const str,time_t &time)
    signed int year = 0; // yes, Y23K problem – we gonna worry then…
    std::string weekday, month, datespec, timespec, zone;
    std::istringstream ss(str);
-   auto const &posix = std::locale("C.UTF-8");
+   auto const &posix = std::locale::classic();
    ss.imbue(posix);
    ss >> weekday;
    // we only superficially check weekday, mostly to avoid accepting localized
index 7acd61f6539438f2a8ec77bc74b1e825aa166eb7..c732753928a430fe8680b36f6435d6b265a34aca 100644 (file)
@@ -83,7 +83,7 @@ static std::string GetProgressFdString(char const * const status,
 {
    float const progress{Done / static_cast<float>(Total) * 100};
    std::ostringstream str;
-   str.imbue(std::locale("C.UTF-8"));
+   str.imbue(std::locale::classic());
    str.precision(4);
    str << status << ':' << pkg << ':' << std::fixed << progress << ':' << msg << '\n';
    return str.str();
@@ -164,7 +164,7 @@ static std::string GetProgressDeb822String(char const * const status,
 {
    float const progress{Done / static_cast<float>(Total) * 100};
    std::ostringstream str;
-   str.imbue(std::locale("C.UTF-8"));
+   str.imbue(std::locale::classic());
    str.precision(4);
    str << "Status: " << status << '\n';
    if (pkg != nullptr)