| ... | @@ -46,7 +46,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const | ... | @@ -46,7 +46,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const |
| 46 | const field_names = comptime std.meta.fieldNames(LibCInstallation); | 46 | const field_names = comptime std.meta.fieldNames(LibCInstallation); |
| 47 | const FoundKey = struct { | 47 | const FoundKey = struct { |
| 48 | found: bool, | 48 | found: bool, |
| 49 | allocated: ?[:0]u8, | 49 | allocated: ?[]u8, |
| 50 | }; | 50 | }; |
| 51 | | 51 | |
| 52 | var found_keys: [field_names.len]FoundKey = @splat(.{ .found = false, .allocated = null }); | 52 | 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 | ... | @@ -60,7 +60,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const |
| 60 | const contents = try Io.Dir.cwd().readFileAlloc(io, libc_file, allocator, .limited(std.math.maxInt(usize))); | 60 | const contents = try Io.Dir.cwd().readFileAlloc(io, libc_file, allocator, .limited(std.math.maxInt(usize))); |
| 61 | defer allocator.free(contents); | 61 | defer allocator.free(contents); |
| 62 | | 62 | |
| 63 | var it = std.mem.tokenizeScalar(u8, contents, '\n'); | 63 | var it = std.mem.tokenizeAny(u8, contents, "\n\r"); |
| 64 | while (it.next()) |line| { | 64 | while (it.next()) |line| { |
| 65 | if (line.len == 0 or line[0] == '#') continue; | 65 | if (line.len == 0 or line[0] == '#') continue; |
| 66 | var line_it = std.mem.splitScalar(u8, line, '='); | 66 | 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 | ... | @@ -72,7 +72,7 @@ pub fn parse(allocator: Allocator, io: Io, libc_file: []const u8, target: *const |
| 72 | if (value.len == 0) { | 72 | if (value.len == 0) { |
| 73 | @field(self, field_name) = null; | 73 | @field(self, field_name) = null; |
| 74 | } else { | 74 | } else { |
| 75 | found_keys[i].allocated = try allocator.dupeSentinel(u8, value, 0); | 75 | found_keys[i].allocated = try allocator.dupe(u8, value); |
| 76 | @field(self, field_name) = found_keys[i].allocated; | 76 | @field(self, field_name) = found_keys[i].allocated; |
| 77 | } | 77 | } |
| 78 | break; | 78 | break; |