mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-17 21:25:58 +02:00
Scanner2 - turned off gratuious logging and fixed an infinite
loop that occurred in figuring out the arguments to a macro.
This commit is contained in:
parent
efcd048454
commit
ded9a06c42
1 changed files with 15 additions and 11 deletions
|
@ -76,10 +76,10 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
|
|
||||||
PrintStream dlog;
|
PrintStream dlog;
|
||||||
{
|
{
|
||||||
try {
|
// try {
|
||||||
dlog = new PrintStream(new FileOutputStream("C:/dlog.txt"));
|
// dlog = new PrintStream(new FileOutputStream("C:/dlog.txt"));
|
||||||
} catch (FileNotFoundException e) {
|
// } catch (FileNotFoundException e) {
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public Scanner2(CodeReader reader,
|
public Scanner2(CodeReader reader,
|
||||||
|
@ -157,6 +157,7 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
|
|
||||||
private void popContext() {
|
private void popContext() {
|
||||||
bufferStack[bufferStackPos] = null;
|
bufferStack[bufferStackPos] = null;
|
||||||
|
bufferData[bufferStackPos] = null;
|
||||||
--bufferStackPos;
|
--bufferStackPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -986,10 +987,10 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
len = bufferPos[bufferStackPos] - start;
|
len = bufferPos[bufferStackPos] - start;
|
||||||
if (expressionEvaluator.evaluate(buffer, start, len, definitions) == 0) {
|
if (expressionEvaluator.evaluate(buffer, start, len, definitions) == 0) {
|
||||||
dlog.println("#if <FALSE> " + new String(buffer,start+1,len-1));
|
if (dlog != null) dlog.println("#if <FALSE> " + new String(buffer,start+1,len-1));
|
||||||
skipOverConditionalCode(true);
|
skipOverConditionalCode(true);
|
||||||
} else
|
} else
|
||||||
dlog.println("#if <TRUE> " + new String(buffer,start+1,len-1));
|
if (dlog != null) dlog.println("#if <TRUE> " + new String(buffer,start+1,len-1));
|
||||||
return;
|
return;
|
||||||
case ppElse:
|
case ppElse:
|
||||||
case ppElif:
|
case ppElif:
|
||||||
|
@ -1081,7 +1082,7 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
if (reader.filename != null)
|
if (reader.filename != null)
|
||||||
fileCache.put(reader.filename, reader);
|
fileCache.put(reader.filename, reader);
|
||||||
dlog.println("#include <" + finalPath + ">");
|
if (dlog != null) dlog.println("#include <" + finalPath + ">");
|
||||||
pushContext(reader.buffer, reader);
|
pushContext(reader.buffer, reader);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1125,7 +1126,7 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
--bufferPos[bufferStackPos];
|
--bufferPos[bufferStackPos];
|
||||||
char[] name = new char[idlen];
|
char[] name = new char[idlen];
|
||||||
System.arraycopy(buffer, idstart, name, 0, idlen);
|
System.arraycopy(buffer, idstart, name, 0, idlen);
|
||||||
dlog.println("#define " + new String(buffer, idstart, idlen));
|
if (dlog != null) dlog.println("#define " + new String(buffer, idstart, idlen));
|
||||||
|
|
||||||
// Now check for function style macro to store the arguments
|
// Now check for function style macro to store the arguments
|
||||||
char[][] arglist = null;
|
char[][] arglist = null;
|
||||||
|
@ -1230,7 +1231,7 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
|
|
||||||
definitions.remove(buffer, idstart, idlen);
|
definitions.remove(buffer, idstart, idlen);
|
||||||
dlog.println("#undef " + new String(buffer, idstart, idlen));
|
if (dlog != null) dlog.println("#undef " + new String(buffer, idstart, idlen));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handlePPIfdef(boolean positive) {
|
private void handlePPIfdef(boolean positive) {
|
||||||
|
@ -1266,13 +1267,13 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
|
|
||||||
if ((definitions.get(buffer, idstart, idlen) != null) == positive) {
|
if ((definitions.get(buffer, idstart, idlen) != null) == positive) {
|
||||||
dlog.println((positive ? "#ifdef" : "#ifndef")
|
if (dlog != null) dlog.println((positive ? "#ifdef" : "#ifndef")
|
||||||
+ " <TRUE> " + new String(buffer, idstart, idlen));
|
+ " <TRUE> " + new String(buffer, idstart, idlen));
|
||||||
// continue on
|
// continue on
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dlog.println((positive ? "#ifdef" : "#ifndef")
|
if (dlog != null) dlog.println((positive ? "#ifdef" : "#ifndef")
|
||||||
+ " <FALSE> " + new String(buffer, idstart, idlen));
|
+ " <FALSE> " + new String(buffer, idstart, idlen));
|
||||||
// skip over this group
|
// skip over this group
|
||||||
skipOverConditionalCode(true);
|
skipOverConditionalCode(true);
|
||||||
|
@ -1635,6 +1636,9 @@ public class Scanner2 implements IScanner, IScannerData {
|
||||||
if (argparens == 0) {
|
if (argparens == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (c == '\n') {
|
||||||
|
// eat it and continue
|
||||||
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// start of next macro arg
|
// start of next macro arg
|
||||||
--bufferPos[bufferStackPos];
|
--bufferPos[bufferStackPos];
|
||||||
|
|
Loading…
Add table
Reference in a new issue