Skip to content

Commit e3462be

Browse files
committed
Handle Windows line endings
1 parent 470eca4 commit e3462be

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

clang/lib/Format/FormatTokenLexer.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,12 @@ void FormatTokenLexer::tryParseJavaTextBlock() {
710710
// From docs.oracle.com/en/java/javase/15/text-blocks/#text-block-syntax:
711711
// A text block begins with three double-quote characters followed by a line
712712
// terminator.
713-
while (S < End && *S != '\n') {
714-
if (!isblank(*S))
713+
while (S < End) {
714+
if (*S == '\n') {
715+
++S;
716+
break;
717+
}
718+
if (!isspace(*S))
715719
return;
716720
++S;
717721
}

clang/unittests/Format/FormatTestJava.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ TEST_F(FormatTestJava, TextBlock) {
836836
" }\n"
837837
"}");
838838

839-
verifyNoChange("String name = \"\"\"\n"
839+
verifyNoChange("String name = \"\"\"\r\n"
840840
" red\n"
841841
" green\n"
842842
" blue\\\n"

0 commit comments

Comments
 (0)