Package: aptitude
Version: 0.4.3-1
Severity: normal
Tags: patch l10n
Hi,
akira yamada (akira) reported on his book[1] about deb package and packaging
that Japanese descriptive text from `aptitude --show-deps' is broken.
Actually, following code at reason_string_list in src/cmdline/cmdline_prompt.cc
cannot handle multibyte characters:
s+=const_cast<pkgCache::DepIterator &>(why->dep).DepType()[0];
Here attached two patches to solve this problem: one is a version I made by
referring to sample code[2] from Junichi Uekawa (dancer), and the other is a
version privately presented from Kouhei Sutou. I rebuilt with each of these
patches and checked that both can work as a solution. However, although I can
understand basically what these patches are doing, I don't have a good C++
skill, and cannot determine which is a better solution nor create a better and
compact patch free of side effect.
Could you please choose one or create a better solution to fix this bug? :-)
[1] http://www.gihyo.co.jp/books/4-7741-2768-X (in Japanese)
[2] http://lists.debian.or.jp/debian-devel/200610/msg00016.html (in Japanese)
Thanks,
-nori
-- System Information:
Debian Release: 3.1
Architecture: i386 (i686)
Kernel: Linux 2.6.8-3-686
Locale: LANG=ja_JP.eucJP, LC_CTYPE=ja_JP.eucJP (charmap=EUC-JP)
Versions of packages aptitude depends on:
ii apt [libapt-pkg-libc6 0.5.28.6 Advanced front-end for dpkg
ii libc6 2.3.2.ds1-22sarge4 GNU C Library: Shared libraries an
ii libgcc1 1:3.4.3-13sarge1 GCC support library
ii libncurses5 5.4-4 Shared libraries for terminal hand
ii libsigc++-1.2-5c102 1.2.5-4 type-safe Signal Framework for C++
ii libstdc++5 1:3.3.5-13 The GNU Standard C++ Library v3
-- no debconf information
--- src/cmdline/cmdline_prompt.cc.orig 2006-10-24 03:16:42.000000000 +0900
+++ src/cmdline/cmdline_prompt.cc 2006-10-24 18:01:46.000000000 +0900
@@ -83,7 +83,13 @@
first=false;
}
- s+=const_cast<pkgCache::DepIterator &>(why->dep).DepType()[0];
+ mbstate_t mbstate;
+ size_t len;
+ char *dep_type=strdup(const_cast<pkgCache::DepIterator &>(why->dep).DepType());
+ memset(&mbstate, 0, sizeof(mbstate));
+ len=mbrlen(dep_type, strlen(dep_type), &mbstate);
+ dep_type[len]=0;
+ s+=dep_type;
s+=": ";
s+=why->pkg.Name();
}
--- src/cmdline/cmdline_prompt.cc.orig 2006-10-24 03:16:42.000000000 +0900
+++ src/cmdline/cmdline_prompt.cc 2006-10-24 18:36:45.000000000 +0900
@@ -19,6 +19,7 @@
#include <vscreen/fragment.h>
#include <vscreen/vscreen.h>
+#include <vscreen/transcode.h>
#include <apt-pkg/algorithms.h>
#include <apt-pkg/dpkgpm.h>
@@ -83,7 +84,27 @@
first=false;
}
- s+=const_cast<pkgCache::DepIterator &>(why->dep).DepType()[0];
+
+ bool converting_success = false;
+ std::string dep_type;
+ std::wstring w_dep_type;
+
+ dep_type = const_cast<pkgCache::DepIterator &>(why->dep).DepType();
+ if (transcode(dep_type, w_dep_type))
+ {
+ std::string dep_type_first_char;
+ std::wstring w_dep_type_first_char;
+ w_dep_type_first_char = w_dep_type.substr(0, 1);
+ if (transcode(w_dep_type_first_char, dep_type_first_char))
+ {
+ s+=dep_type_first_char;
+ converting_success = true;
+ }
+ }
+
+ if (!converting_success)
+ s+=dep_type[0];
+
s+=": ";
s+=why->pkg.Name();
}