Skip to content

Commit

Permalink
cvtres: Fix resource name sorting on big endian hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
squeek502 committed Oct 21, 2024
1 parent 1a797d5 commit 81e4c4e
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cvtres.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 81e4c4e

Please sign in to comment.