summaryrefslogtreecommitdiff
path: root/apt-pkg/deb/dpkgpm.cc
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-01-11 19:09:14 +0100
committerMichael Vogt <michael.vogt@ubuntu.com>2011-01-11 19:09:14 +0100
commitde6d91438ef2e3632615647647099f4c6fa227fa (patch)
treea2db1e4a7e1eb90e7a30314fe30fd9e82168c569 /apt-pkg/deb/dpkgpm.cc
parentfb9caf55cf7e63e3cc7ae4878279ab98b68b3a6e (diff)
add i18n support for the "short read in buffer_copy %s" handling
from dpkg
Diffstat (limited to 'apt-pkg/deb/dpkgpm.cc')
-rw-r--r--apt-pkg/deb/dpkgpm.cc21
1 files changed, 16 insertions, 5 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 3e0964b05..cca590a63 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -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