From: Connor Lane Smith Date: Mon, 17 Oct 2011 09:11:48 +0000 (+0100) Subject: merge xim -> default X-Git-Url: https://git.danieliu.xyz/?a=commitdiff_plain;h=cf641ae49677ae0435780e0641d9b347a4325044;hp=24565608cbf8572211a4a1b3fe7bbe1cf0c4fbbd;p=dmenu.git merge xim -> default --- diff --git a/dmenu.c b/dmenu.c index 895542d..671095e 100644 --- a/dmenu.c +++ b/dmenu.c @@ -41,7 +41,6 @@ static void usage(void); static char text[BUFSIZ] = ""; static int bh, mw, mh; static int inputw, promptw; -static int lines = 0; static size_t cursor = 0; static const char *font = NULL; static const char *prompt = NULL; @@ -49,6 +48,7 @@ static const char *normbgcolor = "#cccccc"; static const char *normfgcolor = "#000000"; static const char *selbgcolor = "#0066ff"; static const char *selfgcolor = "#ffffff"; +static unsigned int lines = 0; static unsigned long normcol[ColLast]; static unsigned long selcol[ColLast]; static Atom utf8; diff --git a/dmenu_run b/dmenu_run index 2d12243..21dc72b 100755 --- a/dmenu_run +++ b/dmenu_run @@ -1,9 +1,12 @@ #!/bin/sh CACHE=${XDG_CACHE_HOME:-"$HOME/.cache"}/dmenu_run +if [ ! -d "`dirname "$CACHE"`" ]; then + CACHE=$HOME/.dmenu_cache +fi ( IFS=: if test "`ls -dt $PATH "$CACHE" 2> /dev/null | sed 1q`" != "$CACHE"; then - mkdir -p "`dirname "$CACHE"`" && lsx $PATH | sort -u > "$CACHE" + lsx $PATH | sort -u > "$CACHE" fi ) cmd=`dmenu "$@" < "$CACHE"` && exec sh -c "$cmd" diff --git a/lsx.c b/lsx.c index f337a4a..cb016cf 100644 --- a/lsx.c +++ b/lsx.c @@ -1,5 +1,6 @@ /* See LICENSE file for copyright and license details. */ #include +#include #include #include #include @@ -8,6 +9,8 @@ static void lsx(const char *dir); +static int status = EXIT_SUCCESS; + int main(int argc, char *argv[]) { int i; @@ -16,7 +19,7 @@ main(int argc, char *argv[]) { lsx("."); else for(i = 1; i < argc; i++) lsx(argv[i]); - return EXIT_SUCCESS; + return status; } void @@ -26,13 +29,15 @@ lsx(const char *dir) { struct stat st; DIR *dp; - if(!(dp = opendir(dir))) { - perror(dir); - return; - } - while((d = readdir(dp))) + for(dp = opendir(dir); dp && (d = readdir(dp)); errno = 0) if(snprintf(buf, sizeof buf, "%s/%s", dir, d->d_name) < (int)sizeof buf - && !stat(buf, &st) && S_ISREG(st.st_mode) && access(buf, X_OK) == 0) + && access(buf, X_OK) == 0 && stat(buf, &st) == 0 && S_ISREG(st.st_mode)) puts(d->d_name); - closedir(dp); + + if(errno != 0) { + status = EXIT_FAILURE; + perror(dir); + } + if(dp) + closedir(dp); }