~subsetpark/erasmus

ref: 58b6093f4a747276713c208c76a9ce77badc1ee3 erasmus/src/util.zig -rw-r--r-- 368 bytes
58b6093f — Zach Smith Add util 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
pub fn nextLine(reader: anytype, buffer: []u8) !?[]const u8 {
    var line = (try reader.readUntilDelimiterOrEof(
        buffer,
        '\n',
    )) orelse return null;
    // trim annoying windows-only carriage return character
    if (@import("builtin").os.tag == .windows) {
        return mem.trimRight(u8, line, "\r");
    } else {
        return line;
    }
}