Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strings/textscanner: fix off-by-one error in textscanner skip #21045

Merged
merged 1 commit into from
Mar 17, 2024

Conversation

kimshrier
Copy link
Contributor

The skip function would not increment the current position if the current position was pointing to the last character in the input. As a result, you could not skip to the end of input. And, this means that you cannot detect end of input if you are using the skip function to move the current position forward.

Looking at the skip_n function, you can skip to the end of input.

This change makes skip and skip_n(1) work the same way and have the same semantics.

I have also updated the unit tests to detect proper behavior when reaching the end of input.

@spytheman spytheman merged commit d7cc6f5 into vlang:master Mar 17, 2024
48 checks passed
@kimshrier kimshrier deleted the textscanner_skip_fix branch April 12, 2024 04:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants