Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 15 Aug 2002 23:49:16 +0800
From:      Chia-liang Kao <clkao@clkao.org>
To:        "Andrey A. Chernov" <ache@nagual.pp.ru>, standards@FreeBSD.ORG, i18n@FreeBSD.ORG
Cc:        keichii@FreeBSD.ORG, tjr@FreeBSD.ORG
Subject:   Re: wcwidth and mklocale
Message-ID:  <20020815154915.GA9607@portege.clkao.org>
In-Reply-To: <20020813035009.GA1084@portege.clkao.org>
References:  <20020811181805.GA1809@portege.clkao.org> <20020812102835.GA1288@nagual.pp.ru> <20020813035009.GA1084@portege.clkao.org>

next in thread | previous in thread | raw e-mail | index | archive | help

--5G06lTa6Jq83wMTw
Content-Type: multipart/mixed; boundary="Bn2rw/3z4jIqBvZU"
Content-Disposition: inline


--Bn2rw/3z4jIqBvZU
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

attached is the revised patch that treats printable wchar without
width specified as SWIDTH_1.

Cheers,
CLK

--Bn2rw/3z4jIqBvZU
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
--- ctype.h	23 Mar 2002 17:24:53 -0000	1.18
+++ ctype.h	15 Aug 2002 15:31:33 -0000
@@ -65,6 +65,12 @@
 #define	_CTYPE_I	0x00080000L		/* Ideogram */
 #define	_CTYPE_T	0x00100000L		/* Special */
 #define	_CTYPE_Q	0x00200000L		/* Phonogram */
+#define	_CTYPE_SWM	0xe0000000L		/* Mask to get screen width data */
+#define	_CTYPE_SWS	30			/* Bits to shift to get width */
+#define	_CTYPE_SW0	0x20000000L		/* 0 width character */
+#define	_CTYPE_SW1	0x00000000L		/* 1 width character / default*/
+#define	_CTYPE_SW2	0x80000000L		/* 2 width character */
+#define	_CTYPE_SW3	0xc0000000L		/* 3 width character */
=20
 __BEGIN_DECLS
 int	isalnum(int);
Index: lib/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
--- iswctype.c	5 Aug 2002 10:45:23 -0000	1.1
+++ iswctype.c	15 Aug 2002 15:43:19 -0000
@@ -211,3 +211,13 @@
 {
         return (__toupper(wc));
 }
+
+#undef wcwidth
+int
+wcwidth(wc)
+        wchar_t wc;
+{
+	int width =3D (unsigned)__maskrune((wc), _CTYPE_SWM) >> _CTYPE_SWS;
+	return width ? width : isprint(wc);
+}
+
Index: usr.bin/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
--- lex.l	28 Apr 2002 12:34:54 -0000	1.6
+++ 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;

--Bn2rw/3z4jIqBvZU--

--5G06lTa6Jq83wMTw
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

iD8DBQE9W817k1XldlEkA5YRAs6OAJ4gVkrRdcT4qhxIH4PpTsgLVzCUEgCdHa2d
vDrI0eg8z0sDJUxYRvJfTC4=
=6F6u
-----END PGP SIGNATURE-----

--5G06lTa6Jq83wMTw--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-i18n" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020815154915.GA9607>