diff options
Diffstat (limited to 'menudriver.c')
-rw-r--r-- | menudriver.c | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/menudriver.c b/menudriver.c index 9b2b07b..1ea810f 100644 --- a/menudriver.c +++ b/menudriver.c @@ -194,7 +194,9 @@ void menudrive(char *dir) if (chdir(next) == -1 || stat("contents", &st)) { bad = 1, chdir(hold); } else { - strcpy(last, next), pushlast(), next[0] = '\0'; + strcpy(last, next); + pushlast(); + next[0] = '\0'; } } else if (S_ISREG(st.st_mode)) { @@ -303,30 +305,26 @@ void menudrive(char *dir) void singleton(char *fil) { struct stat st; - if (stat(fil, &st) == 0 && S_ISREG(st.st_mode)) { /* regular file */ - clrscr(); + if (!(stat(fil, &st) == 0 && S_ISREG(st.st_mode))) { + fprintf(stderr, "menudriver: cannot access \"%s\"\n", fil), exit(1); + return; + } + clrscr(); + + snprintf(cmd, sizeof(cmd), "%s %s", viewer, fil); #ifndef UWIN - if (st.st_mode & S_IXUSR) { /* executable (by owner) */ - snprintf(cmd, sizeof(cmd), "./%s", fil); - system(cmd); - fastback = 0; - } else + if (st.st_mode & S_IXUSR) { /* executable (by owner) */ + snprintf(cmd, sizeof(cmd), "./%s", fil); + fastback = 0; + } #endif - { - snprintf(cmd, sizeof(cmd), "%s %s", viewer, fil); - system(cmd); - } - - if (!fastback) { - wait_for_return(); - } - exit(0); - - } else { - fprintf(stderr, "menudriver: cannot access \"%s\"\n", fil), exit(1); + if (!fastback) { + wait_for_return(); } + + exit(0); } void callshell(char v[]) |