diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java index b1a7c4f1a3e..9e5f21dd5d8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/scanner2/Scanner2Test.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. + * Copyright (c) 2003, 2007 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 @@ -8,6 +8,7 @@ * Contributors: * IBM Corp. - Rational Software - initial implementation * Markus Schorn (Wind River Systems) + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.parser.tests.scanner2; @@ -2501,5 +2502,18 @@ public class Scanner2Test extends BaseScanner2Test buffer.append("a \n"); initializeScanner(buffer.toString()); validateIdentifier("a"); - } + } + + // https://bugs.eclipse.org/bugs/show_bug.cgi?id=182180 + public void testBug182180() throws Exception { + StringBuffer buffer = new StringBuffer(); + buffer + .append("#ifdef _bug_182180_\n") + .append(" printf(\"Hello World /*.ap\\n\");\n") + .append("#endif\n") + .append("bug182180\n"); + initializeScanner(buffer.toString()); + validateIdentifier("bug182180"); + } + } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java index 8a7eb2a3fb6..5e8c78fca75 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/BaseScanner.java @@ -3002,11 +3002,12 @@ abstract class BaseScanner implements IScanner { int pos = bufferPos[bufferStackPos]; boolean escaped = false; + boolean insideString= false; while (++pos < limit) { char ch= buffer[pos]; switch (ch) { case '/': - if (insideComment) { + if (insideComment || insideString) { break; } if (pos + 1 < limit) { @@ -3030,6 +3031,11 @@ abstract class BaseScanner implements IScanner { case '\\': escaped = !escaped; continue; + case '"': + if (!insideComment && !escaped) { + insideString= !insideString; + } + break; case '\n': if (escaped) { break;