From 3bcc4fc3860d319fb2d211f26a2ca3e43778e9f5 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 21 Nov 2022 14:40:55 -0800 Subject: [PATCH] Other suggested changes. --- src/base/main/libSupport.c | 19 +++++++++++++------ src/misc/extra/extraUtilUtil.c | 10 +++++++--- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/base/main/libSupport.c b/src/base/main/libSupport.c index 4d7624133..cdab69ee7 100644 --- a/src/base/main/libSupport.c +++ b/src/base/main/libSupport.c @@ -61,7 +61,7 @@ void open_libs() { DIR* dirp; struct dirent* dp; char *env, *init_p, *p; - int done; + //int done; env = getenv ("ABC_LIB_PATH"); if (env == NULL) { @@ -74,12 +74,14 @@ void open_libs() { } // Extract directories and read libraries - done = 0; + //done = 0; p = init_p; - while (!done) { + //while (!done) { + for (;;) { char *endp = strchr (p,':'); - if (endp == NULL) done = 1; // last directory in the list - else *endp = 0; // end of string + //if (endp == NULL) done = 1; // last directory in the list + //else *endp = 0; // end of string + if (endp != NULL) *endp = 0; // end of string dirp = opendir(p); if (dirp == NULL) { @@ -119,7 +121,12 @@ void open_libs() { } } closedir(dirp); - p = endp+1; + //p = endp+1; + if (endp == NULL) { + break; // last directory in the list + } else { + p = endp+1; + } } ABC_FREE(init_p); diff --git a/src/misc/extra/extraUtilUtil.c b/src/misc/extra/extraUtilUtil.c index 2f0f4559b..7a9e8fd0b 100644 --- a/src/misc/extra/extraUtilUtil.c +++ b/src/misc/extra/extraUtilUtil.c @@ -280,7 +280,7 @@ char * Extra_UtilFileSearch(char *file, char *path, char *mode) save_path = path = Extra_UtilStrsav(path); quit = 0; - do { + for (;;) { cp = strchr(path, ':'); if (cp != 0) { *cp = '\0'; @@ -304,8 +304,12 @@ char * Extra_UtilFileSearch(char *file, char *path, char *mode) return filename; } ABC_FREE(filename); - path = ++cp; - } while (! quit); + if (quit) { + break; + } else { + path = ++cp; + } + } ABC_FREE(save_path); return 0;