diff options
author | Jakob Kaivo <jkk@ung.org> | 2022-03-27 22:12:38 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2022-03-27 22:12:38 -0400 |
commit | a7bf5c70f943fdd9d6c956da5aeb347bd1f54120 (patch) | |
tree | 7b2b37bed78efdf865177d1a134856d7d2b88bd7 | |
parent | 435d1aeca82f2ae9736511951bbe48d212f30d1e (diff) |
remove global variable buf
-rw-r--r-- | menudriver.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/menudriver.c b/menudriver.c index c050d1c..63fed32 100644 --- a/menudriver.c +++ b/menudriver.c @@ -26,8 +26,6 @@ #endif #endif -struct stat buf; - char *menuviewer; char *viewer = "less"; @@ -118,7 +116,8 @@ void menudrive(char *dir) singleton(dir); /* apparently not a directory */ } - while (stat("contents", &buf) == 0) { + struct stat st; + while (stat("contents", &st) == 0) { if (next[0] == '\0' || bad) { clrscr(); @@ -180,29 +179,29 @@ void menudrive(char *dir) (void)sprintf(next, "%d", val - 1); } - if (stat(next, &buf) == 0) { + if (stat(next, &st) == 0) { if (strcmp(next, ".") == 0 || strcmp(next, "..") == 0 || index(next, '/')) { bad = 1; continue; } /* no pathnames - see below */ - if (S_ISDIR(buf.st_mode)) { /* directory */ + if (S_ISDIR(st.st_mode)) { /* directory */ char hold[PATH_MAX]; if (!getcwd(hold, sizeof(hold))) { fprintf(stderr, "panic: cwd too long\n"), exit(1); } - if (chdir(next) == -1 || stat("contents", &buf)) { + if (chdir(next) == -1 || stat("contents", &st)) { bad = 1, chdir(hold); } else { strcpy(last, next), pushlast(), next[0] = '\0'; } - } else if (S_ISREG(buf.st_mode)) { /* regular file */ + } else if (S_ISREG(st.st_mode)) { /* regular file */ clrscr(); #ifndef UWIN - if (buf.st_mode & S_IXUSR) /* executable (by owner) */ + if (st.st_mode & S_IXUSR) /* executable (by owner) */ #else if (strcmp(next, "99") == 0) #endif @@ -308,11 +307,12 @@ void menudrive(char *dir) void singleton(char *fil) { - if (stat(fil, &buf) == 0 && S_ISREG(buf.st_mode)) { /* regular file */ + struct stat st; + if (stat(fil, &st) == 0 && S_ISREG(st.st_mode)) { /* regular file */ clrscr(); #ifndef UWIN - if (buf.st_mode & S_IXUSR) { /* executable (by owner) */ + if (st.st_mode & S_IXUSR) { /* executable (by owner) */ strcpy(cmd, "./"); strcat(cmd, fil); system(cmd); |