summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/deblistparser.cc28
-rw-r--r--apt-pkg/deb/deblistparser.h12
2 files changed, 22 insertions, 18 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 86fd5dc54..860aa3bc2 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -72,9 +72,9 @@ string debListParser::Package() {
// ListParser::Architecture - Return the package arch /*{{{*/
// ---------------------------------------------------------------------
/* This will return the Architecture of the package this section describes */
-string debListParser::Architecture() {
+APT::StringView debListParser::Architecture() {
auto const Arch = Section.Find("Architecture");
- return Arch.empty() ? "none" : Arch.to_string();
+ return Arch.empty() ? "none" : Arch;
}
/*}}}*/
// ListParser::ArchitectureAll /*{{{*/
@@ -89,9 +89,9 @@ bool debListParser::ArchitectureAll() {
/* This is to return the string describing the version in debian form,
epoch:upstream-release. If this returns the blank string then the
entry is assumed to only describe package properties */
-string debListParser::Version()
+APT::StringView debListParser::Version()
{
- return Section.Find("Version").to_string();
+ return Section.Find("Version");
}
/*}}}*/
unsigned char debListParser::ParseMultiArch(bool const showErrors) /*{{{*/
@@ -160,7 +160,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
const char * const Close = (const char * const) memchr(Open, ')', Stop - Open);
if (likely(Close != NULL))
{
- std::string const version(Open + 1, (Close - Open) - 1);
+ APT::StringView const version(Open + 1, (Close - Open) - 1);
if (version != Ver.VerStr())
{
map_stringitem_t const idx = StoreString(pkgCacheGenerator::VERSIONNUMBER, version);
@@ -171,7 +171,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
Stop = Space;
}
- std::string const pkgname(Start, Stop - Start);
+ APT::StringView const pkgname(Start, Stop - Start);
if (pkgname != G.Name())
{
for (pkgCache::PkgIterator P = G.PackageList(); P.end() == false; P = G.NextPkg(P))
@@ -651,7 +651,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
++I;
}
- std::string arch(I, End);
+ std::string const arch(I, End);
if (arch.empty() == false && matchesArch(arch.c_str()) == true)
{
Found = true;
@@ -733,8 +733,7 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
++I;
}
- std::string restriction(I, End);
-
+ std::string const restriction(I, End);
if (restriction.empty() == false && profiles.empty() == false &&
std::find(profiles.begin(), profiles.end(), restriction) != profiles.end())
{
@@ -825,12 +824,13 @@ bool debListParser::ParseDepends(pkgCache::VerIterator &Ver,
{
// Such dependencies are not supposed to be accepted …
// … but this is probably the best thing to do anyway
- std::string Pkg;
if (Package.substr(found + 1) == "native")
- Pkg = Package.substr(0, found).to_string() + ':' + Ver.Cache()->NativeArch();
- else
- Pkg = Package.to_string();
- if (NewDepends(Ver, Pkg, "any", Version, Op | pkgCache::Dep::ArchSpecific, Type) == false)
+ {
+ std::string const Pkg = Package.substr(0, found).to_string() + ':' + Ver.Cache()->NativeArch();
+ if (NewDepends(Ver, Pkg, "any", Version, Op | pkgCache::Dep::ArchSpecific, Type) == false)
+ return false;
+ }
+ else if (NewDepends(Ver, Package, "any", Version, Op | pkgCache::Dep::ArchSpecific, Type) == false)
return false;
}
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 1c5275e0a..a78312f9d 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -69,9 +69,11 @@ class APT_HIDDEN debListParser : public pkgCacheListParser
// These all operate against the current section
virtual std::string Package() APT_OVERRIDE;
- virtual std::string Architecture() APT_OVERRIDE;
virtual bool ArchitectureAll() APT_OVERRIDE;
- virtual std::string Version() APT_OVERRIDE;
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
+ virtual APT::StringView Architecture() APT_OVERRIDE;
+ virtual APT::StringView Version() APT_OVERRIDE;
+#endif
virtual bool NewVersion(pkgCache::VerIterator &Ver) APT_OVERRIDE;
virtual std::vector<std::string> AvailableDescriptionLanguages() APT_OVERRIDE;
virtual MD5SumValue Description_md5() APT_OVERRIDE;
@@ -128,9 +130,11 @@ class APT_HIDDEN debDebFileParser : public debListParser
class APT_HIDDEN debTranslationsParser : public debListParser
{
public:
+#ifdef APT_PKG_EXPOSE_STRING_VIEW
// a translation can never be a real package
- virtual std::string Architecture() APT_OVERRIDE { return ""; }
- virtual std::string Version() APT_OVERRIDE { return ""; }
+ virtual APT::StringView Architecture() APT_OVERRIDE { return ""; }
+ virtual APT::StringView Version() APT_OVERRIDE { return ""; }
+#endif
debTranslationsParser(FileFd *File)
: debListParser(File) {};