summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2014-10-02 18:57:40 +0200
committerOliver Kiddle <opk@zsh.org>2014-10-02 19:29:32 +0200
commit00a654af5c84f10a682f7e47547f7362865f2139 (patch)
tree617ec2ebe0359bb9df7c211121142d6ae816f5e7
parent8cbff0b82ee285b7424476439fe1ef4d1032c593 (diff)
downloadzsh-00a654af5c84f10a682f7e47547f7362865f2139.tar.gz
zsh-00a654af5c84f10a682f7e47547f7362865f2139.tar.xz
zsh-00a654af5c84f10a682f7e47547f7362865f2139.zip
33323: fix bug in removing math functions and complete -M option to functions
-rw-r--r--ChangeLog9
-rw-r--r--Completion/Zsh/Command/_typeset15
-rw-r--r--Doc/Zsh/builtins.yo2
-rw-r--r--Src/builtin.c4
4 files changed, 24 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index b8cdeea0b..f0266954a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2014-10-02  Oliver Kiddle  <opk@zsh.org>
+
+	* 33323: Completion/Zsh/Command/_typeset, Doc/Zsh/builtins.yo,
+	Src/builtin.c: fix bug in removing math functions and complete
+	-M option to functions
+
+	* 33315: Completion/Unix/Command/_sysctl: fix pattern to
+	match freebsd10 and later
+
 2014-10-02  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* unposted: remove "major".
diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset
index f876e1beb..367dbfc23 100644
--- a/Completion/Zsh/Command/_typeset
+++ b/Completion/Zsh/Command/_typeset
@@ -1,7 +1,7 @@
 #compdef autoload declare export functions integer float local readonly typeset
 
 local expl state line func i use curcontext="$curcontext"
-local fopts="-f -k -z"
+local fopts="-f -k -z +k +z"
 local popts="-A -E -F -L -R -T -Z -a -g -h -H -i -l -r -x"
 local -A allargs opt_args
 local -a args
@@ -51,8 +51,9 @@ case ${service} in
   ;;
   float) use="EFHghlprtux";;
   functions)
-    use="UkmTtuz"
+    use="UkmTtuzM"
     func=f
+    allargs[M]='(-k -t -T -u -U -z -M +M +k +t +z)-+M[define mathematical function]'
   ;;
   integer)
     use="Hghilprtux"
@@ -73,14 +74,20 @@ onopts=${(j..)${${words[1,CURRENT-1]:#^-*}##-}}
 offopts=${(j..)${${words[1,CURRENT-1]:#^+*}##+}}
 
 for ((i=1;i<=$#use;++i)); do
-  args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[Uut]]:+$func}]} )
+  args+=( ${allargs[${use[$i]}${${(s::)use[$i]}[(r)[UutT]]:+$func}]} )
 done
 
 _arguments -C -s -A "-*" -S "${args[@]}" '*::vars:= ->vars_eq'
 
 if [[ "$state" = vars_eq ]]; then
   if [[ $func = f ]]; then
-    if (( $+opt_args[-w] ));then
+    if (( $+opt_args[+M] || ( $+opt_args[-M] && $+opt_args[-m] ) )); then
+      _wanted functions expl 'math function' compadd -F line - \
+          ${${${(f)"$(functions -M)"}##*-M }%% *}
+    elif (( $+opt_args[-M] )); then
+      _arguments ':new math function:_functions' ':minimum arguments' \
+      ':maximum arguments' ':shell function:_functions'
+    elif (( $+opt_args[-w] )); then
       _wanted files expl 'zwc file' _files -g '*.zwc(-.)'
     elif [[ $service = autoload || -n $opt_args[(i)-[uU]] ]]; then
       args=(${^fpath}/*(-.:t))
diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 41c189fe2..b8bfeb2eb 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -773,7 +773,7 @@ findex(functions)
 xitem(tt(functions) [ {tt(PLUS())|tt(-)}tt(UXkmtTuz) ] [ var(name) ... ])
 xitem(tt(functions -M) var(mathfn) [ var(min) [ var(max) [ var(shellfn) ] ] ])
 xitem(tt(functions -M) [ tt(-m) var(pattern) ... ])
-item(tt(functions +M) [ tt(-m) ] var(mathfn))(
+item(tt(functions +M) [ tt(-m) ] var(mathfn) ... )(
 Equivalent to tt(typeset -f), with the exception of the tt(-M) option.
 Use of the tt(-M) option may not be combined with any of the options
 handled by tt(typeset -f).
diff --git a/Src/builtin.c b/Src/builtin.c
index a2a3ad748..4a10c7dd1 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2759,7 +2759,7 @@ bin_functions(char *name, char **argv, Options ops, int func)
 		tokenize(*argv);
 		if ((pprog = patcompile(*argv, PAT_STATIC, 0))) {
 		    queue_signals();
-		    for (p = mathfuncs, q = NULL; p; q = p, p = p->next) {
+		    for (p = mathfuncs, q = NULL; p; q = p) {
 			MathFunc next;
 			do {
 			    next = NULL;
@@ -2774,6 +2774,8 @@ bin_functions(char *name, char **argv, Options ops, int func)
 			    }
 			    /* if we deleted one, retry with the new p */
 			} while (next);
+			if (p)
+			    p = p->next;
 		    }
 		    unqueue_signals();
 		} else {