# HG changeset patch # User Mikael Berthe # Date 1152344598 -7200 # Node ID fc6aaa223650f776779b0050ffca71419e95b584 # Parent 1cd6d694ac3c9b07cf437e569ede8f92f129b6f8 Fix a few problems with non-UTF-8 locales diff -r 1cd6d694ac3c -r fc6aaa223650 mcabber/src/hbuf.c --- 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) { diff -r 1cd6d694ac3c -r fc6aaa223650 mcabber/src/screen.c --- 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 diff -r 1cd6d694ac3c -r fc6aaa223650 mcabber/src/utf8.h --- 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 # 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