diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java index 2ab208ac459..0228915bb33 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/DOMLocationInclusionTests.java @@ -309,7 +309,7 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { c_file_code.indexOf("X"), 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertSoleFileLocation( macroDefinitions[1], - "blarg.h", h_file_code.indexOf("#define _BLARG_H_"), "#define _BLARG_H_\r".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "blarg.h", h_file_code.indexOf("#define _BLARG_H_"), "#define _BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation( macroDefinitions[1].getName(), "blarg.h", h_file_code.indexOf("e _BLARG_H_") + 2, "_BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ @@ -390,7 +390,7 @@ public class DOMLocationInclusionTests extends AST2FileBasePluginTest { c_file_code.indexOf("X"), 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ assertSoleFileLocation( macroDefinitions[1], - "blarg.h", h_file_code.indexOf("#define _BLARG_H_"), "#define _BLARG_H_\r".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + "blarg.h", h_file_code.indexOf("#define _BLARG_H_"), "#define _BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ assertSoleFileLocation( macroDefinitions[1].getName(), "blarg.h", h_file_code.indexOf("e _BLARG_H_") + 2, "_BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ 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 a2d636c1dcf..4fe054f36ff 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 @@ -2153,10 +2153,21 @@ abstract class BaseScanner implements IScanner { } // Capture the replacement text - skipOverWhiteSpace(); - int textstart = bufferPos[bufferStackPos] + 1; - int textend = textstart - 1; + + // Set the offsets to the current position in case there + // is no replacement sequence (bug #184804) + int textend = bufferPos[bufferStackPos]; + int textstart = textend + 1; + int varArgDefinitionInd = -1; + skipOverWhiteSpace(); + + // if there is a replacement sequence then adjust the offsets accordingly + if(bufferPos[bufferStackPos] + 1 < limit + && buffer[bufferPos[bufferStackPos] + 1] != '\n') { + textend = bufferPos[bufferStackPos]; + textstart = textend + 1; + } boolean encounteredComment = false; boolean usesVarArgInDefinition = false;