1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-01-31 03:04:49 +01:00

Improve handling of b/n/s subscript flags.

This commit is contained in:
Bart Schaefer 2001-05-06 22:35:08 +00:00
parent c687e5f515
commit d58c1780fd

View file

@ -8,15 +8,39 @@ if [[ "$1" = -q ]]; then
shift
fi
compset -P '\([^\)]##\)' # remove subscript flags
compset -P '\(([^\(\)]|*\(*\)*)##\)' # remove subscript flags
if [[ "$PREFIX" = :* ]]; then
_wanted characters expl 'character class' \
compadd -p: -S ':]' alnum alpha blank cntrl digit graph \
lower print punct space upper xdigit
elif compset -P '\('; then
local match
compset -S '\)*'
if [[ $PREFIX = (#b)*([bns])(?|)(*) ]]; then
local f=$match[1] d=$match[2] e=$match[2] v=$match[3]
[[ $f = s && ${(Pt)${compstate[parameter]}} != scalar ]] && return 1
if [[ -z $d ]]; then
_message 'delimiter'
return
else
case $d in
(\() e=\);;
(\[) e=\];;
(\{) e=\};;
esac
if [[ $v != *$e* ]]; then
case $f in
(s) _message 'separator string';;
(b|n) [[ $v = <-># ]] && _message 'number' || return 1;;
esac
[[ -n $v && $SUFFIX$ISUFFIX != *$e* ]] && _message 'delimiter'
return 0
fi
fi
fi
case ${(Pt)${compstate[parameter]}} in
assoc*) flags=(
'(R k K i I)r[any one value matched by subscript as pattern]'