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

Re: PATCH: _next_label losing empty arguments



Oliver Kiddle wrote:

> Firstly, thanks Bart for the _arguments fix - that solved my problem.

Yes, thanks, Bart. My fault...

> ...
> 
> Is the use of set in this patch instead of eval safe? [...]

Blink. I had completely forgotten about `set -A'. Cute. Faster and
much more readable. Let's use it in other places, too.

(Oliver, I also changed your changes to use ${(@)argv[...]} instead of 
${argv[...][@]}, mostly for consistency with other places, but I think 
it should also be a tad faster. Haven't measured that, though.)

Bye
 Sven

Index: Completion/Base/_arguments
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Base/_arguments,v
retrieving revision 1.21
diff -u -r1.21 _arguments
--- Completion/Base/_arguments	2000/05/22 17:18:05	1.21
+++ Completion/Base/_arguments	2000/05/23 08:51:40
@@ -149,7 +149,7 @@
 	cache=( "$cache[@]" "$tmp[@]" )
       fi
     done
-    eval "${name}=( \"\${(@)cache:# #}\" )"
+    set -A "$name" "${(@)cache:# #}"
   fi
   set -- "$tmpargv[@]" "${(@P)name}"
 fi
Index: Completion/Commands/_complete_help
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_complete_help,v
retrieving revision 1.7
diff -u -r1.7 _complete_help
--- Completion/Commands/_complete_help	2000/05/10 04:55:10	1.7
+++ Completion/Commands/_complete_help	2000/05/23 08:51:41
@@ -32,7 +32,7 @@
     # No need to call the completers more than once with different match specs.
 
     if [[ "$3" = matcher-list ]]; then
-      eval "${4}=( '' )"
+      set -A "$4" ''
     else
       builtin zstyle "$@"
     fi
Index: Completion/Commands/_next_tags
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Commands/_next_tags,v
retrieving revision 1.5
diff -u -r1.5 _next_tags
--- Completion/Commands/_next_tags	2000/04/11 07:57:56	1.5
+++ Completion/Commands/_next_tags	2000/05/23 08:51:41
@@ -62,10 +62,10 @@
         zformat -f descr "${curtag#*:}" "d:$3"
         _description "$gopt" "${curtag%:*}" "$2" "$descr"
         curtag="${curtag%:*}"
-        eval "${2}=( \${(P)2} \$argv[4,-1] )"
+	set -A "$2" "${(P@)2}" "${(@)argv[4,-1]}"
       else
         _description "$gopt" "$curtag" "$2" "$3"
-        eval "${2}=( \$argv[4,-1] \${(P)2} )"
+	set -A "$2" "${(@)argv[4,-1]}" "${(P@)2}"
       fi
 
       return 0
Index: Completion/Core/_description
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_description,v
retrieving revision 1.5
diff -u -r1.5 _description
--- Completion/Core/_description	2000/05/15 23:33:30	1.5
+++ Completion/Core/_description	2000/05/23 08:51:41
@@ -26,8 +26,8 @@
 zstyle -s ":completion:${curcontext}:$1" group-name gname &&
     [[ -z "$gname" ]] && gname="$1"
 zstyle -s ":completion:${curcontext}:$1" matcher match &&
-    opts=($opts -M "${(q)match}")
-[[ -n "$_matcher" ]] && opts=($opts -M "${(q)_matcher}")
+    opts=($opts -M "$match")
+[[ -n "$_matcher" ]] && opts=($opts -M "$_matcher")
 
 if [[ -z "$_comp_no_ignore" ]]; then
   if zstyle -a ":completion:${curcontext}:$1" ignored-patterns _comp_ignore; then
@@ -48,15 +48,15 @@
 
 if [[ -n "$gname" ]]; then
   if [[ -n "$format" ]]; then
-    eval "${name}=($opts $gropt ${(q)gname} -X \"${format}\")"
+    set -A "$name" "$opts[@]" "$gropt" "$gname" -X "$format"
   else
-    eval "${name}=($opts $gropt ${(q)gname})"
+    set -A "$name" "$opts[@]" "$gropt" "$gname"
   fi
 else
   if [[ -n "$format" ]]; then
-    eval "${name}=($opts $gropt -default- -X \"${format}\")"
+    set -A "$name" "$opts[@]" "$gropt" -default- -X "$format"
   else
-    eval "${name}=($opts $gropt -default-)"
+    set -A "$name" "$opts[@]" "$gropt" -default-
   fi
 fi
 
Index: Completion/Core/_next_label
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Core/_next_label,v
retrieving revision 1.3
diff -u -r1.3 _next_label
--- Completion/Core/_next_label	2000/05/22 18:15:54	1.3
+++ Completion/Core/_next_label	2000/05/23 08:51:41
@@ -13,10 +13,10 @@
     zformat -f descr "${curtag#*:}" "d:$3"
     _description "$gopt" "${curtag%:*}" "$2" "$descr"
     curtag="${curtag%:*}"
-    set -A $2 "${(P@)2}" "${argv[4,-1][@]}"
+    set -A $2 "${(P@)2}" "${(@)argv[4,-1]}"
   else
     _description "$gopt" "$curtag" "$2" "$3"
-    set -A $2 "${argv[4,-1][@]}" "${(P@)2}"
+    set -A $2 "${(@)argv[4,-1]}" "${(P@)2}"
   fi
 
   return 0

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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