mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 07:46:12 +03:00
cli: strip CR in line iterator
This commit is contained in:
@ -712,8 +712,8 @@ pub fn LineIterator(comptime ReaderType: type) type {
|
|||||||
unreachable;
|
unreachable;
|
||||||
} orelse return null;
|
} orelse return null;
|
||||||
|
|
||||||
// Trim any whitespace around it
|
// Trim any whitespace (including CR) around it
|
||||||
const trim = std.mem.trim(u8, entry, whitespace);
|
const trim = std.mem.trim(u8, entry, whitespace ++ "\r");
|
||||||
if (trim.len != entry.len) {
|
if (trim.len != entry.len) {
|
||||||
std.mem.copyForwards(u8, entry, trim);
|
std.mem.copyForwards(u8, entry, trim);
|
||||||
entry = entry[0..trim.len];
|
entry = entry[0..trim.len];
|
||||||
@ -833,3 +833,14 @@ test "LineIterator spaces around '='" {
|
|||||||
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
||||||
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "LineIterator with CRLF line endings" {
|
||||||
|
const testing = std.testing;
|
||||||
|
var fbs = std.io.fixedBufferStream("A\r\nB = C\r\n");
|
||||||
|
|
||||||
|
var iter = lineIterator(fbs.reader());
|
||||||
|
try testing.expectEqualStrings("--A", iter.next().?);
|
||||||
|
try testing.expectEqualStrings("--B=C", iter.next().?);
|
||||||
|
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
||||||
|
try testing.expectEqual(@as(?[]const u8, null), iter.next());
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user