diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java index 05ee63739b6..e536b53d38f 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/scanner/SimpleScanner.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2010 IBM Corporation and others. + * Copyright (c) 2004, 2011 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 @@ -800,7 +800,7 @@ public class SimpleScanner { private void getRestOfPreprocessorLine() { int c = getChar(); while (true) { - while ((c != '\n') && (c != '\r') && (c != '/') && (c != EOFCHAR)) { + while ((c != '\n') && (c != '\r') && (c != '/') && (c != '"') && (c != EOFCHAR)) { c = getChar(); } if (c == '/') { @@ -823,6 +823,9 @@ public class SimpleScanner { c = next; continue; } + } else if (c == '"') { + matchStringLiteral(); + c = getChar(); } else { ungetChar(c); break; diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java index e7891ec5f80..e8255213381 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java @@ -2512,4 +2512,10 @@ public class CodeFormatterTest extends BaseUITestCase { public void testMacroInBinaryExpression_Bug344379() throws Exception { assertFormatterResult(); } + + public void testBackslashUInPreprocessorDirective_Bug350433() throws Exception { + String before= "#include \"test\\udp.h\"\n"; + String expected= before; + assertFormatterResult(before, expected); + } }