diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-10-21 02:25:15 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-10-21 02:25:15 +0000 |
commit | 4540e0eba52dab45a94a8451084d7333a61b7307 (patch) | |
tree | b5a6d0cfa72c3a121267f9d754a4b69118c890f5 /Src/Zle/computil.c | |
parent | 95230a1684a7d864a5db128b8fc56669c6555ded (diff) | |
download | zsh-4540e0eba52dab45a94a8451084d7333a61b7307.tar.gz zsh-4540e0eba52dab45a94a8451084d7333a61b7307.tar.xz zsh-4540e0eba52dab45a94a8451084d7333a61b7307.zip |
zsh-workers/8340
Diffstat (limited to 'Src/Zle/computil.c')
-rw-r--r-- | Src/Zle/computil.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index be1062fa3..5d531bb86 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -926,6 +926,8 @@ ca_parse_line(Cadef d) while (i--) if (*p++) freelinklist(p[-1], freestr); + + zfree(ca_laststate.oargs, ca_laststate.d->nopts * sizeof(LinkList)); } for (ptr = d->opts; ptr; ptr = ptr->next) ptr->active = 1; @@ -1051,7 +1053,10 @@ ca_parse_line(Cadef d) (state.def->type == CAA_RREST || state.def->type == CAA_RARGS)) { state.inrest = 0; - state.argbeg = cur; + state.opt = 0; + state.optbeg = state.nargbeg; + state.argbeg = cur - 1; + for (; line; line = compwords[cur++]) { PERMALLOC { addlinknode(state.args, ztrdup(line)); @@ -1082,11 +1087,10 @@ ca_parse_line(Cadef d) else { LinkList l = state.oargs[state.curopt->num]; - for (; line; line = compwords[cur++]) { - PERMALLOC { - addlinknode(l, line); - } LASTALLOC; - } + PERMALLOC { + for (; line; line = compwords[cur++]) + addlinknode(l, ztrdup(line)); + } LASTALLOC; memcpy(&ca_laststate, &state, sizeof(state)); ca_laststate.ddef = NULL; ca_laststate.doff = 0; @@ -1103,8 +1107,8 @@ ca_parse_line(Cadef d) else { ca_laststate.def = adef; ca_laststate.ddef = NULL; - ca_laststate.argbeg = state.nargbeg; - ca_laststate.optbeg = state.restbeg; + ca_laststate.optbeg = state.nargbeg; + ca_laststate.argbeg = state.restbeg; ca_laststate.singles = state.singles; } } @@ -1116,21 +1120,26 @@ ca_colonlist(LinkList l) { if (l) { LinkNode n; - int len = 1; + int len = 0; char *p, *ret, *q; - for (n = firstnode(l); n; incnode(n)) + for (n = firstnode(l); n; incnode(n)) { + len++; for (p = (char *) getdata(n); *p; p++) len += (*p == ':' ? 2 : 1); - + } ret = q = (char *) zalloc(len); - for (n = firstnode(l); n; incnode(n)) + for (n = firstnode(l); n;) { for (p = (char *) getdata(n); *p; p++) { if (*p == ':') *q++ = '\\'; *q++ = *p; } + incnode(n); + if (n) + *q++ = ':'; + } *q = '\0'; return ret; @@ -1206,10 +1215,10 @@ bin_comparguments(char *nam, char **args, char *ops, int func) if (ca_laststate.doff > 0) ignore_prefix(ca_laststate.doff); if (arg->type == CAA_RARGS) - restrict_range(ca_laststate.argbeg - 1, + restrict_range(ca_laststate.optbeg, arrlen(compwords) - 1); else if (arg->type == CAA_RREST) - restrict_range(ca_laststate.optbeg - 1, + restrict_range(ca_laststate.argbeg, arrlen(compwords) - 1); return 0; } |