* methods/rred.cc:
[ntk/apt.git] / apt-pkg / deb / debsrcrecords.cc
index c9c2026..ce55ccd 100644 (file)
@@ -21,6 +21,8 @@
 using std::max;
                                                                        /*}}}*/
 
+using std::string;
+
 // SrcRecordParser::Binaries - Return the binaries field               /*{{{*/
 // ---------------------------------------------------------------------
 /* This member parses the binaries field into a pair of class arrays and
@@ -30,25 +32,32 @@ using std::max;
    used during scanning to find the right package */
 const char **debSrcRecordParser::Binaries()
 {
-   // This should use Start/Stop too, it is supposed to be efficient after all.
-   string Bins = Sect.FindS("Binary");
-   if (Bins.empty() == true || Bins.length() >= 102400)
-      return 0;
-   
-   if (Bins.length() >= BufSize)
-   {
-      delete [] Buffer;
-      // allocate new size based on buffer (but never smaller than 4000)
-      BufSize = max((unsigned int)4000, max((unsigned int)Bins.length()+1,2*BufSize));
-      Buffer = new char[BufSize];
-   }
+   const char *Start, *End;
+   if (Sect.Find("Binary", Start, End) == false)
+      return NULL;
+   for (; isspace(*Start) != 0; ++Start);
+   if (Start >= End)
+      return NULL;
+
+   StaticBinList.clear();
+   free(Buffer);
+   Buffer = strndup(Start, End - Start);
 
-   strcpy(Buffer,Bins.c_str());
-   if (TokSplitString(',',Buffer,StaticBinList,
-                     sizeof(StaticBinList)/sizeof(StaticBinList[0])) == false)
-      return 0;
+   char* bin = Buffer;
+   do {
+      char* binStartNext = strchrnul(bin, ',');
+      char* binEnd = binStartNext - 1;
+      for (; isspace(*binEnd) != 0; --binEnd)
+        binEnd = '\0';
+      StaticBinList.push_back(bin);
+      if (*binStartNext != ',')
+        break;
+      *binStartNext = '\0';
+      for (bin = binStartNext + 1; isspace(*bin) != 0; ++bin);
+   } while (*bin != '\0');
+   StaticBinList.push_back(NULL);
 
-   return (const char **)StaticBinList;
+   return (const char **) &StaticBinList[0];
 }
                                                                        /*}}}*/
 // SrcRecordParser::BuildDepends - Return the Build-Depends information        /*{{{*/
@@ -57,7 +66,7 @@ const char **debSrcRecordParser::Binaries()
    package/version records representing the build dependency. The returned 
    array need not be freed and will be reused by the next call to this 
    function */
-bool debSrcRecordParser::BuildDepends(vector<pkgSrcRecords::Parser::BuildDepRec> &BuildDeps,
+bool debSrcRecordParser::BuildDepends(std::vector<pkgSrcRecords::Parser::BuildDepRec> &BuildDeps,
                                        bool const &ArchOnly, bool const &StripMultiArch)
 {
    unsigned int I;
@@ -102,7 +111,7 @@ bool debSrcRecordParser::BuildDepends(vector<pkgSrcRecords::Parser::BuildDepRec>
 // ---------------------------------------------------------------------
 /* This parses the list of files and returns it, each file is required to have
    a complete source package */
-bool debSrcRecordParser::Files(vector<pkgSrcRecords::File> &List)
+bool debSrcRecordParser::Files(std::vector<pkgSrcRecords::File> &List)
 {
    List.erase(List.begin(),List.end());