Enforce trailing slash in include paths

Fixes rednex#456
This commit is contained in:
ISSOtm
2020-01-13 16:21:13 +01:00
parent 86a28e8201
commit e50bcaa272

View File

@@ -316,7 +316,11 @@ void fstk_AddIncludePath(char *s)
if (NextIncPath == MAXINCPATHS) if (NextIncPath == MAXINCPATHS)
fatalerror("Too many include directories passed from command line"); fatalerror("Too many include directories passed from command line");
if (snprintf(IncludePaths[NextIncPath++], _MAX_PATH, "%s", // Find last occurrence of slash; is it at the end of the string?
char const *lastSlash = strrchr(s, '/');
char const *pattern = lastSlash && *(lastSlash + 1) == 0 ? "%s" : "%s/";
if (snprintf(IncludePaths[NextIncPath++], _MAX_PATH, pattern,
s) >= _MAX_PATH) s) >= _MAX_PATH)
fatalerror("Include path too long '%s'", s); fatalerror("Include path too long '%s'", s);
} }