summaryrefslogtreecommitdiff
path: root/core/diff.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/diff.zig')
-rw-r--r--core/diff.zig7
1 files changed, 5 insertions, 2 deletions
diff --git a/core/diff.zig b/core/diff.zig
index 659576d3..edf037fe 100644
--- a/core/diff.zig
+++ b/core/diff.zig
@@ -294,11 +294,14 @@ fn range(line: []const u8, at: *usize) ?[2]usize {
return .{ start, 1 };
}
+/// A header's number: a line of a file, or a count of them, so a u32 (no
+/// file pardes opens has more lines); one past it makes the line no header,
+/// where the walk's count would overflow (a crafted `+18446744073709551615`).
fn number(line: []const u8, at: *usize) ?usize {
const from = at.*;
- var n: usize = 0;
+ var n: u32 = 0;
while (at.* < line.len and std.ascii.isDigit(line[at.*])) : (at.* += 1)
- n = std.math.add(usize, std.math.mul(usize, n, 10) catch return null, line[at.*] - '0') catch return null;
+ n = std.math.add(u32, std.math.mul(u32, n, 10) catch return null, line[at.*] - '0') catch return null;
return if (at.* > from) n else null;
}