Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: Re: 4.0.1 - arguments test fails



Andrej Borsenkow wrote:

> /tools/src/zsh-4.0.x/Test/Y03arguments.ztst: starting.
> *** /tmp/zsh.ztst.out.959       Sat Jun  2 02:25:33 2001
> --- /tmp/zsh.ztst.tout.959      Sat Jun  2 02:25:33 2001
> ***************
> *** 1,4 ****
>    line: {tst -}{}
>    MESSAGE:{arg}
> - DESCRIPTION:{option}
> - NO:{-x}
> --- 1,2 ----
> Test /tools/src/zsh-4.0.x/Test/Y03arguments.ztst failed: output differs 
> from expected as shown above for:
>   tst_arguments '-x' ':arg:'
>   comptest $'tst -\t'
> Was testing: argument beginning with minus
> /tools/src/zsh-4.0.x/Test/Y03arguments.ztst: test failed.
> gmake[1]: [check] Error 1 (ignored)
> rm -rf Modules .zcompdump
> gmake[1]: Leaving directory `/u3/u1/build/zsh-4.0.x/Test'

Oh boy, am I ashamed.

The patch makes the test suite happy again and also fixes Peter's
problem with history/fc.  It looks big, but that's mostly re-indentation.

There were basically two problems: in the test suite, my bad patch kept
multiple actions from being tried -- the test to keep it from trying the
same action more than once was placed wrongly -- and if we haven't an
option on the command line, we should try to complete options, even if
we've already tried an action.

Oh boy, am I ashamed.

I'm going to commit this now, do I have to commit it somewhere else, too
(because of branching or something)?


I'm soo ashamed.  I'll better creep back into my hole in the ground now...


Bye
  Sven

Index: Completion/Base/Utility/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/Utility/_arguments,v
retrieving revision 1.7
diff -u -r1.7 _arguments
--- Completion/Base/Utility/_arguments	2001/06/01 14:29:11	1.7
+++ Completion/Base/Utility/_arguments	2001/06/06 09:17:26
@@ -186,6 +186,8 @@
   esac
 done
 
+[[ "$PREFIX" = [-+] ]] && alwopt=arg
+
 zstyle -s ":completion:${curcontext}:options" auto-description autod
 
 if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
@@ -227,106 +229,108 @@
   while true; do
     while _tags; do
       anum=1
-      while [[ anum -le  $#descrs ]]; do
-
-	action="$actions[anum]"
-	descr="$descrs[anum]"
-	subc="$subcs[anum++]"
+      if [[ -z "$tried" ]]; then
+        while [[ anum -le  $#descrs ]]; do
 
-        if [[ -z "$tried" ]] && { [[ -n "$matched" ]] || _requested "$subc" }; then
+	  action="$actions[anum]"
+	  descr="$descrs[anum]"
+	  subc="$subcs[anum++]"
 
-          curcontext="${oldcontext%:*}:$subc"
+          if [[ -n "$matched" ]] || _requested "$subc"; then
 
-          _description "$subc" expl "$descr"
+            curcontext="${oldcontext%:*}:$subc"
 
-          if [[ "$action" = \=\ * ]]; then
-            action="$action[3,-1]"
-            words=( "$subc" "$words[@]" )
-	    (( CURRENT++ ))
-          fi
+            _description "$subc" expl "$descr"
 
-          if [[ "$action" = -\>* ]]; then
-	    action="${${action[3,-1]##[ 	]#}%%[ 	]#}"
-	    if (( ! $state[(I)$action] )); then
-              comparguments -W line opt_args
-              state=( "$state[@]" "$action" )
-	      if [[ -n "$usecc" ]]; then
-	        curcontext="${oldcontext%:*}:$subc"
-	      else
-	        context=( "$context[@]" "$subc" )
-	      fi
-              compstate[restore]=''
-              aret=yes
+            if [[ "$action" = \=\ * ]]; then
+              action="$action[3,-1]"
+              words=( "$subc" "$words[@]" )
+	      (( CURRENT++ ))
             fi
-          else
-            if [[ -z "$local" ]]; then
-              local line
-              typeset -A opt_args
-              local=yes
-            fi
 
-            comparguments -W line opt_args
+            if [[ "$action" = -\>* ]]; then
+	      action="${${action[3,-1]##[ 	]#}%%[ 	]#}"
+	      if (( ! $state[(I)$action] )); then
+                comparguments -W line opt_args
+                state=( "$state[@]" "$action" )
+	        if [[ -n "$usecc" ]]; then
+	          curcontext="${oldcontext%:*}:$subc"
+	        else
+	          context=( "$context[@]" "$subc" )
+	        fi
+                compstate[restore]=''
+                aret=yes
+              fi
+            else
+              if [[ -z "$local" ]]; then
+                local line
+                typeset -A opt_args
+                local=yes
+              fi
 
-            if [[ "$action" = \ # ]]; then
+              comparguments -W line opt_args
 
-              # An empty action means that we should just display a message.
+              if [[ "$action" = \ # ]]; then
 
-	      _message "$descr"
-	      mesg=yes
-	      tried=yes
+                # An empty action means that we should just display a message.
 
-            elif [[ "$action" = \(\(*\)\) ]]; then
+	        _message "$descr"
+	        mesg=yes
+	        tried=yes
+                alwopt=${alwopt:-yes}
+              elif [[ "$action" = \(\(*\)\) ]]; then
 
-              # ((...)) contains literal strings with descriptions.
+                # ((...)) contains literal strings with descriptions.
 
-              eval ws\=\( "${action[3,-3]}" \)
+                eval ws\=\( "${action[3,-3]}" \)
 
-              _describe -t "$subc" "$descr" ws -M "$matcher" "$subopts[@]" ||
-                  alwopt=${alwopt:-yes}
-	      tried=yes
+                _describe -t "$subc" "$descr" ws -M "$matcher" "$subopts[@]" ||
+                    alwopt=${alwopt:-yes}
+	        tried=yes
 
-            elif [[ "$action" = \(*\) ]]; then
+              elif [[ "$action" = \(*\) ]]; then
 
-              # Anything inside `(...)' is added directly.
+                # Anything inside `(...)' is added directly.
 
