Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 12 Aug 2002 00:40:04 -0700
From:      "Michael C. Wu" <keichii@iteration.net>
To:        Chia-liang Kao <clkao@clkao.org>
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>
In-Reply-To: <20020811181805.GA1809@portege.clkao.org>
References:  <20020811181805.GA1809@portege.clkao.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




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