-
Notifications
You must be signed in to change notification settings - Fork 550
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
tr''' does not work properly #15853
Comments
From @khwilliamsonThis is a bug report for perl from khw@cpan.org, Using a single quote as a delimiter in tr or y does not work properly. The parsing for these commands is split between toke.c and op.c, with It so happens that the intermediate form is unchanged from the input for tr'abc'def' but ranges don't work tr'a-z'A-Z' # translates only the three chars 'a', '-', 'z' I haven't investigated \t, etc. My guess is that it has been broken from the beginning, and it's amazing One possibility to fix this is to simply prohibit single-quotish Otherwise, the portion of scan_const that deals with this would have to tr '\xDF'\xFE' should not be evaluated as double-quotish, for example. Since I don't have much knowledge of the parser's overall operation, Flags: This perlbug was built using Perl 5.25.9 - Thu Jan 19 08:46:21 MST 2017 Site configuration information for perl 5.25.7: Configured by khw at Fri Nov 18 08:29:04 MST 2016. Summary of my perl5 (revision 5 version 25 subversion 7) configuration: @INC for perl 5.25.7: Environment for perl 5.25.7: |
From @tonycozOn Mon, 30 Jan 2017 18:24:38 -0800, khw wrote:
We'd need to modify S_tokeq() to handle ranges in single-quotish tr'''. Possibly it could check for broken unicode to avoid #130675. I don't think tr''' should support escapes beyond \' Tony |
The RT System itself - Status changed from 'new' to 'open' |
From @khwilliamsonOn Mon, 30 Jan 2017 20:04:28 -0800, tonyc wrote:
Agreed
Agreed
I don't know why the handling of tr/// is split between op.c and toke.c. I'm now thinking that most of it should be moved to op.c, with the toke.c part merely expanding the single- or double-quotish things. Then there would be no need to have an intermediate form, and I believe the code would be cleaner. |
From @khwilliamsonOn Mon, 06 Feb 2017 17:05:19 -0800, khw wrote:
I have figured out why it is split between op.c and tr.c. If op.c didn't get it before it was fully parsed, it wouldn't be able to distinguish between things like an interior hyphen was input as a literal, and hence should be treated as a metacharacter; or if it was the expansion of something like \x2D, in which case it isn't a metacharacter. We have the same problem, and have (mostly) solved it, for regex patterns that are compiled separately, but it's work, and has presented a bunch of bugs over the years |
From @khwilliamsonThis is actually working as designed. I added doc clarifications in See also http://nntp.perl.org/group/perl.perl5.porters/251544 -- |
@khwilliamson - Status changed from 'open' to 'rejected' |
Migrated from rt.perl.org#130679 (status was 'rejected')
Searchable as RT130679$
The text was updated successfully, but these errors were encountered: