diff -Naur apt-0.5.15lorg2.orig/apt-pkg/contrib/cmndline.cc apt-0.5.15lorg2/apt-pkg/contrib/cmndline.cc --- apt-0.5.15lorg2.orig/apt-pkg/contrib/cmndline.cc 2007-10-30 14:42:33 +0300 +++ apt-0.5.15lorg2/apt-pkg/contrib/cmndline.cc 2007-10-30 14:43:33 +0300 @@ -19,9 +19,23 @@ #include #include + +#include /*}}}*/ using namespace std; +void CommandLine::FreeFileList() +{ + if (FileList) + { + for (const char **I=FileList; *I; ++I) + free(const_cast(*I)); + + delete [] FileList; + FileList = 0; + } +} + // CommandLine::CommandLine - Constructor /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -35,7 +49,7 @@ /* */ CommandLine::~CommandLine() { - delete [] FileList; + FreeFileList(); } /*}}}*/ // CommandLine::Parse - Main action member /*{{{*/ @@ -43,8 +57,11 @@ /* */ bool CommandLine::Parse(int argc,const char **argv) { - delete [] FileList; + FreeFileList(); FileList = new const char *[argc]; + std::uninitialized_fill(const_cast(FileList), + const_cast(FileList+argc), + static_cast(0)); const char **Files = FileList; int I; for (I = 1; I != argc; I++) @@ -54,7 +71,7 @@ // It is not an option if (*Opt != '-') { - *Files++ = Opt; + *Files++ = strdup(Opt); continue; } @@ -136,7 +153,7 @@ // Copy any remaining file names over for (; I != argc; I++) - *Files++ = argv[I]; + *Files++ = strdup(argv[I]); *Files = 0; return true; diff -Naur apt-0.5.15lorg2.orig/apt-pkg/contrib/cmndline.h apt-0.5.15lorg2/apt-pkg/contrib/cmndline.h --- apt-0.5.15lorg2.orig/apt-pkg/contrib/cmndline.h 2007-10-24 19:20:13 +0400 +++ apt-0.5.15lorg2/apt-pkg/contrib/cmndline.h 2007-10-30 14:42:59 +0300 @@ -52,6 +52,10 @@ class CommandLine { + CommandLine(const CommandLine& other); + CommandLine& operator=(const CommandLine& other); + + public: struct Args; struct Dispatch; @@ -84,6 +88,7 @@ CommandLine(Args *AList,Configuration *Conf); ~CommandLine(); + void FreeFileList(); }; struct CommandLine::Args diff -Naur apt-0.5.15lorg2.orig/cmdline/apt-get.cc apt-0.5.15lorg2/cmdline/apt-get.cc --- apt-0.5.15lorg2.orig/cmdline/apt-get.cc 2007-10-30 14:42:33 +0300 +++ apt-0.5.15lorg2/cmdline/apt-get.cc 2007-10-30 14:42:59 +0300 @@ -3366,6 +3366,7 @@ {0,"check-only","APT::Get::Check-Only",0}, // CNC:2003-03-06 {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, + {0,"manifest","manifest",CommandLine::HasArg}, {0,0,0,0}}; CommandLine::Dispatch Cmds[] = {{"update",&DoUpdate}, {"upgrade",&DoUpgrade}, @@ -3405,6 +3406,27 @@ return 100; } + //append manifest content to FileList + if (!_config->Find("manifest").empty()) + { + std::ifstream is(_config->Find("manifest").c_str()); + vector new_filelist; + std::string line; + + for (const char **I = CmdL.FileList; *I != 0; I++) + new_filelist.push_back(strdup(*I)); + while (std::getline(is,line)) + new_filelist.push_back(strdup(line.c_str())); + + CmdL.FreeFileList(); + + size_t len = new_filelist.size(); + CmdL.FileList = new const char *[len + 1]; + for(int i=0;iFindB("help") == true || _config->FindB("version") == true ||