authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-06-24 11:34:35+02:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2026-06-24 11:34:35+02:00
log7208ca510cbab5d91c566c053b27f554617cfe16
treec77f226952d868bfb51b5e424db24d379ce10ea5
parentf26cdb2771a4bb4d5f1d5acc446ec51c3e177f75
parent00ea8a98973255deb5e44a722bc946976fda629d

Merge pull request 'std.zig.LibCInstallation: parse - tokenize CR, fix panic' (#35913) from cursedbythevoid/libcinstallation-parse-fixes into master

Reviewed-on: https://codeberg.org/ziglang/zig/pulls/35913 Reviewed-by: Ryan Liptak <squeek502@noreply.codeberg.org>

1 files changed, 3 insertions(+), 3 deletions(-)

lib/std/zig/LibCInstallation.zig+3-3
......@@ -46,7 +46,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const
4646 const field_names = comptime std.meta.fieldNames(LibCInstallation);
4747 const FoundKey = struct {
4848 found: bool,
49 allocated: ?[:0]u8,
49 allocated: ?[]u8,
5050 };
5151
5252 var found_keys: [field_names.len]FoundKey = @splat(.{ .found = false, .allocated = null });
......@@ -60,7 +60,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const
6060 const contents = try Io.Dir.cwd().readFileAlloc(io, libc_file, allocator, .limited(std.math.maxInt(usize)));
6161 defer allocator.free(contents);
6262
63 var it = std.mem.tokenizeScalar(u8, contents, '\n');
63 var it = std.mem.tokenizeAny(u8, contents, "\n\r");
6464 while (it.next()) |line| {
6565 if (line.len == 0 or line[0] == '#') continue;
6666 var line_it = std.mem.splitScalar(u8, line, '=');
......@@ -72,7 +72,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const
7272 if (value.len == 0) {
7373 @field(self, field_name) = null;
7474 } else {
75 found_keys[i].allocated = try allocator.dupeSentinel(u8, value, 0);
75 found_keys[i].allocated = try allocator.dupe(u8, value);
7676 @field(self, field_name) = found_keys[i].allocated;
7777 }
7878 break;