-              eval ws\=\( "${action[2,-2]}" \)
+                eval ws\=\( "${action[2,-2]}" \)
 
-              _all_labels "$subc" expl "$descr" compadd "$subopts[@]" -a - ws ||
-                  alwopt=${alwopt:-yes}
-	      tried=yes
-            elif [[ "$action" = \{*\} ]]; then
+                _all_labels "$subc" expl "$descr" compadd "$subopts[@]" -a - ws ||
+                    alwopt=${alwopt:-yes}
+	        tried=yes
+              elif [[ "$action" = \{*\} ]]; then
 
-              # A string in braces is evaluated.
+                # A string in braces is evaluated.
 
-              while _next_label "$subc" expl "$descr"; do
-                eval "$action[2,-2]" && ret=0
-              done
-              (( ret )) && alwopt=${alwopt:-yes}
-	      tried=yes
-            elif [[ "$action" = \ * ]]; then
+                while _next_label "$subc" expl "$descr"; do
+                  eval "$action[2,-2]" && ret=0
+                done
+                (( ret )) && alwopt=${alwopt:-yes}
+	        tried=yes
+              elif [[ "$action" = \ * ]]; then
 
-              # If the action starts with a space, we just call it.
+                # If the action starts with a space, we just call it.
 
-	      eval "action=( $action )"
-              while _next_label "$subc" expl "$descr"; do
-                "$action[@]" && ret=0
-              done
-              (( ret )) && alwopt=${alwopt:-yes}
-	      tried=yes
-            else
+	        eval "action=( $action )"
+                while _next_label "$subc" expl "$descr"; do
+                  "$action[@]" && ret=0
+                done
+                (( ret )) && alwopt=${alwopt:-yes}
+	        tried=yes
+              else
 
-              # Otherwise we call it with the description-arguments.
+                # Otherwise we call it with the description-arguments.
 
-	      eval "action=( $action )"
-              while _next_label "$subc" expl "$descr"; do
-                "$action[1]" "$subopts[@]" "$expl[@]" "${(@)action[2,-1]}" && ret=0
-	      done
-              (( ret )) && alwopt=${alwopt:-yes}
-	      tried=yes
+	        eval "action=( $action )"
+                while _next_label "$subc" expl "$descr"; do
+                  "$action[1]" "$subopts[@]" "$expl[@]" "${(@)action[2,-1]}" && ret=0
+	        done
+                (( ret )) && alwopt=${alwopt:-yes}
+	        tried=yes
+              fi
             fi
           fi
-        fi
-      done
+        done
+      fi
       if [[ -z "$hasopts" &&
             -z "$matched" &&
             ( -z "$tried" || -n "$alwopt" ) &&

-- 
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author