Hopefully fix unicode detection on BSD systems
authorMikael Berthe <mikael@lilotux.net>
Thu, 07 Dec 2006 21:18:48 +0100
changeset 1089 a61c3311a5bb
parent 1088 c55b24818546
child 1090 fff7ee4cefab
Hopefully fix unicode detection on BSD systems The ncurses library's unicode support wasn't correctly detected on some systems (FreeBSD for example). This patch adds a HAVE_UNICODE define with autoconf.
mcabber/configure.ac
mcabber/src/screen.c
mcabber/src/utf8.h
--- a/mcabber/configure.ac	Wed Dec 06 23:18:36 2006 +0100
+++ b/mcabber/configure.ac	Thu Dec 07 21:18:48 2006 +0100
@@ -7,7 +7,8 @@
 AC_CONFIG_SRCDIR([src])
 AM_CONFIG_HEADER(config.h)
 
-AC_PROG_LIBTOOL
+#AC_PROG_LIBTOOL
+AC_PROG_RANLIB
 
 # Checks for programs.
 AC_PROG_CC
@@ -25,38 +26,6 @@
     CFLAGS="$CFLAGS -Wall"
 fi
 
-# Checks for libraries.
-
-AC_CHECK_FUNC(initscr,,
-[
-    cf_ncurses="ncurses"
-    for lib in ncursesw ncurses
-    do
-        AC_CHECK_LIB($lib, waddnwstr, [cf_ncurses="$lib"; break])
-    done
-    AC_CHECK_LIB($cf_ncurses, initscr,
-        [LIBS="$LIBS -l$cf_ncurses"
-         if test "$cf_ncurses" = ncursesw; then
-            AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/panel.h],,
-                 [AC_CHECK_HEADERS([ncurses.h panel.h],,
-                                   AC_MSG_ERROR([Missing header file]))])
-         else
-             AC_CHECK_HEADERS([ncurses/ncurses.h ncurses/panel.h],,
-                 [AC_CHECK_HEADERS([ncurses.h panel.h],,
-                                   AC_MSG_ERROR([Missing header file]))])
-         fi
-        ],
-        [CF_CURSES_LIBS])
-])
-
-AC_CHECK_LIB([panelw], [new_panel],,
-             AC_CHECK_LIB([panel], [new_panel])
-            )
-
-AC_CHECK_DECLS([strptime],,,
-[#define _GNU_SOURCE
-#include <time.h>])
-
 # Checks for header files.
 AC_HEADER_STDC
 AC_CHECK_HEADERS([arpa/inet.h fcntl.h locale.h netdb.h netinet/in.h stddef.h \
@@ -86,9 +55,49 @@
                 memmove memset modf select setlocale socket strcasecmp \
                 strchr strdup strncasecmp strrchr strstr strcasestr])
 
+
+AC_CHECK_DECLS([strptime],,,
+[#define _GNU_SOURCE
+#include <time.h>])
+
 # Check for tm_gmtoff
 MC_TM_GMTOFF
 
+# Checks for libraries.
+
+AC_CHECK_FUNC(initscr,,
+[
+    cf_ncurses="ncurses"
+    for lib in ncursesw ncurses
+    do
+        AC_CHECK_LIB($lib, waddnwstr,
+            [cf_ncurses="$lib"; cf_ncurses_unicode="yes"; break])
+    done
+    AC_CHECK_LIB($cf_ncurses, initscr,
+        [LIBS="$LIBS -l$cf_ncurses"
+         if test "$cf_ncurses" = ncursesw; then
+            AC_CHECK_HEADERS([ncursesw/ncurses.h ncursesw/panel.h],,
+                 [AC_CHECK_HEADERS([ncurses.h panel.h],,
+                                   AC_MSG_ERROR([Missing header file]))])
+         else
+             AC_CHECK_HEADERS([ncurses/ncurses.h ncurses/panel.h],,
+                 [AC_CHECK_HEADERS([ncurses.h panel.h],,
+                                   AC_MSG_ERROR([Missing header file]))])
+         fi
+        ],
+        [CF_CURSES_LIBS])
+])
+
+AC_CHECK_LIB([panelw], [new_panel],,
+             AC_CHECK_LIB([panel], [new_panel])
+            )
+
+if test x"$cf_ncurses_unicode" = x"yes"; then
+    AC_DEFINE([HAVE_UNICODE], [], [Define if ncurses have unicode support])
+else
+    AC_MSG_WARN([Your ncurses installation does not support unicode])
+fi
+
 # Check for glib
 AM_PATH_GLIB_2_0(2.0.0, , AC_MSG_ERROR([glib is required]),[g_list_append])
 
--- a/mcabber/src/utf8.h	Wed Dec 06 23:18:36 2006 +0100
+++ b/mcabber/src/utf8.h	Thu Dec 07 21:18:48 2006 +0100
@@ -3,9 +3,12 @@
 
 #include <config.h>
 
+#if defined HAVE_UNICODE && defined HAVE_WCHAR_H && defined HAVE_WCTYPE_H
+# define UNICODE
+#endif
+
 #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
@@ -18,11 +21,6 @@
 # define iswblank(c) (c == ' ')
 # define iswalnum(c) isalnum(c)
 # define iswprint(c) isprint(c)
-# undef UNICODE
-#endif
-
-#ifndef HAVE_NCURSESW_NCURSES_H
-# undef UNICODE
 #endif
 
 extern int utf8_mode;