]> git.armaanb.net Git - dmenu.git/blobdiff - stest.c
adopted Alex Sedov's config.h revival patch to tip
[dmenu.git] / stest.c
diff --git a/stest.c b/stest.c
index e75d321648100ab4fac4ab0c925d4bf962a7d562..e1dcf36ed5079dfda7f77cd15b569a83d0c06f80 100644 (file)
--- a/stest.c
+++ b/stest.c
@@ -18,7 +18,7 @@ static struct stat old, new;
 int
 main(int argc, char *argv[]) {
        struct dirent *d;
-       char buf[BUFSIZ];
+       char buf[BUFSIZ], *p;
        DIR *dir;
        int opt;
 
@@ -36,6 +36,12 @@ main(int argc, char *argv[]) {
                        fprintf(stderr, "usage: %s [-abcdefghlpqrsuwx] [-n file] [-o file] [file...]\n", argv[0]);
                        exit(2);
                }
+       if(optind == argc)
+               while(fgets(buf, sizeof buf, stdin)) {
+                       if((p = strchr(buf, '\n')))
+                               *p = '\0';
+                       test(buf, buf);
+               }
        for(; optind < argc; optind++)
                if(FLAG('l') && (dir = opendir(argv[optind]))) {
                        /* test directory contents */
@@ -54,8 +60,7 @@ void
 test(const char *path, const char *name) {
        struct stat st, ln;
 
-       if(!stat(path, &st) && !lstat(path, &ln)
-       && ( FLAG('a') || name[0] != '.')                             /* hidden            */
+       if(!stat(path, &st) && (FLAG('a') || name[0] != '.')          /* hidden files      */
        && (!FLAG('b') || S_ISBLK(st.st_mode))                        /* block special     */
        && (!FLAG('c') || S_ISCHR(st.st_mode))                        /* character special */
        && (!FLAG('d') || S_ISDIR(st.st_mode))                        /* directory         */