]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-cmndline.cc
Move sysconf(_SC_OPEN_MAX); out of the for() loop to avoid unneeded syscalls
[apt.git] / apt-private / private-cmndline.cc
index d6d7bca64be8ebedc56effc33e850d4e3ab0e46c..0b5ba5b4fdf81c07846dacdbe2c06810dc2cbffb 100644 (file)
@@ -2,19 +2,17 @@
 #include <config.h>
 
 #include <apt-pkg/cmndline.h>
-#include <apt-pkg/configuration.h>
 
-#include <vector>
+#include <apt-private/private-cmndline.h>
 
+#include <vector>
 #include <stdarg.h>
 #include <string.h>
 
-#include "private-cmndline.h"
-
 #include <apti18n.h>
                                                                        /*}}}*/
 
-bool strcmp_match_in_list(char const * const Cmd, ...)                 /*{{{*/
+APT_SENTINEL static bool strcmp_match_in_list(char const * const Cmd, ...)             /*{{{*/
 {
    va_list args;
    bool found = false;
@@ -33,7 +31,7 @@ bool strcmp_match_in_list(char const * const Cmd, ...)                        /*{{{*/
                                                                        /*}}}*/
 #define addArg(w,x,y,z) Args.push_back(CommandLine::MakeArgs(w,x,y,z))
 #define CmdMatches(...) strcmp_match_in_list(Cmd, __VA_ARGS__, NULL)
-bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
 {
    if (CmdMatches("depends", "rdepends", "xvcg", "dotty"))
    {
@@ -72,6 +70,8 @@ bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char const * con
    else
       return false;
 
+   bool const found_something = Args.empty() == false;
+
    // FIXME: move to the correct command(s)
    addArg('g', "generate", "APT::Cache::Generate", 0);
    addArg('t', "target-release", "APT::Default-Release", CommandLine::HasArg);
@@ -79,10 +79,11 @@ bool addArgumentsAPTCache(std::vector<CommandLine::Args> &Args, char const * con
 
    addArg('p', "pkg-cache", "Dir::Cache::pkgcache", CommandLine::HasArg);
    addArg('s', "src-cache", "Dir::Cache::srcpkgcache", CommandLine::HasArg);
-   return true;
+
+   return found_something;
 }
                                                                        /*}}}*/
-bool addArgumentsAPTCDROM(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPTCDROM(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
 {
    if (CmdMatches("add", "ident") == false)
       return false;
@@ -100,7 +101,7 @@ bool addArgumentsAPTCDROM(std::vector<CommandLine::Args> &Args, char const * con
    return true;
 }
                                                                        /*}}}*/
-bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
 {
    if (CmdMatches("dump"))
    {
@@ -115,10 +116,10 @@ bool addArgumentsAPTConfig(std::vector<CommandLine::Args> &Args, char const * co
    return true;
 }
                                                                        /*}}}*/
-bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
 {
    if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade",
-           "dselect-upgrade", "autoremove"))
+           "dselect-upgrade", "autoremove", "full-upgrade"))
    {
       addArg(0, "show-progress", "DpkgPM::Progress", 0);
       addArg('f', "fix-broken", "APT::Get::Fix-Broken", 0);
@@ -141,6 +142,7 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
    {
       addArg('b', "compile", "APT::Get::Compile", 0);
       addArg('b', "build", "APT::Get::Compile", 0);
+      addArg('P', "build-profiles", "APT::Build-Profiles", CommandLine::HasArg);
       addArg(0, "diff-only", "APT::Get::Diff-Only", 0);
       addArg(0, "debian-only", "APT::Get::Diff-Only", 0);
       addArg(0, "tar-only", "APT::Get::Tar-Only", 0);
@@ -149,6 +151,7 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
    else if (CmdMatches("build-dep"))
    {
       addArg('a', "host-architecture", "APT::Get::Host-Architecture", CommandLine::HasArg);
+      addArg('P', "build-profiles", "APT::Build-Profiles", CommandLine::HasArg);
       addArg(0, "purge", "APT::Get::Purge", 0);
       addArg(0, "solver", "APT::Solver", CommandLine::HasArg);
       // this has no effect *but* sbuild is using it (see LP: #1255806)
@@ -163,7 +166,7 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
 
    if (CmdMatches("install", "remove", "purge", "upgrade", "dist-upgrade",
            "deselect-upgrade", "autoremove", "clean", "autoclean", "check",
-           "build-dep"))
+           "build-dep", "full-upgrade", "source"))
    {
       addArg('s', "simulate", "APT::Get::Simulate", 0);
       addArg('s', "just-print", "APT::Get::Simulate", 0);
@@ -172,6 +175,8 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
       addArg('s', "no-act", "APT::Get::Simulate", 0);
    }
 
+   bool const found_something = Args.empty() == false;
+
    // FIXME: move to the correct command(s)
    addArg('d',"download-only","APT::Get::Download-Only",0);
    addArg('y',"yes","APT::Get::Assume-Yes",0);
@@ -197,10 +202,10 @@ bool addArgumentsAPTGet(std::vector<CommandLine::Args> &Args, char const * const
    addArg(0,"install-suggests","APT::Install-Suggests",CommandLine::Boolean);
    addArg(0,"fix-policy","APT::Get::Fix-Policy-Broken",0);
 
-   return true;
+   return found_something;
 }
                                                                        /*}}}*/
-bool addArgumentsAPTMark(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPTMark(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
 {
    if (CmdMatches("auto", "manual", "hold", "unhold", "showauto",
            "showmanual", "showhold", "showholds", "install",
@@ -220,7 +225,7 @@ bool addArgumentsAPTMark(std::vector<CommandLine::Args> &Args, char const * cons
    return true;
 }
                                                                        /*}}}*/
-bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
+static bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cmd)/*{{{*/
 {
    if (CmdMatches("list"))
    {
@@ -230,6 +235,10 @@ bool addArgumentsAPT(std::vector<CommandLine::Args> &Args, char const * const Cm
       addArg('v', "verbose", "APT::Cmd::List-Include-Summary", 0);
       addArg('a', "all-versions", "APT::Cmd::All-Versions", 0);
    }
+   else if (CmdMatches("show"))
+   {
+      addArg('a', "all-versions", "APT::Cache::AllVersions", 0);
+   }
    else if (addArgumentsAPTGet(Args, Cmd) || addArgumentsAPTCache(Args, Cmd))
    {
        // we have no (supported) command-name overlaps so far, so we call