From ab94ebe064bf751de73a11398b1af5589ab8c668 Mon Sep 17 00:00:00 2001
From: Julian Andres Klode <julian.klode@canonical.com>
Date: Mon, 6 May 2019 22:23:45 +0200
Subject: Merge the ParseDepends functions

---
 apt-pkg/deb/deblistparser.cc | 40 +++++-----------------------------------
 apt-pkg/deb/deblistparser.h  | 41 ++++++++++++-----------------------------
 2 files changed, 17 insertions(+), 64 deletions(-)

(limited to 'apt-pkg')

diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 80ca10e37..832e3948d 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -545,28 +545,6 @@ const char *debListParser::ConvertRelation(const char *I,unsigned int &Op)
 // ---------------------------------------------------------------------
 /* This parses the dependency elements out of a standard string in place,
    bit by bit. */
-const char *debListParser::ParseDepends(const char *Start,const char *Stop,
-               std::string &Package,std::string &Ver,unsigned int &Op)
-   { return ParseDepends(Start, Stop, Package, Ver, Op, false, true, false); }
-const char *debListParser::ParseDepends(const char *Start,const char *Stop,
-               std::string &Package,std::string &Ver,unsigned int &Op,
-               bool const &ParseArchFlags)
-   { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, true, false); }
-const char *debListParser::ParseDepends(const char *Start,const char *Stop,
-               std::string &Package,std::string &Ver,unsigned int &Op,
-               bool const &ParseArchFlags, bool const &StripMultiArch)
-   { return ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags, StripMultiArch, false); }
-const char *debListParser::ParseDepends(const char *Start,const char *Stop,
-					string &Package,string &Ver,
-					unsigned int &Op, bool const &ParseArchFlags,
-					bool const &StripMultiArch,
-					bool const &ParseRestrictionsList)
-{
-   return debListParser::ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags,
-                                      StripMultiArch, ParseRestrictionsList,
-                                      _config->Find("APT::Architecture"));
-}
-
 const char *debListParser::ParseDepends(const char *Start,const char *Stop,
 					string &Package,string &Ver,
 					unsigned int &Op, bool const &ParseArchFlags,
@@ -584,23 +562,15 @@ const char *debListParser::ParseDepends(const char *Start,const char *Stop,
 
    return res;
 }
-const char *debListParser::ParseDepends(const char *Start,const char *Stop,
-					StringView &Package,StringView &Ver,
-					unsigned int &Op, bool ParseArchFlags,
-					bool StripMultiArch,
-					bool ParseRestrictionsList)
-{
-   return debListParser::ParseDepends(Start, Stop, Package, Ver, Op, ParseArchFlags,
-                                      StripMultiArch, ParseRestrictionsList,
-                                      _config->Find("APT::Architecture"));
-}
 
-const char *debListParser::ParseDepends(const char *Start,const char *Stop,
-					StringView &Package,StringView &Ver,
+const char *debListParser::ParseDepends(const char *Start, const char *Stop,
+					StringView &Package, StringView &Ver,
 					unsigned int &Op, bool ParseArchFlags,
 					bool StripMultiArch,
-					bool ParseRestrictionsList, string const &Arch)
+					bool ParseRestrictionsList, string Arch)
 {
+   if (Arch.empty())
+      Arch = _config->Find("APT::Architecture");
    // Strip off leading space
    for (;Start != Stop && isspace_ascii(*Start) != 0; ++Start);
    
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 1d731d5a9..807968452 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -77,35 +77,18 @@ class APT_HIDDEN debListParser : public pkgCacheListParser
 
    virtual bool Step() APT_OVERRIDE;
 
-   APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
-	 std::string &Package,std::string &Ver,unsigned int &Op);
-   APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
-	 std::string &Package,std::string &Ver,unsigned int &Op,
-	 bool const &ParseArchFlags);
-   APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
-	 std::string &Package,std::string &Ver,unsigned int &Op,
-	 bool const &ParseArchFlags, bool const &StripMultiArch);
-   APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
-	 std::string &Package,std::string &Ver,unsigned int &Op,
-	 bool const &ParseArchFlags, bool const &StripMultiArch,
-	 bool const &ParseRestrictionsList);
-   APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
-	 std::string &Package,std::string &Ver,unsigned int &Op,
-	 bool const &ParseArchFlags, bool const &StripMultiArch,
-	 bool const &ParseRestrictionsList,
-	 std::string const &Arch);
-
-   APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
-	 APT::StringView &Package,
-    APT::StringView &Ver,unsigned int &Op,
-	 bool const ParseArchFlags = false, bool StripMultiArch = true,
-	 bool const ParseRestrictionsList = false);
-   APT_PUBLIC static const char *ParseDepends(const char *Start,const char *Stop,
-	 APT::StringView &Package,
-	 APT::StringView &Ver,unsigned int &Op,
-	 bool const ParseArchFlags, bool StripMultiArch,
-	 bool const ParseRestrictionsList,
-	 std::string const &Arch);
+   APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop,
+					      std::string &Package, std::string &Ver, unsigned int &Op,
+					      bool const &ParseArchFlags = false, bool const &StripMultiArch = true,
+					      bool const &ParseRestrictionsList = false,
+					      std::string const &Arch = "");
+
+   APT_PUBLIC static const char *ParseDepends(const char *Start, const char *Stop,
+					      APT::StringView &Package,
+					      APT::StringView &Ver, unsigned int &Op,
+					      bool const ParseArchFlags = false, bool StripMultiArch = true,
+					      bool const ParseRestrictionsList = false,
+					      std::string Arch = "");
 
    APT_PUBLIC static const char *ConvertRelation(const char *I,unsigned int &Op);
 
-- 
cgit v1.2.3