diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-08-05 00:12:13 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-08-05 15:50:13 +0200 |
commit | 506cc372436f6b03ac79762e66e307bb4c5a28ea (patch) | |
tree | 69675c7066381954a272bd62feb156f10c07168c /compiler.c | |
parent | 54b7fac1af2704ec464a290b099cee8cf96c19f1 (diff) |
compiler: fix deriving module path from source runpath
The current implementation of `uc_compiler_canonicalize_path()` used the
entire runtime path of the source object as path prefix, not just the
directory part of it.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'compiler.c')
-rw-r--r-- | compiler.c | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -3169,14 +3169,14 @@ uc_compiler_compile_module_source(uc_compiler_t *compiler, uc_source_t *source, } static char * -uc_compiler_canonicalize_path(const char *path, const char *basedir) +uc_compiler_canonicalize_path(const char *path, const char *runpath) { char *p, *resolved; if (*path == '/') xasprintf(&p, "%s", path); - else if (basedir) - xasprintf(&p, "%s/%s", basedir, path); + else if (runpath && (p = strrchr(runpath, '/')) != NULL) + xasprintf(&p, "%.*s/%s", (int)(p - runpath), runpath, path); else xasprintf(&p, "./%s", path); @@ -3188,7 +3188,7 @@ uc_compiler_canonicalize_path(const char *path, const char *basedir) } static char * -uc_compiler_expand_module_path(const char *name, const char *basedir, const char *template) +uc_compiler_expand_module_path(const char *name, const char *runpath, const char *template) { int namelen, prefixlen; char *path, *p; @@ -3207,7 +3207,7 @@ uc_compiler_expand_module_path(const char *name, const char *basedir, const char if (*p == '.') *p = '/'; - p = uc_compiler_canonicalize_path(path, basedir); + p = uc_compiler_canonicalize_path(path, runpath); free(path); |