mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
Fixed handling of defined() in expression evaluator.
This commit is contained in:
parent
2164ad4e15
commit
a259c14511
2 changed files with 16 additions and 3 deletions
|
@ -878,7 +878,8 @@ public class Scanner2Test extends BaseScanner2Test
|
|||
try
|
||||
{
|
||||
validateEOF();
|
||||
fail(EXPECTED_FAILURE);
|
||||
// These are no longer scanner exceptions, the are simply ignored.
|
||||
//fail(EXPECTED_FAILURE);
|
||||
}
|
||||
catch (ScannerException se)
|
||||
{
|
||||
|
|
|
@ -241,7 +241,7 @@ public class ExpressionEvaluator {
|
|||
int limit = bufferLimit[bufferStackPos];
|
||||
|
||||
// check first character
|
||||
int c = buffer[++bufferPos[bufferStackPos]];
|
||||
char c = buffer[++bufferPos[bufferStackPos]];
|
||||
if (!((c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z'))) {
|
||||
throw new EvalException("illegal identifier in defined()");
|
||||
}
|
||||
|
@ -250,12 +250,14 @@ public class ExpressionEvaluator {
|
|||
int idstart = bufferPos[bufferStackPos];
|
||||
int idlen = 1;
|
||||
while (++bufferPos[bufferStackPos] < limit) {
|
||||
if ((c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z') || (c >= '0' || c <= '9')) {
|
||||
c = buffer[bufferPos[bufferStackPos]];
|
||||
if ((c >= 'A' && c <= 'Z') || c == '_' || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9')) {
|
||||
++idlen;
|
||||
continue;
|
||||
} else
|
||||
break;
|
||||
}
|
||||
--bufferPos[bufferStackPos];
|
||||
|
||||
// consume to the closing paren;
|
||||
while (true) {
|
||||
|
@ -286,6 +288,8 @@ public class ExpressionEvaluator {
|
|||
return value;
|
||||
}
|
||||
|
||||
private static char[] _defined = "defined".toCharArray();
|
||||
|
||||
private void nextToken() throws EvalException {
|
||||
contextLoop:
|
||||
while (bufferStackPos >= 0) {
|
||||
|
@ -374,6 +378,14 @@ public class ExpressionEvaluator {
|
|||
|
||||
--bufferPos[bufferStackPos];
|
||||
|
||||
// Check for defined(
|
||||
pos = bufferPos[bufferStackPos];
|
||||
if (pos + 1 < limit && buffer[pos + 1] == '('
|
||||
&& CharArrayUtils.equals(buffer, start, len, _defined)) {
|
||||
tokenType = t_defined;
|
||||
return;
|
||||
}
|
||||
|
||||
// Check for macro expansion
|
||||
Object expObject = null;
|
||||
if (bufferData[bufferStackPos] instanceof FunctionStyleMacro.Expansion) {
|
||||
|
|
Loading…
Add table
Reference in a new issue