From 81e4c4e6f07247e64b33d874f11f217bdeef5878 Mon Sep 17 00:00:00 2001 From: Ryan Liptak Date: Mon, 21 Oct 2024 00:38:25 -0700 Subject: [PATCH] cvtres: Fix resource name sorting on big endian hosts --- src/cvtres.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cvtres.zig b/src/cvtres.zig index 651879c..2016adb 100644 --- a/src/cvtres.zig +++ b/src/cvtres.zig @@ -532,7 +532,15 @@ const ResourceTree = struct { } switch (a) { .name => { - return std.mem.lessThan(u16, a.name, b.name); + const n = @min(a.name.len, b.name.len); + for (a.name[0..n], b.name[0..n]) |a_c, b_c| { + switch (std.math.order(std.mem.littleToNative(u16, a_c), std.mem.littleToNative(u16, b_c))) { + .eq => continue, + .lt => return true, + .gt => return false, + } + } + return a.name.len < b.name.len; }, .ordinal => { return a.ordinal < b.ordinal;