diff options
author | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2002-05-23 12:22:58 +0000 |
---|---|---|
committer | Sven Wischnowsky <wischnow@users.sourceforge.net> | 2002-05-23 12:22:58 +0000 |
commit | 9b5b330799ce35d5f833092f7fe503170e4b3e02 (patch) | |
tree | 1bb7345380cb445c60f442f8f81df3f512eb5e9f | |
parent | 86f38401aacfcd9b3ef6cb54faf305f7c843e60b (diff) | |
download | zsh-9b5b330799ce35d5f833092f7fe503170e4b3e02.tar.gz zsh-9b5b330799ce35d5f833092f7fe503170e4b3e02.tar.xz zsh-9b5b330799ce35d5f833092f7fe503170e4b3e02.zip |
report option arguments to _arguments in the original form (17196)
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Src/Zle/computil.c | 38 |
2 files changed, 37 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog index 5e17440ef..552ecd846 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2002-05-23 Sven Wischnowsky <wischnow@zsh.org> + * 17196: Src/Zle/computil.c: report option arguments to + _arguments in the original form + * 17214: Completion/Base/Utility/_arguments: for automatic long options completion, use the string after the equal signs (from the --help-text) as the description to shown when completing diff --git a/Src/Zle/computil.c b/Src/Zle/computil.c index 7254db531..412347ec9 100644 --- a/Src/Zle/computil.c +++ b/Src/Zle/computil.c @@ -1734,6 +1734,33 @@ freecastate(Castate s) zfree(s->oargs, s->d->nopts * sizeof(LinkList)); } +/* Return a copy of an option's argument, ignoring possible quoting + * in the option name. */ + +static char * +ca_opt_arg(Caopt opt, char *line) +{ + char *o = opt->name; + + while (1) { + if (*o == '\\') + o++; + if (*line == '\\' || *line == '\'' || *line == '"') + line++; + if (!*o || *o != *line) + break; + o++; + line++; + } + if (*line && (opt->type == CAO_EQUAL || opt->type == CAO_OEQUAL)) { + if (*line == '\\') + line++; + if (*line == '=') + line++; + } + return ztrdup(line); +} + /* Parse a command line. */ static int @@ -1742,7 +1769,7 @@ ca_parse_line(Cadef d, int multi, int first) Caarg adef, ddef; Caopt ptr, wasopt = NULL, dopt; struct castate state; - char *line, *pe, **argxor = NULL; + char *line, *oline, *pe, **argxor = NULL; int cur, doff, argend, arglast, ne; Patprog endpat = NULL, napat = NULL; LinkList sopts = NULL; @@ -1808,6 +1835,7 @@ ca_parse_line(Cadef d, int multi, int first) doff = state.singles = arglast = 0; /* remove quotes */ + oline = line; line = dupstring(line); ne = noerrs; noerrs = 2; @@ -1827,7 +1855,7 @@ ca_parse_line(Cadef d, int multi, int first) if (state.def) { state.arg = 0; if (state.curopt) - zaddlinknode(state.oargs[state.curopt->num], ztrdup(line)); + zaddlinknode(state.oargs[state.curopt->num], ztrdup(oline)); if ((state.opt = (state.def->type == CAA_OPT)) && state.def->opt) state.oopt++; @@ -1909,7 +1937,8 @@ ca_parse_line(Cadef d, int multi, int first) state.def->type != CAA_RREST) state.def = state.def->next; - zaddlinknode(state.oargs[state.curopt->num], ztrdup(pe)); + zaddlinknode(state.oargs[state.curopt->num], + ca_opt_arg(state.curopt, oline)); } if (state.def) state.opt = 0; @@ -1962,7 +1991,8 @@ ca_parse_line(Cadef d, int multi, int first) state.def->type != CAA_RREST) state.def = state.def->next; - zaddlinknode(state.oargs[state.curopt->num], ztrdup(pe)); + zaddlinknode(state.oargs[state.curopt->num], + ca_opt_arg(state.curopt, line)); } if (state.def) state.opt = 0; |