Date: Mon, 12 Aug 2002 02:18:05 +0800 From: Chia-liang Kao <clkao@clkao.org> To: standards@freebsd.org, i18n@freebsd.org Cc: keichii@freebsd.org, tjr@freebsd.org Subject: wcwidth and mklocale Message-ID: <20020811181805.GA1809@portege.clkao.org>
next in thread | raw e-mail | index | archive | help
--4SFOXa2GPu3tIq4H Content-Type: multipart/mixed; boundary="jRHKVT23PllUwdXP" Content-Disposition: inline --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --jRHKVT23PllUwdXP Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="swidth.diff" Content-Transfer-Encoding: quoted-printable Index: include/ctype.h =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 */ =20 __BEGIN_DECLS int isalnum(int); Index: mklocale/lex.l =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 =3D _CTYPE_Q|_CTYPE_R|_CTYPE_G; return(LIST); } +SWIDTH0 { yylval.i =3D _CTYPE_SW0; return(LIST); } +SWIDTH1 { yylval.i =3D _CTYPE_SW1; return(LIST); } +SWIDTH2 { yylval.i =3D _CTYPE_SW2; return(LIST); } +SWIDTH3 { yylval.i =3D _CTYPE_SW3; return(LIST); } =20 VARIABLE[\t ] { static char vbuf[1024]; char *v =3D vbuf; Index: libc/locale/iswctype.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D 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 =20 MAPLOWER <'A' - 'Z' : 'a'> MAPLOWER <'a' - 'z' : 'a'> --jRHKVT23PllUwdXP-- --4SFOXa2GPu3tIq4H Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE9Vqpdk1XldlEkA5YRAo/OAKCCtBkQnkI5lwXnWCxenyzxP41tQQCcDVex SBL9ueMLluk83Iq/FlkBBgk= =GOvH -----END PGP SIGNATURE----- --4SFOXa2GPu3tIq4H-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-standards" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020811181805.GA1809>