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

Re: PATCH: more zle fixes



Andrey Borzenkov wrote:
> On Wednesday 23 February 2005 16:05, Peter Stephenson wrote:
> > +    char s[MB_CUR_MAX+1];
> 
> MB_CUR_MAX is not required to be constant so the above may well be invalid on
> non-GCC.

It can be a VARARR.

> conversion from wc to mb may require extra space for shift characters above 
> MB_CUR_MAX. Completely bulletproof solution must check for resulting length 
> and allocate buffer that is needed. Unfortunately it is not quite clear how 
> to check length; wctomb(0, ...) does not return length, instead resets 
> internal state.

Maybe we can leave a few bytes extra, if we can work out how many, but
I'll leave it as it is for now.

Index: Src/Zle/complist.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v
retrieving revision 1.65
diff -u -r1.65 complist.c
--- Src/Zle/complist.c	23 Feb 2005 13:50:45 -0000	1.65
+++ Src/Zle/complist.c	23 Feb 2005 13:51:57 -0000
@@ -1862,7 +1862,8 @@
 msearch(Cmatch **ptr, int ins, int back, int rep, int *wrapp)
 {
 #ifdef ZLE_UNICODE_SUPPORT
-    char s[MB_CUR_MAX+1];
+    /* MB_CUR_MAX may not be constant */
+    VARARR(char *, s, MB_CUR_MAX+1);
 #else
     char s[2];
 #endif

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