diff --git a/src/compiler.c b/src/compiler.c index 383ab5e..60db30c 100644 --- a/src/compiler.c +++ b/src/compiler.c @@ -242,7 +242,7 @@ static int compile_module_with_dependencies(ModuleFileStack* unit, module_ref->module_path = mem_new_g_array(MemoryNamespaceOpt, sizeof(char*)); } - module_ref_push(module_ref, g_filename_display_basename(file->path)); + module_ref_push(module_ref, module_from_basename(file->path)); GHashTable* imports = mem_new_g_hash_table(MemoryNamespaceAst, g_str_hash, g_str_equal); @@ -370,7 +370,7 @@ static int compile_module_with_dependencies(ModuleFileStack* unit, continue; } - module_ref_push(module_ref, g_filename_display_basename(path)); + module_ref_push(module_ref, module_from_basename(path)); ModuleFile* imported_file = push_file(unit, path); AST_NODE_PTR imported_module = diff --git a/src/io/files.c b/src/io/files.c index dd4d960..aabaef0 100644 --- a/src/io/files.c +++ b/src/io/files.c @@ -58,6 +58,17 @@ ModuleFile* push_file(ModuleFileStack* stack, const char* path) { return new_file; } +char* module_from_basename(char* path) { + char* basename = g_path_get_basename(path); + char* dot = strrchr(basename, '.'); + + if (dot != NULL) { + *dot = '\0'; + } + + return basename; +} + void delete_files(ModuleFileStack* stack) { for (size_t i = 0; i < stack->files->len; i++) { const ModuleFile* file = g_array_index(stack->files, ModuleFile*, i); diff --git a/src/io/files.h b/src/io/files.h index 6f31108..94ce4ed 100644 --- a/src/io/files.h +++ b/src/io/files.h @@ -42,6 +42,8 @@ typedef struct TokenLocation_t { ModuleRef* module_ref; } TokenLocation; +char* module_from_basename(char* path); + /** * @brief Create a new, empty file stack. * @return