From 0ae7987ceccca9068d13022dd39cdce36180c606 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Thu, 27 Feb 2020 18:54:30 -0800 Subject: [PATCH] Printf debugging the .so search; fixed file truncation bug --- 4ed_search_list.cpp | 2 ++ platform_linux/linux_4ed.cpp | 2 +- platform_linux/linux_4ed_functions.cpp | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/4ed_search_list.cpp b/4ed_search_list.cpp index 9eecc551..976872c4 100644 --- a/4ed_search_list.cpp +++ b/4ed_search_list.cpp @@ -42,9 +42,11 @@ get_full_path(Arena *arena, Path_Search_List *search_list, String_Const_u8 relat u8 *path_base = relative_base - node_size; block_copy(path_base, node->string.str, node_size); String_Const_u8 name = SCu8(path_base, opl); + printf("get_full_path: trying %.*s\n", string_expand(name)); File_Attributes attribs = system_quick_file_attributes(arena, name); if (attribs.size > 0){ result = name; + printf("hit\n"); break; } } diff --git a/platform_linux/linux_4ed.cpp b/platform_linux/linux_4ed.cpp index 838f5c6c..1a481880 100644 --- a/platform_linux/linux_4ed.cpp +++ b/platform_linux/linux_4ed.cpp @@ -1666,7 +1666,7 @@ main(int argc, char **argv){ char custom_fail_version_msg[] = "Failed to load custom code due to a version mismatch. Try rebuilding with buildsuper."; char custom_fail_init_apis[] = "Failed to load custom code due to missing 'init_apis' symbol. Try rebuilding with buildsuper"; - Scratch_Block scratch(&linuxvars.tctx, Scratch_Share); + Scratch_Block scratch(&linuxvars.tctx); String_Const_u8 default_file_name = string_u8_litexpr("custom_4coder.so"); Path_Search_List search_list = {}; search_list_add_system_path(scratch, &search_list, SystemPath_CurrentDirectory); diff --git a/platform_linux/linux_4ed_functions.cpp b/platform_linux/linux_4ed_functions.cpp index 9d005377..689d9c89 100644 --- a/platform_linux/linux_4ed_functions.cpp +++ b/platform_linux/linux_4ed_functions.cpp @@ -212,7 +212,7 @@ system_save_file(Arena* scratch, char* file_name, String_Const_u8 data){ // TODO(inso): should probably put a \n on the end if it's a text file. - int fd = open(file_name, O_WRONLY|O_CREAT, 0666); + int fd = open(file_name, O_TRUNC|O_WRONLY|O_CREAT, 0666); if (fd != -1) { int bytes_written = write(fd, data.str, data.size); if (bytes_written == -1) {