commit 7208ca510cbab5d91c566c053b27f554617cfe16 (tree)
parent f26cdb2771a4bb4d5f1d5acc446ec51c3e177f75
Author: Ryan Liptak <squeek502@noreply.codeberg.org>
Date: Wed, 24 Jun 2026 11:34:35 +0200
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>
Diffstat:
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/std/zig/LibCInstallation.zig b/lib/std/zig/LibCInstallation.zig
@@ -46,7 +46,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const
const field_names = comptime std.meta.fieldNames(LibCInstallation);
const FoundKey = struct {
found: bool,
- allocated: ?[:0]u8,
+ allocated: ?[]u8,
};
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
const contents = try Io.Dir.cwd().readFileAlloc(io, libc_file, allocator, .limited(std.math.maxInt(usize)));
defer allocator.free(contents);
- var it = std.mem.tokenizeScalar(u8, contents, '\n');
+ var it = std.mem.tokenizeAny(u8, contents, "\n\r");
while (it.next()) |line| {
if (line.len == 0 or line[0] == '#') continue;
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
if (value.len == 0) {
@field(self, field_name) = null;
} else {
- found_keys[i].allocated = try allocator.dupeSentinel(u8, value, 0);
+ found_keys[i].allocated = try allocator.dupe(u8, value);
@field(self, field_name) = found_keys[i].allocated;
}
break;