From: Sven Wischnowsky <wischnow@informatik.hu-berlin.de>
To: zsh-workers@sunsite.auc.dk
Subject: PATCH: Re: Bug in colored listings with backreference patterns?
Date: Tue, 13 Jun 2000 12:38:26 +0200 (MET DST) [thread overview]
Message-ID: <200006131038.MAA31179@beta.informatik.hu-berlin.de> (raw)
In-Reply-To: "Bart Schaefer"'s message of Sun, 11 Jun 2000 07:42:23 +0000
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
reply other threads:[~2000-06-13 12:46 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200006131038.MAA31179@beta.informatik.hu-berlin.de \
--to=wischnow@informatik.hu-berlin.de \
--cc=zsh-workers@sunsite.auc.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).