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

Re: PATCH: Re: tags stuff



I wrote:

> Argh. Sorry I change the getopts used in `_arguments' and `_values' bu 
> didn't remove the `shift OPTIND-1's.

No, Sven, that's not good at all. If you use `getopts ":O:C" opt' this 
will loop over all arguments given to `_arguments'. Makes things
slow. Ah, see, you've already been wondering why `xdvi <TAB>' became
so slow.

So we better use a simple custom-made loop.

Bye
 Sven

diff -u -r oldcompletion/Base/_arguments Completion/Base/_arguments
--- oldcompletion/Base/_arguments	Mon Nov 15 13:07:55 1999
+++ Completion/Base/_arguments	Mon Nov 15 14:35:45 1999
@@ -153,12 +153,12 @@
 fi
 
 subopts=()
-while getopts ':O:C' opt; do
-  if [[ "$opt" = O ]]; then
-    subopts=( "${(@P)OPTARG}" )
-  else
-    usecc=yes
-  fi
+while [[ "$1" = -(O*|C) ]]; do
+  case "$1" in
+  -C) usecc=yes; shift ;;
+  -O) subopts=( "${(@P)2}" ); shift 2 ;;
+  *)  subopts=( "${(@P)1[3,-1]}" ); shift ;;
+  esac
 done
 
 _style -s options auto-description autod
diff -u -r oldcompletion/Base/_values Completion/Base/_values
--- oldcompletion/Base/_values	Mon Nov 15 13:07:55 1999
+++ Completion/Base/_values	Mon Nov 15 14:36:04 1999
@@ -3,12 +3,12 @@
 local subopts opt usecc
 
 subopts=()
-while getopts ':O:C' opt; do
-  if [[ "$opt" = O ]]; then
-    subopts=( "${(@P)OPTARG}" )
-  else
-    usecc=yes
-  fi
+while [[ "$1" = -(O*|C) ]]; do
+  case "$1" in
+  -C) usecc=yes; shift ;;
+  -O) subopts=( "${(@P)2}" ); shift 2 ;;
+  *)  subopts=( "${(@P)1[3,-1]}" ); shift ;;
+  esac
 done
 
 if compvalues -i "$@"; then

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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