Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: multibyte $WORDCHARS



Peter Stephenson wrote:
> This fully fixes up WORDCHARS to use multibyte characters, with the
> single exception of the [[:WORD:]] test --- I don't want to mess around
> with the pattern code until we start work properly on the main shell.

Excepting as how I forgot to unmetafy wordchars before exploring its
ichness.  I suspect a NULL before the end of WORDCHARS may wreak havoc.

Index: Src/utils.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/utils.c,v
retrieving revision 1.91
diff -u -r1.91 utils.c
--- Src/utils.c	20 Sep 2005 15:10:27 -0000	1.91
+++ Src/utils.c	20 Sep 2005 15:14:47 -0000
@@ -2499,15 +2499,18 @@
     }
 #ifdef ZLE_UNICODE_SUPPORT
     if (wordchars) {
-	const char *wordchars_ptr = wordchars;
+	char *wordchars_unmeta;
+	const char *wordchars_ptr;
 	mbstate_t mbs;
-	int nchars;
+	int nchars, unmetalen;
+
+	wordchars_unmeta = dupstring(wordchars);
+	wordchars_ptr = unmetafy(wordchars_unmeta, &unmetalen);
 
 	memset(&mbs, 0, sizeof(mbs));
 	wordchars_wide = (wchar_t *)
-	    zrealloc(wordchars_wide, (strlen(wordchars)+1)*sizeof(wchar_t));
-	nchars = mbsrtowcs(wordchars_wide, &wordchars_ptr, strlen(wordchars),
-			   &mbs);
+	    zrealloc(wordchars_wide, (unmetalen+1)*sizeof(wchar_t));
+	nchars = mbsrtowcs(wordchars_wide, &wordchars_ptr, unmetalen, &mbs);
 	if (nchars == -1) {
 	    /* Conversion state is undefined: better just set to null */
 	    *wordchars_wide = L'\0';

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


**********************************************************************
This email and any files transmitted with it are confidential and
intended solely for the use of the individual or entity to whom they
are addressed. If you have received this email in error please notify
the system manager.

**********************************************************************



Messages sorted by: Reverse Date, Date, Thread, Author