about summary refs log tree commit diff
path: root/Completion/User/_gprof
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-07 12:54:47 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-07 12:54:47 +0000
commit6cc1204ea97b3c02da1b3d2a4df93712f0c5fefb (patch)
treea6d4da4a9a1342461ad90d298b64b04b3bc67f8d /Completion/User/_gprof
parent77f9967f32aa39ea0290162e0c3921a0ebca394e (diff)
downloadzsh-6cc1204ea97b3c02da1b3d2a4df93712f0c5fefb.tar.gz
zsh-6cc1204ea97b3c02da1b3d2a4df93712f0c5fefb.tar.xz
zsh-6cc1204ea97b3c02da1b3d2a4df93712f0c5fefb.zip
zsh-workers/7690
Diffstat (limited to 'Completion/User/_gprof')
-rw-r--r--Completion/User/_gprof51
1 files changed, 47 insertions, 4 deletions
diff --git a/Completion/User/_gprof b/Completion/User/_gprof
index 66354c875..aec50e0d6 100644
--- a/Completion/User/_gprof
+++ b/Completion/User/_gprof
@@ -1,12 +1,55 @@
 #compdef gprof
 
+local state line ret=1
+typeset -A options
+
 _arguments -s -{a,b,c,D,h,i,l,L,s,T,v,w,x,y,z} \
-           -{A,C,e,E,f,F,J,n,N,O,p,P,q,Q,Z}:'function name: _exec_funcs' \
+           -{A,C,e,E,f,F,J,n,N,O,p,P,q,Q,Z}:'function name:->funcs' \
 	   '-I:directory:_dir_list' \
-	   '-d-:debug level:' '-k:function names: _exec_funcs -p' \
+	   '-d-:debug level:' '-k:function names:->pair' \
 	   '-m:minimum execution count:' \
 	   ':executable:_files -g \*\(\*\)' \
 	   ':profile file:_files -g gmon.\*' \
 	   -- -s '(#--[no-] --)' \
-           '*=name*:function name: _exec_funcs' \
-	   '*=dirs*:directory:_dir_list'
+           '*=name*:function name:->funcs' \
+	   '*=dirs*:directory:_dir_list' && ret=0
+
+if [[ -n "$state" ]]; then
+  local cmd pair expl
+
+  [[ "$state" = pair ]] && pair=yes
+
+  if [[ $#line -gt 1 ]]; then
+    cmd="$line[2]"
+  else
+    return 1
+  fi
+
+  if [[ -n "$cmd" ]]; then
+    if [[ "$cmd" = /* ]]; then
+      tmp="$cmd"
+    else
+      tmp="$PWD/$cmd"
+    fi
+
+    if [[ "$tmp" != "$_gprof_command" ]]; then
+      _gprof_command="$tmp"
+      _gprof_funcs=( "${(@)${(@M)${(@f)$(nm $cmd)}:#[^ ]# [tT] ([^_]|_[^_])*}##* }" )
+    fi
+  
+    if [[ -n "$pair" ]]; then
+      if compset -P '*/'; then
+        _description expl 'call arc to function'
+      else
+        _description expl 'call arc from function'
+      fi
+    else
+      _description expl function
+    fi
+    compadd -M 'r:|_=* r:|=*' - "$_gprof_funcs[@]" && ret=0
+  else
+    return 1
+  fi
+fi
+
+return ret