slang-users mailing list

[2008 Date Index] [2008 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

[slang-users] Re: [Patch] Use of glibc wcwidth


This is patch for slang(revision:231).

2008/3/4, cedre. m <cedre.m@xxxxxxxxx>:
> Hello, I am Japanese centos user.
> I use slang library(ntsysv, system-config-*). Thank you.
>
> This patch resolves unicode ambiguous width problem, by wcwidth(glibc).
>

--
Sugiyama
cedre.m@xxxxxxxxx
diff -ur slang-r231/autoconf/configure.ac slang-r231-ambiguous/autoconf/configure.ac
--- slang-r231/autoconf/configure.ac	2008-03-11 20:55:25.000000000 +0900
+++ slang-r231-ambiguous/autoconf/configure.ac	2008-03-11 20:54:51.000000000 +0900
@@ -220,6 +220,21 @@
 AC_SUBST(GNU_READLINE)
 AC_SUBST(LIB_READLINE)
 
+gnu_wcwidth=unknown
+AC_ARG_WITH([gnu-wcwidth],
+  [  --without-gnu-wcwidth         Don't use the glibc wcwidth.],
+  gnu_wcwidth=$withval)
+
+if test "$gnu_wcwidth" != "no"; then
+  AC_EGREP_CPP(yes,[
+#include <features.h>
+#include <wchar.h>
+#if defined(__GLIBC__) && defined(_WCHAR_H) && defined(__STDC_ISO_10646__)
+yes
+#endif
+],AC_DEFINE(HAVE_GNU_WCWIDTH,1,[Define if you want glibc wcwidth.]))
+fi
+
 JD_GET_MODULES(src/modules.unx)
 JD_CREATE_MODULE_ORULES
 
diff -ur slang-r231/src/config.hin slang-r231-ambiguous/src/config.hin
--- slang-r231/src/config.hin	2008-03-11 20:55:24.000000000 +0900
+++ slang-r231-ambiguous/src/config.hin	2008-03-11 20:53:09.000000000 +0900
@@ -78,6 +78,8 @@
 
 #undef HAVE_SYS_MMAN_H
 
+#undef HAVE_GNU_WCWIDTH
+
 /* Set these to the appropriate values */
 #undef SIZEOF_SHORT
 #undef SIZEOF_INT
diff -ur slang-r231/src/slang.h slang-r231-ambiguous/src/slang.h
--- slang-r231/src/slang.h	2008-03-11 20:55:24.000000000 +0900
+++ slang-r231-ambiguous/src/slang.h	2008-03-11 20:36:58.000000000 +0900
@@ -330,6 +330,7 @@
 
 #define SLWCWIDTH_SINGLE_WIDTH	0x0001 /* all double width characters given as single width */
 #define SLWCWIDTH_CJK_LEGACY	0x0002 /* Ambiguous characters given width of 2 */
+#define SLWCWIDTH_GLIBC	0x0004
 SL_EXTERN int SLwchar_set_wcwidth_flags (int flags);
 
 /* The skip_char functions also skip over malformed strings counting each byte
diff -ur slang-r231/src/slcommon.c slang-r231-ambiguous/src/slcommon.c
--- slang-r231/src/slcommon.c	2008-03-11 20:55:24.000000000 +0900
+++ slang-r231-ambiguous/src/slcommon.c	2008-03-11 20:38:46.000000000 +0900
@@ -150,6 +150,8 @@
      {
 	if ((*cjk == 0) || (0==strcmp(cjk,"yes")))
 	  (void) SLwchar_set_wcwidth_flags (SLWCWIDTH_CJK_LEGACY);
+	else if (0==strcmp(cjk,"glibc"))
+	  (void) SLwchar_set_wcwidth_flags (SLWCWIDTH_GLIBC);
      }
    return mode;
 }
diff -ur slang-r231/src/slwcwidth.c slang-r231-ambiguous/src/slwcwidth.c
--- slang-r231/src/slwcwidth.c	2008-03-11 20:55:24.000000000 +0900
+++ slang-r231-ambiguous/src/slwcwidth.c	2008-03-11 20:51:35.000000000 +0900
@@ -26,6 +26,9 @@
 
 #define DEFINE_PSLWC_WIDTH_TABLE
 #include "slwcwidth.h"
+#ifdef HAVE_GNU_WCWIDTH
+#include <wchar.h>
+#endif
 
 static int Width_Flags = 0;
 int SLwchar_wcwidth (SLwchar_Type ch)
@@ -44,6 +47,10 @@
      {
 	if (Width_Flags & SLWCWIDTH_CJK_LEGACY)
 	  w = 2;
+#ifdef HAVE_GNU_WCWIDTH
+	else if (Width_Flags & SLWCWIDTH_GLIBC)
+	  w = wcwidth((wchar_t)ch);
+#endif
 	else
 	  w = 1;
      }





[2008 date index] [2008 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]