From owner-freebsd-i18n Mon Aug 12 0:42:22 2002 Delivered-To: freebsd-i18n@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F3FAB37B400; Mon, 12 Aug 2002 00:42:14 -0700 (PDT) Received: from nuit.iteration.net (nuit.iteration.net [198.92.249.80]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8E7CF43E65; Mon, 12 Aug 2002 00:42:14 -0700 (PDT) (envelope-from keichii@nuit.iteration.net) Received: by nuit.iteration.net (Postfix, from userid 1001) id E03D311B5E6; Mon, 12 Aug 2002 00:40:04 -0700 (PDT) Date: Mon, 12 Aug 2002 00:40:04 -0700 From: "Michael C. Wu" To: Chia-liang Kao Cc: standards@freebsd.org, i18n@freebsd.org, keichii@freebsd.org, tjr@freebsd.org Subject: Re: wcwidth and mklocale Message-ID: <20020812074004.GA73751@nuit.iteration.net> Reply-To: "Michael C. Wu" References: <20020811181805.GA1809@portege.clkao.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20020811181805.GA1809@portege.clkao.org> User-Agent: Mutt/1.3.28i X-PGP-Fingerprint: 5025 F691 F943 8128 48A8 5025 77CE 29C5 8FA1 2E20 X-PGP-Key-ID: 0x8FA12E20 Sender: owner-freebsd-i18n@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG I will commit this in three days, pending discussion (or no discussion) Thanks, Michael On Mon, Aug 12, 2002 at 02:18:05AM +0800, Chia-liang Kao scribbled: | attached is a patch implmenting SWIDTH[0-3] in mklocale and wcwidth in | libc. it is obtained from netbsd/citrus code. | | the share_mklocale files shall be updated with the SWIDTH info as the | ASCII one in the patch. | | should there be a default value for SWIDTH in each locale file? should | we maintain the binary file format compatibility? I think ache is | making the loading of locale files graceful. | | Cheers, | CLK | Index: include/ctype.h | =================================================================== | RCS file: /home/ncvs/src/include/ctype.h,v | retrieving revision 1.18 | diff -u -r1.18 ctype.h | --- include/ctype.h 23 Mar 2002 17:24:53 -0000 1.18 | +++ include/ctype.h 11 Aug 2002 18:06:39 -0000 | @@ -65,6 +65,12 @@ | #define _CTYPE_I 0x00080000L /* Ideogram */ | #define _CTYPE_T 0x00100000L /* Special */ | #define _CTYPE_Q 0x00200000L /* Phonogram */ | +#define _CTYPE_SWM 0xc0000000L /* Mask to get screen width data */ | +#define _CTYPE_SWS 30 /* Bits to shift to get width */ | +#define _CTYPE_SW0 0x00000000L /* 0 width character */ | +#define _CTYPE_SW1 0x40000000L /* 1 width character */ | +#define _CTYPE_SW2 0x80000000L /* 2 width character */ | +#define _CTYPE_SW3 0xc0000000L /* 3 width character */ | | __BEGIN_DECLS | int isalnum(int); | Index: mklocale/lex.l | =================================================================== | RCS file: /home/ncvs/src/usr.bin/mklocale/lex.l,v | retrieving revision 1.6 | diff -u -r1.6 lex.l | --- mklocale/lex.l 28 Apr 2002 12:34:54 -0000 1.6 | +++ mklocale/lex.l 11 Aug 2002 17:07:56 -0000 | @@ -118,6 +118,10 @@ | return(LIST); } | PHONOGRAM { yylval.i = _CTYPE_Q|_CTYPE_R|_CTYPE_G; | return(LIST); } | +SWIDTH0 { yylval.i = _CTYPE_SW0; return(LIST); } | +SWIDTH1 { yylval.i = _CTYPE_SW1; return(LIST); } | +SWIDTH2 { yylval.i = _CTYPE_SW2; return(LIST); } | +SWIDTH3 { yylval.i = _CTYPE_SW3; return(LIST); } | | VARIABLE[\t ] { static char vbuf[1024]; | char *v = vbuf; | Index: libc/locale/iswctype.c | =================================================================== | RCS file: /home/ncvs/src/lib/libc/locale/iswctype.c,v | retrieving revision 1.1 | diff -u -r1.1 iswctype.c | --- libc/locale/iswctype.c 5 Aug 2002 10:45:23 -0000 1.1 | +++ libc/locale/iswctype.c 11 Aug 2002 18:02:20 -0000 | @@ -211,3 +211,12 @@ | { | return (__toupper(wc)); | } | + | +#undef wcwidth | +int | +wcwidth(wc) | + wchar_t wc; | +{ | + return ((unsigned)__maskrune((wc), _CTYPE_SWM) >> _CTYPE_SWS); | +} | + | Index: share_mklocale//la_LN.US-ASCII.src | =================================================================== | RCS file: /home/ncvs/src/share/mklocale/la_LN.US-ASCII.src,v | retrieving revision 1.2 | diff -u -r1.2 la_LN.US-ASCII.src | --- share_mklocale//la_LN.US-ASCII.src 30 Nov 2001 05:05:53 -0000 1.2 | +++ share_mklocale//la_LN.US-ASCII.src 11 Aug 2002 17:38:18 -0000 | @@ -17,6 +17,7 @@ | XDIGIT '0' - '9' 'a' - 'f' 'A' - 'F' | BLANK ' ' '\t' | PRINT 0x20 - 0x7e | +SWIDTH1 0x20 - 0x7e | | MAPLOWER <'A' - 'Z' : 'a'> | MAPLOWER <'a' - 'z' : 'a'> ------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-i18n" in the body of the message