[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#237675: new multibyte patch



> New patch attached: I wrote some replacement functions for those
> functions to fix them.

A bit more simplified patch attached.


diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/Makefile.conf.in dpkg-1.10.22/Makefile.conf.in
--- dpkg-1.10.22.orig/Makefile.conf.in	2004-06-02 06:18:15.000000000 +0900
+++ dpkg-1.10.22/Makefile.conf.in	2004-06-20 19:36:42.000000000 +0900
@@ -74,6 +74,7 @@
 SSD_LIBS		= @SSD_LIBS@
 
 CURSES_LIBS		= @CURSES_LIBS@
+TEXTWRAP_LIBS		= @TEXTWRAP_LIBS@
 
 ZLIB_CFLAGS		= @ZLIB_CFLAGS@
 ZLIB_LIBS		= @ZLIB_LIBS@
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/configure.in dpkg-1.10.22/configure.in
--- dpkg-1.10.22.orig/configure.in	2004-06-02 06:20:47.000000000 +0900
+++ dpkg-1.10.22/configure.in	2004-06-23 04:16:35.000000000 +0900
@@ -184,12 +184,18 @@
 
 # check for the proper curses library. This can be either
 # -lcurses or -lncurses, we need to check for either one.
-AC_CHECK_LIB(ncurses,initscr, CURSES_LIBS="-lncurses $CURSES_LIBS", AC_CHECK_LIB(curses,initscr, CURSES_LIBS="-lcurses $CURSES_LIBS"))
+AC_CHECK_LIB(ncursesw,initscr, CURSES_LIBS="-lncursesw $CURSES_LIBS", AC_CHECK_LIB(cursesw,initscr, CURSES_LIBS="-lcursesw $CURSES_LIBS"))
 if test "x$CURSES_LIBS" = "x"; then
  AC_MSG_WARN(no curses library found)
 fi
 AC_SUBST(CURSES_LIBS)
 
+AC_CHECK_LIB(textwrap,textwrap,TEXTWRAP_LIBS="-ltextwrap $TEXTWRAP_LIBS")
+if test "x$TEXTWRAP_LIBS" = "x"; then
+ AC_MSG_WARN(not textwrap library found)
+fi
+AC_SUBST(TEXTWRAP_LIBS)
+
 DPKG_CHECK_DEFINE(TIOCNOTTY,sys/ioctl.h)
 
 ZLIB_CFLAGS=
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/debian/control dpkg-1.10.22/debian/control
--- dpkg-1.10.22.orig/debian/control	2004-06-02 06:18:15.000000000 +0900
+++ dpkg-1.10.22/debian/control	2004-06-20 19:36:42.000000000 +0900
@@ -6,7 +6,7 @@
 Origin: debian
 Bugs: debbugs://bugs.debian.org
 Standards-Version: 3.5.8
-Build-Depends: debiandoc-sgml, sgml-base (>= 1.9.1), sgmltools-lite, libncurses-dev, gettext (>= 0.12.1-3), zlib1g-dev (>= 1:1.1.3-19.1), autotools-dev
+Build-Depends: debiandoc-sgml, sgml-base (>= 1.9.1), sgmltools-lite, libncursesw5-dev, gettext (>= 0.12.1-3), zlib1g-dev (>= 1:1.1.3-19.1), autotools-dev, libtextwrap-dev
 
 Package: dpkg
 Architecture: any
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/debian/dselect.substvars dpkg-1.10.22/debian/dselect.substvars
--- dpkg-1.10.22.orig/debian/dselect.substvars	1970-01-01 09:00:00.000000000 +0900
+++ dpkg-1.10.22/debian/dselect.substvars	2004-06-23 04:03:06.000000000 +0900
@@ -0,0 +1 @@
+shlibs:Depends=libc6 (>= 2.3.2.ds1-4), libgcc1 (>= 1:3.4-0), libncursesw5 (>= 5.4-1), libstdc++5 (>= 1:3.3.3-1), libtextwrap1
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/dselect/Makefile.in dpkg-1.10.22/dselect/Makefile.in
--- dpkg-1.10.22.orig/dselect/Makefile.in	2004-06-02 06:18:15.000000000 +0900
+++ dpkg-1.10.22/dselect/Makefile.in	2004-06-23 04:17:30.000000000 +0900
@@ -9,7 +9,8 @@
 CXX_SOURCES	= basecmds.cc baselist.cc basetop.cc bindings.cc curkeys.cc \
 		  main.cc methkeys.cc methlist.cc method.cc methparse.cc \
 		  pkgcmds.cc pkgdepcon.cc pkgdisplay.cc pkginfo.cc pkgkeys.cc \
-		  pkglist.cc pkgsublist.cc pkgtop.cc helpmsgs.cc
+		  pkglist.cc pkgsublist.cc pkgtop.cc helpmsgs.cc \
+		  mbhelpers.cc
 
 MAN8PAGES	= dselect.8
 
@@ -47,13 +48,13 @@
 	done
 
 dselect: $(OBJECTS) ../lib/libdpkg.a
-	$(CXX) $(LDFLAGS) -o $@ $(OBJECTS) $(CURSES_LIBS) $(LIBS) $(NLS_LIBS)
+	$(CXX) $(LDFLAGS) -o $@ $(OBJECTS) $(TEXTWRAP_LIBS) $(CURSES_LIBS) $(LIBS) $(NLS_LIBS)
 
 basecmds.o: helpmsgs.h
 curkeys.o: curkeys.h
 
 curkeys.h: keyoverride $(srcdir)/mkcurkeys.pl
-	cursesfile=`echo '#include <curses.h>' | \
+	cursesfile=`echo '#include <ncursesw/curses.h>' | \
 		 $(CC) -E - | grep 'curses.h' | head -n 1 | \
 		 $(SED) -e 's/^[^"]*"//; s/".*$$//'`; \
 	if [ "$$cursesfile" = "" ]; then echo "can't find curses file"; exit 1; fi; \
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/dselect/baselist.cc dpkg-1.10.22/dselect/baselist.cc
--- dpkg-1.10.22.orig/dselect/baselist.cc	2004-06-02 06:18:15.000000000 +0900
+++ dpkg-1.10.22/dselect/baselist.cc	2004-06-23 04:01:34.000000000 +0900
@@ -30,6 +30,7 @@
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <sys/termios.h>
+#include <textwrap.h>
 
 extern "C" {
 #include <dpkg.h>
@@ -318,54 +319,46 @@
   }
 }
 
-void baselist::wordwrapinfo(int offset, const char *m) {
-  int usemax= xmax-5;
-  if (debug) fprintf(debug,"baselist[%p]::wordwrapinfo(%d, `%s')\n",this,offset,m);
-  int wrapping=0;
+static char *reformat(int offset, const char *s) {
+  int pos = 0;
+  /* if offset == 0:
+   *   all '^.\n -> '\n\n'
+   *   all '^\n' -> '\n\n'
+   *   so we may need 2 times more space
+   * if offset > 1
+   *   we need le amount of space
+   */
+  char *news = (char *)malloc(2*strlen(s)+1);
+  const char *p = s;
   for (;;) {
-    int offleft=offset; while (*m == ' ' && offleft>0) { m++; offleft--; }
-    const char *p= strchr(m,'\n');
-    int l= p ? (int)(p-m) : strlen(m);
-    while (l && isspace(m[l-1])) l--;
-    if (!l || *m == '.' && l == 1) {
-      if (wrapping) waddch(infopad,'\n');
-      waddch(infopad,'\n');
-      wrapping= 0;
-    } else if (*m == ' ' || usemax < 10) {
-      if (wrapping) waddch(infopad,'\n');
-      waddnstr(infopad, m, l);
-      waddch(infopad,'\n'); wrapping= 0;
-    } else {
-      int x,y;
-      if (wrapping) {
-        getyx(infopad, y,x);
-        if (x+1 >= usemax) {
-          waddch(infopad,'\n');
-        } else {
-          waddch(infopad,' ');
-        }
-      }
-      for (;;) {
-        getyx(infopad, y,x);
-        int dosend= usemax-x;
-        if (l <= dosend) {
-          dosend=l;
-        } else {
-          int i=dosend;
-          while (i > 0 && m[i] != ' ') i--;
-          if (i > 0 || x > 0) dosend=i;
-        }
-        if (dosend) waddnstr(infopad, m, dosend);
-        while (dosend < l && m[dosend] == ' ') dosend++;
-        l-= dosend; m+= dosend;
-        if (l <= 0) break;
-        waddch(infopad,'\n');
-      }
-      wrapping= 1;
+    int offleft = offset;
+    if (*p == ' ' && offleft > 0) {p++; offleft--;};
+    const char *e = strchr(p, '\n');
+    int l = e ? e-p : strlen(p);
+    if ((l == 1 && *p == '.') || l==0 ) { news[pos++] = '\n'; news[pos++] = '\n'; }
+    else { 
+      if (p > s && *p == ' ')
+        news[pos-1] = '\n';
+      memcpy(news+pos, p, l); pos += l; news[pos++]=' ';
     }
-    if (!p) break;
-    m= ++p;
+    if (!e) break;
+    p = ++e;
   }
+  news[pos] = 0;
+  return news;
+}
+
+void baselist::wordwrapinfo(int offset, const char *m) {
+  int usemax= xmax-5;
+  if (debug) fprintf(debug,"baselist[%p]::wordwrapinfo(%d, `%s')\n",this,offset,m);
+  textwrap_t prop;
+  textwrap_init(&prop);
+  textwrap_columns(&prop, usemax);
+  char *rs = reformat(offset, m);
+  char *os = textwrap(&prop, rs);
+  waddstr(infopad, os);
+  free(os);
+  free(rs);
   if (debug) fprintf(debug,"baselist[%p]::wordwrapinfo() done\n",this);
 }
 
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/dselect/dselect.h dpkg-1.10.22/dselect/dselect.h
--- dpkg-1.10.22.orig/dselect/dselect.h	2004-06-02 06:18:15.000000000 +0900
+++ dpkg-1.10.22/dselect/dselect.h	2004-06-23 02:41:01.000000000 +0900
@@ -28,7 +28,7 @@
 
 #include <signal.h>
 #undef ERR
-#include <curses.h>
+#include <ncursesw/curses.h>
 
 struct helpmenuentry {
   char key;
@@ -183,5 +183,16 @@
 
 urqresult falliblesubprocess(const char *exepath, const char *name,
                              const char *const *args);
+extern int addstrwidth(WINDOW *, const char *, int);
+extern void helper_printleft(WINDOW*, const char *, int);
+
+/* multibyte helpers */
+extern int mbsnwidth(const char *str, int len);
+extern int mbswidth(const char *str);
+extern int mb_mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n);
+extern int mb_waddnstr(WINDOW *win, const char *str, int n);
+extern int mb_mvaddnstr(int y, int x, const char *str, int n);
+extern int mb_printleft(const char *str, int w);
+extern int mb_wprintleft(WINDOW *win, const char *str, int w);
 
 #endif /* DSELECT_H */
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/dselect/main.cc dpkg-1.10.22/dselect/main.cc
--- dpkg-1.10.22.orig/dselect/main.cc	2004-06-02 06:18:15.000000000 +0900
+++ dpkg-1.10.22/dselect/main.cc	2004-06-23 04:05:53.000000000 +0900
@@ -35,8 +35,8 @@
 #include <limits.h>
 #include <ctype.h>
 #include <assert.h>
-
-#include <term.h>
+#include <wchar.h>
+#include <ncursesw/term.h>
 
 extern "C" {
 #include <dpkg.h>
@@ -348,16 +348,22 @@
 void dme(int i, int so) {
   char buf[120];
   const menuentry *me= &menuentries[i];
-  sprintf(buf," %c %d. %-11.11s %-80.80s ",
-          so ? '*' : ' ', i,
-          gettext(me->option),
-          gettext(me->menuent));
-  
+  snprintf(buf, sizeof(buf)/sizeof(*buf), " %c %d. ",
+          so ? '*' : ' ', i);
   int y,x;
   getmaxyx(stdscr,y,x);
 
+  int rwidth = x-1; 
+
   attrset(so ? A_REVERSE : A_NORMAL);
-  mvaddnstr(i+2,0, buf,x-1);
+  mb_mvaddnstr(i+2,0, buf, rwidth);
+  rwidth -= strlen(buf);
+  if (rwidth > 0) {
+    mb_printleft(gettext(me->option), rwidth < 11? rwidth : 11);
+    if (rwidth > 11) addch(' ');
+    rwidth -= 12;
+    if (rwidth > 0) mb_printleft(gettext(me->menuent), rwidth);
+  }
   attrset(A_NORMAL);
 }
 
@@ -374,7 +380,7 @@
   clear();
   attrset(A_BOLD);
   sprintf(buf,gettext(programdesc),DSELECT);
-  mvaddnstr(0,0,buf,x-1);
+  mb_mvaddnstr(0,0,buf,x-1);
 
   attrset(A_NORMAL);
   const struct menuentry *mep; int i;
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/dselect/mbhelpers.cc dpkg-1.10.22/dselect/mbhelpers.cc
--- dpkg-1.10.22.orig/dselect/mbhelpers.cc	1970-01-01 09:00:00.000000000 +0900
+++ dpkg-1.10.22/dselect/mbhelpers.cc	2004-06-23 02:40:48.000000000 +0900
@@ -0,0 +1,118 @@
+#include <wchar.h>
+#include <stdlib.h>
+#include <string.h>
+#include <curses.h>
+
+/* returns width of first LEN bytes of STR */
+int mbsnwidth(const char *str, int len) {
+  mbstate_t state;
+  int n, w = 0;
+  wchar_t wc;
+  int ret;
+  
+  memset(&state, 0, sizeof(state));
+  while (len>0) {
+    ret = mbrtowc(&wc, str, len, &state);
+    if (ret <= 0)
+      break;
+    len -= ret;
+    str += ret;
+    n = wcwidth(wc);
+    if (n == -1) break;
+    w += n;
+  }
+  return w;
+}
+
+int mbswidth(const char *str) {
+  size_t len;
+  
+  len = mbstowcs(0, str, 0);
+
+  wchar_t *wcs = new wchar_t[len];
+
+  len = mbstowcs(wcs, str, len);
+  int width = wcswidth(wcs, len);
+  
+  delete [] wcs;
+  return width;
+}
+
+/* returns number of bytes of the STR prefix, whose width is at most WIDTH */
+static int mbscrop(const char *str, int width) {
+  mbstate_t state;
+  int totallength = 0;
+  int totalwidth = 0;
+
+  memset(&state, 0, sizeof(state));
+  while(1) {
+    wchar_t wc;
+    int w;
+    int length = mbrtowc(&wc, str, strlen(str), &state);
+    if (length <= 0) break;
+
+    w = wcwidth(wc);
+
+    if ((totalwidth + w) > width)
+      break;
+    totalwidth += w;
+    totallength += length;
+    str += length;
+  }
+  return totallength;
+}
+
+int mb_mvwaddnstr(WINDOW *win, int y, int x, const char *str, int n) {
+  mbstate_t state;
+  int totallength = 0;
+  const char *p = str;
+  memset(&state, 0, sizeof(state));
+
+  while (n > 0) {		// for each characters, in the given width (n)
+    wchar_t wc;
+    int length;
+    int width;
+
+    length = mbrtowc(&wc, p, strlen(p), &state);
+    if (length <= 0) break;
+
+    width = wcwidth(wc);
+    n -= width;
+
+    if (n < 0) break;
+
+    totallength += length;
+    p += length;
+  }
+
+  if (win)
+    return mvwaddnstr(win, y, x, str, totallength);
+  else
+    return mvaddnstr(y, x, str, totallength);
+}
+
+int mb_waddnstr(WINDOW *win, const char *str, int n) {
+  int x, y;
+  getyx(win, y, x);
+  return mb_mvwaddnstr(win, y, x, str, n);
+}
+
+int mb_mvaddnstr(int y, int x, const char *str, int n) {
+  return mb_mvwaddnstr(stdscr, y, x, str, n);
+}
+
+int mb_wprintleft(WINDOW *win, const char *s, int w) {
+  int len = mbscrop(s, w);
+  int width = mbsnwidth(s, len);
+  mb_waddnstr(win, s, width);
+
+  int spcs = w - width;
+  for (int i = 0; i < spcs; i++)
+    waddch(win, ' ');
+  return OK;
+};
+
+int mb_printleft(const char *s, int w) {
+  return mb_wprintleft(stdscr, s, w);
+};
+
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/dselect/methlist.cc dpkg-1.10.22/dselect/methlist.cc
--- dpkg-1.10.22.orig/dselect/methlist.cc	2004-06-02 06:18:15.000000000 +0900
+++ dpkg-1.10.22/dselect/methlist.cc	2004-06-23 04:15:37.000000000 +0900
@@ -75,7 +75,7 @@
 void methodlist::redrawtitle() {
   if (title_height) {
     mywerase(titlewin);
-    mvwaddnstr(titlewin,0,0,_("dselect - list of access methods"),xmax);
+    mb_mvwaddnstr(titlewin,0,0,_("dselect - list of access methods"),xmax);
     wnoutrefresh(titlewin);
   }
 }
@@ -98,8 +98,10 @@
   mvwaddch(listpad,index,0,
            table[index] == coption ? '*' : ' ');
   wattrset(listpad, selected ? listsel_attr : list_attr);
-  mvwprintw(listpad,index,name_column-1, " %-*.*s ",
-            name_width, name_width, table[index]->name);
+  wmove(listpad,index,name_column-1);
+  waddch(listpad, ' ');
+  mb_wprintleft(listpad,table[index]->name, name_width);
+  waddch(listpad, ' ');
   
   i= description_width;
   p= table[index]->summary ? table[index]->summary : "";
@@ -118,8 +120,8 @@
     wattrset(colheadspad,colheads_attr);
     mywerase(colheadspad);
     mvwaddstr(colheadspad,0,0, "  ");
-    mvwaddnstr(colheadspad,0,name_column, _("Abbrev."), name_width);
-    mvwaddnstr(colheadspad,0,description_column, _("Description"), description_width);
+    mb_mvwaddnstr(colheadspad,0,name_column, _("Abbrev."), name_width);
+    mb_mvwaddnstr(colheadspad,0,description_column, _("Description"), description_width);
   }
   refreshcolheads();
 }
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/dselect/pkgdisplay.cc dpkg-1.10.22/dselect/pkgdisplay.cc
--- dpkg-1.10.22.orig/dselect/pkgdisplay.cc	2004-06-02 06:18:15.000000000 +0900
+++ dpkg-1.10.22/dselect/pkgdisplay.cc	2004-06-23 01:15:29.000000000 +0900
@@ -119,12 +119,13 @@
                          N_("Removed"),
                          N_("Purged") };
 
-static int maximumstring(const char *const *array) {
+static int maximumstringwidth(const char *const *array) {
   int maxlen= 0;
   while (*array) {
-    int l= strlen(gettext(*array));
+    int l= mbswidth(gettext(*array));
     const char *p= strchr(*array, '(');
     if (p && p > *array && *--p == ' ') l= p - *array;
+    l = mbsnwidth(*array, l);
     if (l > maxlen) maxlen= l;
     array++;
   }
@@ -136,8 +137,8 @@
 
   if (verbose) {
     status_hold_width= 9;
-    status_status_width= maximumstring(statusstrings);
-    status_want_width= maximumstring(wantstrings);
+    status_status_width= maximumstringwidth(statusstrings);
+    status_want_width= maximumstringwidth(wantstrings);
     status_width= status_hold_width+status_status_width+status_want_width*2+3;
     priority_width= 8;
     package_width= 16;
@@ -196,24 +197,24 @@
   
   if (title_height) {
     mywerase(titlewin);
-    mvwaddnstr(titlewin,0,0,
-               recursive ?  _("dselect - recursive package listing") :
-               !readwrite ? _("dselect - inspection of package states") :
-                            _("dselect - main package listing"),
-               xmax);
+    mb_mvwaddnstr(titlewin,0,0,
+                  recursive ?  _("dselect - recursive package listing") :
+                  !readwrite ? _("dselect - inspection of package states") :
+                  _("dselect - main package listing"),
+                  xmax);
     getyx(titlewin,y,x);
     if (x < xmax) {
       switch (sortorder) {
       case so_section:
         switch (statsortorder) {
         case sso_unsorted:
-          waddnstr(titlewin, _(" (by section)"), xmax-x);
+          mb_waddnstr(titlewin, _(" (by section)"), xmax-x);
           break;
         case sso_avail:
-          waddnstr(titlewin, _(" (avail., section)"), xmax-x);
+          mb_waddnstr(titlewin, _(" (avail., section)"), xmax-x);
           break;
         case sso_state:
-          waddnstr(titlewin, _(" (status, section)"), xmax-x);
+          mb_waddnstr(titlewin, _(" (status, section)"), xmax-x);
           break;
         default:
           internerr("bad statsort in redrawtitle/so_section");
@@ -222,13 +223,13 @@
       case so_priority:
         switch (statsortorder) {
         case sso_unsorted:
-          waddnstr(titlewin, _(" (by priority)"), xmax-x);
+          mb_waddnstr(titlewin, _(" (by priority)"), xmax-x);
           break;
         case sso_avail:
-          waddnstr(titlewin, _(" (avail., priority)"), xmax-x);
+          mb_waddnstr(titlewin, _(" (avail., priority)"), xmax-x);
           break;
         case sso_state:
-          waddnstr(titlewin, _(" (status, priority)"), xmax-x);
+          mb_waddnstr(titlewin, _(" (status, priority)"), xmax-x);
           break;
         default:
           internerr("bad statsort in redrawtitle/so_priority");
@@ -237,19 +238,19 @@
       case so_alpha:
         switch (statsortorder) {
         case sso_unsorted:
-          waddnstr(titlewin, _(" (alphabetically)"), xmax-x);
+          mb_waddnstr(titlewin, _(" (alphabetically)"), xmax-x);
           break;
         case sso_avail:
-          waddnstr(titlewin, _(" (by availability)"), xmax-x);
+          mb_waddnstr(titlewin, _(" (by availability)"), xmax-x);
           break;
         case sso_state:
-          waddnstr(titlewin, _(" (by status)"), xmax-x);
+          mb_waddnstr(titlewin, _(" (by status)"), xmax-x);
           break;
         default:
           internerr("bad statsort in redrawtitle/so_priority");
         }
         break;
-        waddnstr(titlewin, _(" (alphabetically)"), xmax-x);
+        mb_waddnstr(titlewin, _(" (alphabetically)"), xmax-x);
         break;
       case so_unsorted:
         break;
@@ -261,7 +262,7 @@
                                                  : _(" mark:+/=/- verbose:v help:?"))
                                       : (verbose ? _(" terse:v help:?")
                                                  : _(" verbose:v help:?"));
-    int l= strlen(helpstring);
+    int l= mbswidth(helpstring);
     getyx(titlewin,y,x);
     if (xmax-l > 0) {
       mvwaddstr(titlewin,0,xmax-l, helpstring);
diff -uNr -x '*~' -x autom4te.cache -x configure -x '*.po' -x '*.pot' dpkg-1.10.22.orig/dselect/pkgtop.cc dpkg-1.10.22/dselect/pkgtop.cc
--- dpkg-1.10.22.orig/dselect/pkgtop.cc	2004-06-02 06:18:15.000000000 +0900
+++ dpkg-1.10.22/dselect/pkgtop.cc	2004-06-23 03:39:27.000000000 +0900
@@ -127,7 +127,7 @@
   } else {
     describemany(buf,priority,section,table[cursorline]->pkg->clientdata);
   }
-  mvwaddnstr(thisstatepad,0,0, buf, total_width);
+  mb_mvwaddnstr(thisstatepad,0,0, buf, total_width);
   pnoutrefresh(thisstatepad, 0,leftofscreen, thisstate_row,0,
                thisstate_row, lesserint(total_width - 1, xmax - 1));
 
@@ -145,29 +145,27 @@
   if (pkg->name) {
 
     if (verbose) {
-
-      mvwprintw(listpad,index,0, "%-*.*s ",
-                status_hold_width, status_hold_width,
-                gettext(eflagstrings[pkg->eflag]));
-      wprintw(listpad, "%-*.*s ",
-              status_status_width, status_status_width,
-              gettext(statusstrings[pkg->status]));
-      wprintw(listpad, "%-*.*s ",
-              status_want_width, status_want_width,
+      wmove(listpad,index,0);
+      mb_wprintleft(listpad,gettext(eflagstrings[pkg->eflag]),
+		    status_hold_width);
+      waddch(listpad, ' ');
+      mb_wprintleft(listpad,gettext(statusstrings[pkg->status]),
+		    status_status_width);
+      waddch(listpad, ' ');
+      mb_wprintleft(listpad,
               /* fixme: keep this ? */
               /*table[index]->original == table[index]->selected ? "(same)"
-              : */gettext(wantstrings[table[index]->original]));
+              : */gettext(wantstrings[table[index]->original]),status_want_width);
+      waddch(listpad, ' ');
       wattrset(listpad, selected ? selstatesel_attr : selstate_attr);
-      wprintw(listpad, "%-*.*s",
-              status_want_width, status_want_width,
-              gettext(wantstrings[table[index]->selected]));
+      mb_wprintleft(listpad,gettext(wantstrings[table[index]->selected]),
+		    status_want_width);
       wattrset(listpad, selected ? listsel_attr : list_attr);
       waddch(listpad, ' ');
-  
-      mvwprintw(listpad,index,priority_column-1, " %-*.*s",
-                priority_width, priority_width,
-                pkg->priority == pkginfo::pri_other ? pkg->otherpriority :
-                gettext(prioritystrings[pkg->priority]));
+      wmove(listpad,index,priority_column-1); 
+      waddch(listpad, ' ');
+      mb_wprintleft(listpad,pkg->priority == pkginfo::pri_other ? pkg->otherpriority :
+                gettext(prioritystrings[pkg->priority]),priority_width);
 
     } else {
 
@@ -189,33 +187,39 @@
         for (i=priority_width, p=pkg->otherpriority;
              i > 0 && *p;
              i--, p++)
+	  /* FIXME priority is ASCII string */
           waddch(listpad, tolower(*p));
         while (i-- > 0) waddch(listpad,' ');
       } else {
-        wprintw(listpad, "%-*.*s", priority_width, priority_width,
-                gettext(priorityabbrevs[pkg->priority]));
+        mb_wprintleft(listpad,gettext(priorityabbrevs[pkg->priority]),
+		      priority_width);
       }
 
     }
 
-    mvwprintw(listpad,index,section_column-1, " %-*.*s",
-              section_width, section_width,
-              pkg->section ? pkg->section : "?");
-  
-    mvwprintw(listpad,index,package_column-1, " %-*.*s ",
-              package_width, package_width, pkg->name);
-
-    if (versioninstalled_width)
-      mvwprintw(listpad,index,versioninstalled_column, "%-*.*s ",
-                versioninstalled_width, versioninstalled_width,
-                versiondescribe(&pkg->installed.version,vdew_never));
+    wmove(listpad, index, section_column-1);
+    waddch(listpad, ' ');
+    mb_wprintleft(listpad,pkg->section ? pkg->section : "?", section_width);
+    wmove(listpad, index, package_column-1);
+    waddch(listpad, ' ');
+    mb_wprintleft(listpad,pkg->name, package_width);
+    waddch(listpad, ' ');
+
+    if (versioninstalled_width) {
+      wmove(listpad,index,versioninstalled_column);
+      mb_wprintleft(listpad,
+		    versiondescribe(&pkg->installed.version,vdew_never),
+		    versioninstalled_width);
+      waddch(listpad, ' '); 
+    }
     if (versionavailable_width) {
       if (informativeversion(&pkg->available.version) &&
           versioncompare(&pkg->available.version,&pkg->installed.version) > 0)
         wattrset(listpad, selected ? selstatesel_attr : selstate_attr);
-      mvwprintw(listpad,index,versionavailable_column, "%-*.*s",
-                versionavailable_width, versionavailable_width,
-                versiondescribe(&pkg->available.version,vdew_never));
+      wmove(listpad,index,versionavailable_column);
+      mb_wprintleft(listpad,
+		    versiondescribe(&pkg->available.version,vdew_never),
+		    versionavailable_width);
       wattrset(listpad, selected ? listsel_attr : list_attr);
       waddch(listpad,' ');
     }
@@ -255,6 +259,7 @@
   }
 
   while (i>0) { waddch(listpad,' '); i--; }
+  
 }
 
 void packagelist::redrawcolheads() {
@@ -264,37 +269,37 @@
     if (verbose) {
       wmove(colheadspad,0,0);
       for (int i=0; i<status_width-status_want_width; i++) waddch(colheadspad,'.');
-      mvwaddnstr(colheadspad,0,
-                 0,
-                 _("Error"),
-                 status_hold_width);
-      mvwaddnstr(colheadspad,0,
-                 status_hold_width+1,
-                 _("Installed?"),
-                 status_status_width);
-      mvwaddnstr(colheadspad,0,
-                 status_hold_width+status_status_width+2,
-                 _("Old mark"),
-                 status_want_width);
-      mvwaddnstr(colheadspad,0,
-                 status_hold_width+status_status_width+status_want_width+3,
-                 _("Marked for"),
-                 status_want_width);
+      mb_mvwaddnstr(colheadspad,0,
+		    0,
+		    _("Error"),
+		    status_hold_width);
+      mb_mvwaddnstr(colheadspad,0,
+		    status_hold_width+1,
+		    _("Installed?"),
+		    status_status_width);
+      mb_mvwaddnstr(colheadspad,0,
+		    status_hold_width+status_status_width+2,
+		    _("Old mark"),
+		    status_want_width);
+      mb_mvwaddnstr(colheadspad,0,
+		    status_hold_width+status_status_width+status_want_width+3,
+		    _("Marked for"),
+		    status_want_width);
     } else {
       mvwaddstr(colheadspad,0,0, _("EIOM"));
     }
-    mvwaddnstr(colheadspad,0,section_column, _("Section"), section_width);
-    mvwaddnstr(colheadspad,0,priority_column, _("Priority"), priority_width);
-    mvwaddnstr(colheadspad,0,package_column, _("Package"), package_width);
+    mb_mvwaddnstr(colheadspad,0,section_column, _("Section"), section_width);
+    mb_mvwaddnstr(colheadspad,0,priority_column, _("Priority"), priority_width);
+    mb_mvwaddnstr(colheadspad,0,package_column, _("Package"), package_width);
 
     if (versioninstalled_width)
-      mvwaddnstr(colheadspad,0,versioninstalled_column,
-                 _("Inst.ver"),versioninstalled_width);
+      mb_mvwaddnstr(colheadspad,0,versioninstalled_column,
+		    _("Inst.ver"),versioninstalled_width);
     if (versionavailable_width)
-      mvwaddnstr(colheadspad,0,versionavailable_column,
-                 _("Avail.ver"),versionavailable_width);
+      mb_mvwaddnstr(colheadspad,0,versionavailable_column,
+		    _("Avail.ver"),versionavailable_width);
 
-    mvwaddnstr(colheadspad,0,description_column, _("Description"), description_width);
+    mb_mvwaddnstr(colheadspad,0,description_column, _("Description"), description_width);
   }
   refreshcolheads();
 }

Reply to: