From e6236e5c3edad07c8e347007bb3fb9f7d14dc7f9 Mon Sep 17 00:00:00 2001 From: Hyp-X Date: Mon, 1 Aug 2022 15:59:00 +0200 Subject: [PATCH 1/4] Update user32.odin Added UnregisterClassW procedure to windows\user32.odin --- core/sys/windows/user32.odin | 1 + 1 file changed, 1 insertion(+) diff --git a/core/sys/windows/user32.odin b/core/sys/windows/user32.odin index 47de354b6..d0a0d5b0a 100644 --- a/core/sys/windows/user32.odin +++ b/core/sys/windows/user32.odin @@ -18,6 +18,7 @@ foreign user32 { RegisterClassW :: proc(lpWndClass: ^WNDCLASSW) -> ATOM --- RegisterClassExW :: proc(^WNDCLASSEXW) -> ATOM --- + UnregisterClassW :: proc(lpClassName: LPCWSTR, hInstance: HINSTANCE) -> BOOL --- CreateWindowExW :: proc( dwExStyle: DWORD, From 28ec50d567c748e9e0deb14f6d1ff6993e02a329 Mon Sep 17 00:00:00 2001 From: Atanas Dimitrov Date: Wed, 3 Aug 2022 16:09:36 +0300 Subject: [PATCH 2/4] Fix string orderings to account for prefix-equal strings --- core/runtime/internal.odin | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/runtime/internal.odin b/core/runtime/internal.odin index 30798f623..16af84ebc 100644 --- a/core/runtime/internal.odin +++ b/core/runtime/internal.odin @@ -341,7 +341,12 @@ string_eq :: proc "contextless" (lhs, rhs: string) -> bool { string_cmp :: proc "contextless" (a, b: string) -> int { x := transmute(Raw_String)a y := transmute(Raw_String)b - return memory_compare(x.data, y.data, min(x.len, y.len)) + + ret := memory_compare(x.data, y.data, min(x.len, y.len)) + if ret == 0 && x.len != y.len { + return -1 if x.len < y.len else +1 + } + return ret } string_ne :: #force_inline proc "contextless" (a, b: string) -> bool { return !string_eq(a, b) } From 4cb489b9e43e6934f69886db3a10bce9d3524970 Mon Sep 17 00:00:00 2001 From: Atanas Dimitrov Date: Wed, 3 Aug 2022 16:22:54 +0300 Subject: [PATCH 3/4] Fix sort.compare_strings for prefixes --- core/sort/sort.odin | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/sort/sort.odin b/core/sort/sort.odin index 2ce74294d..a2b4d7ea0 100644 --- a/core/sort/sort.odin +++ b/core/sort/sort.odin @@ -684,5 +684,10 @@ compare_f64s :: proc(a, b: f64) -> int { compare_strings :: proc(a, b: string) -> int { x := transmute(mem.Raw_String)a y := transmute(mem.Raw_String)b - return mem.compare_byte_ptrs(x.data, y.data, min(x.len, y.len)) + + ret := mem.compare_byte_ptrs(x.data, y.data, min(x.len, y.len)) + if ret == 0 && x.len != y.len { + return -1 if x.len < y.len else +1 + } + return ret } From dbec4b0d0e4395e22e178a3fea91b6bfdcd52c61 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Wed, 3 Aug 2022 11:49:42 -0400 Subject: [PATCH 4/4] fixed memory leak from calling get_env --- core/os/os2/user.odin | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/os/os2/user.odin b/core/os/os2/user.odin index 1fb653b85..00cccd2a7 100644 --- a/core/os/os2/user.odin +++ b/core/os/os2/user.odin @@ -6,19 +6,19 @@ import "core:runtime" user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) { #partial switch ODIN_OS { case .Windows: - dir = get_env("LocalAppData") + dir = get_env("LocalAppData", allocator) if dir != "" { dir = strings.clone_safe(dir, allocator) or_return } case .Darwin: - dir = get_env("HOME") + dir = get_env("HOME", allocator) if dir != "" { dir = strings.concatenate_safe({dir, "/Library/Caches"}, allocator) or_return } case: // All other UNIX systems - dir = get_env("XDG_CACHE_HOME") + dir = get_env("XDG_CACHE_HOME", allocator) if dir == "" { - dir = get_env("HOME") + dir = get_env("HOME", allocator) if dir == "" { return } @@ -34,19 +34,19 @@ user_cache_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) { #partial switch ODIN_OS { case .Windows: - dir = get_env("AppData") + dir = get_env("AppData", allocator) if dir != "" { dir = strings.clone_safe(dir, allocator) or_return } case .Darwin: - dir = get_env("HOME") + dir = get_env("HOME", allocator) if dir != "" { dir = strings.concatenate_safe({dir, "/Library/Application Support"}, allocator) or_return } case: // All other UNIX systems - dir = get_env("XDG_CACHE_HOME") + dir = get_env("XDG_CACHE_HOME", allocator) if dir == "" { - dir = get_env("HOME") + dir = get_env("HOME", allocator) if dir == "" { return } @@ -59,13 +59,13 @@ user_config_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Erro return } -user_home_dir :: proc() -> (dir: string, err: Error) { +user_home_dir :: proc(allocator: runtime.Allocator) -> (dir: string, err: Error) { env := "HOME" #partial switch ODIN_OS { case .Windows: env = "USERPROFILE" } - if v := get_env(env); v != "" { + if v := get_env(env, allocator); v != "" { return v, nil } return "", .Invalid_Path