From 385af149dc68c7447300bae0a32162635320c00d Mon Sep 17 00:00:00 2001 From: Mustafa Quraish Date: Mon, 25 Mar 2024 00:16:00 -0400 Subject: [PATCH] fix linux build --- bootstrap/stage0.c | 2 +- compiler/parser.oc | 2 +- tests/custom_varargs_functions.oc | 7 ++++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bootstrap/stage0.c b/bootstrap/stage0.c index c3651d7..fdc18b1 100644 --- a/bootstrap/stage0.c +++ b/bootstrap/stage0.c @@ -8966,7 +8966,7 @@ void compiler_parser_Parser_create_namespaces_for_initial_file(compiler_parser_P std_map_Map__4_insert(cur_ns->namespaces, base, new_ns); cur_ns=new_ns; } - char *file_base = basename(filename); + char *file_base = strdup(basename(filename)); if (str_ends_with(file_base, ".oc")) { file_base[(strlen(file_base) - 3)]='\0'; } diff --git a/compiler/parser.oc b/compiler/parser.oc index f196e14..b9c8b24 100644 --- a/compiler/parser.oc +++ b/compiler/parser.oc @@ -2130,7 +2130,7 @@ def Parser::create_namespaces_for_initial_file(&this, filename: str, single_file } // Remove file extension - let file_base = basename(filename) + let file_base = basename(filename).copy() if file_base.ends_with(".oc") { file_base[file_base.len() - 3] = '\0' } diff --git a/tests/custom_varargs_functions.oc b/tests/custom_varargs_functions.oc index 9fdba89..62e9ceb 100644 --- a/tests/custom_varargs_functions.oc +++ b/tests/custom_varargs_functions.oc @@ -1,3 +1,5 @@ +/// out: "a b!\na, b\n3 = 28\n" + import std::variadic::{ VarArgs, vprintf } [variadic_format] @@ -8,7 +10,6 @@ def my_print(fmt: str, ...) { args.end() } -[formatting "%s %s" "$.str, $.len"] [variadic_format] def my_println(fmt: str, ...) { let args: VarArgs @@ -19,7 +20,7 @@ def my_println(fmt: str, ...) { } def main() { - my_print("Hello, %s!\n", "world") - my_println("Hello, %s!", "world") + my_print("a %s!\n", "b") + my_println("a, %s", "b") my_println(`{1+2} = {7*4}`) } \ No newline at end of file