From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16778 invoked from network); 13 Jun 2000 12:46:59 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 13 Jun 2000 12:46:59 -0000 Received: (qmail 18992 invoked by alias); 13 Jun 2000 12:45:56 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 11875 Received: (qmail 18981 invoked from network); 13 Jun 2000 12:45:56 -0000 Date: Tue, 13 Jun 2000 12:38:26 +0200 (MET DST) Message-Id: <200006131038.MAA31179@beta.informatik.hu-berlin.de> From: Sven Wischnowsky To: zsh-workers@sunsite.auc.dk In-reply-to: "Bart Schaefer"'s message of Sun, 11 Jun 2000 07:42:23 +0000 Subject: PATCH: Re: Bug in colored listings with backreference patterns? Bart Schaefer wrote: > Possibly related is a repeatable core dump I'm getting. > > ------------------------------------------------------------------------ > setopt extendedglob # Doc for ZLS_COLORS should mention this > zstyle ':completion:*:zsh-options' list-colors \ > 'no=22:=(#b)(sh|csh|ksh)#(*glob*)#*=39=04;32=31' > # The above crashes the shell, but if this 04; ^^^ is removed, it works. > ------------------------------------------------------------------------ > > I have zsh-mem-debug enabled, and it appears to be dereferencing through > what used to be a pointer inside a struct that has since been freed (it's > dereferncing 0xffffffff), possibly in getcoldef() -- the stack is mostly > garbage, even running inside GDB. > > What you should see if the pattern above works, is that all options that > start with sh|csh|ksh are underlined and have the shell name in green; if > the substring "glob" appears, then the rest is in red (still underlined); > and all other options that contain "glob" are in red (but not underlined). Wrong calculation of the maximum capability length (which was then used in a VARARR, which messed up the stack). Bye Sven Index: Src/Zle/complist.c =================================================================== RCS file: /cvsroot/zsh/zsh/Src/Zle/complist.c,v retrieving revision 1.25 diff -u -r1.25 complist.c --- Src/Zle/complist.c 2000/06/11 08:15:27 1.25 +++ Src/Zle/complist.c 2000/06/13 10:38:06 @@ -122,13 +122,17 @@ Extcol exts; /* strings for extensions */ }; +/* Combined length of LC and RC, maximum length of capability strings. */ + +static int lr_caplen, max_caplen; + /* This parses the value of a definition (the part after the `='). * The return value is a pointer to the character after it. */ static char * getcolval(char *s, int multi) { - char *p; + char *p, *o = s; for (p = s; *s && *s != ':' && (!multi || *s != '='); p++, s++) { if (*s == '\\' && s[1]) { @@ -172,6 +176,8 @@ } if (p != s) *p = '\0'; + if ((s - o) > max_caplen) + max_caplen = s - o; return s; } @@ -325,10 +331,6 @@ return fc; } -/* Combined length of LC and RC, maximum length of capability strings. */ - -static int lr_caplen, max_caplen; - /* This initializes the given terminal color structure. */ static void @@ -337,6 +339,7 @@ char *s; int i, l; + max_caplen = lr_caplen = 0; if (!(s = getsparam("ZLS_COLORS")) && !(s = getsparam("ZLS_COLOURS"))) { for (i = 0; i < NUM_COLS; i++) @@ -362,7 +365,6 @@ s = getcoldef(c, s); /* Use default values for those that aren't set explicitly. */ - max_caplen = lr_caplen = 0; for (i = 0; i < NUM_COLS; i++) { if (!c->files[i] || !c->files[i]->col) c->files[i] = filecol(defcols[i]); -- Sven Wischnowsky wischnow@informatik.hu-berlin.de