1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Scanner2 - sanity point - fixed some problems I was having with comments.

This commit is contained in:
Doug Schaefer 2004-06-22 19:20:10 +00:00
parent fdfc59936c
commit b0040c1336

View file

@ -628,7 +628,6 @@ public class Scanner2 implements IScanner, IScannerData {
// Check for macro expansion // Check for macro expansion
Object expObject = definitions.get(buffer, start, len); Object expObject = definitions.get(buffer, start, len);
if (expObject == null) {
// but not if it has been expanded on the stack already // but not if it has been expanded on the stack already
// i.e. recursion avoidance // i.e. recursion avoidance
@ -641,7 +640,6 @@ public class Scanner2 implements IScanner, IScannerData {
expObject = null; expObject = null;
break; break;
} }
}
if (expObject != null) { if (expObject != null) {
if (expObject instanceof FunctionStyleMacro) { if (expObject instanceof FunctionStyleMacro) {
@ -1245,8 +1243,13 @@ public class Scanner2 implements IScanner, IScannerData {
int nesting = 0; int nesting = 0;
while (bufferPos[bufferStackPos] < limit) { while (bufferPos[bufferStackPos] < limit) {
skipOverWhiteSpace(); skipOverWhiteSpace();
char c = buffer[++bufferPos[bufferStackPos]];
if (++bufferPos[bufferStackPos] >= limit)
return;
char c = buffer[bufferPos[bufferStackPos]];
if (c == '#') { if (c == '#') {
skipOverWhiteSpace(); skipOverWhiteSpace();
@ -1304,8 +1307,7 @@ public class Scanner2 implements IScanner, IScannerData {
} }
} }
} }
} } else if (c != '\n')
skipToNewLine(); skipToNewLine();
} }
} }
@ -1326,6 +1328,8 @@ public class Scanner2 implements IScanner, IScannerData {
if (buffer[pos + 1] == '/') { if (buffer[pos + 1] == '/') {
// C++ comment, skip rest of line // C++ comment, skip rest of line
skipToNewLine(); skipToNewLine();
// leave the new line there
--bufferPos[bufferStackPos];
return; return;
} else if (buffer[pos + 1] == '*') { } else if (buffer[pos + 1] == '*') {
// C comment, find closing */ // C comment, find closing */
@ -1468,9 +1472,9 @@ public class Scanner2 implements IScanner, IScannerData {
private void skipToNewLine() { private void skipToNewLine() {
char[] buffer = bufferStack[bufferStackPos]; char[] buffer = bufferStack[bufferStackPos];
int limit = bufferLimit[bufferStackPos]; int limit = bufferLimit[bufferStackPos];
int pos = ++bufferPos[bufferStackPos];
int pos = bufferPos[bufferStackPos]; if (pos < limit && buffer[pos] == '\n')
if (pos >= limit || buffer[pos] == '\n')
return; return;
boolean escaped = false; boolean escaped = false;