font: handle CRLF line endings in octants.txt parsing
Trim trailing \r when splitting octants.txt by \n at comptime. On Windows, git may convert LF to CRLF on checkout, leaving \r at the end of each line. Without trimming, the parser tries to use \r as a struct field name in @field(), causing a compile error. Follows the same pattern used in x11_color.zig for rgb.txt parsing.pull/11839/head
parent
fead488d23
commit
650b9d470a
|
|
@ -102,7 +102,14 @@ pub fn draw1CD00_1CDE5(
|
|||
|
||||
const data = @embedFile("octants.txt");
|
||||
var it = std.mem.splitScalar(u8, data, '\n');
|
||||
while (it.next()) |line| {
|
||||
while (it.next()) |raw_line| {
|
||||
// Trim \r so this works with both LF and CRLF line endings,
|
||||
// since git may convert octants.txt to CRLF on Windows checkouts.
|
||||
const line = if (raw_line.len > 0 and raw_line[raw_line.len - 1] == '\r')
|
||||
raw_line[0 .. raw_line.len - 1]
|
||||
else
|
||||
raw_line;
|
||||
|
||||
// Skip comments
|
||||
if (line.len == 0 or line[0] == '#') continue;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue