Don't traverse the entire HOME directory but for real this time

This commit is contained in:
Hanicef 2024-06-28 12:37:13 +02:00
parent 32bbc48be5
commit f713f5fdeb
2 changed files with 16 additions and 11 deletions

View file

@ -1390,8 +1390,8 @@ static const char *searchWad(const char *searchDir)
#define CHECKWADPATH(ret) \ #define CHECKWADPATH(ret) \
do { \ do { \
I_OutputMsg(",%s", returnWadPath); \ I_OutputMsg(",%s", ret); \
if (isWadPathOk(returnWadPath)) \ if (isWadPathOk(ret)) \
return ret; \ return ret; \
} while (0) } while (0)
@ -1416,7 +1416,9 @@ static const char *locateWad(void)
#ifndef NOCWD #ifndef NOCWD
// examine current dir // examine current dir
strcpy(returnWadPath, "."); strcpy(returnWadPath, ".");
CHECKWADPATH(NULL); I_OutputMsg(",%s", returnWadPath);
if (isWadPathOk(returnWadPath))
return NULL;
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
@ -1433,13 +1435,13 @@ static const char *locateWad(void)
#ifndef NOHOME #ifndef NOHOME
// find in $HOME // find in $HOME
I_OutputMsg(",HOME/" DEFAULTDIR);
if ((envstr = I_GetEnv("HOME")) != NULL) if ((envstr = I_GetEnv("HOME")) != NULL)
{ {
char *tmp = malloc(strlen(envstr) + sizeof(DEFAULTDIR)); char *tmp = malloc(strlen(envstr) + 1 + sizeof(DEFAULTDIR));
strcpy(tmp, envstr); strcpy(tmp, envstr);
strcat(tmp, "/");
strcat(tmp, DEFAULTDIR); strcat(tmp, DEFAULTDIR);
SEARCHWAD(envstr); CHECKWADPATH(tmp);
free(tmp); free(tmp);
} }
#endif #endif

View file

@ -3003,8 +3003,8 @@ static const char *searchWad(const char *searchDir)
#define CHECKWADPATH(ret) \ #define CHECKWADPATH(ret) \
do { \ do { \
I_OutputMsg(",%s", returnWadPath); \ I_OutputMsg(",%s", ret); \
if (isWadPathOk(returnWadPath)) \ if (isWadPathOk(ret)) \
return ret; \ return ret; \
} while (0) } while (0)
@ -3033,7 +3033,9 @@ static const char *locateWad(void)
#ifndef NOCWD #ifndef NOCWD
// examine current dir // examine current dir
strcpy(returnWadPath, "."); strcpy(returnWadPath, ".");
CHECKWADPATH(NULL); I_OutputMsg(",%s", returnWadPath);
if (isWadPathOk(returnWadPath))
return NULL;
#endif #endif
#ifdef __APPLE__ #ifdef __APPLE__
@ -3053,10 +3055,11 @@ static const char *locateWad(void)
I_OutputMsg(",HOME/" DEFAULTDIR); I_OutputMsg(",HOME/" DEFAULTDIR);
if ((envstr = I_GetEnv("HOME")) != NULL) if ((envstr = I_GetEnv("HOME")) != NULL)
{ {
char *tmp = malloc(strlen(envstr) + sizeof(DEFAULTDIR)); char *tmp = malloc(strlen(envstr) + 1 + sizeof(DEFAULTDIR));
strcpy(tmp, envstr); strcpy(tmp, envstr);
strcat(tmp, "/");
strcat(tmp, DEFAULTDIR); strcat(tmp, DEFAULTDIR);
SEARCHWAD(envstr); CHECKWADPATH(tmp);
free(tmp); free(tmp);
} }
#endif #endif