-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix bug in SubstitutionString replace #30513
Conversation
Incorrect indentation and overly long line
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.
Thanks. I think the following comment by @digital-carver at #27125 needs to be taken into account, though:
There's a change in behaviour due to this though: invalid single letter sequences like
\m
,\j
, etc. are silently replaced by their corresponding character (m
,j
, ...) byunescape_string
, whereas currently_replace
emits the "Bad replacement string" error for those. Perhapsunescape_string
needs another optional argument to enable astrict
mode, or... is there a reasonunescape_string
is currently not strict about invalid C sequences, while it errors out on invalid Unicode sequences?
Thanks for your review @nalimilan. I thought the following comment has already been merged in pull request #27238 ?
|
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.
Thanks!
I realize that if performance really matters it could be more efficient to pass a function instead of an array of characters: c -> c == '\\' || c == 'g' || '0' <= c <= '9'
would need fewer operations. But that probably doesn't matter a lot.
Thanks for approving this PR @nalimilan. I think it is better to allow array of characters for making the usage of this function easier. |
Hi @StefanKarpinski @nalimilan , just came in to see if this could be merged. |
Bump. @StefanKarpinski ok to merge? (needs rebase tho) |
Can be squash-merged if CI passes. |
fixes #27125