Skip to content

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

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

Closed
wants to merge 2 commits into from
Closed

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
@@ -482,7 +477,7 @@ fn format_lines(text: &mut StringBuffer, name: &str, config: &Config, report: &m
});
}

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