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

Re: Problems with _arguments



Andrej Borsenkow wrote:

> This little completion stopped to work. I suspect new computil module ...

Yep. The main problem was that I forgot to save the parsing state in
with restricting rest-argument-definitions.

Bye
 Sven

diff -u oldsrc/Zle/computil.c Src/Zle/computil.c
--- oldsrc/Zle/computil.c	Mon Oct 18 10:38:44 1999
+++ Src/Zle/computil.c	Mon Oct 18 10:53:48 1999
@@ -1043,24 +1043,28 @@
 	    if (!state.def)
 		state.curopt = NULL;
 	} else if (state.arg) {
-	    PERMALLOC {
-		addlinknode(state.args, ztrdup(line));
-	    } LASTALLOC;
+	    if (state.inopt) {
+		state.inopt = 0;
+		state.nargbeg = cur - 1;
+	    }
 	    if ((adef = state.def = ca_get_arg(d, state.nth)) &&
 		(state.def->type == CAA_RREST ||
 		 state.def->type == CAA_RARGS)) {
 		state.inrest = 0;
+		state.argbeg = cur;
 		for (; line; line = compwords[cur++]) {
 		    PERMALLOC {
 			addlinknode(state.args, ztrdup(line));
 		    } LASTALLOC;
 		}
+		memcpy(&ca_laststate, &state, sizeof(state));
+		ca_laststate.ddef = NULL;
+		ca_laststate.doff = 0;
 		break;
 	    }
-	    if (state.inopt) {
-		state.inopt = 0;
-		state.nargbeg = cur - 1;
-	    }
+	    PERMALLOC {
+		addlinknode(state.args, ztrdup(line));
+	    } LASTALLOC;
 	    if (state.def && state.def->type != CAA_NORMAL &&
 		state.def->type != CAA_OPT && state.inarg) {
 		state.restbeg = cur;
@@ -1083,6 +1087,9 @@
 			addlinknode(l, line);
 		    } LASTALLOC;
 		}
+		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