1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-09-06 23:31:28 +02:00

zsh-workers/8749

This commit is contained in:
Tanaka Akira 1999-11-23 14:24:39 +00:00
parent 003d108896
commit 616d348e39
2 changed files with 32 additions and 13 deletions

View file

@ -165,8 +165,9 @@ _style -s options auto-description autod
if comparguments -i "$autod" "$@"; then if comparguments -i "$autod" "$@"; then
local nm="$compstate[nmatches]" action noargs aret expl local local nm="$compstate[nmatches]" action noargs aret expl local
local next direct odirect equal single match matched ws tmp1 tmp2 local next direct odirect equal single match matched ws tmp1 tmp2 tmp3
local opts subc prefix suffix local opts subc prefix suffix
local origpre="$PREFIX" origipre="$IPREFIX"
if comparguments -D descr action; then if comparguments -D descr action; then
comparguments -C subc comparguments -C subc
@ -254,11 +255,17 @@ if comparguments -i "$autod" "$@"; then
fi fi
fi fi
fi fi
if [[ -z "$matched" ]] && _requested options && if [[ -z "$matched" ]] && _requested options &&
{ ! _style options prefix-needed || { ! _style options prefix-needed ||
[[ "$PREFIX" = [-+]* ]] } ; then [[ "$origpre" = [-+]* ]] } ; then
comparguments -M match local prevpre="$PREFIX" previpre="$IPREFIX"
PREFIX="$origpre"
IPREFIX="$origipre"
comparguments -M match
if comparguments -s single; then if comparguments -s single; then
_description expl option _description expl option
@ -271,11 +278,13 @@ if comparguments -i "$autod" "$@"; then
compadd "$expl[@]" -QqS= - "${PREFIX}${SUFFIX}" compadd "$expl[@]" -QqS= - "${PREFIX}${SUFFIX}"
else else
tmp1=( "$next[@]" "$direct[@]" "$odirect[@]" "$equal[@]" ) tmp1=( "$next[@]" "$direct[@]" "$odirect[@]" "$equal[@]" )
tmp3=( "${(M@)tmp1:#[-+]?[^:]*}" )
tmp1=( "${(M@)tmp1:#[-+]?(|:*)}" ) tmp1=( "${(M@)tmp1:#[-+]?(|:*)}" )
tmp2=( "${PREFIX}${(@M)^${(@)${(@)tmp1%%:*}#[-+]}:#?}" ) tmp2=( "${PREFIX}${(@M)^${(@)${(@)tmp1%%:*}#[-+]}:#?}" )
_describe -o option \ _describe -o option \
tmp1 tmp2 -Q -S '' tmp1 tmp2 -Q -S '' -- \
tmp3 -Q
fi fi
single=yes single=yes
else else
@ -285,11 +294,16 @@ if comparguments -i "$autod" "$@"; then
direct -QS '' -M "$match" -- \ direct -QS '' -M "$match" -- \
equal -QqS= -M "$match" equal -QqS= -M "$match"
fi fi
PREFIX="$prevpre"
IPREFIX="$previpre"
fi fi
done done
if [[ -n "$opts" && -z "$aret$matched" && if [[ -n "$opts" && -z "$aret$matched" &&
nm -eq compstate[nmatches] ]]; then nm -eq compstate[nmatches] ]]; then
PREFIX="$origpre"
IPREFIX="$origipre"
prefix="${PREFIX#*\=}" prefix="${PREFIX#*\=}"
suffix="$SUFFIX" suffix="$SUFFIX"
PREFIX="${PREFIX%%\=*}" PREFIX="${PREFIX%%\=*}"

View file

@ -941,13 +941,17 @@ ca_get_opt(Cadef d, char *line, int full, char **end)
{ {
Caopt p; Caopt p;
if (full) { /* The full string may be an option. */
/* The full string has to be an option. */
for (p = d->opts; p; p = p->next) for (p = d->opts; p; p = p->next)
if (p->active && !strcmp(p->name, line)) if (p->active && !strcmp(p->name, line)) {
return p; if (end)
} else { *end = line + strlen(line);
return p;
}
if (!full) {
/* The string from the line probably only begins with an option. */ /* The string from the line probably only begins with an option. */
for (p = d->opts; p; p = p->next) for (p = d->opts; p; p = p->next)
if (p->active && ((!p->args || p->type == CAO_NEXT) ? if (p->active && ((!p->args || p->type == CAO_NEXT) ?
@ -1160,7 +1164,7 @@ ca_parse_line(Cadef d)
} LASTALLOC; } LASTALLOC;
ca_inactive(d, state.curopt->xor); ca_inactive(d, state.curopt->xor);
/* Collect the argument strings. MAybe. */ /* Collect the argument strings. Maybe. */
if (state.def && if (state.def &&
(state.curopt->type == CAO_DIRECT || (state.curopt->type == CAO_DIRECT ||
@ -1431,7 +1435,7 @@ bin_comparguments(char *nam, char **args, char *ops, int func)
return 1; return 1;
} }
case 'O': case 'O':
if (ca_laststate.opt) { if (ca_laststate.opt || (ca_laststate.doff && ca_laststate.def)) {
LinkList next = newlinklist(); LinkList next = newlinklist();
LinkList direct = newlinklist(); LinkList direct = newlinklist();
LinkList odirect = newlinklist(); LinkList odirect = newlinklist();
@ -1484,7 +1488,8 @@ bin_comparguments(char *nam, char **args, char *ops, int func)
return 1; return 1;
} }
case 's': case 's':
if (ca_laststate.d->single && ca_laststate.singles) { if (ca_laststate.d->single && ca_laststate.singles &&
ca_laststate.opt) {
setsparam(args[1], setsparam(args[1],
ztrdup(ca_laststate.ddef ? ztrdup(ca_laststate.ddef ?
(ca_laststate.ddef->type == CAO_DIRECT ? (ca_laststate.ddef->type == CAO_DIRECT ?