mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 442186: Code formatter handling of CRLF after single line comment
Change-Id: I1a17ec992fd881851e076c732629ac912effc2f1 Signed-off-by: John Dallaway <john@dallaway.org.uk> Reviewed-on: https://git.eclipse.org/r/32024 Tested-by: Hudson CI Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
This commit is contained in:
parent
ce5a26d6ce
commit
e23f4ef14b
2 changed files with 15 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
||||
* Copyright (c) 2004, 2014 IBM Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
|
@ -9,6 +9,7 @@
|
|||
* IBM Corporation - initial implementation
|
||||
* Anton Leherbauer - adding tokens for preprocessing directives
|
||||
* Markus Schorn - classification of preprocessing directives.
|
||||
* John Dallaway - handle CRLF after single line comment (bug 442186)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.formatter.scanner;
|
||||
|
||||
|
@ -831,7 +832,13 @@ public class SimpleScanner {
|
|||
private void matchSinglelineComment(boolean includeNewline) {
|
||||
int c = getChar();
|
||||
while (c != '\n' && c != EOFCHAR) {
|
||||
c = getChar();
|
||||
int next = getChar();
|
||||
if (c == '\r' && next == '\n' && !includeNewline) {
|
||||
// exclude CRLF line ending
|
||||
ungetChar(next);
|
||||
break;
|
||||
}
|
||||
c = next;
|
||||
}
|
||||
if (c == EOFCHAR || !includeNewline) {
|
||||
ungetChar(c);
|
||||
|
|
|
@ -2999,4 +2999,10 @@ public class CodeFormatterTest extends BaseUITestCase {
|
|||
public void testFunctionMacroInInitializerExpression() throws Exception {
|
||||
assertFormatterResult();
|
||||
}
|
||||
|
||||
public void testCrLfAfterSingleLineComment_Bug442186() throws Exception {
|
||||
String before = "#define TESTING1 //\r\n#define TESTING2 // CR \r in comment\r\n";
|
||||
String expected = before;
|
||||
assertFormatterResult(before, expected);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue