]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-output.cc
prepare cachesets for -std=c++11
[apt.git] / apt-private / private-output.cc
index fc76a05bc7a35f93ff4a45057adf2bb176997157..9944ab002ed310b56a4c277ad3971bf747026cf9 100644 (file)
@@ -52,14 +52,14 @@ static void SigWinch(int)
 #endif
 }
                                                                        /*}}}*/
-bool InitOutput()                                                      /*{{{*/
+bool InitOutput(std::basic_streambuf<char> * const out)                        /*{{{*/
 {
    if (!isatty(STDOUT_FILENO) && _config->FindI("quiet", -1) == -1)
       _config->Set("quiet","1");
 
-   c0out.rdbuf(cout.rdbuf());
-   c1out.rdbuf(cout.rdbuf());
-   c2out.rdbuf(cout.rdbuf());
+   c0out.rdbuf(out);
+   c1out.rdbuf(out);
+   c2out.rdbuf(out);
    if (_config->FindI("quiet",0) > 0)
       c0out.rdbuf(devnull.rdbuf());
    if (_config->FindI("quiet",0) > 1)
@@ -199,10 +199,12 @@ static std::string GetShortDescription(pkgCacheFile &CacheFile, pkgRecords &reco
    std::string ShortDescription = "(none)";
    if(ver)
    {
-      pkgCache::DescIterator Desc = ver.TranslatedDescription();
-      pkgRecords::Parser & parser = records.Lookup(Desc.FileList());
-
-      ShortDescription = parser.ShortDesc();
+      pkgCache::DescIterator const Desc = ver.TranslatedDescription();
+      if (Desc.end() == false)
+      {
+        pkgRecords::Parser & parser = records.Lookup(Desc.FileList());
+        ShortDescription = parser.ShortDesc();
+      }
    }
    return ShortDescription;
 }
@@ -222,11 +224,14 @@ static std::string GetLongDescription(pkgCacheFile &CacheFile, pkgRecords &recor
       return EmptyDescription;
 
    pkgCache::DescIterator const Desc = ver.TranslatedDescription();
-   pkgRecords::Parser & parser = records.Lookup(Desc.FileList());
-   std::string const longdesc = parser.LongDesc();
-   if (longdesc.empty() == true)
-      return EmptyDescription;
-   return SubstVar(longdesc, "\n ", "\n  ");
+   if (Desc.end() == false)
+   {
+      pkgRecords::Parser & parser = records.Lookup(Desc.FileList());
+      std::string const longdesc = parser.LongDesc();
+      if (longdesc.empty() == false)
+        return SubstVar(longdesc, "\n ", "\n  ");
+   }
+   return EmptyDescription;
 }
                                                                        /*}}}*/
 void ListSingleVersion(pkgCacheFile &CacheFile, pkgRecords &records,   /*{{{*/