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

Re: PATCH: _diff



Alexandre Duret-Lutz wrote:

> X-Seq: 9675
> 
> >>> "Sven" == Sven Wischnowsky <wischnow@xxxxxxxxxxxxxxxxxxxxxxx> writes:
> 
>  Sven> Oliver Kiddle wrote:
> 
>  >> I object to using
>  >> non-local variables like _diff_is_gnu and calling 'diff' instead of
>  >> pulling out the first word on the command-line.
> 
>  Sven> Well, if we use something like _diff_is_gnu[$words[1]], using a
>  Sven> non-local variable should be fine, right?
> 
> I don't think so, because _diff_options may be called from places where
> $words[1] is not the command name, e.g. called from _prcs (maybe _cvs_diff
> could call it too).

Err, right, I forgot...

> Hum, looking closer to _prcs, I see there is a problem, if I do
> 
> % prcs diff -P zsh -- -u <TAB>
> 
> the values of $words when entering the _diff_options functions are
> 
> diff -P zsh -- -u 
> 
> (this begin with diff since $words was shifted in _prcs)
> and the -P option is removed from the diff options list, which is wrong.
> I'd like this array te be restricted to
> 
> -- -u
> 
> unfortunately, I don't see how to do that with _arguments.
> The _arguments line calling _diff_options reads
> 
> '--[introduce diff options]:*:diff options: _diff_options'
> 
> I can't use the `*::message:action' syntax here.  So I guess
> I have to write an intermediate function that shift the $words 
> array $CURRENT times before calling _diff_options.  Or I am missing
> some syntaxic sugar in _arguments?

Of course, `--:*::...' should work (reporting anything after the
`--'), there was just a little thinko in ca_parse_line().

Bye
 Sven

diff -ru ../z.old/Src/Zle/computil.c Src/Zle/computil.c
--- ../z.old/Src/Zle/computil.c	Fri Feb 11 09:23:09 2000
+++ Src/Zle/computil.c	Fri Feb 11 11:46:04 2000
@@ -1235,12 +1235,12 @@
 	    else {
 		LinkList l = state.oargs[state.curopt->num];
 
+		if (cur < compcurrent)
+		    memcpy(&ca_laststate, &state, sizeof(state));
 		PERMALLOC {
 		    for (; line; line = compwords[cur++])
 			addlinknode(l, ztrdup(line));
 		} LASTALLOC;
-		if (cur < compcurrent)
-		    memcpy(&ca_laststate, &state, sizeof(state));
 		ca_laststate.ddef = NULL;
 		ca_laststate.doff = 0;
 		break;

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author