mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 09:15:38 +02:00
Scanner fix for lost comment character within an #ifdef'ed out block.
This commit is contained in:
parent
cda607e788
commit
92d74a7ca9
2 changed files with 12 additions and 2 deletions
|
@ -26,6 +26,7 @@ import org.eclipse.cdt.core.parser.ParserFactoryError;
|
||||||
import org.eclipse.cdt.core.parser.ParserMode;
|
import org.eclipse.cdt.core.parser.ParserMode;
|
||||||
import org.eclipse.cdt.core.parser.ScannerException;
|
import org.eclipse.cdt.core.parser.ScannerException;
|
||||||
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
import org.eclipse.cdt.core.parser.ast.IASTInclusion;
|
||||||
|
import org.eclipse.cdt.internal.core.parser.scanner.Scanner;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
|
@ -1645,4 +1646,15 @@ public class ScannerTestCase extends BaseScannerTest
|
||||||
validateToken( IToken.tRBRACE);
|
validateToken( IToken.tRBRACE);
|
||||||
validateEOF();
|
validateEOF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testEndif() throws Exception
|
||||||
|
{
|
||||||
|
Writer writer = new StringWriter();
|
||||||
|
writer.write( "#ifdef __X__\n" ); //$NON-NLS-1$
|
||||||
|
writer.write( " // comment\n" ); //$NON-NLS-1$
|
||||||
|
writer.write( "#endif\n" ); //$NON-NLS-1$
|
||||||
|
initializeScanner( writer.toString() );
|
||||||
|
validateEOF();
|
||||||
|
assertEquals( ((Scanner)scanner).getBranchTracker().getDepth(), 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1662,13 +1662,11 @@ public final class Scanner implements IScanner, IScannerData {
|
||||||
if( c == '/' )
|
if( c == '/' )
|
||||||
{
|
{
|
||||||
skipOverSinglelineComment();
|
skipOverSinglelineComment();
|
||||||
c = getChar(false);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if( c == '*' )
|
else if( c == '*' )
|
||||||
{
|
{
|
||||||
skipOverMultilineComment();
|
skipOverMultilineComment();
|
||||||
c = getChar(false);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue