Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: _whois
- X-seq: zsh-workers 8599
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: Re: PATCH: _whois
- Date: Tue, 9 Nov 1999 09:58:01 +0100 (MET)
- In-reply-to: Tanaka Akira's message of 09 Nov 1999 07:09:34 +0900
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Tanaka Akira wrote:
> I modified _whois to complete arguments of fwhois.
>
> And I found a problem.
>
> Z:akr@is27e1u11% Src/zsh -f
> is27e1u11% bindkey -e; fpath=($PWD/Completion/*(/)); autoload -U compinit; compinit -D; compdef _tst tst
> is27e1u11% compconf group_matches=yes message_format='%d' description_format='%d'
> is27e1u11% compconf describe_options=yes describe_values=yes option_prefix=yes
> is27e1u11% comptag argument='*=1' option='*=2[describe]' glob='*=1' path='*=2' file='*=3'
> is27e1u11% fwhois 'DOMAIN <TAB>
> zsh: segmentation fault (core dumped) Src/zsh -f
>
> (gdb) where
> #0 0xff136d84 in strlen ()
> #1 0xa15d0 in bslashquote (s=0x0, e=0x0, instring=1) at utils.c:3011
> #2 0xff06da80 in multiquote (s=0x0, ign=1) at compcore.c:933
> #3 0xff071348 in addmatches (dat=0xffbe7280, argv=0x1d2634) at compcore.c:1711
> #4 0xff068238 in bin_compadd (name=0x1d24f0 "compadd", argv=0x1d2634,
> ops=0xffbe7388 "", func=0) at complete.c:606
I couldn't reproduce it, but judging from the stack trace, the patch
should fix this (patch-readers will notice that there even is some
redundancy in this patch, trying to avoid getting this bug again
later).
So, does it fix it?
Bye
Sven
diff -u oldsrc/Zle/compcore.c Src/Zle/compcore.c
--- oldsrc/Zle/compcore.c Mon Nov 8 13:29:49 1999
+++ Src/Zle/compcore.c Tue Nov 9 09:11:12 1999
@@ -923,34 +923,40 @@
char *
multiquote(char *s, int ign)
{
- char *os = s, *p = compqstack;
+ if (s) {
+ char *os = s, *p = compqstack;
- if (p && *p && (ign < 1 || p[ign])) {
- if (ign > 0)
- p += ign;
- while (*p) {
- if (ign >= 0 || p[1])
- s = bslashquote(s, NULL,
- (*p == '\'' ? 1 : (*p == '"' ? 2 : 0)));
- p++;
+ if (p && *p && (ign < 1 || p[ign])) {
+ if (ign > 0)
+ p += ign;
+ while (*p) {
+ if (ign >= 0 || p[1])
+ s = bslashquote(s, NULL,
+ (*p == '\'' ? 1 : (*p == '"' ? 2 : 0)));
+ p++;
+ }
}
+ return (s == os ? dupstring(s) : s);
}
- return (s == os ? dupstring(s) : s);
+ return NULL;
}
/**/
char *
tildequote(char *s, int ign)
{
- int tilde;
+ if (s) {
+ int tilde;
- if ((tilde = (*s == '~')))
- *s = 'x';
- s = multiquote(s, ign);
- if (tilde)
- *s = '~';
+ if ((tilde = (*s == '~')))
+ *s = 'x';
+ s = multiquote(s, ign);
+ if (tilde)
+ *s = '~';
- return s;
+ return s;
+ }
+ return NULL;
}
/* Check if we have to complete a parameter name. */
@@ -1708,10 +1714,12 @@
} else if (dat->rems)
dat->rems = dupstring(dat->rems);
- lpre = ((!(dat->aflags & CAF_QUOTE) &&
- (!dat->ppre && (dat->flags & CMF_FILE))) ?
- tildequote(lpre, 1) : multiquote(lpre, 1));
- lsuf = multiquote(lsuf, 1);
+ if (lpre)
+ lpre = ((!(dat->aflags & CAF_QUOTE) &&
+ (!dat->ppre && (dat->flags & CMF_FILE))) ?
+ tildequote(lpre, 1) : multiquote(lpre, 1));
+ if (lsuf)
+ lsuf = multiquote(lsuf, 1);
}
/* Walk through the matches given. */
obpl = bpl;
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author