Summary: | Infinite loop in scanner when using eof=Integer.MAX_VALUE | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Philipe Mulet <philippe_mulet> |
Component: | Core | Assignee: | Olivier Thomann <Olivier_Thomann> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | ||
Version: | 3.1 | ||
Target Milestone: | 3.1 M6 | ||
Hardware: | PC | ||
OS: | Windows XP | ||
Whiteboard: |
Description
Philipe Mulet
2005-03-23 09:11:54 EST
I suggest that internally the eof position is set to source.length if the specified end is bigger than source.length. I propose the following patch. Index: Scanner.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java,v retrieving revision 1.140 diff -u -r1.140 Scanner.java --- Scanner.java 23 Mar 2005 14:36:51 -0000 1.140 +++ Scanner.java 23 Mar 2005 16:55:03 -0000 @@ -2301,6 +2301,9 @@ this.diet = false; this.initialPosition = this.startPosition = this.currentPosition = begin; this.eofPosition = end < Integer.MAX_VALUE ? end + 1 : end; + if (this.source != null && this.source.length < this.eofPosition) { + this.eofPosition = this.source.length; + } this.commentPtr = -1; // reset comment stack this.foundTaskCount = 0; Even better: Index: Scanner.java =================================================================== RCS file: /home/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Scanner.java,v retrieving revision 1.140 diff -u -r1.140 Scanner.java --- Scanner.java 23 Mar 2005 14:36:51 -0000 1.140 +++ Scanner.java 23 Mar 2005 16:59:12 -0000 @@ -2300,7 +2300,11 @@ this.diet = false; this.initialPosition = this.startPosition = this.currentPosition = begin; - this.eofPosition = end < Integer.MAX_VALUE ? end + 1 : end; + if (this.source != null && this.source.length < end) { + this.eofPosition = this.source.length; + } else { + this.eofPosition = end < Integer.MAX_VALUE ? end + 1 : end; + } this.commentPtr = -1; // reset comment stack this.foundTaskCount = 0; I released this patch. This fixes this issue. When no source is set, the eof position will be left as is. When the source is set, the eof position is updated accordingly. Verified in 20050330-0500 |