zsh-workers
 help / color / mirror / code / Atom feed
* Re: PATCH: some small speedups
@ 1999-12-14 10:52 Sven Wischnowsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 1999-12-14 10:52 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> Sven Wischnowsky wrote:
> > That's all. No docs, no configure (but the module uses gettimeofday()!).
> > If anyone has questions -- ask me. If anyone wants to have this
> > improved (or turned into a real module with configure testing and
> > docs) -- don't ask me. But feel free to do that yourself, don't forget 
> > to stick your name in the comment in zprof.c, then ;-)
> 
> gettimeofday() is used elsewhere in the source.

Oops, hadn't seen that.

>  If there are no other
> problems it can be included.  Documentation should be easy enough to write.

Yes, for you. But I know I would just make a mess out of the attempt
to describe what the fields in the output mean ;-)

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: some small speedups
  1999-12-13 12:38 Sven Wischnowsky
@ 1999-12-13 21:31 ` Peter Stephenson
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Stephenson @ 1999-12-13 21:31 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky wrote:
> That's all. No docs, no configure (but the module uses gettimeofday()!).
> If anyone has questions -- ask me. If anyone wants to have this
> improved (or turned into a real module with configure testing and
> docs) -- don't ask me. But feel free to do that yourself, don't forget 
> to stick your name in the comment in zprof.c, then ;-)

gettimeofday() is used elsewhere in the source.  If there are no other
problems it can be included.  Documentation should be easy enough to write.

-- 
Peter Stephenson <pws@pwstephenson.fsnet.co.uk>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: some small speedups
@ 1999-12-13 12:38 Sven Wischnowsky
  1999-12-13 21:31 ` Peter Stephenson
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 1999-12-13 12:38 UTC (permalink / raw)
  To: zsh-workers


Adam Spiers wrote:

> Sven Wischnowsky (wischnow@informatik.hu-berlin.de) wrote:
> > Btw, at the weekend I remembered that I had once written myself a
> > small shell function profiling module -- anyone interested?
> 
> Yes please...

In the form of a patch...


Note that I wrote that between 11pm and 1am some time ago, so don't
expect any wonders...

It works like this: you zmodload zprof, execute the functions you want 
to profile and then call the builtin zprof (without args). It will
then print profiling information to stdout. But the module will
continue profiling functions (until you unload the module). The zprof
builtin understands only one option: -c clears the profiling
information it has collected so far.

When profiling the completion code (or any autoloaded function) it
probably makes sense to fisrt call the functions at least once and
start profiling after that -- otherwise the time to load the functions
might give results for things you don't really care about.


The output is slightly modelled after the gprof output: a summary at
the top showing number of calls and timing information (total, per
call and percent) for the functions (both including times for called
functions and the time for only the function itself).

After that comes the information for the call arcs (from function A to
function B).


That's all. No docs, no configure (but the module uses gettimeofday()!).
If anyone has questions -- ask me. If anyone wants to have this
improved (or turned into a real module with configure testing and
docs) -- don't ask me. But feel free to do that yourself, don't forget 
to stick your name in the comment in zprof.c, then ;-)

Bye
 Sven

