1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Patch for Devin Steffler

Fixed 79921 - [Scanner] problems with ')' inside a string being passed to va_args macro parm
	Fixed 79227 - [Scanner][IProblem][Ethereal] "Unbounded string encountered" invalid IProblems with invalid offsets highlighting weird commented code
This commit is contained in:
John Camelon 2004-12-02 03:15:08 +00:00
parent e5362d1983
commit 5d45047d01
2 changed files with 25 additions and 3 deletions

View file

@ -2532,5 +2532,17 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
writer.write("if (WIFEXITED(test)) {}\n}\n"); //$NON-NLS-1$
parse(writer.toString());
}
public void testBug79921_79227() throws Exception {
Writer writer = new StringWriter();
writer.write("/* some\n* commented\n* code\n*/\n"); //$NON-NLS-1$
writer.write("#define g_message(...) g_log (1, 2, __VA_ARGS__);\n"); //$NON-NLS-1$
writer.write("int g_log (int a, int b, ...) { return 0; }\n"); //$NON-NLS-1$
writer.write("int foo2() {\n"); //$NON-NLS-1$
writer.write("g_message(\"a string [as] f%2.2x (%2)\") \\\n"); //$NON-NLS-1$
writer.write("// ^ the culprit\n}\n"); //$NON-NLS-1$
parse(writer.toString());
}
}

View file

@ -2612,6 +2612,7 @@ public class Scanner2 implements IScanner, IScannerData {
int currarg = -1;
CharArrayObjectMap argmap = new CharArrayObjectMap(arglist.length);
boolean insideString = false;
while (bufferPos[bufferStackPos] < limit) {
skipOverWhiteSpace();
@ -2632,13 +2633,22 @@ public class Scanner2 implements IScanner, IScannerData {
int argend = -1;
if ((macro.hasGCCVarArgs() || macro.hasVarArgs()) && currarg == macro.getVarArgsPosition()) {
--bufferPos[bufferStackPos]; // go back to first char of macro args
// there are varargs and the other parms have been accounted for, the rest will replace __VA_ARGS__ or name where "name..." is the parm
while (++bufferPos[bufferStackPos] < limit) {
if (buffer[bufferPos[bufferStackPos]] == ')') {
do {
if (buffer[bufferPos[bufferStackPos]] == '"') {
if (insideString)
insideString = false;
else
insideString = true;
}
if (!insideString && buffer[bufferPos[bufferStackPos]] == ')') {
--bufferPos[bufferStackPos];
break;
}
}
} while (++bufferPos[bufferStackPos] < limit);
argend = bufferPos[bufferStackPos];
} else
argend = skipOverMacroArg();