-
Notifications
You must be signed in to change notification settings - Fork 43
Re-port new integer-scanning utility methods #127
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
Merged
Merged
+57
−46
Conversation
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
This may help prevent ArrayIndexOutOfBounds randomly seen in CI. See ruby#125
* Parse base should be from current pointer so add that to the get calls. * Pull out ascii check into util method. * Rename curr local var to ptr to better match C version.
This is to align the base10 code with the freshly-ported base16 code. See ruby#125
Contributor
Author
Member
It does inside |
Contributor
Author
Aha, so it does! I will tweak this to move the final integer parse and |
This aligns with C code that does the final parse and curr update in strscan_parse_integer.
Member
|
Thanks! |
kou
pushed a commit
that referenced
this pull request
May 3, 2025
Fix GH-152 CRuby can walk off the end because there's always a null byte. In JRuby, the byte array is often (usually?) the exact size of the string. So we need to check if len++ walked off the end. This code was ported from a version by @byroot in #127 but I missed adding this check due to a lack of tests. A test is included for both "-" and "+" parsing.
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
May 8, 2025
(ruby/strscan#153) Fix ruby/strscan#152 CRuby can walk off the end because there's always a null byte. In JRuby, the byte array is often (usually?) the exact size of the string. So we need to check if len++ walked off the end. This code was ported from a version by @byroot in ruby/strscan#127 but I missed adding this check due to a lack of tests. A test is included for both "-" and "+" parsing. ruby/strscan@1abe4ca556
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 is a re-port of the C code from @byroot for fast base 10 and base 16 integer scanning.
In #125, @kou pointed out there's an intermittent failure in the JRuby extension. We were unable to confirm exactly the circumstances that cause that failure, but this re-port should at least help reduce the change it is a bug in the original Java code.