* merged with debian-sid branch
[ntk/apt.git] / cmdline / apt-cache.cc
index 7d402a2..74fa71c 100644 (file)
@@ -1225,31 +1225,41 @@ bool DisplayRecord(pkgCache::VerIterator V)
       return false;
    }
 
-   // Strip the Description
-   unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "Description:");
-   *DescP='\0';
+   // Get a pointer to start of Description field
+   const unsigned char *DescP = (unsigned char*)strstr((char*)Buffer, "Description:");
 
-   // Write all the rest
-   if (fwrite(Buffer,1,V.FileList()->Size+1,stdout) < (size_t)(V.FileList()->Size+1))
+   // Write all but Description
+   if (fwrite(Buffer,1,DescP - Buffer,stdout) < (size_t)(DescP - Buffer))
    {
       delete [] Buffer;
       return false;
    }
 
-   delete [] Buffer;
-
    // Show the right description
    pkgRecords Recs(*GCache);
-   pkgCache::DescIterator DescDefault = V.DescriptionList();
-   pkgCache::DescIterator Desc = DescDefault;
-   for (; Desc.end() == false; Desc++)
-      if (pkgIndexFile::LanguageCode() == Desc.LanguageCode())
-        break;
-   if (Desc.end() == true) Desc = DescDefault;
-
+   pkgCache::DescIterator Desc = V.TranslatedDescription();
    pkgRecords::Parser &P = Recs.Lookup(Desc.FileList());
-   cout << "Description" << ( (strcmp(Desc.LanguageCode(),"") != 0) ? "-" : "" ) << Desc.LanguageCode() << ": " << P.LongDesc() << endl;
+   cout << "Description" << ( (strcmp(Desc.LanguageCode(),"") != 0) ? "-" : "" ) << Desc.LanguageCode() << ": " << P.LongDesc();
 
+   // Find the first field after the description (if there is any)
+   for(DescP++;DescP != &Buffer[V.FileList()->Size];DescP++) 
+   {
+      if(*DescP == '\n' && *(DescP+1) != ' ') 
+      {
+        // write the rest of the buffer
+        const unsigned char *end=&Buffer[V.FileList()->Size];
+        if (fwrite(DescP,1,end-DescP,stdout) < (size_t)(end-DescP)) 
+        {
+           delete [] Buffer;
+           return false;
+        }
+
+        break;
+      }
+   }
+   // write a final newline (after the description)
+   cout<<endl;
+   delete [] Buffer;
 
    return true;
 }
@@ -1406,19 +1416,6 @@ bool ShowPackage(CommandLine &CmdL)
 
       ++found;
 
-      // Show virtual packages
-      if (Pkg->ProvidesList != 0)
-      {
-        ioprintf(std::cout,_("Package %s is a virtual package provided by:\n"),
-                 Pkg.Name());
-        
-        pkgCache::PrvIterator I = Pkg.ProvidesList();
-        for (; I.end() == false; I++)
-           cout << "  " << I.OwnerPkg().Name() << endl;
-        cout << _("You should explicitly select one to show.") << endl;
-        continue;
-      }
-
       // Find the proper version to use.
       if (_config->FindB("APT::Cache::AllVersions","true") == true)
       {
@@ -1633,10 +1630,11 @@ bool Madison(CommandLine &CmdL)
 
    pkgCache &Cache = *GCache;
 
-   // Create the text record parsers
+   // Create the src text record parsers and ignore errors about missing
+   // deb-src lines that are generated from pkgSrcRecords::pkgSrcRecords
    pkgSrcRecords SrcRecs(*SrcList);
    if (_error->PendingError() == true)
-      return false;
+      _error->Discard();
 
    for (const char **I = CmdL.FileList + 1; *I != 0; I++)
    {