diff options
Diffstat (limited to 'apt-pkg/deb')
| -rw-r--r-- | apt-pkg/deb/deblistparser.cc | 21 | ||||
| -rw-r--r-- | apt-pkg/deb/debrecords.cc | 29 | ||||
| -rw-r--r-- | apt-pkg/deb/debsrcrecords.h | 7 |
3 files changed, 29 insertions, 28 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index a1247dd98..6f47053a5 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -126,7 +126,7 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/ { if (showErrors == true) _error->Warning("Architecture: all package '%s' can't be Multi-Arch: same", - Section.FindS("Package").c_str()); + Package().c_str()); MA = pkgCache::Version::No; } else @@ -140,7 +140,7 @@ unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/ { if (showErrors == true) _error->Warning("Unknown Multi-Arch type '%s' for package '%s'", - MultiArch.to_string().c_str(), Section.FindS("Package").c_str()); + MultiArch.to_string().c_str(), Package().c_str()); MA = pkgCache::Version::No; } @@ -256,21 +256,20 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver) // ListParser::AvailableDescriptionLanguages /*{{{*/ std::vector<std::string> debListParser::AvailableDescriptionLanguages() { - std::vector<std::string> const understood = APT::Configuration::getLanguages(true); std::vector<std::string> avail; static constexpr int prefixLen = 12; char buf[32] = "Description-"; - if (Section.Exists("Description") == true) - avail.push_back(""); - for (std::vector<std::string>::const_iterator lang = understood.begin(); lang != understood.end(); ++lang) + if (Section.Exists(pkgTagSection::Key::Description)) + avail.emplace_back(); + for (auto const &lang : APT::Configuration::getLanguages(true)) { - if (unlikely(lang->size() > sizeof(buf) - prefixLen)) { - _error->Warning("Ignoring translated description %s", lang->c_str()); + if (unlikely(lang.size() > sizeof(buf) - prefixLen)) { + _error->Warning("Ignoring translated description %s", lang.c_str()); continue; } - memcpy(buf + prefixLen, lang->c_str(), lang->size()); - if (Section.Exists(StringView(buf, prefixLen + lang->size())) == true) - avail.push_back(*lang); + memcpy(buf + prefixLen, lang.c_str(), lang.size()); + if (Section.Exists(StringView(buf, prefixLen + lang.size())) == true) + avail.push_back(lang); } return avail; } diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc index 8fb17ae0b..e2ffaefff 100644 --- a/apt-pkg/deb/debrecords.cc +++ b/apt-pkg/deb/debrecords.cc @@ -16,6 +16,7 @@ #include <apt-pkg/fileutl.h> #include <apt-pkg/pkgcache.h> #include <apt-pkg/strutl.h> +#include <apt-pkg/tagfile-keys.h> #include <apt-pkg/tagfile.h> #include <algorithm> @@ -57,13 +58,13 @@ debRecordParserBase::debRecordParserBase() : Parser(), d(NULL) {} // RecordParserBase::FileName - Return the archive filename on the site /*{{{*/ string debRecordParserBase::FileName() { - return Section.FindS("Filename"); + return Section.Find(pkgTagSection::Key::Filename).to_string(); } /*}}}*/ // RecordParserBase::Name - Return the package name /*{{{*/ string debRecordParserBase::Name() { - string Result = Section.FindS("Package"); + auto Result = Section.Find(pkgTagSection::Key::Package).to_string(); // Normalize mixed case package names to lower case, like dpkg does // See Bug#807012 for details @@ -75,7 +76,7 @@ string debRecordParserBase::Name() // RecordParserBase::Homepage - Return the package homepage /*{{{*/ string debRecordParserBase::Homepage() { - return Section.FindS("Homepage"); + return Section.Find(pkgTagSection::Key::Homepage).to_string(); } /*}}}*/ // RecordParserBase::Hashes - return the available archive hashes /*{{{*/ @@ -88,7 +89,7 @@ HashStringList debRecordParserBase::Hashes() const if (hash.empty() == false) hashes.push_back(HashString(*type, hash)); } - auto const size = Section.FindULL("Size", 0); + auto const size = Section.FindULL(pkgTagSection::Key::Size, 0); if (size != 0) hashes.FileSize(size); return hashes; @@ -97,7 +98,7 @@ HashStringList debRecordParserBase::Hashes() const // RecordParserBase::Maintainer - Return the maintainer email /*{{{*/ string debRecordParserBase::Maintainer() { - return Section.FindS("Maintainer"); + return Section.Find(pkgTagSection::Key::Maintainer).to_string(); } /*}}}*/ // RecordParserBase::RecordField - Return the value of an arbitrary field /*{{*/ @@ -134,20 +135,20 @@ string debRecordParserBase::LongDesc(std::string const &lang) break; else if (*l == "en") { - orig = Section.FindS("Description"); + orig = Section.Find(pkgTagSection::Key::Description).to_string(); if (orig.empty() == false) break; } } if (orig.empty() == true) - orig = Section.FindS("Description"); + orig = Section.Find(pkgTagSection::Key::Description).to_string(); } else { std::string const tagname = "Description-" + lang; orig = Section.FindS(tagname.c_str()); if (orig.empty() == true && lang == "en") - orig = Section.FindS("Description"); + orig = Section.Find(pkgTagSection::Key::Description).to_string(); } char const * const codeset = nl_langinfo(CODESET); @@ -165,17 +166,17 @@ static const char * const SourceVerSeparators = " ()"; // RecordParserBase::SourcePkg - Return the source package name if any /*{{{*/ string debRecordParserBase::SourcePkg() { - string Res = Section.FindS("Source"); - string::size_type Pos = Res.find_first_of(SourceVerSeparators); - if (Pos == string::npos) - return Res; - return string(Res,0,Pos); + auto Res = Section.Find(pkgTagSection::Key::Source).to_string(); + auto const Pos = Res.find_first_of(SourceVerSeparators); + if (Pos != std::string::npos) + Res.erase(Pos); + return Res; } /*}}}*/ // RecordParserBase::SourceVer - Return the source version number if present /*{{{*/ string debRecordParserBase::SourceVer() { - string Pkg = Section.FindS("Source"); + auto const Pkg = Section.Find(pkgTagSection::Key::Source).to_string(); string::size_type Pos = Pkg.find_first_of(SourceVerSeparators); if (Pos == string::npos) return ""; diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h index b572d3427..1a0bbe0fd 100644 --- a/apt-pkg/deb/debsrcrecords.h +++ b/apt-pkg/deb/debsrcrecords.h @@ -12,6 +12,7 @@ #include <apt-pkg/fileutl.h> #include <apt-pkg/srcrecords.h> +#include <apt-pkg/tagfile-keys.h> #include <apt-pkg/tagfile.h> #include <string> @@ -40,9 +41,9 @@ class APT_HIDDEN debSrcRecordParser : public pkgSrcRecords::Parser virtual bool Jump(unsigned long const &Off) APT_OVERRIDE {iOffset = Off; return Tags.Jump(Sect,Off);}; virtual std::string Package() const APT_OVERRIDE; - virtual std::string Version() const APT_OVERRIDE {return Sect.FindS("Version");}; - virtual std::string Maintainer() const APT_OVERRIDE {return Sect.FindS("Maintainer");}; - virtual std::string Section() const APT_OVERRIDE {return Sect.FindS("Section");}; + virtual std::string Version() const APT_OVERRIDE {return Sect.Find(pkgTagSection::Key::Version).to_string();}; + virtual std::string Maintainer() const APT_OVERRIDE {return Sect.Find(pkgTagSection::Key::Maintainer).to_string();}; + virtual std::string Section() const APT_OVERRIDE {return Sect.Find(pkgTagSection::Key::Section).to_string();}; virtual const char **Binaries() APT_OVERRIDE; virtual bool BuildDepends(std::vector<BuildDepRec> &BuildDeps, bool const &ArchOnly, bool const &StripMultiArch = true) APT_OVERRIDE; virtual unsigned long Offset() APT_OVERRIDE {return iOffset;}; |
