]> git.saurik.com Git - apt.git/commitdiff
add i18n support for the "short read in buffer_copy %s" handling
authorMichael Vogt <michael.vogt@ubuntu.com>
Tue, 11 Jan 2011 18:09:14 +0000 (19:09 +0100)
committerMichael Vogt <michael.vogt@ubuntu.com>
Tue, 11 Jan 2011 18:09:14 +0000 (19:09 +0100)
from dpkg

apt-pkg/deb/dpkgpm.cc
debian/changelog

index 3e0964b05b8d98ece354f88b53fdfd6560f89f62..cca590a63fae09e945ef897badbeeabb5338d810 100644 (file)
@@ -1298,11 +1298,22 @@ void pkgDPkgPM::WriteApportReport(const char *pkgpath, const char *errormsg)
       return;
    }
 
-   // do not report dpkg I/O errors
-   // XXX - this message is localized, but this only matches the English version.  This is better than nothing.
-   if(strstr(errormsg, "short read in buffer_copy (")) {
-      std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl;
-      return;
+   // do not report dpkg I/O errors, this is a format string, so we compare
+   // the prefix and the suffix of the error with the dpkg error message
+   const char *short_read_error = dgettext("dpkg", "short read in buffer_copy %s");
+   vector<string> list = VectorizeString(short_read_error, '%');
+   if (list.size() > 1) 
+   {
+      // we need to split %s, VectorizeString only allows char so we need
+      // to kill the "s" manually
+      if (list[1].size() > 1) {
+         list[1].erase(0, 1);
+         if(strstr(errormsg, list[0].c_str()) && 
+            strstr(errormsg, list[1].c_str())) {
+            std::clog << _("No apport report written because the error message indicates a dpkg I/O error") << std::endl;
+            return;
+         }
+      }
    }
 
    // get the pkgname and reportfile
index 40dd30807eef0355afe13d5995da3ca3251f36a7..8555604a5436c16ff2317c99f544810a58e76d2a 100644 (file)
@@ -3,6 +3,8 @@ apt (0.8.10ubuntu2) UNRELEASED; urgency=low
   * apt-pkg/deb/dpkgpm.cc:
     - ignore lzma "Cannot allocate memory" errors, thanks to Brian
       Murray
+    - add i18n support for the "short read in buffer_copy %s" handling
+      from dpkg
 
  -- Michael Vogt <michael.vogt@ubuntu.com>  Tue, 11 Jan 2011 18:26:05 +0100