Merge branch 'actually-avoid-traversing-home' into 'next'

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

See merge request STJr/SRB2!2493
This commit is contained in:
sphere 2024-07-01 17:03:06 +00:00
commit fd4e69425e
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