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

^^ and $$ behave unlike ^ and $ when the string being matched is a single line ending in \r\n in Rakudo #3537

Closed
p6rt opened this issue Oct 3, 2014 · 4 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Oct 3, 2014

Migrated from rt.perl.org#122891 (status was 'resolved')

Searchable as RT122891$

@p6rt
Copy link
Author

p6rt commented Oct 3, 2014

From @masak

<jnthn> m​: say "a\n" ~~ /^^\s*$$/
<camelia> rakudo-moar d69a87​: OUTPUT«Nil␤»
<jnthn> m​: say "a\r\n" ~~ /^^\s*$$/
<camelia> rakudo-moar d69a87​: OUTPUT«「」␤␤»
<jnthn> That's why Pod tables are bust on Windows.
<masak> jnthn​: that looks clearly wrong to me.
<masak> \r\n are whitespace.
<jnthn> masak​: That's not the problem
<jnthn> masak​: The problem is that it doesn't match, so then goes right one char
<jnthn> masak​: Then ^^ says "oh, I'm after a \r, that'll do", and $$
says "oh, I'm before a \n, that'll do"
<masak> oh!
<masak> ...wow.
<jnthn> Yeah... o.O
<jnthn> And given \r actually *is* a valid line sep on...older
mac...or something...
<jnthn> I don't immediately know what to do about it.
<jnthn> For now, it's easy to patch the Pod code, since it's already
dealing with full lines always
<lizmat> this is a similar problem with .lines
<jnthn> So its use of ^^ and $$ is kinda overkill; if you already know
you have a line, ^ and $ are good enough
<jnthn> But yeah, there is a deeper issue here
<masak> yes, \r was the newline marker on Mac OS 9.
<FROGGS[mobile]> I'd think that ^^ would "gobble" \r\n already
<jnthn> FROGGS[mobile]​: ^^ and $$ don't swallow
<jnthn> They're zero-width assertions
<masak> jnthn​: I think a reasonable expectation is that if you *have*
a single line, ^ and $ should act as ^^ and $$, respectively.
<jnthn> masak​: Yes, sounds sane. Question is how we get there ;)
<jnthn> Anyway, I'm going to do the wrokaround in Pod.pm so that we
don't have Pod-parsing bugs on Windows.
<jnthn> And the ^^$$ issue probably deserves an RT.
* masak submits one
<masak> does it make sense to ask "how does Perl 5 regexes handle this one?" ?
<jnthn> masak​: Maybe... :)

@p6rt
Copy link
Author

p6rt commented Nov 10, 2015

From @jnthn

On Fri Oct 03 03​:11​:45 2014, masak wrote​:

<jnthn> m​: say "a\n" ~~ /^^\s*$$/
<camelia> rakudo-moar d69a87​: OUTPUT«Nil␤»
<jnthn> m​: say "a\r\n" ~~ /^^\s*$$/
<camelia> rakudo-moar d69a87​: OUTPUT«「」␤␤»
<jnthn> That's why Pod tables are bust on Windows.
<masak> jnthn​: that looks clearly wrong to me.
<masak> \r\n are whitespace.
<jnthn> masak​: That's not the problem
<jnthn> masak​: The problem is that it doesn't match, so then goes
right one char
<jnthn> masak​: Then ^^ says "oh, I'm after a \r, that'll do", and $$
says "oh, I'm before a \n, that'll do"
<masak> oh!
<masak> ...wow.
<jnthn> Yeah... o.O

This is no longer a problem, thanks to \r\n being a single grapheme. Test coverage added in S05-metachars/line-anchors.t.

/jnthn

@p6rt
Copy link
Author

p6rt commented Nov 10, 2015

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt closed this as completed Nov 10, 2015
@p6rt
Copy link
Author

p6rt commented Nov 10, 2015

@jnthn - Status changed from 'open' to 'resolved'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant