From a7bf5c70f943fdd9d6c956da5aeb347bd1f54120 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Sun, 27 Mar 2022 22:12:38 -0400 Subject: remove global variable buf --- menudriver.c | 20 ++++++++++---------- 1 file 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); -- cgit v1.2.1