mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-03-08 02:44:43 +01:00
wasm-linker: fix splitSegmentName and add unit test
This commit is contained in:
parent
788b7f8f11
commit
d999a8e33b
1 changed files with 9 additions and 1 deletions
|
|
@ -1182,10 +1182,18 @@ fn emitProducerSection(gpa: Allocator, binary_bytes: *std.ArrayListUnmanaged(u8)
|
|||
|
||||
fn splitSegmentName(name: []const u8) struct { []const u8, []const u8 } {
|
||||
const start = @intFromBool(name.len >= 1 and name[0] == '.');
|
||||
const pivot = mem.indexOfScalarPos(u8, name, start, '.') orelse 0;
|
||||
const pivot = mem.indexOfScalarPos(u8, name, start, '.') orelse name.len;
|
||||
return .{ name[0..pivot], name[pivot..] };
|
||||
}
|
||||
|
||||
test splitSegmentName {
|
||||
{
|
||||
const a, const b = splitSegmentName(".data");
|
||||
try std.testing.expectEqualStrings(".data", a);
|
||||
try std.testing.expectEqualStrings("", b);
|
||||
}
|
||||
}
|
||||
|
||||
fn wantSegmentMerge(
|
||||
wasm: *const Wasm,
|
||||
a_id: Wasm.DataSegmentId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue