From b7382e51f175a37e7bec706990f9fc6b3bb818b8 Mon Sep 17 00:00:00 2001 From: Anton Leherbauer Date: Fri, 5 Aug 2011 15:13:13 +0200 Subject: [PATCH] Bug 350433 - [formatter] Line wrapping if "\ua" or "\ud" occurs in preprocessor directive --- .../cdt/internal/formatter/scanner/SimpleScanner.java | 7 +++++-- .../org/eclipse/cdt/ui/tests/text/CodeFormatterTest.java | 6 ++++++ 2 files changed, 11 insertions(+), 2 deletions(-) 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); + } }