mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Enforce trailing slash in include paths
Fixes rednex#456
This commit is contained in:
@@ -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);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user