1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 09:46:02 +02:00

Fix for 182180: Bug with parser and #ifdef statements and "/*"

This commit is contained in:
Anton Leherbauer 2007-04-13 11:27:30 +00:00
parent 6a9d44ea95
commit 1dfa6ff276
2 changed files with 23 additions and 3 deletions

View file

@ -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;
@ -2502,4 +2503,17 @@ public class Scanner2Test extends BaseScanner2Test
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");
}
}

View file

@ -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;