More or less working acquire system
[ntk/apt.git] / apt-pkg / tagfile.cc
index f6855f1..91653f6 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: tagfile.cc,v 1.10 1998/07/19 04:42:10 jgg Exp $
+// $Id: tagfile.cc,v 1.13 1998/10/30 07:53:41 jgg Exp $
 /* ######################################################################
 
    Fast scanner for RFC-822 type header information
@@ -72,11 +72,12 @@ bool pkgTagFile::Fill()
    Start = Buffer;
    End = Buffer + EndSize;
    
-   // See if only a bit of the file is left 
-   if (Left < Size)
+   // See if only a bit of the file is left
+   if (Left < Size - (End - Buffer))
    {
       if (Fd.Read(End,Left) == false)
         return false;
+      
       End += Left;
       Left = 0;
    }
@@ -84,6 +85,7 @@ bool pkgTagFile::Fill()
    {
       if (Fd.Read(End,Size - (End - Buffer)) == false)
         return false;
+      
       Left -= Size - (End - Buffer);
       End = Buffer + Size;
    }   
@@ -125,13 +127,16 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength)
    {
       if (Stop[-1] != '\n')
         continue;
+
+      // Skip line feeds
+      for (; Stop[0] == '\r' && Stop < End; Stop++);
+      
       if (Stop[0] == '\n')
       {
         // Extra one at the end to simplify find
         Indexes[TagCount] = Stop - Section;
-        for (; Stop[0] == '\n' && Stop < End; Stop++);
+        for (; (Stop[0] == '\n' || Stop[0] == '\r') && Stop < End; Stop++);
         return true;
-        break;
       }
       
       if (isspace(Stop[0]) == 0)
@@ -167,6 +172,7 @@ bool pkgTagSection::Find(const char *Tag,const char *&Start,
       End = Section + Indexes[I+1];
       for (; (isspace(*Start) != 0 || *Start == ':') && Start < End; Start++);
       for (; isspace(End[-1]) != 0 && End > Start; End--);
+      
       return true;
    }
    Start = End = 0;