From 4d2aca39cdd96958b3f0bbc6973f15aac5133cdc Mon Sep 17 00:00:00 2001 From: Jaakko Heinonen Date: Fri, 5 Dec 2003 16:09:42 +0000 Subject: [PATCH] wide character support --- abook.c | 3 +- abook_rl.c | 36 ++++ config.h.in | 9 + configure | 532 ++++++++++++++++++++++++++++++++++++++++++++++++++- configure.in | 49 ++++- 5 files changed, 617 insertions(+), 12 deletions(-) diff --git a/abook.c b/abook.c index 5181203..fe37f71 100644 --- a/abook.c +++ b/abook.c @@ -6,9 +6,10 @@ * Copyright (C) Jaakko Heinonen */ -#include +#include #include #include +#include #include #include #include diff --git a/abook_rl.c b/abook_rl.c index 22c66ce..f9ebba6 100644 --- a/abook_rl.c +++ b/abook_rl.c @@ -31,6 +31,10 @@ # include #endif +#ifdef HANDLE_MULTIBYTE +# include +#endif + #define RL_READLINE_NAME "Abook" static int rl_x, rl_y; @@ -45,10 +49,42 @@ rl_refresh() wrefresh(rl_win); } +#ifdef HANDLE_MULTIBYTE +static int +rline_calc_point() +{ + char *p; + int ret = 0; + + mbtowc(NULL, NULL, 0); + for(p = rl_line_buffer;(p - rl_line_buffer) < rl_point;) { + int a, l; + wchar_t wc; + + if((a = mbtowc(&wc, p, MB_CUR_MAX)) == 0) + break; + else if (a == -1) + return rl_point; /* fall back */ + else + p += a; + + l = wcwidth(wc); + if(l > 0) + ret += l; + } + + return ret; +} +#endif + static void rline_update() { +#ifdef HANDLE_MULTIBYTE + int real_point = rline_calc_point() + rl_x; +#else int real_point = rl_point + rl_x; +#endif if(real_point > (COLS - 1)) mvwaddnstr(rl_win, rl_y, rl_x, diff --git a/config.h.in b/config.h.in index 1298c7a..7814ddd 100644 --- a/config.h.in +++ b/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.in by autoheader. */ +/* Handle multibyte characters */ +#undef HANDLE_MULTIBYTE + /* Define to 1 if you have the header file. */ #undef HAVE_HISTORY_H @@ -15,6 +18,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H +/* Define to 1 if you have the `mbtowc' function. */ +#undef HAVE_MBTOWC + /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H @@ -82,6 +88,9 @@ /* Define if vsnprintf is available. */ #undef HAVE_VSNPRINTF +/* Define to 1 if you have the `wcwidth' function. */ +#undef HAVE_WCWIDTH + /* Name of package */ #undef PACKAGE diff --git a/configure b/configure index 406e4aa..6f61bd4 100755 --- a/configure +++ b/configure @@ -850,6 +850,7 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --disable-dependency-tracking Speeds up one-time builds --enable-dependency-tracking Do not reject slow dependency extractors + --enable-widec Enable wide character support (experimental) --enable-debug Enable debugging support Optional Packages: @@ -4316,6 +4317,310 @@ fi done +ac_widec_funcs=yes +if test "${ac_cv_header_wchar_h+set}" = set; then + echo "$as_me:$LINENO: checking for wchar.h" >&5 +echo $ECHO_N "checking for wchar.h... $ECHO_C" >&6 +if test "${ac_cv_header_wchar_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: $ac_cv_header_wchar_h" >&5 +echo "${ECHO_T}$ac_cv_header_wchar_h" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking wchar.h usability" >&5 +echo $ECHO_N "checking wchar.h usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking wchar.h presence" >&5 +echo $ECHO_N "checking wchar.h presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: wchar.h: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: wchar.h: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: wchar.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: wchar.h: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + no:yes ) + { echo "$as_me:$LINENO: WARNING: wchar.h: present but cannot be compiled" >&5 +echo "$as_me: WARNING: wchar.h: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: wchar.h: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: wchar.h: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: wchar.h: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: wchar.h: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for wchar.h" >&5 +echo $ECHO_N "checking for wchar.h... $ECHO_C" >&6 +if test "${ac_cv_header_wchar_h+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_header_wchar_h=$ac_header_preproc +fi +echo "$as_me:$LINENO: result: $ac_cv_header_wchar_h" >&5 +echo "${ECHO_T}$ac_cv_header_wchar_h" >&6 + +fi +if test $ac_cv_header_wchar_h = yes; then + ac_have_wchar_h=yes +else + ac_have_wchar_h=no +fi + + + + +for ac_func in mbtowc wcwidth +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6 +if eval "test \"\${$as_ac_var+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $ac_func (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ +#ifdef __STDC__ +# include +#else +# include +#endif +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +{ +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +char (*f) () = $ac_func; +#endif +#ifdef __cplusplus +} +#endif + +int +main () +{ +return f != $ac_func; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + eval "$as_ac_var=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +eval "$as_ac_var=no" +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6 +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +else + ac_widec_funcs=no +fi +done + +echo "$as_me:$LINENO: checking for wchar_t" >&5 +echo $ECHO_N "checking for wchar_t... $ECHO_C" >&6 +if test "${ac_cv_type_wchar_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +if ((wchar_t *) 0) + return 0; +if (sizeof (wchar_t)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_type_wchar_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_type_wchar_t=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +fi +echo "$as_me:$LINENO: result: $ac_cv_type_wchar_t" >&5 +echo "${ECHO_T}$ac_cv_type_wchar_t" >&6 +if test $ac_cv_type_wchar_t = yes; then + : +else + ac_widec_funcs=no +fi + + +if test x$ac_widec_funcs = xyes -a x$ac_have_wchar_h = xyes; then + ac_widec_possible=yes +else + ac_widec_possible=no +fi + +# Check whether --enable-widec or --disable-widec was given. +if test "${enable_widec+set}" = set; then + enableval="$enable_widec" + case "${enableval}" in + yes) ac_widec_support=true ;; + no) ac_widec_support=false ;; + *) { { echo "$as_me:$LINENO: error: bad value ${enableval} for --enable-widec" >&5 +echo "$as_me: error: bad value ${enableval} for --enable-widec" >&2;} + { (exit 1); exit 1; }; } ;; + esac +else + ac_widec_support=false +fi; + +if test x$ac_widec_support = xtrue -a x$ac_widec_possible != xyes; then + { { echo "$as_me:$LINENO: error: Wide character support is not possible due to missing wide character functions or wchar.h" >&5 +echo "$as_me: error: Wide character support is not possible due to missing wide character functions or wchar.h" >&2;} + { (exit 1); exit 1; }; } +fi + abook_cv_curses=/usr @@ -4331,7 +4636,217 @@ if test "${with_curses+set}" = set; then fi fi; -echo "$as_me:$LINENO: checking for initscr in -lncurses" >&5 +if test x$ac_widec_support = xtrue; then + echo "$as_me:$LINENO: checking for initscr in -lncursesw" >&5 +echo $ECHO_N "checking for initscr in -lncursesw... $ECHO_C" >&6 +if test "${ac_cv_lib_ncursesw_initscr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lncursesw $LIBS" +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any gcc2 internal prototype to avoid an error. */ +#ifdef __cplusplus +extern "C" +#endif +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char initscr (); +int +main () +{ +initscr (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext conftest$ac_exeext +if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5 + (eval $ac_link) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest$ac_exeext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_lib_ncursesw_initscr=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_cv_lib_ncursesw_initscr=no +fi +rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +echo "$as_me:$LINENO: result: $ac_cv_lib_ncursesw_initscr" >&5 +echo "${ECHO_T}$ac_cv_lib_ncursesw_initscr" >&6 +if test $ac_cv_lib_ncursesw_initscr = yes; then + LIBS="$LIBS -lncursesw" + if test x$abook_cv_curses = x/usr -a -d /usr/include/ncursesw; then + CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" + fi + +for ac_header in ncurses.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 +else + # Is the header compilable? +echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 + (eval $ac_compile) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && + { ac_try='test -s conftest.$ac_objext' + { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5 + (eval $ac_try) 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +ac_header_compiler=no +fi +rm -f conftest.$ac_objext conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6 + +# Is the header present? +echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6 +cat >conftest.$ac_ext <<_ACEOF +#line $LINENO "configure" +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5 + (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null; then + if test -s conftest.err; then + ac_cpp_err=$ac_c_preproc_warn_flag + else + ac_cpp_err= + fi +else + ac_cpp_err=yes +fi +if test -z "$ac_cpp_err"; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi +rm -f conftest.err conftest.$ac_ext +echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6 + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc in + yes:no ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; + no:yes ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + ( + cat <<\_ASBOX +## ------------------------------------ ## +## Report this to bug-autoconf@gnu.org. ## +## ------------------------------------ ## +_ASBOX + ) | + sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac +echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6 +if eval "test \"\${$as_ac_Header+set}\" = set"; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=$ac_header_preproc" +fi +echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5 +echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6 + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +else + + { { echo "$as_me:$LINENO: error: \"Wide character support is not possible due to missing ncursesw library. Please install it or disable wide character support\"" >&5 +echo "$as_me: error: \"Wide character support is not possible due to missing ncursesw library. Please install it or disable wide character support\"" >&2;} + { (exit 1); exit 1; }; } +fi + +else + echo "$as_me:$LINENO: checking for initscr in -lncurses" >&5 echo $ECHO_N "checking for initscr in -lncurses... $ECHO_C" >&6 if test "${ac_cv_lib_ncurses_initscr+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -4387,9 +4902,9 @@ echo "$as_me:$LINENO: result: $ac_cv_lib_ncurses_initscr" >&5 echo "${ECHO_T}$ac_cv_lib_ncurses_initscr" >&6 if test $ac_cv_lib_ncurses_initscr = yes; then LIBS="$LIBS -lncurses" - if test x$abook_cv_curses = x/usr -a -d /usr/include/ncurses; then - CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses" - fi + if test x$abook_cv_curses = x/usr -a -d /usr/include/ncurses; then + CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses" + fi for ac_header in ncurses.h do @@ -5162,6 +5677,7 @@ fi fi +fi @@ -5618,6 +6134,14 @@ echo "$as_me: error: *** readline library not found or it doesn't support histor fi +if test x$ac_widec_support = xtrue; then + +cat >>confdefs.h <<\_ACEOF +#define HANDLE_MULTIBYTE 1 +_ACEOF + +fi + for ac_func in resizeterm do diff --git a/configure.in b/configure.in index c5284a6..0ba524c 100644 --- a/configure.in +++ b/configure.in @@ -25,6 +25,27 @@ AC_CHECK_HEADER(stdarg.h,AC_DEFINE(HAVE_STDARG_H),AC_MSG_ERROR([*** stdarg.h is AC_FUNC_STRCOLL AC_CHECK_FUNCS(setlocale) +ac_widec_funcs=yes +AC_CHECK_HEADER(wchar.h,[ac_have_wchar_h=yes], [ac_have_wchar_h=no]) +AC_CHECK_FUNCS(mbtowc wcwidth,,ac_widec_funcs=no) +AC_CHECK_TYPE(wchar_t,,ac_widec_funcs=no) + +if test x$ac_widec_funcs = xyes -a x$ac_have_wchar_h = xyes; then + ac_widec_possible=yes +else + ac_widec_possible=no +fi + +AC_ARG_ENABLE(widec, [ --enable-widec Enable wide character support (experimental) ], [case "${enableval}" in + yes) ac_widec_support=true ;; + no) ac_widec_support=false ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-widec) ;; + esac], [ac_widec_support=false]) + +if test x$ac_widec_support = xtrue -a x$ac_widec_possible != xyes; then + AC_MSG_ERROR(Wide character support is not possible due to missing wide character functions or wchar.h) +fi + dnl ------------------- dnl (n)curses detection dnl ------------------- @@ -39,13 +60,23 @@ AC_ARG_WITH(curses, [ --with-curses=DIR Where ncurses is installed ], CPPFLAGS="$CPPFLAGS -I${abook_cv_curses}/include" fi]) -AC_CHECK_LIB(ncurses, initscr, - [LIBS="$LIBS -lncurses" - if test x$abook_cv_curses = x/usr -a -d /usr/include/ncurses; then - CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses" - fi - AC_CHECK_HEADERS(ncurses.h)], - [CF_CURSES_LIBS]) +if test x$ac_widec_support = xtrue; then + AC_CHECK_LIB(ncursesw, initscr, + [LIBS="$LIBS -lncursesw" + if test x$abook_cv_curses = x/usr -a -d /usr/include/ncursesw; then + CPPFLAGS="$CPPFLAGS -I/usr/include/ncursesw" + fi + AC_CHECK_HEADERS(ncurses.h)],[ + AC_MSG_ERROR("Wide character support is not possible due to missing ncursesw library. Please install it or disable wide character support")]) +else + AC_CHECK_LIB(ncurses, initscr, + [LIBS="$LIBS -lncurses" + if test x$abook_cv_curses = x/usr -a -d /usr/include/ncurses; then + CPPFLAGS="$CPPFLAGS -I/usr/include/ncurses" + fi + AC_CHECK_HEADERS(ncurses.h)], + [CF_CURSES_LIBS]) +fi dnl -------------------------- dnl end of (n)curses detection @@ -75,6 +106,10 @@ dnl ------------------------- dnl end of readline detection dnl ------------------------- +if test x$ac_widec_support = xtrue; then + AC_DEFINE(HANDLE_MULTIBYTE, 1, [Handle multibyte characters]) +fi + AC_CHECK_FUNCS(resizeterm) AC_CHECK_FUNC(snprintf, [AC_DEFINE(HAVE_SNPRINTF)],) -- 2.39.2