diff -ru ../z.old/Src/Modules/zprof.c Src/Modules/zprof.c
--- ../z.old/Src/Modules/zprof.c	Mon Dec 13 13:26:15 1999
+++ Src/Modules/zprof.c	Mon Dec 13 13:08:45 1999
@@ -0,0 +1,328 @@
+/*
+ * zprof.c - a shell function profiling module for zsh
+ *
+ * This file is part of zsh, the Z shell.
+ *
+ * Copyright (c) 1996-1997 Sven Wischnowsky
+ * All rights reserved.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and to distribute modified versions of this software for any
+ * purpose, provided that the above copyright notice and the following
+ * two paragraphs appear in all copies of this software.
+ *
+ * In no event shall Sven Wischnowsky or the Zsh Development Group be liable
+ * to any party for direct, indirect, special, incidental, or consequential
+ * damages arising out of the use of this software and its documentation,
+ * even if Sven Wischnowsky and the Zsh Development Group have been advised of
+ * the possibility of such damage.
+ *
+ * Sven Wischnowsky and the Zsh Development Group specifically disclaim any
+ * warranties, including, but not limited to, the implied warranties of
+ * merchantability and fitness for a particular purpose.  The software
+ * provided hereunder is on an "as is" basis, and Sven Wischnowsky and the
+ * Zsh Development Group have no obligation to provide maintenance,
+ * support, updates, enhancements, or modifications.
+ *
+ */
+
+#include "zprof.mdh"
+#include "zprof.pro"
+
+#include <sys/time.h>
+#include <unistd.h>
+
+typedef struct pfunc *Pfunc;
+
+struct pfunc {
+    Pfunc next;
+    char *name;
+    long calls;
+    double time;
+    double self;
+    long num;
+};
+
+typedef struct sfunc *Sfunc;
+
+struct sfunc {
+    Pfunc p;
+    Sfunc prev;
+    double beg;
+};
+
+typedef struct parc *Parc;
+
+struct parc {
+    Parc next;
+    Pfunc from;
+    Pfunc to;
+    long calls;
+    double time;
+    double self;
+};
+
+static Pfunc calls;
+static int ncalls;
+static Parc arcs;
+static int narcs;
+static Sfunc stack;
+
+static void
+freepfuncs(Pfunc f)
+{
+    Pfunc n;
+
+    for (; f; f = n) {
+	n = f->next;
+	zsfree(f->name);
+	zfree(f, sizeof(*f));
+    }
+}
+
+static void
+freeparcs(Parc a)
+{
+    Parc n;
+
+    for (; a; a = n) {
+	n = a->next;
+	zfree(a, sizeof(*a));
+    }
+}
+
+static Pfunc
+findpfunc(char *name)
+{
+    Pfunc f;
+
+    for (f = calls; f; f = f->next)
+	if (!strcmp(name, f->name))
+	    return f;
+
+    return NULL;
+}
+
+static Parc
+findparc(Pfunc f, Pfunc t)
+{
+    Parc a;
+
+    for (a = arcs; a; a = a->next)
+	if (a->from == f && a->to == t)
+	    return a;
+
+    return NULL;
+}
+
+static int
+cmpsfuncs(Pfunc *a, Pfunc *b)
+{
+    return ((*a)->self > (*b)->self ? -1 : ((*a)->self != (*b)->self));
+}
+
+static int
+cmptfuncs(Pfunc *a, Pfunc *b)
+{
+    return ((*a)->time > (*b)->time ? -1 : ((*a)->time != (*b)->time));
+}
+
+static int
+cmpparcs(Parc *a, Parc *b)
+{
+    return ((*a)->time > (*b)->time ? -1 : ((*a)->time != (*b)->time));
+}
+
+static int
+bin_zprof(char *nam, char **args, char *ops, int func)
+{
+    if (ops['c']) {
+	freepfuncs(calls);
+	calls = NULL;
+	ncalls = 0;
+	freeparcs(arcs);
+	arcs = NULL;
+	narcs = 0;
+    } else {
+	VARARR(Pfunc, fs, (ncalls + 1));
+	Pfunc f, *fp;
+	VARARR(Parc, as, (narcs + 1));
+	Parc a, *ap;
+	long i;
+	double total;
+
+	for (total = 0.0, f = calls, fp = fs; f; f = f->next, fp++) {
+	    *fp = f;
+	    total += f->self;
+	}
+	*fp = NULL;
+	for (a = arcs, ap = as; a; a = a->next, ap++)
+	    *ap = a;
+	*ap = NULL;
+
+	qsort(fs, ncalls, sizeof(f),
+	      (int (*) _((const void *, const void *))) cmpsfuncs);
+	qsort(as, narcs, sizeof(a),
+	      (int (*) _((const void *, const void *))) cmpparcs);
+
+	printf("num  calls                time                       self            name\n-----------------------------------------------------------------------------------\n");
+	for (fp = fs, i = 1; *fp; fp++, i++) {
+	    printf("%2ld) %4ld       %8.2f %8.2f  %5.2f%%  %8.2f %8.2f  %5.2f%%  %s\n",
+		   ((*fp)->num = i),
+		   (*fp)->calls,
+		   (*fp)->time, (*fp)->time / ((double) (*fp)->calls),
+		   ((*fp)->time / total) * 100.0,
+		   (*fp)->self, (*fp)->self / ((double) (*fp)->calls),
+		   ((*fp)->self / total) * 100.0,
+		   (*fp)->name);
+	}
+	qsort(fs, ncalls, sizeof(f),
+	      (int (*) _((const void *, const void *))) cmptfuncs);
+
+	for (fp = fs; *fp; fp++) {
+	    printf("\n-----------------------------------------------------------------------------------\n\n");
+	    for (ap = as; *ap; ap++)
+		if ((*ap)->to == *fp) {
+		    printf("    %4ld/%-4ld  %8.2f %8.2f  %5.2f%%  %8.2f %8.2f             %s [%ld]\n",
+			   (*ap)->calls, (*fp)->calls,
+			   (*ap)->time, (*ap)->time / ((double) (*ap)->calls),
+			   ((*ap)->time / total) * 100.0,
+			   (*ap)->self, (*ap)->self / ((double) (*ap)->calls),
+			   (*ap)->from->name, (*ap)->from->num);
+		}
+	    printf("%2ld) %4ld       %8.2f %8.2f  %5.2f%%  %8.2f %8.2f  %5.2f%%  %s\n",
+		   (*fp)->num, (*fp)->calls,
+		   (*fp)->time, (*fp)->time / ((double) (*fp)->calls),
+		   ((*fp)->time / total) * 100.0,
+		   (*fp)->self, (*fp)->self / ((double) (*fp)->calls),
+		   ((*fp)->self / total) * 100.0,
+		   (*fp)->name);
+	    for (ap = as + narcs - 1; ap >= as; ap--)
+		if ((*ap)->from == *fp) {
+		    printf("    %4ld/%-4ld  %8.2f %8.2f  %5.2f%%  %8.2f %8.2f             %s [%ld]\n",
+			   (*ap)->calls, (*ap)->to->calls,
+			   (*ap)->time, (*ap)->time / ((double) (*ap)->calls),
+			   ((*ap)->time / total) * 100.0,
+			   (*ap)->self, (*ap)->self / ((double) (*ap)->calls),
+			   (*ap)->to->name, (*ap)->to->num);
+		}
+	}
+    }
+    return 0;
+}
+
+/**/
+static int
+zprof_wrapper(List list, FuncWrap w, char *name)
+{
+    struct sfunc sf, *sp;
+    Pfunc f;
+    Parc a = NULL;
+    struct timeval tv;
+    struct timezone dummy;
+    double prev, now;
+
+    if (!(f = findpfunc(name))) {
+	PERMALLOC {
+	    f = (Pfunc) zalloc(sizeof(*f));
+	    f->name = ztrdup(name);
+	    f->calls = 0;
+	    f->time = f->self = 0.0;
+	    f->next = calls;
+	    calls = f;
+	    ncalls++;
+	} LASTALLOC;
+    }
+    if (stack) {
+	if (!(a = findparc(stack->p, f))) {
+	    PERMALLOC {
+		a = (Parc) zalloc(sizeof(*a));
+		a->from = stack->p;
+		a->to = f;
+		a->calls = 0;
+		a->time = a->self = 0.0;
+		a->next = arcs;
+		arcs = a;
+		narcs++;
+	    } LASTALLOC;
+	}
+    }
+    sf.prev = stack;
+    sf.p = f;
+    stack = &sf;
+
+    f->calls++;
+    tv.tv_sec = tv.tv_usec = 0;
+    gettimeofday(&tv, &dummy);
+    sf.beg = prev = ((((double) tv.tv_sec) * 1000.0) +
+		     (((double) tv.tv_usec) / 1000.0));
+    runshfunc(list, w, name);
+    tv.tv_sec = tv.tv_usec = 0;
+    gettimeofday(&tv, &dummy);
+
+    now = ((((double) tv.tv_sec) * 1000.0) +
+	   (((double) tv.tv_usec) / 1000.0));
+    f->self += now - sf.beg;
+    for (sp = sf.prev; sp && sp->p != f; sp = sp->prev);
+    if (!sp)
+	f->time += now - prev;
+    if (a) {
+	a->calls++;
+	a->self += now - sf.beg;
+    }
+    stack = sf.prev;
+
+    if (stack) {
+	stack->beg += now - prev;
+	if (a)
+	    a->time += now - prev;
+    }
+    return 0;
+}
+
+static struct builtin bintab[] = {
+    BUILTIN("zprof", 0, bin_zprof, 0, 0, 0, "c", NULL),
+};
+
+static struct funcwrap wrapper[] = {
+    WRAPDEF(zprof_wrapper),
+};
+
+/**/
+int
+setup_zprof(Module m)
+{
+    return 0;
+}
+
+/**/
+int
+boot_zprof(Module m)
+{
+    calls = NULL;
+    ncalls = 0;
+    arcs = NULL;
+    narcs = 0;
+    stack = NULL;
+    return !(addbuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab)) |
+	     !addwrapper(m, wrapper));
+}
+
+/**/
+int
+cleanup_zprof(Module m)
+{
+    freepfuncs(calls);
+    freeparcs(arcs);
+    deletebuiltins(m->nam, bintab, sizeof(bintab)/sizeof(*bintab));
+    deletewrapper(m, wrapper);
+    return 0;
+}
+
+/**/
+int
+finish_zprof(Module m)
+{
+    return 0;
+}
diff -ru ../z.old/Src/Modules/zprof.mdd Src/Modules/zprof.mdd
--- ../z.old/Src/Modules/zprof.mdd	Mon Dec 13 13:26:15 1999
+++ Src/Modules/zprof.mdd	Mon Dec 13 12:44:09 1999
@@ -0,0 +1,3 @@
+autobins="zprof"
+
+objects="zprof.o"

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: some small speedups
@ 1999-12-13 12:27 Sven Wischnowsky
  0 siblings, 0 replies; 6+ messages in thread
