Correctly resolve '../' paths
This commit is contained in:
parent
3444d1652d
commit
df61a0805f
@ -29,7 +29,7 @@ public char *resolve_path(const char *path, const char *relative_to, const char
|
||||
if (streq(path, "~") || starts_with(path, "~/")) {
|
||||
char *resolved = realpath(heap_strf("%s%s", getenv("HOME"), path+1), buf);
|
||||
if (resolved) return GC_strdup(resolved);
|
||||
} else if (streq(path, ".") || starts_with(path, "./")) {
|
||||
} else if (streq(path, ".") || starts_with(path, "./") || starts_with(path, "../")) {
|
||||
char *relative_dir = dirname(GC_strdup(relative_to));
|
||||
char *resolved = realpath(heap_strf("%s/%s", relative_dir, path), buf);
|
||||
if (resolved) return GC_strdup(resolved);
|
||||
|
2
tomo.c
2
tomo.c
@ -326,7 +326,7 @@ void build_file_dependency_graph(const char *filename, Table_t *to_compile, Tabl
|
||||
case USE_LOCAL: {
|
||||
const char *path = use->path;
|
||||
path = resolve_path(path, filename, "");
|
||||
if (!path) errx(1, "Couldn't resolve import: %s", use->path);
|
||||
if (!path) errx(1, "Couldn't resolve import: %s relative to: %s", use->path, filename);
|
||||
if (Table$str_get(*to_compile, path))
|
||||
continue;
|
||||
build_file_dependency_graph(path, to_compile, to_link);
|
||||
|
Loading…
Reference in New Issue
Block a user