[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Fix for PR 38065
|
Title: Message
Here is
another small patch. The problem is caused by the scanner: it mistreated '\'
characters. getChar() handles "'\' as the last character on the line" scenario,
where '\' and the end-of-line are correctly skipped (imitating preprocessor
activity). But it didn't backtrack properly in other cases, effectively skipping
'\' characters anywhere else in the code (outside strings). You could write
cl\ass C\Foo\Bar {
and it was automagically transformed
to
class CFooBar {
for the parser.
Now getChar() does
additional ungetChar() in case '\' is not the last character on the line (and it
throws ScannerException, from ungetChar()).
/Vic
Index:
parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS
file:
/home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving
revision 1.26
diff -u -r1.26 Scanner.java
---
parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 May 2003
20:04:51 -0000 1.26
+++
parser/org/eclipse/cdt/internal/core/parser/Scanner.java 4 Jun 2003
19:02:28 -0000
@@ -198,7 +198,7 @@
return
buffer.toString();
}
- protected void
skipOverTextUntilNewline() {
+ protected void skipOverTextUntilNewline()
throws ScannerException {
for (;;)
{
switch (getChar())
{
case NOCHAR :
@@ -366,12 +366,12
@@
Index:
parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS
file:
/home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving
revision 1.26
diff -u -r1.26 Scanner.java
---
parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 May 2003
20:04:51 -0000 1.26
+++
parser/org/eclipse/cdt/internal/core/parser/Scanner.java 4 Jun 2003
19:04:07 -0000
@@ -198,7 +198,7 @@
return
buffer.toString();
}
- protected void
skipOverTextUntilNewline() {
+ protected void skipOverTextUntilNewline()
throws ScannerException {
for (;;)
{
switch (getChar()) {
Index:
parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS
file:
/home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving
revision 1.26
diff -u -r1.26 Scanner.java
---
parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 May 2003
20:04:51 -0000 1.26
+++
parser/org/eclipse/cdt/internal/core/parser/Scanner.java 4 Jun 2003
19:05:14 -0000
@@ -198,7 +198,7 @@
return
buffer.toString();
}
- protected void
skipOverTextUntilNewline() {
+ protected void skipOverTextUntilNewline()
throws ScannerException {
for (;;)
{
switch (getChar())
{
case NOCHAR :
Index:
parser/org/eclipse/cdt/internal/core/parser/Scanner.java
===================================================================
RCS
file:
/home/tools/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/Scanner.java,v
retrieving
revision 1.26
diff -u -r1.26 Scanner.java
---
parser/org/eclipse/cdt/internal/core/parser/Scanner.java 1 May 2003
20:04:51 -0000 1.26
+++
parser/org/eclipse/cdt/internal/core/parser/Scanner.java 4 Jun 2003
19:06:40 -0000
@@ -198,7 +198,7 @@
return
buffer.toString();
}
- protected void
skipOverTextUntilNewline() {
+ protected void skipOverTextUntilNewline()
throws ScannerException {
for (;;)
{
switch (getChar())
{
case NOCHAR :
@@ -366,12 +366,12
@@
callback =
c;
}
- private int getChar()
+ private
int getChar() throws
ScannerException
{
return getChar( false
);
}
- private int getChar( boolean
insideString ) {
+ private int getChar( boolean insideString ) throws
ScannerException {
int c =
NOCHAR;
lastContext =
contextStack.getCurrentContext();
@@ -423,6 +423,10
@@
c =
getChar(false);
if( c ==
'\n')
contextStack.newLine();
+ } else // '\' is not the last character on the
line
+ {
+ ungetChar(c);
+ c
=
'\\';
}
}
else
if( c == '\n' )