diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseScannerTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseScannerTest.java index 1340a22010f..1dbded359f5 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseScannerTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/BaseScannerTest.java @@ -47,7 +47,7 @@ public class BaseScannerTest extends TestCase { protected void initializeScanner( String input, ParserMode mode, ISourceElementRequestor requestor ) throws ParserFactoryError { - scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), mode, ParserLanguage.CPP, requestor, null, null ); + scanner= ParserFactory.createScanner( new StringReader(input),"TEXT", new ScannerInfo(), mode, ParserLanguage.CPP, requestor, null, null ); //$NON-NLS-1$ } protected void initializeScanner(String input) throws ParserFactoryError @@ -65,10 +65,10 @@ public class BaseScannerTest extends TestCase { while (t != null) { if (verbose) - System.out.println("Token t = " + t); + System.out.println("Token t = " + t); //$NON-NLS-1$ if ((t.getType()> IToken.tLAST)) - System.out.println("Unknown type for token " + t); + System.out.println("Unknown type for token " + t); //$NON-NLS-1$ t= scanner.nextToken(); } } @@ -208,10 +208,10 @@ public class BaseScannerTest extends TestCase { assertNull(scanner.getDefinition(name)); } - public static final String EXCEPTION_THROWN = "Exception thrown "; + public static final String EXCEPTION_THROWN = "Exception thrown "; //$NON-NLS-1$ - public static final String EXPECTED_FAILURE = "This statement should not be reached " - + "as we sent in bad preprocessor input to the scanner"; + public static final String EXPECTED_FAILURE = "This statement should not be reached " //$NON-NLS-1$ + + "as we sent in bad preprocessor input to the scanner"; //$NON-NLS-1$ public static final boolean verbose = false; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ScannerTestCase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ScannerTestCase.java index 3779aaf9e3b..956872351f8 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ScannerTestCase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ScannerTestCase.java @@ -1572,4 +1572,10 @@ public class ScannerTestCase extends BaseScannerTest fullyTokenize(); assertTrue( callback.problems.isEmpty() ); } + + public void testBug62378() throws Exception + { + initializeScanner( "\"\\?\\?<\""); //$NON-NLS-1$ + validateString("\\?\\?<" ); //$NON-NLS-1$ + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java index cd5a7994dc0..1025946c75b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Scanner.java @@ -958,7 +958,6 @@ public class Scanner implements IScanner { { // TODO : we could probably return the partial string -- it might cause // the parse to get by... - handleProblem( IProblem.SCANNER_UNBOUNDED_STRING, null, beginOffset, false, true ); return null; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContextInclusion.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContextInclusion.java index 02949dc881c..b9a9ab3533d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContextInclusion.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContextInclusion.java @@ -18,6 +18,7 @@ import org.eclipse.cdt.core.parser.ast.IASTInclusion; public class ScannerContextInclusion implements IScannerContext { + public static final int UNDO_BUFFER_SIZE = 4; protected Reader reader; private String filename; private IASTInclusion inc; @@ -52,7 +53,7 @@ public class ScannerContextInclusion implements IScannerContext } } protected int pos = 0; - protected int undo[] = new int[2]; + protected int undo[] = new int[UNDO_BUFFER_SIZE]; public final void ungetChar(int c) { undo[pos++] = c; }