Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
PATCH: Re: Core dump in compdescribe (Re: problem with _arguments)
- X-seq: zsh-workers 12400
- From: Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxx
- Subject: PATCH: Re: Core dump in compdescribe (Re: problem with _arguments)
- Date: Thu, 27 Jul 2000 10:28:44 +0200 (MET DST)
- In-reply-to: "Bart Schaefer"'s message of Thu, 27 Jul 2000 07:44:27 +0000
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
Bart Schaefer wrote:
> ...
>
> Fiddling with this, I caused a core dump in computil:
>
> zagzig<5> compdef _foo foo
> zagzig<6> foo -
> _describe:compdescribe:36: invalid argument: -Q
>
> Program received signal SIGSEGV, Segmentation fault.
> 0x80d486b in cd_get (params=0xbfffb208)
> at ../../../zsh-3.1.6/Src/Zle/computil.c:173
> 173 for (p = set->strs; *p; p++)
> (gdb) where 2
> #0 0x80d486b in cd_get (params=0xbfffb208)
> at ../../../zsh-3.1.6/Src/Zle/computil.c:173
> #1 0x80d4d9c in bin_compdescribe (nam=0x400e83c8 "compdescribe",
> args=0xbfffb204, ops=0xbfffb27c "", func=0)
> at ../../../zsh-3.1.6/Src/Zle/computil.c:276
>
>
> I didn't think the entire 168 stack frames would be useful. I got this
> core dump when I accidentally deleted the word "option" at _arguments
> line 342:
>
> next=( "$next[@]" "$odirect[@]" )
> - _describe -o option \
> + _describe -o \
> next -Q -M "$matcher" -- \
> direct -QS '' -M "$matcher" -- \
> equal -QqS= -M "$matcher"
compdescribe shouldn't have used the malformed sets after detecting
that initialisation didn't work.
In another message:
> Recalling that the original spec was:
>
> - the function has one optional option '-l' with no parameter
> - the first parameter can't be completed
> - subsequent parameters are files
>
> I think _arguments has done the right thing, because any string other than
> "-l" might just be a first parameter that happens to begin with hyphen.
>
> However, if the spec had been "the first parameter must not begin with a
> hyphen but cannot be completed" then I don't know how to express that in
> the current _arguments syntax without using a state machine, which seems
> like overkill in this situation.
Yes, that's where I wasn't sure.
One can always use an action with `{...}'. For example:
_arguments \
'-l[message for option]' \
':arg1:{ [[ "$PREFIX" != -* ]] && _message "description for first param" }' \
'*:description for files:_files'
Although I don't want to say that this is a `nice' solution.
Bye
Sven
Index: Src/Zle/computil.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/computil.c,v
retrieving revision 1.38
diff -u -r1.38 computil.c
--- Src/Zle/computil.c 2000/07/17 08:05:56 1.38
+++ Src/Zle/computil.c 2000/07/27 08:24:25
@@ -115,6 +115,7 @@
if (cd_parsed) {
zsfree(cd_state.sep);
freecdsets(cd_state.sets);
+ cd_parsed = 0;
}
setp = &(cd_state.sets);
cd_state.sep = ztrdup(sep);
@@ -153,6 +154,7 @@
if ((*args = tmp))
args++;
}
+ cd_parsed = 1;
return 0;
}
@@ -259,10 +261,8 @@
}
switch (args[0][1]) {
case 'i':
- cd_parsed = 1;
return cd_init(nam, "", args + 1, 0);
case 'I':
- cd_parsed = 1;
return cd_init(nam, args[1], args + 2, 1);
case 'g':
if (cd_parsed) {
--
Sven Wischnowsky wischnow@xxxxxxxxxxxxxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author