Skip to content

Handle \r like \n to avoid difference of length between LF and CRLF line endings#1347

Closed
ghost wants to merge 2 commits intomasterfrom
unknown repository
Closed

Handle \r like \n to avoid difference of length between LF and CRLF line endings#1347
ghost wants to merge 2 commits intomasterfrom
unknown repository

Conversation

@ghost
Copy link

@ghost ghost commented Feb 28, 2017

cc. #1335

@ghost ghost changed the title \r is now treated like \n to avoid difference of behaviour between LF and CRLF line endings \r is now treated like \n to avoid difference of length between LF and CRLF line endings Feb 28, 2017
@ghost ghost changed the title \r is now treated like \n to avoid difference of length between LF and CRLF line endings Handle \r like \n to avoid difference of length between LF and CRLF line endings Feb 28, 2017
src/lib.rs Outdated
}

if c == '\n' {
if c == '\n' || c == '\r' {
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is quite right - a line ending in \r\n will be counted as two lines rather than one. I think it might be better to keep the original treatment, but don't increment line_len, although that assumes line_len is only used for the max line length test.

Copy link
Author

@ghost ghost Feb 28, 2017

Choose a reason for hiding this comment

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

I think you're right, my bad. By the way, if you have a better name for this PR, don't hesitate :P

@ghost ghost closed this Mar 1, 2017
This pull request was closed.
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.

1 participant