zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zsh-workers@sunsite.dk (Zsh hackers list)
Subject: Re: PATCH: multibyte $WORDCHARS
Date: Tue, 20 Sep 2005 16:17:29 +0100	[thread overview]
Message-ID: <200509201517.j8KFHT7w021402@news01.csr.com> (raw)
In-Reply-To: <200509201506.j8KF6f9X020818@news01.csr.com>

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@csr.com>                  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.

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


      reply	other threads:[~2005-09-20 15:17 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-20 15:06 Peter Stephenson
2005-09-20 15:17 ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200509201517.j8KFHT7w021402@news01.csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).