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

Fix bug in SubstitutionString replace #30513

Merged
merged 14 commits into from
Aug 16, 2019
Merged

Conversation

sam0410
Copy link
Contributor

@sam0410 sam0410 commented Dec 25, 2018

fixes #27125

sam0410 and others added 2 commits December 26, 2018 03:26
Incorrect indentation and overly long line
Copy link
Member

@nalimilan nalimilan left a 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, ...) by unescape_string, whereas currently _replace emits the "Bad replacement string" error for those. Perhaps unescape_string needs another optional argument to enable a strict mode, or... is there a reason unescape_string is currently not strict about invalid C sequences, while it errors out on invalid Unicode sequences?

base/regex.jl Outdated Show resolved Hide resolved
base/strings/io.jl Outdated Show resolved Hide resolved
@sam0410
Copy link
Contributor Author

sam0410 commented Dec 28, 2018

Thanks for your review @nalimilan. I thought the following comment has already been merged in pull request #27238 ?

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, ...) by unescape_string, whereas currently _replace emits the "Bad replacement string" error for those. Perhaps unescape_string needs another optional argument to enable a strict mode, or... is there a reason unescape_string is currently not strict about invalid C sequences, while it errors out on invalid Unicode sequences?

NEWS.md Outdated Show resolved Hide resolved
base/strings/io.jl Outdated Show resolved Hide resolved
base/regex.jl Show resolved Hide resolved
base/strings/io.jl Outdated Show resolved Hide resolved
base/strings/io.jl Outdated Show resolved Hide resolved
Copy link
Member

@nalimilan nalimilan left a 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.

@sam0410
Copy link
Contributor Author

sam0410 commented Jan 21, 2019

Thanks for approving this PR @nalimilan. I think it is better to allow array of characters for making the usage of this function easier.

@sam0410
Copy link
Contributor Author

sam0410 commented Jul 25, 2019

Hi @StefanKarpinski @nalimilan , just came in to see if this could be merged.

@StefanKarpinski StefanKarpinski self-assigned this Jul 29, 2019
@StefanKarpinski StefanKarpinski added the forget me not PRs that one wants to make sure aren't forgotten label Jul 29, 2019
@JeffBezanson
Copy link
Member

Bump. @StefanKarpinski ok to merge? (needs rebase tho)

@StefanKarpinski
Copy link
Member

Can be squash-merged if CI passes.

@JeffBezanson JeffBezanson merged commit 681dfdc into JuliaLang:master Aug 16, 2019
@simeonschaub simeonschaub removed the forget me not PRs that one wants to make sure aren't forgotten label May 29, 2021
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.

SubstitutionString can't contain escape sequences \n, \t, etc. during replace
6 participants