Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: minor zle_utils fix
- X-seq: zsh-workers 20727
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-workers@xxxxxxxxxx
- Subject: Re: PATCH: minor zle_utils fix
- Date: Wed, 19 Jan 2005 10:49:07 +0000
- In-reply-to: <20050119012630.GA2463@xxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <20050116162247.GA26801@xxxxxxxxxxx> <200501171040.j0HAe6mY003515@xxxxxxxxxxxxxx> <20050119012630.GA2463@xxxxxxxxxxx>
Clint Adams wrote:
> > The API for the Unicode version is not yet defined, but it will probably
> > be that way. The alternative is to create it on the heap, but I hope
> > it will usually be easy enough to free it explicitly. The existing
> > non-Unicode version will presumably remain the way it is.
>
> I'm not committing this because it changes the non-Unicode version;
> would you rather ifdef the free()'s in the calling functions?
Your way's probably neater; we probably don't need to lose too much
sleep about the efficiency of the old interface as long as it's not too
gross. So the patch will need matching free()s in all callers. I think
there's just one at the moment.
We probably also need to metafy the line. The only call to zlegetline()
was previously in bufferwords() in hist.c which used the line directly
at points where (as far as I can see) it wouldn't have been metafied,
which is needed when the line is passed to the lexer. I suspect it
probably should have been metafied --- it would be good if someone could
confirm --- but it wasn't, which is why zlegetline() doesn't do that at
the moment. Other uses will certainly need metafication.
Then we probably need to return zlegetline() at the end of zlread()
to return a form of metafied zleline, and then fix up the callers of
that, too.
> --- orig/Src/Zle/zle_utils.c
> +++ mod/Src/Zle/zle_utils.c
> @@ -89,10 +89,36 @@
> mod_export unsigned char *
> zlegetline(int *ll, int *cs)
> {
> + char *s;
> +#ifdef ZLE_UNICODE_SUPPORT
> + char *mb_cursor;
> + int i, j;
> + size_t wc_len, mb_len = 0;
> +
> + wc_len = wcslen(zleline);
As discussed previously, this should just be zlell; we are not using
terminating wide nulls. This fits in with current usage where we don't
use terminating ordinary nulls since an ASCII NUL is a valid character
in unsigned char *zleline.
> + s = ztrdup(zleline);
> + return (unsigned char *)s;
Same here in the alternative branch: we need to duplicate the first
zlell characters and metafy. This is the same as the
zleline = (unsigned char *) metafy((char *) zleline, zlell, META_REALLOC);
near the end of the current zleread(). (It looks like we'll still need
to add a '\n' in zleread(), but not in the existing use of zlegetline();
probably best to add L'\n' in zlread() before converting.)
Otherwise this is a good start.
> + mb_cursor = s = zalloc(wc_len * MB_CUR_MAX); /* perhaps try less first then realloc */
Not sure what the best strategy is here, but this will certainly do for now.
--
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.
This footnote also confirms that this email message has been swept by
MIMEsweeper for the presence of computer viruses.
www.mimesweeper.com
**********************************************************************
Messages sorted by:
Reverse Date,
Date,
Thread,
Author