X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/6d9b79dd961242702f0079e3dab2dd1c62bbc61e..4cdc3bf0e24a74b0af45e1cbabfcaebd9d0c3318:/ftparchive/writer.cc diff --git a/ftparchive/writer.cc b/ftparchive/writer.cc index 894a1173b..1036ce0b8 100644 --- a/ftparchive/writer.cc +++ b/ftparchive/writer.cc @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -623,12 +624,12 @@ SourcesWriter::SourcesWriter(FileFd * const GivenOutput, string const &DB, strin // SourcesWriter::DoPackage - Process a single package /*{{{*/ static std::string getDscHash(unsigned int const DoHashes, Hashes::SupportedHashes const DoIt, pkgTagSection &Tags, char const * const FieldName, - HashString const * const Hash, unsigned long long Size, std::string FileName) + HashString const * const Hash, unsigned long long Size, std::string const &FileName) { if ((DoHashes & DoIt) != DoIt || Tags.Exists(FieldName) == false || Hash == NULL) return ""; std::ostringstream out; - out << "\n " << Hash->HashValue() << " " << Size << " " << FileName + out << "\n " << Hash->HashValue() << " " << std::to_string(Size) << " " << FileName << "\n " << Tags.FindS(FieldName); return out.str(); } @@ -802,7 +803,7 @@ bool SourcesWriter::DoPackage(string FileName) if (Tags.Exists(fieldname) == true) continue; std::ostringstream streamout; - streamout << "\n " << hs->HashValue() << " " << Db.GetFileSize() << " " << ParseJnk; + streamout << "\n " << hs->HashValue() << " " << std::to_string(Db.GetFileSize()) << " " << ParseJnk; out->append(streamout.str()); } @@ -987,38 +988,33 @@ ReleaseWriter::ReleaseWriter(FileFd * const GivenOutput, string const &/*DB*/) : AddPatterns(_config->FindVector("APT::FTPArchive::Release::Patterns")); time_t const now = time(NULL); + auto const posix = std::locale("C.UTF-8"); - setlocale(LC_TIME, "C"); - - char datestr[128]; - if (strftime(datestr, sizeof(datestr), "%a, %d %b %Y %H:%M:%S UTC", - gmtime(&now)) == 0) - { - datestr[0] = '\0'; - } + // FIXME: use TimeRFC1123 here? But that uses GMT to satisfy HTTP/1.1 + std::ostringstream datestr; + datestr.imbue(posix); + datestr << std::put_time(gmtime(&now), "%a, %d %b %Y %H:%M:%S UTC"); time_t const validuntil = now + _config->FindI("APT::FTPArchive::Release::ValidTime", 0); - char validstr[128]; - if (now == validuntil || - strftime(validstr, sizeof(validstr), "%a, %d %b %Y %H:%M:%S UTC", - gmtime(&validuntil)) == 0) + std::ostringstream validstr; + if (validuntil != now) { - validstr[0] = '\0'; + datestr.imbue(posix); + validstr << std::put_time(gmtime(&validuntil), "%a, %d %b %Y %H:%M:%S UTC"); } - setlocale(LC_TIME, ""); - map Fields; Fields["Origin"] = ""; Fields["Label"] = ""; Fields["Suite"] = ""; Fields["Version"] = ""; Fields["Codename"] = ""; - Fields["Date"] = datestr; - Fields["Valid-Until"] = validstr; + Fields["Date"] = datestr.str(); + Fields["Valid-Until"] = validstr.str(); Fields["Architectures"] = ""; Fields["Components"] = ""; Fields["Description"] = ""; + Fields["Signed-By"] = ""; if (_config->FindB("APT::FTPArchive::DoByHash", false) == true) Fields["Acquire-By-Hash"] = "true";