about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-07-25 14:49:32 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-07-25 14:49:32 +0000
commitf29d50fe9ce5178eb2136bc06bad9fa995f7e318 (patch)
treec7fd5ef2024fb1998f21d3834812846e3c29b2f4
parent1df4b6620bde483aaf38521f7675547d42b62c42 (diff)
downloadzsh-f29d50fe9ce5178eb2136bc06bad9fa995f7e318.tar.gz
zsh-f29d50fe9ce5178eb2136bc06bad9fa995f7e318.tar.xz
zsh-f29d50fe9ce5178eb2136bc06bad9fa995f7e318.zip
move pattern matching in the loop to make sure all match specs are used (15487)
-rw-r--r--ChangeLog4
-rw-r--r--Completion/Base/Utility/_describe90
-rw-r--r--Src/Zle/complete.c5
3 files changed, 54 insertions, 45 deletions
diff --git a/ChangeLog b/ChangeLog
index 44f16c151..6e6bd380a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2001-07-25  Sven Wischnowsky  <wischnow@zsh.org>
 
+	* 15487: Completion/Base/Utility/_describe, Src/Zle/complete.c:
+	move pattern matching in the loop to make sure all match specs
+	are used
+
 	* 15485: Completion/Unix/Command/_lzop,
 	Completion/Zsh/Type/_directory_stack,
 	Completion/Zsh/Type/_file_descriptors, Completion/Zsh/Type/_jobs:
diff --git a/Completion/Base/Utility/_describe b/Completion/Base/Utility/_describe
index bed75a318..f97834586 100644
--- a/Completion/Base/Utility/_describe
+++ b/Completion/Base/Utility/_describe
@@ -5,6 +5,7 @@
 local _opt _expl _tmpm _tmpd
 local _type=values _descr _ret=1 _showd _nm _hide _args _grp _sep
 local csl="$compstate[list]" csl2
+local _oargv _argv _new _strs _mats _opts _i _try=0
 
 # Get the option.
 
@@ -25,55 +26,17 @@ zstyle -T ":completion:${curcontext}:$_type" verbose && _showd=yes
 
 zstyle -s ":completion:${curcontext}:$_type" list-separator _sep || _sep=--
 
-if zstyle -T ":completion:${curcontext}:$_type" list-grouped; then
-  local _argv _new _strs _mats _opts _i=2
+_descr="$1"
+shift
 
-  _argv=( "$@" )
+if [[ -n "$showd" ]] &&
+   zstyle -T ":completion:${curcontext}:$_type" list-grouped; then
+  _oargv=( "$@" )
   _grp=(-g)
-  _new=( "$1" )
-  shift
-
-  while (( $# )); do
-
-    _strs="_a_$_i"
-    eval local "_a_$_i;_a_$_i"'=( "${'$1'[@]}" )'
-    _argv[_i]="_a_$_i"
-    shift
-    (( _i++ ))
-
-    if [[ "$1" = (|-*) ]]; then
-      _mats=
-    else
-      _matss="_a_$_i"
-      eval local "_a_$_i;_a_$_i"'=( "${'$1'[@]}" )'
-      _argv[_i]="_a_$_i"
-      shift
-      (( _i++ ))
-    fi
-
-    _opts=( "${(@)argv[1,(i)--]:#--}" )
-    shift "$#_opts"
-    (( _i += $#_opts ))
-    if [[ $1 == -- ]]; then
-      shift
-      (( _i++ ))
-    fi
-
-    if [[ -n $_mats ]]; then
-      compadd "$_opts[@]" -O $_strs -D $_mats -a $_strs
-    else
-      compadd "$_opts[@]" -O $_strs -a $_strs
-    fi
-  done
-
-  set - "$_argv[@]"
 else
   _grp=()
 fi
 
-_descr="$1"
-shift
-
 [[ "$_type" = options ]] &&
     zstyle -t ":completion:${curcontext}:options" prefix-hidden &&
         _hide="${(M)PREFIX##(--|[-+])}"
@@ -82,6 +45,47 @@ _tags "$_type"
 while _tags; do
   while _next_label "$_type" _expl "$_descr"; do
 
+    if (( $#_grp )); then
+  
+      set -- "$_oargv[@]"
+      _argv=( "$_oargv[@]" )
+      _i=1
+      (( _try++ ))
+      while (( $# )); do
+    
+        _strs="_a_$_try$_i"
+        eval local "_a_$_try$_i;_a_$_try$_i"'=( "${'$1'[@]}" )'
+        _argv[_i]="_a_$_try$_i"
+        shift
+        (( _i++ ))
+    
+        if [[ "$1" = (|-*) ]]; then
+          _mats=
+        else
+          _matss="_a_$_try$_i"
+          eval local "_a_$_try$_i;_a_$_try$_i"'=( "${'$1'[@]}" )'
+          _argv[_i]="_a_$_try$_i"
+          shift
+          (( _i++ ))
+        fi
+    
+        _opts=( "${(@)argv[1,(i)--]:#--}" )
+        shift "$#_opts"
+        (( _i += $#_opts ))
+        if [[ $1 == -- ]]; then
+          shift
+          (( _i++ ))
+        fi
+    
+        if [[ -n $_mats ]]; then
+          compadd "$_opts[@]" "$_expl[@]" -O $_strs -D $_mats -s $_strs
+        else
+          compadd "$_opts[@]" "$_expl[@]" -O $_strs -a $_strs
+        fi
+      done
+      set - "$_argv[@]"
+    fi
+
     if [[ -n "$_showd" ]]; then
       compdescribe -I "$_hide" "$_sep " _expl "$_grp[@]" "$@"
     else
diff --git a/Src/Zle/complete.c b/Src/Zle/complete.c
index 106e0ddab..f9a160bb7 100644
--- a/Src/Zle/complete.c
+++ b/Src/Zle/complete.c
@@ -616,14 +616,15 @@ bin_compadd(char *name, char **argv, char *ops, int func)
 	    }
 	}
     }
+
+ ca_args:
+
     if (mstr && (match = parse_cmatcher(name, mstr)) == pcm_err) {
 	zsfree(mstr);
 	return 1;
     }
     zsfree(mstr);
 
- ca_args:
-
     if (!*argv && !dat.group && !dat.mesg &&
 	!(dat.aflags & (CAF_NOSORT|CAF_UNIQALL|CAF_UNIQCON|CAF_ALL)))
 	return 1;