-
Notifications
You must be signed in to change notification settings - Fork 131
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
Conversation
@javax-swing
javax-swing
Jul 11, 2018
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.
may as well use for i <- 1 until source.length
and remove the if i>= 1
checks below
@javax-swing
javax-swing
Jul 11, 2018
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.
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)
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?
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.
No description provided.