diff options
| author | Ryan Liptak <squeek502@hotmail.com> | 2025-10-03 01:18:53 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2025-10-08 16:42:55 -0700 |
| commit | 328ae41468f3514251ac1b0726c41eca9fbc3fb5 (patch) | |
| tree | 32315d9cc319b31a88afb68b0d5b7448b64cbf2d /lib/std/math | |
| parent | 60be67d3c0ba6ae15fa7115596734ab1e74fbcd3 (diff) | |
| download | zig-328ae41468f3514251ac1b0726c41eca9fbc3fb5.tar.gz zig-328ae41468f3514251ac1b0726c41eca9fbc3fb5.zip | |
Reader.peekDelimiterInclusive: Fix handling of `stream` implementations that return 0
Previously, the logic in peekDelimiterInclusive (when the delimiter was not found in the existing buffer) used the `n` returned from `r.vtable.stream` as the length of the slice to check, but it's valid for `vtable.stream` implementations to return 0 if they wrote to the buffer instead of `w`. In that scenario, the `indexOfScalarPos` would be given a 0-length slice so it would never be able to find the delimiter.
This commit changes the logic to assume that `r.vtable.stream` can both:
- return 0, and
- modify seek/end (i.e. it's also valid for a `vtable.stream` implementation to rebase)
Also introduces `std.testing.ReaderIndirect` which helps in being able to test against Reader implementations that return 0 from `stream`/`readVec`
Fixes #25428
Diffstat (limited to 'lib/std/math')
0 files changed, 0 insertions, 0 deletions
