]> mj.ucw.cz Git - checkmail.git/commitdiff
Use libncursesw, because UTF-8 does not work otherwise.
authorMartin Mares <mj@ucw.cz>
Wed, 16 Jan 2008 09:39:11 +0000 (10:39 +0100)
committerMartin Mares <mj@ucw.cz>
Wed, 16 Jan 2008 09:39:11 +0000 (10:39 +0100)
ChangeLog
Makefile
README
cm.c

index f865d92d38409d24e921e250b69c7f6ca186d3a7..6116cedfd0accc182f1717549ede227c38ae7d25 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2008-01-16  Martin Mares <mj@ucw.cz>
+
+       * Non-ASCII characters are displayed properly in UTF-8 locale.
+         Unfortunately, this needs linking checkmail with libncursesw,
+         because plain libncurses chokes on multi-byte characters whose
+         parts do not look printable. This mode is now enabled by default,
+         tweak the Makefile if you do not have libncursesw.
+
 2007-06-25  Martin Mares <mj@ucw.cz>
 
        * Non-ASCII characters encoded as per RFC 2047 are now deciphered
index 11106e0501eacbfba98ba7372f5232ef3bbc32d1..5b897b1b52a391c7e777136dc6a833732281b967 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,18 @@
+# Define if you want support for wide characters (needs libncursesw)
+CONFIG_WIDE_CURSES=1
+
 #DEBUG=-ggdb
 CFLAGS=-O2 -Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline $(DEBUG) -std=gnu99 -DVERSION=$(VERSION) -DYEAR=$(YEAR)
+
+ifdef CONFIG_WIDE_CURSES
+LDFLAGS=-lncursesw
+CFLAGS+=-DCONFIG_WIDE_CURSES=1
+else
 LDFLAGS=-lncurses
+endif
 
-VERSION=1.0
-YEAR=2007
+VERSION=1.1
+YEAR=2008
 
 all: cm
 
diff --git a/README b/README
index 7863091e3da6ed53f5de5371be977d38b454f6da..3873dbca5e2db0b33a996c2f8e9dfaa767f45bd5 100644 (file)
--- a/README
+++ b/README
@@ -2,7 +2,7 @@
 
                                 Checkmail @VERSION@
 
-                   (c) 2005--2007 Martin Mares <mj@ucw.cz>
+                   (c) 2005--2008 Martin Mares <mj@ucw.cz>
 
 ================================================================================
 
diff --git a/cm.c b/cm.c
index 92141ef269851101c971aff5876840a3847220ac..a112a005c74556e349889c50286616b4dadc7814 100644 (file)
--- a/cm.c
+++ b/cm.c
@@ -1,9 +1,11 @@
 /*
  *     Incoming Mail Checker
  *
- *     (c) 2005--2007 Martin Mares <mj@ucw.cz>
+ *     (c) 2005--2008 Martin Mares <mj@ucw.cz>
  */
 
+#define _GNU_SOURCE
+
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <pwd.h>
 #include <time.h>
+
+#ifdef CONFIG_WIDE_CURSES
+#include <ncursesw/ncurses.h>
+#else
 #include <curses.h>
+#endif
 
 #include "util.h"
 #include "clists.h"
@@ -611,7 +618,16 @@ redraw_line(int i)
              getyx(stdscr, yy, xx);
              int remains = COLS-1-xx;
              if (remains > 2)
-               printw("%-.*s", remains, b->snippet);
+               {
+#ifdef CONFIG_WIDE_CURSES
+                 size_t len = strlen(b->snippet)+1;
+                 wchar_t snip[len];
+                 mbstowcs(snip, b->snippet, len);
+                 addnwstr(snip, remains);
+#else
+                 printw("%-.*s", remains, b->snippet);
+#endif
+               }
            }
        }
     }