mirror of
https://github.com/netwide-assembler/nasm.git
synced 2025-01-30 16:41:05 +08:00
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
This commit is contained in:
commit
eb82f99367
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user