microsoft / clang

Other
201 stars 69 forks source link

Don't compare line endings when checking format #3

Closed michellemcdaniel closed 9 years ago

michellemcdaniel commented 9 years ago

By using readlines() when splitting the lines of code for formatted and unformatted files, clang-format-diff.py reports lines that do not have diffs as having diffs because the line endings in the original code differs from the line endings generated by clang-format on Windows. This fix changes clang-format-diff.py to use read().split() which discards line endings, fixing this problem.

michellemcdaniel commented 9 years ago

@swaroop-sridhar PTAL

swaroop-sridhar commented 9 years ago

Would read().split("\n") be sufficient? Green. Please submit the patch to clang as well. Thanks.

michellemcdaniel commented 9 years ago

No, it would not. Splitting on \n doesn't catch the \r, which is the comparison that is causing problems. splitlines() catches \n and \r