summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-03-27 22:41:26 -0400
committerJakob Kaivo <jkk@ung.org>2022-03-27 22:41:26 -0400
commit4232bd5a9b3f4152fa7983e721b7807c2eabe8a3 (patch)
tree831664c3df591e1f3bb5cc6dbb4cfcae042e3466
parent21ad08b05f88f9282cd03278968b1bafef0bef39 (diff)
clean up singleton()
-rw-r--r--menudriver.c38
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[])