wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit 96389a015e2b8b4a36a0c4399dda8ce9597bb056
parent 65c8c8d536348fdda19b9e931f1a0412c2118242
Author: Kris Maglione <kris@suckless.org>
Date:   Thu, 12 Aug 2010 20:10:13 -0400

Fix wmiir proglist.

Diffstat:
cmd/menu/history.c | 7++++---
cmd/wmii/mouse.c | 2+-
cmd/wmiir.c | 19+++++++++++++++----
3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/cmd/menu/history.c b/cmd/menu/history.c @@ -59,7 +59,7 @@ history_dump(const char *path, int max) { fd = mkstemp(tmp); if(fd < 0) { fprint(2, "%s: Can't create temporary history file %q: %r\n", argv0, path); - return; + _exit(1); } hist.string = input.string; @@ -84,10 +84,11 @@ history_dump(const char *path, int max) { for(h=first; h; h=h->next) if(Bprint(&b, "%s\n", h->string) < 0) { unlink(tmp); - exit(1); + fprint(2, "%s: Can't write temporary history file %q: %r\n", argv0, path); + _exit(1); } Bterm(&b); rename(tmp, path); - exit(0); + _exit(0); } diff --git a/cmd/wmii/mouse.c b/cmd/wmii/mouse.c @@ -643,7 +643,7 @@ mouse_checkresize(Frame *f, Point p, bool exec) { static void _grab(XWindow w, uint button, ulong mod) { XGrabButton(display, button, mod, w, false, ButtonMask, - GrabModeSync, GrabModeAsync, None, None); + GrabModeSync, GrabModeSync, None, None); } /* Doesn't belong here */ diff --git a/cmd/wmiir.c b/cmd/wmiir.c @@ -4,10 +4,12 @@ #define IXP_NO_P9_ #define IXP_P9_STRUCTS #include <dirent.h> +#include <errno.h> #include <limits.h> #include <locale.h> #include <stdio.h> #include <string.h> +#include <sys/stat.h> #include <sys/signal.h> #include <time.h> #include <unistd.h> @@ -432,7 +434,9 @@ static int xproglist(int argc, char *argv[]) { DIR *d; struct dirent *de; - char *dir; + struct stat stat; + char *dir, *cwd; + int i; quotefmtinstall(); @@ -441,12 +445,19 @@ xproglist(int argc, char *argv[]) { usage(); }ARGEND; + i = 7, cwd = nil; + do + cwd = erealloc(cwd, 1<<i); + while(!getcwd(cwd, 1<<i) && errno == ERANGE); + while((dir = ARGF())) /* Don't use Blprint. wimenu expects UTF-8. */ - if((d = opendir(dir))) { - while((de = readdir(d))) - if(access(de->d_name, X_OK)) + if(!chdir(cwd) && !chdir(dir) && (d = opendir(dir))) { + while((de = readdir(d))) { + lstat(de->d_name, &stat); + if(S_ISREG(stat.st_mode) && !access(de->d_name, X_OK)) Bprint(outbuf, "%q\n", de->d_name); + } closedir(d); }