aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornight199uk <night199uk@hermitcrabslab.com>2018-10-18 23:19:47 +0200
committerCyrill Gorcunov <gorcunov@gmail.com>2018-10-19 01:00:11 +0300
commitfdb1a1b15130d858d51916cca7e09a2566c4b69f (patch)
treebc9a909a12e64bebee76f573822e3353015ffab0
parente1bd3bc7b497d58efc1c7a5c56dbc591d5be880f (diff)
downloadnasm-fdb1a1b15130d858d51916cca7e09a2566c4b69f.tar.gz
nasm-fdb1a1b15130d858d51916cca7e09a2566c4b69f.tar.xz
nasm-fdb1a1b15130d858d51916cca7e09a2566c4b69f.zip
preproc: Make the preprocessor use nasm_catfile for include
All include paths to nasm must already have a trailing separator prefix which is uncommon among tools. Change to using nasm_catfile which gives a more normal behaviour. https://bugzilla.nasm.us/show_bug.cgi?id=3392205 Signed-off-by: night199uk <night199uk@hermitcrabslab.com> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
-rw-r--r--asm/preproc.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/asm/preproc.c b/asm/preproc.c
index cdf03bc1..0174c9ab 100644
--- a/asm/preproc.c
+++ b/asm/preproc.c
@@ -1515,19 +1515,18 @@ static FILE *inc_fopen_search(const char *file, StrList **slpath,
FILE *fp;
char *prefix = "";
const IncPath *ip = ipath;
- int len = strlen(file);
- size_t prefix_len = 0;
+ int len;
StrList *sl;
- size_t path_len;
+ char *sp;
bool found;
while (1) {
- path_len = prefix_len + len + 1;
-
- sl = nasm_malloc(path_len + sizeof sl->next);
- memcpy(sl->str, prefix, prefix_len);
- memcpy(sl->str+prefix_len, file, len+1);
+ sp = nasm_catfile(prefix, file);
+ len = strlen(sp) + 1;
+ sl = nasm_malloc(len + sizeof sl->next);
+ memcpy(sl->str, sp, len);
sl->next = NULL;
+ nasm_free(sp);
if (omode == INC_PROBE) {
fp = NULL;
@@ -1547,7 +1546,6 @@ static FILE *inc_fopen_search(const char *file, StrList **slpath,
return NULL;
prefix = ip->path;
- prefix_len = strlen(prefix);
ip = ip->next;
}
}