560f4e
From f92e6a9a7360b0485ebdaa006042337ffd9aa8df Mon Sep 17 00:00:00 2001
560f4e
From: Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
560f4e
Date: Fri, 6 Feb 2015 23:06:07 +0900
560f4e
Subject: [PATCH 1/2] 34456: lopts should be initialized as an array
560f4e
560f4e
otherwise an empty element remains in lopts, which causes
560f4e
a trouble when _arguments -- '*:' is called.
560f4e
560f4e
Upstream-commit: 2810317ae2f2f96d06add76c17510a90f2ea3f62
560f4e
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
560f4e
---
560f4e
 Completion/Base/Utility/_arguments | 2 +-
560f4e
 1 file changed, 1 insertion(+), 1 deletion(-)
560f4e
560f4e
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
560f4e
index d70c442..1f35e8d 100644
560f4e
--- a/Completion/Base/Utility/_arguments
560f4e
+++ b/Completion/Base/Utility/_arguments
560f4e
@@ -26,7 +26,7 @@ if (( long )); then
560f4e
 
560f4e
   if (( ! ${(P)+name} )); then
560f4e
     local iopts sopts pattern tmpo dir cur cache
560f4e
-    typeset -U lopts
560f4e
+    typeset -Ua lopts
560f4e
 
560f4e
     cache=()
560f4e
 
560f4e
-- 
560f4e
2.5.5
560f4e
560f4e
560f4e
From 08801bde8876d8a671165b1856ad99aec5dd6564 Mon Sep 17 00:00:00 2001
560f4e
From: Jun-ichi Takimoto <takimoto-j@kba.biglobe.ne.jp>
560f4e
Date: Wed, 30 Sep 2015 23:56:14 +0900
560f4e
Subject: [PATCH 2/2] 36697: handle options of _arguments correctly
560f4e
560f4e
Upstream-commit: 756526eef3e064c3ffb023ae5e5e6df42e6e9162
560f4e
Signed-off-by: Kamil Dudka <kdudka@redhat.com>
560f4e
---
560f4e
 Completion/Base/Utility/_arguments | 45 +++++++++++++++++++-------------------
560f4e
 1 file changed, 23 insertions(+), 22 deletions(-)
560f4e
560f4e
diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments
560f4e
index 1f35e8d..87fb20e 100644
560f4e
--- a/Completion/Base/Utility/_arguments
560f4e
+++ b/Completion/Base/Utility/_arguments
560f4e
@@ -8,15 +8,33 @@ local oldcontext="$curcontext" hasopts rawret optarg singopt alwopt
560f4e
 local setnormarg start rest
560f4e
 local -a match mbegin mend
560f4e
 
560f4e
+subopts=()
560f4e
+singopt=()
560f4e
+while [[ "$1" = -([AMO]*|[CRSWnsw]) ]]; do
560f4e
+  case "$1" in
560f4e
+  -C)  usecc=yes; shift ;;
560f4e
+  -O)  subopts=( "${(@P)2}" ); shift 2 ;;
560f4e
+  -O*) subopts=( "${(@P)${1[3,-1]}}" ); shift ;;
560f4e
+  -R)  rawret=yes; shift;;
560f4e
+  -n)  setnormarg=yes; NORMARG=-1; shift;;
560f4e
+  -w)  optarg=yes; shift;;
560f4e
+  -W)  alwopt=arg; shift;;
560f4e
+  -[Ss])  singopt+=( $1 ); shift;;
560f4e
+  -[AM])  singopt+=( $1 $2 ); shift 2 ;;
560f4e
+  -[AM]*) singopt+=( $1 ); shift ;;
560f4e
+  esac
560f4e
+done
560f4e
+
560f4e
+[[ $1 = ':' ]] && shift
560f4e
+singopt+=( ':' )  # always end with ':' to indicate the end of options
560f4e
+
560f4e
+[[ "$PREFIX" = [-+] ]] && alwopt=arg
560f4e
+
560f4e
 long=$argv[(I)--]
560f4e
 if (( long )); then
560f4e
   local name tmp tmpargv
560f4e
 
560f4e
-  if [[ long -eq 1 ]]; then
560f4e
-    tmpargv=()
560f4e
-  else
560f4e
-    tmpargv=( "${(@)argv[1,long-1]}" )
560f4e
-  fi
560f4e
+  tmpargv=( "${(@)argv[1,long-1]}" )  # optspec's before --, if any
560f4e
 
560f4e
   name=${~words[1]}
560f4e
   [[ "$name" = [^/]*/* ]] && name="$PWD/$name"
560f4e
@@ -290,23 +308,6 @@ if (( long )); then
560f4e
   set -- "$tmpargv[@]" "${(@P)name}"
560f4e
 fi
560f4e
 
560f4e
-subopts=()
560f4e
-singopt=()
560f4e
-while [[ "$1" = -(O*|[CRWnsw]) ]]; do
560f4e
-  case "$1" in
560f4e
-  -C)  usecc=yes; shift ;;
560f4e
-  -O)  subopts=( "${(@P)2}" ); shift 2 ;;
560f4e
-  -O*) subopts=( "${(@P)${1[3,-1]}}" ); shift ;;
560f4e
-  -R)  rawret=yes; shift;;
560f4e
-  -n)  setnormarg=yes; NORMARG=-1; shift;;
560f4e
-  -w)  optarg=yes; shift;;
560f4e
-  -s)  singopt=(-s); shift;;
560f4e
-  -W)  alwopt=arg; shift;;
560f4e
-  esac
560f4e
-done
560f4e
-
560f4e
-[[ "$PREFIX" = [-+] ]] && alwopt=arg
560f4e
-
560f4e
 zstyle -s ":completion:${curcontext}:options" auto-description autod
560f4e
 
560f4e
 if (( $# )) && comparguments -i "$autod" "$singopt[@]" "$@"; then
560f4e
-- 
560f4e
2.5.5
560f4e