From d50ca53788aa062b84fa7fddeb691d735eeb3d3b Mon Sep 17 00:00:00 2001 From: engelsman Date: Mon, 19 Apr 2010 21:15:30 +0000 Subject: [PATCH] tweaked fl_wcwidth.c and mk_wcwidth.c to remove system wchar_t commented out, or replaced, wchar_t with unsigned int. commented out unused functions from mk_wcwidth.c. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7536 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/xutf8/fl_wcwidth.c | 13 ++++++++----- src/xutf8/mk_wcwidth.c | 37 ++++++++++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 8 deletions(-) diff --git a/src/xutf8/fl_wcwidth.c b/src/xutf8/fl_wcwidth.c index 005ade003..6adeb924e 100644 --- a/src/xutf8/fl_wcwidth.c +++ b/src/xutf8/fl_wcwidth.c @@ -30,13 +30,16 @@ * forward declare the routines as static to avoid name leakage. */ +#if 0 #include /* for size_t only */ -typedef unsigned int wchar_t; /* supercede system wchar_t */ +#endif -static int mk_wcwidth(wchar_t ucs); -static int mk_wcswidth(const wchar_t *pwcs, size_t n); -static int mk_wcwidth_cjk(wchar_t ucs); -static int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n); +static int mk_wcwidth(unsigned int ucs); +#if 0 +static int mk_wcswidth(const unsigned int *pwcs, size_t n); +static int mk_wcwidth_cjk(unsigned int ucs); +static int mk_wcswidth_cjk(const unsigned int *pwcs, size_t n); +#endif #include "mk_wcwidth.c" diff --git a/src/xutf8/mk_wcwidth.c b/src/xutf8/mk_wcwidth.c index c0bebaecc..0c4eb2cc9 100644 --- a/src/xutf8/mk_wcwidth.c +++ b/src/xutf8/mk_wcwidth.c @@ -1,9 +1,10 @@ /* - * Important! + * FLTK: Important! * This file should remain as close to Markus Kuhn's original source * as possible for easy checking for changes later, however unlikely. * All customisations to work with FLTK shall be annotated! */ + /* * This is an implementation of wcwidth() and wcswidth() (defined in * IEEE Std 1002.1-2001) for Unicode. @@ -67,8 +68,8 @@ /* * FLTK - avoid possible problems on systems with 32-bit wchar_t. - * In the first instance, wchar_t is superceded in calling file - * to avoid any unnecessary changes in this one. + * Don't include wchar.h, and change wchar_t to unsigned int. + * Can we guarantee sizeof(unsigned int) >= 4 ? */ #if 0 #include @@ -80,7 +81,11 @@ struct interval { }; /* auxiliary function for binary search in interval table */ +/* + * FLTK: was static int bisearch(wchar_t ucs, const struct interval *table, int max) { + */ +static int bisearch(unsigned int ucs, const struct interval *table, int max) { int min = 0; int mid; @@ -132,7 +137,11 @@ static int bisearch(wchar_t ucs, const struct interval *table, int max) { * in ISO 10646. */ +/* + * FLTK: was int mk_wcwidth(wchar_t ucs) + */ +int mk_wcwidth(unsigned int ucs) { /* sorted list of non-overlapping intervals of non-spacing characters */ /* generated by "uniset +cat=Me +cat=Mn +cat=Cf -00AD +1160-11FF +200B c" */ @@ -217,7 +226,16 @@ int mk_wcwidth(wchar_t ucs) } +/* + * FLTK: comment out the remaining functions, as we don't need themm. + */ +#if 0 + +/* + * FLTK: was int mk_wcswidth(const wchar_t *pwcs, size_t n) + */ +int mk_wcswidth(const unsigned int *pwcs, size_t n) { int w, width = 0; @@ -240,7 +258,11 @@ int mk_wcswidth(const wchar_t *pwcs, size_t n) * the traditional terminal character-width behaviour. It is not * otherwise recommended for general use. */ +/* + * FLTK: was int mk_wcwidth_cjk(wchar_t ucs) + */ +int mk_wcwidth_cjk(unsigned int ucs) { /* sorted list of non-overlapping intervals of East Asian Ambiguous * characters, generated by "uniset +WIDTH-A -cat=Me -cat=Mn -cat=Cf c" */ @@ -308,7 +330,11 @@ int mk_wcwidth_cjk(wchar_t ucs) } +/* + * FLTK: was int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n) + */ +int mk_wcswidth_cjk(const unsigned int *pwcs, size_t n) { int w, width = 0; @@ -320,3 +346,8 @@ int mk_wcswidth_cjk(const wchar_t *pwcs, size_t n) return width; } + +/* + * FLTK: end of commented out functions + */ +#endif