From: Daniel Jasper Date: Wed, 30 Oct 2013 07:36:40 +0000 (+0000) Subject: clang-format: fix for \r\r\n produced in multiline block comments X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=74b7363bcfc502dec34092af434da787cf9d5b9f;p=clang clang-format: fix for \r\r\n produced in multiline block comments Patch by Christopher Olsen. Thank you! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@193678 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/BreakableToken.cpp b/lib/Format/BreakableToken.cpp index cbc50f566a..97475780f4 100644 --- a/lib/Format/BreakableToken.cpp +++ b/lib/Format/BreakableToken.cpp @@ -25,13 +25,14 @@ namespace clang { namespace format { -static const char *const Blanks = " \t\v\f"; +static const char *const Blanks = " \t\v\f\r"; static bool IsBlank(char C) { switch (C) { case ' ': case '\t': case '\v': case '\f': + case '\r': return true; default: return false; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 991763cdf7..2f6e06ff02 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -6984,6 +6984,17 @@ TEST_F(FormatTest, SupportsCRLF) { " b; \\\r\n" " c; d; \r\n", getGoogleStyle())); + + EXPECT_EQ("/*\r\n" + "multi line block comments\r\n" + "should not introduce\r\n" + "an extra carriage return\r\n" + "*/\r\n", + format("/*\r\n" + "multi line block comments\r\n" + "should not introduce\r\n" + "an extra carriage return\r\n" + "*/\r\n")); } TEST_F(FormatTest, MunchSemicolonAfterBlocks) {