-
Notifications
You must be signed in to change notification settings - Fork 4
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
Add (very basic) support for replace #1
Conversation
e276978
to
e216d5b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is amazing!! Thank you!
I have some simplifying suggestions and a few nits.
- There is no reason for the replacement to share lifetime with the subject, because the replacement is not present in the return value, even if no replacement occured
This fixes the following issue in replace_impl: the call to try_reserve passed in a difference of capacities, but try_reserve expects a difference between the desired capacity and the length. Because the initial capacity was nonzero but the length was zero, this caused us to reserve less capacity than we ought to have, leading to an OOB write. Fix this by reworking replace_impl to have less unsafe code. Now we zero initialize the buffer, but we also prefer a stack buffer so we may save an allocation - probably a wash overall. Add a test for this case.
oof, that's on me for not properly testing this, and misreading the documentation. I think I had too much faith in fish's |
@ridiculousfish I also think you merged this to the wrong repository, you merged it to https://github.com/ridiculousfish/rust-pcre2 instead of https://github.com/fish-shell/rust-pcre2 |
Whoops! Thanks, merged to https://github.com/fish-shell/rust-pcre2 |
See fish-shell/fish-shell#9854