Repository navigation
Fix indexing in some parsing helpers - #324
Merged
Merged
Conversation
These cases reproduce each incorrect result before the implementation changes. Co-authored-by: Thomas Gazagnaire <thomas@gazagnaire.org>
Writing at the compacted index avoids gaps when earlier bytes are dropped.
Reducing the view by one removes only its final byte and keeps singleton tails valid.
Using the separator and absolute view offsets returns the correct pieces from reverse scans.
Adding the source view offset points each returned slice at the matched bytes.
Member
|
LGTM |
jmid
pushed a commit
to ocaml/opam-repository
that referenced
this pull request
Sep 6, 2026
CHANGES: - Fix indexing and subview offset handling in `filter_map`, reverse `tail` and `cuts`, and `find`/`find_sub` (@avsm, @samoht, mirage/ocaml-cstruct#324)
dinosaure
reviewed
Sep 10, 2026
| Alcotest.(check ls) "59" (cuts ~empty:false ~sep:"aa" "aaaaaa") []; | ||
| Alcotest.(check ls) "rev 0" (cuts ~rev:true ~empty:true ~sep:"," "") [""] ; | ||
| Alcotest.(check ls) "rev 1" (cuts ~rev:true ~empty:false ~sep:"," "") [] ; | ||
| Alcotest.(check ls) "rev 2" (cuts ~rev:true ~empty:true ~sep:"," "") [""]; |
dinosaure
reviewed
Sep 10, 2026
| Alcotest.(check ls) "rev 0" (cuts ~rev:true ~empty:true ~sep:"," "") [""] ; | ||
| Alcotest.(check ls) "rev 1" (cuts ~rev:true ~empty:false ~sep:"," "") [] ; | ||
| Alcotest.(check ls) "rev 2" (cuts ~rev:true ~empty:true ~sep:"," "") [""]; | ||
| Alcotest.(check ls) "rev 3" (cuts ~rev:true ~empty:false ~sep:"," "") []; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This corrects indexing and offset handling in
filter_map, reversetailandcuts, andfind/find_subon subviews.It also adds regression coverage for forward and reverse parsing behavior and returned view offsets. Reviewed also by @samoht