- Subject: [slang-users] [Patch] Use of glibc wcwidth
- From: "cedre.m" <cedre.m@xxxxxxxxx>
- Date: Tue, 4 Mar 2008 20:49:20 +0900
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).
http://www.unicode.org/reports/tr11/#Ambiguous
http://mediasrv.ns.ac.yu/unicode/www.unicode.org/unicode/reports/tr11-4/index.htm
http://www.stained-g.net/shinichiro/unicode5-ambiguous-width.html
http://people.debian.org/~kubota/unicode-symbols-width2.html.en
--
Sugiyama
cedre.m@xxxxxxxxx
# using glibc wcwidth instead of slwcwidth.
# cedre.m@xxxxxxxxx
diff -urN slang-2.1.3/autoconf/configure.ac slang-2.1.3-wcwidth/autoconf/configure.ac
--- slang-2.1.3/autoconf/configure.ac 2007-08-30 03:54:49.000000000 +0900
+++ slang-2.1.3-wcwidth/autoconf/configure.ac 2008-03-04 19:08:17.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 -urN slang-2.1.3/src/config.hin slang-2.1.3-wcwidth/src/config.hin
--- slang-2.1.3/src/config.hin 2007-08-30 12:29:28.000000000 +0900
+++ slang-2.1.3-wcwidth/src/config.hin 2008-03-04 19:08:17.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 -urN slang-2.1.3/src/slsmg.c slang-2.1.3-wcwidth/src/slsmg.c
--- slang-2.1.3/src/slsmg.c 2007-10-14 03:34:10.000000000 +0900
+++ slang-2.1.3-wcwidth/src/slsmg.c 2008-03-04 19:08:17.000000000 +0900
@@ -214,44 +214,46 @@
unsigned char vt100_char;
unsigned char ascii;
SLwchar_Type unicode;
+ SLwchar_Type unicode_not_ambiguous; // not_wide ?
}
ACS_Def_Type;
static SLCONST ACS_Def_Type UTF8_ACS_Map[] =
{
- {'+', '>', 0x2192 }, /* RIGHTWARDS ARROW */
- {',', '<', 0x2190 }, /* LEFTWARDS ARROW */
- {'-', '^', 0x2191 }, /* UPWARDS ARROW */
- {'.', 'v', 0x2193 }, /* DOWNWARDS ARROW */
- {'0', '#', 0x25AE }, /* BLACK VERTICAL RECTANGLE */
- {'`', '+', 0x25C6 }, /* BLACK DIAMOND */
- {'a', ':', 0x2592 }, /* MEDIUM SHADE */
- {'f', '\'', 0x00B0 },/* DEGREE SIGN */
- {'g', '#', 0x00B1 }, /* PLUS-MINUS SIGN */
- {'h', '#', 0x2592 }, /* MEDIUM SHADE */
- {'i', '#', 0x2603 }, /* SNOWMAN */
- {'j', '+', 0x2518 }, /* BOX DRAWINGS LIGHT UP AND LEFT */
- {'k', '+', 0x2510 }, /* BOX DRAWINGS LIGHT DOWN AND LEFT */
- {'l', '+', 0x250c }, /* BOX DRAWINGS LIGHT DOWN AND RIGHT */
- {'m', '+', 0x2514 }, /* BOX DRAWINGS LIGHT UP AND RIGHT */
- {'n', '+', 0x253C }, /* BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL */
- {'o', '~', 0x23BA }, /* HORIZONTAL SCAN LINE-1 */
- {'p', '-', 0x23BB }, /* HORIZONTAL SCAN LINE-3 (ncurses addition) */
- {'q', '-', 0x2500 }, /* BOX DRAWINGS LIGHT HORIZONTAL */
- {'r', '-', 0x23BC }, /* HORIZONTAL SCAN LINE-7 (ncurses addition) */
- {'s', '_', 0x23BD }, /* HORIZONTAL SCAN LINE-9 */
- {'t', '+', 0x251C }, /* BOX DRAWINGS LIGHT VERTICAL AND RIGHT */
- {'u', '+', 0x2524 }, /* BOX DRAWINGS LIGHT VERTICAL AND LEFT */
- {'v', '+', 0x2534 }, /* BOX DRAWINGS LIGHT UP AND HORIZONTAL */
- {'w', '+', 0x252C }, /* BOX DRAWINGS LIGHT DOWN AND HORIZONTAL */
- {'x', '|', 0x2502 }, /* BOX DRAWINGS LIGHT VERTICAL */
- {'y', '<', 0x2264 }, /* LESS-THAN OR EQUAL TO (ncurses addition) */
- {'z', '>', 0x2265 }, /* GREATER-THAN OR EQUAL TO (ncurses addition) */
- {'{', '*', 0x03C0 }, /* GREEK SMALL LETTER PI (ncurses addition) */
- {'|', '!', 0x2260 }, /* NOT EQUAL TO (ncurses addition) */
- {'}', 'f', 0x00A3 }, /* POUND SIGN (ncurses addition) */
- {'~', 'o', 0x00B7 }, /* MIDDLE DOT */
- {0, 0, 0}
+ {'+', '>', 0x2192, 0}, /* RIGHTWARDS ARROW [A/21AA] */
+ {',', '<', 0x2190, 0}, /* LEFTWARDS ARROW [A/21A9] */
+ {'-', '^', 0x2191, 0x2303}, /* UPWARDS ARROW [A/2303] */
+ {'.', 'v', 0x2193, 0x2304}, /* DOWNWARDS ARROW [A/2304] */
+ {'0', '#', 0x25AE, 0}, /* BLACK VERTICAL RECTANGLE */
+ {'`', '+', 0x25C6, 0x2666}, /* BLACK DIAMOND [BLACK DIAMOND SUIT] */
+ {'a', ':', 0x2592, 0}, /* MEDIUM SHADE [A]. */
+ {'f', '\'', 0x00B0, 0xFF9F},/* DEGREE SIGN
+ [HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK] */
+ {'g', '#', 0x00B1, 0}, /* PLUS-MINUS SIGN [A]. */
+ {'h', '#', 0x2592, 0}, /* MEDIUM SHADE [A]. */
+ {'i', '#', 0x2603, 0}, /* SNOWMAN [N] */
+ {'j', '+', 0x2518, 0}, /* BOX DRAWINGS LIGHT UP AND LEFT [A] */
+ {'k', '+', 0x2510, 0}, /* BOX DRAWINGS LIGHT DOWN AND LEFT [A] */
+ {'l', '+', 0x250c, 0}, /* BOX DRAWINGS LIGHT DOWN AND RIGHT [A] */
+ {'m', '+', 0x2514, 0}, /* BOX DRAWINGS LIGHT UP AND RIGHT [A] */
+ {'n', '+', 0x253C, 0}, /* BOX DRAWINGS LIGHT VERTICAL AND HORIZONTAL [A] */
+ {'o', '~', 0x23BA, 0}, /* HORIZONTAL SCAN LINE-1 [N] */
+ {'p', '-', 0x23BB, 0}, /* HORIZONTAL SCAN LINE-3 (ncurses addition) [N] */
+ {'q', '-', 0x2500, 0}, /* BOX DRAWINGS LIGHT HORIZONTAL [A] */
+ {'r', '-', 0x23BC, 0}, /* HORIZONTAL SCAN LINE-7 (ncurses addition) [N] */
+ {'s', '_', 0x23BD, 0}, /* HORIZONTAL SCAN LINE-9 [N] */
+ {'t', '+', 0x251C, 0}, /* BOX DRAWINGS LIGHT VERTICAL AND RIGHT [A] */
+ {'u', '+', 0x2524, 0}, /* BOX DRAWINGS LIGHT VERTICAL AND LEFT [A] */
+ {'v', '+', 0x2534, 0}, /* BOX DRAWINGS LIGHT UP AND HORIZONTAL [A] */
+ {'w', '+', 0x252C, 0}, /* BOX DRAWINGS LIGHT DOWN AND HORIZONTAL [A] */
+ {'x', '|', 0x2502, 0}, /* BOX DRAWINGS LIGHT VERTICAL [A] */
+ {'y', '<', 0x2264, 0}, /* LESS-THAN OR EQUAL TO (ncurses addition) [A]. */
+ {'z', '>', 0x2265, 0}, /* GREATER-THAN OR EQUAL TO (ncurses addition) [A] */
+ {'{', '*', 0x03C0, 0}, /* GREEK SMALL LETTER PI (ncurses addition) [A]. */
+ {'|', '!', 0x2260, 0}, /* NOT EQUAL TO (ncurses addition) [A]. */
+ {'}', 'f', 0x00A3, 0}, /* POUND SIGN (ncurses addition) [N] */
+ {'~', 'o', 0x00B7, 0xFF65},/* MIDDLE DOT [HALFWIDTH KATAKANA MIDDLE DOT] */
+ {0, 0, 0, 0}
};
#define ACS_MODE_NONE -1
@@ -288,7 +290,12 @@
acs = UTF8_ACS_Map;
while (acs->vt100_char != 0)
{
- ACS_Map[acs->vt100_char] = acs->unicode;
+ if (SLwchar_wcwidth(acs->unicode) == 1)
+ ACS_Map[acs->vt100_char] = acs->unicode;
+ else if (acs->unicode_not_ambiguous)
+ ACS_Map[acs->vt100_char] = acs->unicode_not_ambiguous;
+ else
+ ACS_Map[acs->vt100_char] = acs->ascii;
acs++;
}
break;
diff -urN slang-2.1.3/src/slwcwidth.c slang-2.1.3-wcwidth/src/slwcwidth.c
--- slang-2.1.3/src/slwcwidth.c 2007-01-11 01:09:07.000000000 +0900
+++ slang-2.1.3-wcwidth/src/slwcwidth.c 2008-03-04 19:08:17.000000000 +0900
@@ -24,8 +24,13 @@
#include "slang.h"
#include "_slang.h"
+#ifndef HAVE_GNU_WCWIDTH
#define DEFINE_PSLWC_WIDTH_TABLE
#include "slwcwidth.h"
+#else
+#include <wchar.h>
+#define SL_WIDTH_ALOOKUP(y,x) y = wcwidth((wchar_t)x)
+#endif
static int Ignore_Double_Width = 0;
int SLwchar_wcwidth (SLwchar_Type ch)
[2008 date index]
[2008 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]