From: Sven Wischnowsky @ 1999-12-13 12:27 UTC (permalink / raw)
  To: zsh-workers


I wrote:

> ...

Damn, sent the wrong patch, use this one instead, please.

Sorry.

Bye
 Sven

diff -ru ../z.old/Completion/Builtins/_pids Completion/Builtins/_pids
--- ../z.old/Completion/Builtins/_pids	Mon Dec 13 12:47:14 1999
+++ Completion/Builtins/_pids	Mon Dec 13 12:48:20 1999
@@ -3,7 +3,7 @@
 # If given the `-m <pattern>' option, this tries to complete only pids
 # of processes whose command line match the `<pattern>'.
 
-local list expl match desc listargs args
+local out list expl match desc listargs args
 
 _wanted processes expl 'process ID' || return 1
 
@@ -12,12 +12,18 @@
   shift 2
 fi
 
-zstyle -a ":completion${curcontext}:ps" list-arguments listargs
 zstyle -a ":completion${curcontext}:ps" arguments args
-(( $#listargs )) || listargs=( "$args[@]" )
+
+out="$(command ps $args 2>/dev/null)"
 
 if zstyle -t ":completion${curcontext}:processes" verbose; then
-  list=("${(@Mr:COLUMNS-1:)${(f@)$(command ps $listargs 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+  zstyle -a ":completion${curcontext}:ps" list-arguments listargs
+  (( $#listargs )) || listargs=( "$args[@]" )
+  if [[ "$listargs" = "$args" ]]; then
+    list=("${(@Mr:COLUMNS-1:)${(f@)out}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+  else
+    list=("${(@Mr:COLUMNS-1:)${(f@)$(command ps $listargs 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+  fi
   desc=(-ld list)
 else
   desc=()
diff -ru ../z.old/Completion/Core/_path_files Completion/Core/_path_files
--- ../z.old/Completion/Core/_path_files	Mon Dec 13 12:47:21 1999
+++ Completion/Core/_path_files	Mon Dec 13 12:48:42 1999
@@ -6,7 +6,7 @@
 local linepath realpath donepath prepath testpath exppath
 local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf opre osuf cpre
 local pats haspats=no ignore group expl addpfx addsfx remsfx
-local nm=$compstate[nmatches] menu match matcher mopts
+local nm=$compstate[nmatches] menu match matcher mopts atmp
 
 typeset -U prepaths exppaths
 
@@ -366,12 +366,12 @@
 	fi
       else
         if [[ "$tmp3" = */* ]]; then
+	  atmp=( -Qf "$mopts[@]" -p "$linepath$tmp4"
+	         -W "$prepath$realpath$testpath" "$ignore[@]"
+	         "$addpfx[@]" "$addsfx[@]" "$remsfx[@]"
+                 -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" )
           for i in "$tmp1[@]"; do
-	    compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -s "/${i#*/}" \
-		    -W "$prepath$realpath$testpath" "$ignore[@]" \
-		    "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
-                    -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \
-		    - "${i%%/*}"
+	    compadd "$atmp[@]" -s "/${i#*/}" - "${i%%/*}"
 	  done
         else
 	  compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \
diff -ru ../z.old/Completion/Core/compinit Completion/Core/compinit
--- ../z.old/Completion/Core/compinit	Mon Dec 13 12:47:21 1999
+++ Completion/Core/compinit	Mon Dec 13 12:50:53 1999
@@ -485,13 +485,13 @@
 
 # Default styles. This should be executed conditionally somehow.
 
-compstyle '*'         verbose       'yes'
-compstyle '*'         prefix-needed 'yes'
-compstyle '*'         prefix-hidden 'no'
-compstyle ':correct'  accept        '2n'
-compstyle ':correct'  prompt        'correct to:'
-compstyle '*'         completer     '_complete'
-compstyle '*:default' list-colors   no=0 fi=0 di=0 ln=0 pi=0 so=0 bd=0 cd=0 ex=0
+zstyle ':completion:*'        verbose       'yes'
+zstyle ':completion:*'        prefix-needed 'yes'
+zstyle ':completion:*'        prefix-hidden 'no'
+zstyle ':completion:correct'  accept        '2n'
+zstyle ':completion:correct'  prompt        'correct to:'
+zstyle ':completion:*'        completer     '_complete'
+zstyle ':completion*:default' list-colors   no=0 fi=0 di=0 ln=0 pi=0 so=0 bd=0 cd=0 ex=0
 
 # Now we automatically make the definition files autoloaded.
 
diff -ru ../z.old/Completion/User/_cvs Completion/User/_cvs
--- ../z.old/Completion/User/_cvs	Mon Dec 13 12:47:25 1999
+++ Completion/User/_cvs	Mon Dec 13 12:48:20 1999
@@ -578,7 +578,7 @@
     omit=(${pref}*(D:t))
     eval 'entries=(${entries:#('${(j:|:)${(@)omit:q}}')})'
     _tags directories && compadd "$@" -P "$qpref" - ${entries:q} ||
-    _cvs_directories "$@"
+        _cvs_directories "$@"
   else
     _files "$@"
   fi
@@ -595,9 +595,9 @@
     omit=($_cvs_ignore_default ${entries:q} ${=cvsignore})
     [[ -r ~/.cvsignore ]] && omit=($omit $(<~/.cvsignore))
     [[ -r ${pref}.cvsignore ]] && omit=($omit $(<${pref}.cvsignore))
-    _files "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' ||
-    _files "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' ||
-    _cvs_directories "$@"
+    _path_files "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' ||
+        _path_files "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' ||
+        _cvs_directories "$@"
   else
     _files "$@"
   fi
diff -ru ../z.old/Completion/User/_pbm Completion/User/_pbm
--- ../z.old/Completion/User/_pbm	Mon Dec 13 12:47:29 1999
+++ Completion/User/_pbm	Mon Dec 13 12:48:21 1999
@@ -21,7 +21,7 @@
     _description files expl 'picture file'
     set -- "$expl[@]"
   fi
-  _files "$@" -g "$pat" || _files "$@" -g '*.(#i)p[bgp]m'
+  _path_files "$@" -g "$pat" || _files "$@" -g '*.(#i)p[bgp]m'
   return
 fi
 
@@ -774,5 +774,5 @@
 
 *)
   _description files expl 'picture file'
-  _files "$expl[@]" -g "$pat" || _files "$expl[@]" -g '*.(#i)p[bgp]m'
+  _path_files "$expl[@]" -g "$pat" || _files "$expl[@]" -g '*.(#i)p[bgp]m'
 esac

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: PATCH: some small speedups
  1999-12-13 12:01 Sven Wischnowsky
@ 1999-12-13 12:21 ` Adam Spiers
  0 siblings, 0 replies; 6+ messages in thread
From: Adam Spiers @ 1999-12-13 12:21 UTC (permalink / raw)
  To: zsh-workers

Sven Wischnowsky (wischnow@informatik.hu-berlin.de) wrote:
> Btw, at the weekend I remembered that I had once written myself a
> small shell function profiling module -- anyone interested?

Yes please...


^ permalink raw reply	[flat|nested] 6+ messages in thread

* PATCH: some small speedups
@ 1999-12-13 12:01 Sven Wischnowsky
  1999-12-13 12:21 ` Adam Spiers
  0 siblings, 1 reply; 6+ messages in thread
From: Sven Wischnowsky @ 1999-12-13 12:01 UTC (permalink / raw)
  To: zsh-workers


This should make some things a tiny bit faster...

- avoiding some parameter expansions in a loop in _path_files
- avoid calling _files more than once in some functions
- avoid calling ps(1) twice in _pids -- one comment for this one:
  maybe we should replace the arguments and list-arguments styles with 
  two new styles that give the whole command, not only the arguments
  to ps?

And this patch also replaces the calls to compstyle in compinit with
calls to zstyle. I simply forgot to change them before.


Btw, at the weekend I remembered that I had once written myself a
small shell function profiling module -- anyone interested?

Bye
 Sven

diff -u -r ../oz/Completion/Builtins/_pids Completion/Builtins/_pids
--- ../oz/Completion/Builtins/_pids	Fri Dec 10 15:23:25 1999
+++ Completion/Builtins/_pids	Sun Dec 12 00:23:20 1999
@@ -3,7 +3,7 @@
 # If given the `-m <pattern>' option, this tries to complete only pids
 # of processes whose command line match the `<pattern>'.
 
-local list expl match desc listargs args
+local out list expl match desc listargs args
 
 _wanted processes expl 'process ID' || return 1
 
@@ -12,12 +12,18 @@
   shift 2
 fi
 
-zstyle -a ":completion${curcontext}:ps" list-arguments listargs
 zstyle -a ":completion${curcontext}:ps" arguments args
-(( $#listargs )) || listargs=( "$args[@]" )
+
+out="$(command ps $args 2>/dev/null)"
 
 if zstyle -t ":completion${curcontext}:processes" verbose; then
-  list=("${(@Mr:COLUMNS-1:)${(f@)$(command ps $listargs 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+  zstyle -a ":completion${curcontext}:ps" list-arguments listargs
+  (( $#listargs )) || listargs=( "$args[@]" )
+  if [[ "$listargs" = "$args" ]]; then
+    list=("${(@Mr:COLUMNS-1:)${(f@)out}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+  else
+    list=("${(@Mr:COLUMNS-1:)${(f@)$(command ps $listargs 2>/dev/null)}[2,-1]:#[ 	]#${PREFIX}[0-9]#${SUFFIX}[ 	]*${~match}}")
+  fi
   desc=(-ld list)
 else
   desc=()
diff -u -r ../oz/Completion/Core/_path_files Completion/Core/_path_files
--- ../oz/Completion/Core/_path_files	Fri Dec 10 15:23:30 1999
+++ Completion/Core/_path_files	Sun Dec 12 00:28:00 1999
@@ -6,7 +6,7 @@
 local linepath realpath donepath prepath testpath exppath
 local tmp1 tmp2 tmp3 tmp4 i orig pre suf tpre tsuf opre osuf cpre
 local pats haspats=no ignore group expl addpfx addsfx remsfx
-local nm=$compstate[nmatches] menu match matcher mopts
+local nm=$compstate[nmatches] menu match matcher mopts atmp
 
 typeset -U prepaths exppaths
 
@@ -366,12 +366,12 @@
 	fi
       else
         if [[ "$tmp3" = */* ]]; then
+	  atmp=( -Qf "$mopts[@]" -p "$linepath$tmp4"
+	         -W "$prepath$realpath$testpath" "$ignore[@]"
+	         "$addpfx[@]" "$addsfx[@]" "$remsfx[@]"
+                 -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" )
           for i in "$tmp1[@]"; do
-	    compadd -Qf "$mopts[@]" -p "$linepath$tmp4" -s "/${i#*/}" \
-		    -W "$prepath$realpath$testpath" "$ignore[@]" \
-		    "$addpfx[@]" "$addsfx[@]" "$remsfx[@]" \
-                    -M "r:|/=* r:|=* $match" "$group[@]" "$expl[@]" \
-		    - "${i%%/*}"
+	    compadd "$args[@]" -s "/${i#*/}" - "${i%%/*}"
 	  done
         else
 	  compadd -Qf "$mopts[@]" -p "$linepath$tmp4" \
diff -u -r ../oz/Completion/User/_cvs Completion/User/_cvs
--- ../oz/Completion/User/_cvs	Fri Dec 10 15:23:33 1999
+++ Completion/User/_cvs	Sat Dec 11 00:47:46 1999
@@ -578,7 +578,7 @@
     omit=(${pref}*(D:t))
     eval 'entries=(${entries:#('${(j:|:)${(@)omit:q}}')})'
     _tags directories && compadd "$@" -P "$qpref" - ${entries:q} ||
-    _cvs_directories "$@"
+        _cvs_directories "$@"
   else
     _files "$@"
   fi
@@ -595,9 +595,9 @@
     omit=($_cvs_ignore_default ${entries:q} ${=cvsignore})
     [[ -r ~/.cvsignore ]] && omit=($omit $(<~/.cvsignore))
     [[ -r ${pref}.cvsignore ]] && omit=($omit $(<${pref}.cvsignore))
-    _files "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' ||
-    _files "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' ||
-    _cvs_directories "$@"
+    _path_files "$@" -g '*~(*/|)('${(j:|:)omit}')(D)' ||
+        _path_files "$@" -g '*~(*/|)('${(j:|:)${(@)entries:q}}')(D)' ||
+        _cvs_directories "$@"
   else
     _files "$@"
   fi
diff -u -r ../oz/Completion/User/_pbm Completion/User/_pbm
--- ../oz/Completion/User/_pbm	Fri Dec 10 15:23:35 1999
+++ Completion/User/_pbm	Sat Dec 11 01:00:09 1999
@@ -21,7 +21,7 @@
     _description files expl 'picture file'
     set -- "$expl[@]"
   fi
-  _files "$@" -g "$pat" || _files "$@" -g '*.(#i)p[bgp]m'
+  _path_files "$@" -g "$pat" || _files "$@" -g '*.(#i)p[bgp]m'
   return
 fi
 
@@ -774,5 +774,5 @@
 
 *)
   _description files expl 'picture file'
-  _files "$expl[@]" -g "$pat" || _files "$expl[@]" -g '*.(#i)p[bgp]m'
+  _path_files "$expl[@]" -g "$pat" || _files "$expl[@]" -g '*.(#i)p[bgp]m'
 esac

--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-12-14 10:52 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-14 10:52 PATCH: some small speedups Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
1999-12-13 12:38 Sven Wischnowsky
1999-12-13 21:31 ` Peter Stephenson
1999-12-13 12:27 Sven Wischnowsky
1999-12-13 12:01 Sven Wischnowsky
1999-12-13 12:21 ` Adam Spiers

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).