summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyrill Gorcunov <gorcunov@gmail.com>2018-10-21 15:06:36 +0300
committerCyrill Gorcunov <gorcunov@gmail.com>2018-10-21 15:06:36 +0300
commiteb82f993679d8552d05bfc671bb3909c8f3f0573 (patch)
tree985ed6aacdda386224fa7c4bcbe814ca7b87d0df
parent1f620b8e8445d9f61a309f536e670e49adb16542 (diff)
parentfdb1a1b15130d858d51916cca7e09a2566c4b69f (diff)
downloadnasm-eb82f993679d8552d05bfc671bb3909c8f3f0573.tar.gz
Merge branch 'nasm-2.14.xx'
* nasm-2.14.xx: preproc: Make the preprocessor use nasm_catfile for include path: nasm_catfile -- Fix incorrect return of filename only
-rw-r--r--asm/preproc.c16
-rw-r--r--nasmlib/path.c12
2 files changed, 13 insertions, 15 deletions
diff --git a/asm/preproc.c b/asm/preproc.c
index 0c357d0f..6cae4a7a 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;
}
}
diff --git a/nasmlib/path.c b/nasmlib/path.c
index 9dadaba8..d228ed1e 100644
--- a/nasmlib/path.c
+++ b/nasmlib/path.c
@@ -164,7 +164,7 @@ char *nasm_catfile(const char *dir, const char *file)
#else
size_t dl = strlen(dir);
size_t fl = strlen(file);
- char *p;
+ char *p, *pp;
bool dosep = true;
if (!dl || ismatch(separators, dir[dl-1])) {
@@ -172,14 +172,14 @@ char *nasm_catfile(const char *dir, const char *file)
dosep = false;
}
- p = nasm_malloc(dl + fl + dosep + 1);
+ p = pp = nasm_malloc(dl + fl + dosep + 1);
- memcpy(p, dir, dl);
- p += dl;
+ memcpy(pp, dir, dl);
+ pp += dl;
if (dosep)
- *p++ = catsep;
+ *pp++ = catsep;
- memcpy(p, file, fl+1);
+ memcpy(pp, file, fl+1);
return p;
#endif