Bug#245982: cdebconf: newt frontend incorectly truncates long lines
Package: cdebconf
Version: svn, 26.04.2004
Severity: normal
Tags: patch d-i
Newt frontend incorectly truncates long lines in select and
multiselect elements. You can see this in languagechooser menu, just
look at Russian entry. Attached patch fixes this bug.
-- System Information:
Debian Release: testing/unstable
APT prefers unstable
APT policy: (500, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.26
Locale: LANG=uk_UA, LC_CTYPE=uk_UA
Index: cdebconf/src/modules/frontend/newt/newt.c
===================================================================
--- cdebconf/src/modules/frontend/newt/newt.c (revision 14415)
+++ cdebconf/src/modules/frontend/newt/newt.c (working copy)
@@ -457,7 +457,7 @@
int t_width_title, t_width_buttons;
char **choices, **choices_trans, **defvals, *answer;
int count = 0, defcount, i, k, ret, def;
- const char *p;
+ char *p;
size_t res;
wchar_t c;
int *tindex = NULL;
@@ -508,9 +508,12 @@
sel_width = win_width-8;
for (i = 0; i < count; i++) {
if (strwidth(choices_trans[i]) > sel_width) {
- for (res = 0, p = choices_trans[i]; (k = mbtowc (&c, p, MB_LEN_MAX)) > 0 && res < sel_width; p += k)
- res += wcwidth (c);
- choices_trans[i][res] = 0;
+ for (res = 0, p = choices_trans[i]; (k = mbtowc (&c, p, MB_LEN_MAX)) > 0; p += k) {
+ res += wcwidth (c);
+ if (res > sel_width)
+ break;
+ }
+ *p = 0;
}
}
}
@@ -610,7 +613,7 @@
int *tindex = NULL;
const char *indices = q_get_indices(q);
char *full_description = get_full_description(q);
- const char *p;
+ char *p;
size_t res;
int k;
wchar_t c;
@@ -656,9 +659,12 @@
sel_width = win_width-8;
for (i = 0; i < count; i++) {
if (strwidth(choices_trans[i]) > sel_width) {
- for (res = 0, p = choices_trans[i]; (k = mbtowc (&c, p, MB_LEN_MAX)) > 0 && res < sel_width; p += k)
- res += wcwidth (c);
- choices_trans[i][res] = 0;
+ for (res = 0, p = choices_trans[i]; (k = mbtowc (&c, p, MB_LEN_MAX)) > 0; p += k) {
+ res += wcwidth (c);
+ if (res > sel_width)
+ break;
+ }
+ *p = 0;
}
}
}
Reply to: