changeset 932:fc6aaa223650

Fix a few problems with non-UTF-8 locales
author Mikael Berthe <mikael@lilotux.net>
date Sat, 08 Jul 2006 09:43:18 +0200
parents 1cd6d694ac3c
children ede9260be93d
files mcabber/src/hbuf.c mcabber/src/screen.c mcabber/src/utf8.h
diffstat 3 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mcabber/src/hbuf.c	Sat Jul 08 09:43:01 2006 +0200
+++ b/mcabber/src/hbuf.c	Sat Jul 08 09:43:18 2006 +0200
@@ -203,7 +203,7 @@
       while (*c && cur_w <= width) {
         if (iswblank(get_char(c)))
           br = c;
-        cur_w += wcwidth(get_char(c));
+        cur_w += get_char_width(c);
         c = next_char(c);
       }
       if (*c && cur_w > width) {
--- a/mcabber/src/screen.c	Sat Jul 08 09:43:01 2006 +0200
+++ b/mcabber/src/screen.c	Sat Jul 08 09:43:18 2006 +0200
@@ -2221,15 +2221,15 @@
   }
   // Right side
   if (direction >= 0) {
-    int delta = wcwidth(get_char(c));
+    int delta = get_char_width(c);
     while (ptr_inputline > c) {
       c = next_char(c);
-      delta += wcwidth(get_char(c));
+      delta += get_char_width(c);
     }
     c = &inputLine[inputline_offset];
     while (delta >= maxX) {
       for (i = 0; i < 5; i++) {
-        delta -= wcwidth(get_char(c));
+        delta -= get_char_width(c);
         c = next_char(c);
       }
     }
@@ -2652,7 +2652,7 @@
 
 display:
   if (display_char) {
-    if (iswprint(key) && (!utf8_mode || kcode.utf8 || key < 128)) {
+    if (kcode.utf8 ? iswprint(key) : isprint(key)) {
       char tmpLine[INPUTLINE_LENGTH+1];
 
       // Check the line isn't too long
--- a/mcabber/src/utf8.h	Sat Jul 08 09:43:01 2006 +0200
+++ b/mcabber/src/utf8.h	Sat Jul 08 09:43:18 2006 +0200
@@ -6,8 +6,10 @@
 #ifdef HAVE_WCHAR_H
 # include <wchar.h>
 # define UNICODE
+# define get_char_width(c) (utf8_mode ? wcwidth(get_char(c)) : 1)
 #else
 # define wcwidth(c) 1
+# define get_char_width(c) 1
 #endif
 
 #ifdef HAVE_WCTYPE_H