ref: 097e4c979953e913a1431b6d5ece672959afa29f
parent: 2c37a1e9714ca640fa685a78a0865988b333a953
parent: e50bcaa2725a3538433455fed617f198fed7b47d
author: Eldred Habert <eldredhabert0@gmail.com>
date: Thu Jan 16 14:18:00 EST 2020
Merge pull request #468 from ISSOtm/include_stem Enforce trailing slash in include paths
--- a/src/asm/fstack.c
+++ b/src/asm/fstack.c
@@ -316,7 +316,11 @@
if (NextIncPath == MAXINCPATHS)
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)
fatalerror("Include path too long '%s'", s);
}