Quellcode durchsuchen

restart debSrcRecordParsers only if needed

The offset variable in DebSrcRecordParser was not initialized which we
now do and based on it do not trigger a restart if the parser was not
used yet avoiding a needless rescan of the section.

Detected while working on the previous commit e62aa1dd. Both commits act
as a "fix" for the bug shown in the testcase of the commit – this one
here would only hide it through.
David Kalnischkies vor 12 Jahren
Ursprung
Commit
6a9c9d63ed
2 geänderte Dateien mit 6 neuen und 5 gelöschten Zeilen
  1. 3 3
      apt-pkg/deb/debsrcrecords.h
  2. 3 2
      apt-pkg/srcrecords.cc

+ 3 - 3
apt-pkg/deb/debsrcrecords.h

@@ -30,7 +30,7 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
    
    public:
 
-   virtual bool Restart() {return Tags.Jump(Sect,0);};
+   virtual bool Restart() {return Jump(0);};
    virtual bool Step() {iOffset = Tags.Offset(); return Tags.Step(Sect);};
    virtual bool Jump(unsigned long const &Off) {iOffset = Off; return Tags.Jump(Sect,Off);};
 
@@ -50,8 +50,8 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
    virtual bool Files(std::vector<pkgSrcRecords::File> &F);
 
    debSrcRecordParser(std::string const &File,pkgIndexFile const *Index) 
-      : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400), 
-        Buffer(NULL) {}
+      : Parser(Index), Fd(File,FileFd::ReadOnly, FileFd::Extension), Tags(&Fd,102400),
+        iOffset(0), Buffer(NULL) {}
    virtual ~debSrcRecordParser();
 };
 

+ 3 - 2
apt-pkg/srcrecords.cc

@@ -70,8 +70,9 @@ bool pkgSrcRecords::Restart()
    Current = Files.begin();
    for (std::vector<Parser*>::iterator I = Files.begin();
         I != Files.end(); ++I)
-      (*I)->Restart();
-   
+      if ((*I)->Offset() != 0)
+	 (*I)->Restart();
+
    return true;
 }
 									/*}}}*/