Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support '\r' and '\r\n' line endings, closes scala/bug#5669 #164

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

Merged
gourlaysama merged 3 commits into scala:1.1.x from Philippus:issue-5669
Nov 5, 2018

Conversation

Copy link
Member

@Philippus Philippus commented Jul 6, 2018

No description provided.

@Philippus Philippus changed the title (削除) Support '\r' and '\r\n' line endings (削除ここまで) (追記) @Philippus Support '\r' and '\r\n' line endings, closes scala/bug#5669 (追記ここまで) Jul 6, 2018
@Philippus Philippus changed the title (削除) @Philippus Support '\r' and '\r\n' line endings, closes scala/bug#5669 (削除ここまで) (追記) Support '\r' and '\r\n' line endings, closes scala/bug#5669 (追記ここまで) Jul 6, 2018
if (source.charAt(i) == '\n') lineStarts += (i + 1)
lineStarts += source.length
lineStarts += 0 // first line
for (i <- 0 until source.length) {
Copy link

@javax-swing javax-swing Jul 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may as well use for i <- 1 until source.length and remove the if i>= 1 checks below

Philippus reacted with thumbs up emoji
lineStarts += source.length
lineStarts += 0 // first line
for (i <- 0 until source.length) {
if (i >= 1 && source.charAt(i - 1) == '\n') // \n or \r\n
Copy link

@javax-swing javax-swing Jul 11, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the majority of the time the last character won't be a \r or \n might be worth binding charAt(i - 1) to a variable to save the extra lookup (dependant on the performance requirements of this code)

@gourlaysama gourlaysama merged commit c3f8797 into scala:1.1.x Nov 5, 2018
@Philippus Philippus deleted the issue-5669 branch November 12, 2018 19:15
Copy link
Member

in the Scala community build, this build caused this Twirl test case to start failing: https://github.com/playframework/twirl/blob/68ad7b378be54887a09c5a67792bacc933d17d68/parser/src/test/scala/play/twirl/parser/test/ParserSpec.scala#L187-L189 (referencing https://github.com/playframework/twirl/blob/master/parser/src/test/resources/unclosedBracket2.scala.html)

[play-twirl] [info] x unclosedBracket2.scala.html
[play-twirl] [error] '31' is not equal to '32' (ParserSpec.scala:37)

the test file doesn't have any \r or \r\n line endings, so it seems probable it's a real regression? wdyt?

Copy link
Member Author

I've reproduced it:
contents of the index generated by genIndex differs:
new: ArrayBuffer(0, 85, 86, 111, 112, 136, 155, 166, 167, 169, 170, 185, 186, 207, 208, 233, 234, 243, 265, 266, 291, 292, 310, 335, 336, 346, 347, 356, 357, 367, 368, 370)
vs
old: ArrayBuffer(0, 85, 86, 111, 112, 136, 155, 166, 167, 169, 170, 185, 186, 207, 208, 233, 234, 243, 265, 266, 291, 292, 310, 335, 336, 346, 347, 356, 357, 367, 368, 370, 370)
will work on a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@SethTisue SethTisue SethTisue approved these changes

+1 more reviewer

@javax-swing javax-swing javax-swing left review comments

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /