Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: make unicode support configurable



Here's a first pass at turning the ZLE_UNICODE_SUPPORT define into a
configure item.  The attached patch allows the user to specify either
--with-unicode-support or --without-unicode-support (to force the
decision), otherwise it runs a test to see if it thinks unicode can
be supported (which consists of the current checks from system.h
transplanted into configure).  The code in system.h was also modified
to check the value of ZLE_UNICODE_SUPPORT instead of set it.

Some questions that should be answered:

  o Do we like the above name for the --with/--without option?
  o Is including locale.h (if it exists) the right include file for
    the new configure test for __STDC_ISO_10646__?  (It works on my
    Linux system.)
  o Do we need the old unicode "subset" logic that I removed from
    system.h?

..wayne..
--- configure.ac	1 Aug 2005 09:54:56 -0000	1.37
+++ configure.ac	15 Aug 2005 16:56:54 -0000
@@ -2063,6 +2063,43 @@ int ptsname();], ,
    fi
 fi
 
+dnl ---------------
+dnl unicode support
+dnl ---------------
+AC_ARG_WITH(unicode-support,
+[  --with-unicode-support     support unicode characters in the line editor])
+
+echo $with_unicode_support >/tmp/uni
+case x"$with_unicode_support" in
+  xyes) zsh_cv_c_zle_unicode_support=yes ;;
+  xno) zsh_cv_c_zle_unicode_support=no ;;
+  *)
+    AC_CACHE_CHECK(if the compiler supports wide characters,
+     zsh_cv_c_zle_unicode_support,
+    [AC_TRY_COMPILE([
+#ifdef HAVE_LOCALE_H
+# include <locale.h>
+#endif
+     ], [
+int main() {
+#if defined(HAVE_WCHAR_H) && defined(HAVE_WCTOMB) \
+ && defined(HAVE_MBRTOWC) && defined(HAVE_WCRTOMB) \
+ && defined (__STDC_ISO_10646__)
+    return 0;
+#else
+#error Not supported.
+#endif
+}
+    ],
+      zsh_cv_c_zle_unicode_support=yes,
+      zsh_cv_c_zle_unicode_support=no)])
+    ;;
+esac
+AH_TEMPLATE([ZLE_UNICODE_SUPPORT],
+[Define to 1 if you want unicode support in the line editor.])
+if test $zsh_cv_c_zle_unicode_support = yes; then
+  AC_DEFINE(ZLE_UNICODE_SUPPORT)
+fi
 
 dnl ---------------
 dnl dynamic loading
--- Src/system.h	15 Aug 2005 10:01:48 -0000	1.33
+++ Src/system.h	15 Aug 2005 16:56:54 -0000
@@ -691,22 +691,9 @@ extern short ospeed;
 #define UNUSED(x) x
 #endif
 
-/*
- * This is a subset of ZLE_UNICODE_SUPPORT.  It is not all that likely
- * that only the subset is supported, however it's easy to make the
- * \u and \U escape sequences work with just the following.
- */
-#if defined(HAVE_WCHAR_H) && defined(HAVE_WCTOMB) && defined (__STDC_ISO_10646__)
+#ifdef ZLE_UNICODE_SUPPORT
 # include <wchar.h>
 # include <wctype.h>
-
-/*
- * More stringent requirements to enable complete Unicode conversion
- * between wide characters and multibyte strings.
- */
-#if defined(HAVE_MBRTOWC) && defined(HAVE_WCRTOMB)
-#define ZLE_UNICODE_SUPPORT	1
-#endif
 #else
 # ifdef HAVE_LANGINFO_H
 #   include <langinfo.h>


Messages sorted by: Reverse Date, Date, Thread, Author