This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 34f880e181 Fix case when ANTLR getText() causes assertion in 
LexerInput.
34f880e181 is described below

commit 34f880e181ea29855cf41771573f77be42ca73ec
Author: Laszlo Kishalmi <laszlo.kisha...@gmail.com>
AuthorDate: Mon Mar 6 17:57:45 2023 -0800

    Fix case when ANTLR getText() causes assertion in LexerInput.
---
 .../netbeans/spi/lexer/antlr4/LexerInputCharStream.java    | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git 
a/ide/lexer.antlr4/src/org/netbeans/spi/lexer/antlr4/LexerInputCharStream.java 
b/ide/lexer.antlr4/src/org/netbeans/spi/lexer/antlr4/LexerInputCharStream.java
index 2f782bb275..3a2f672262 100644
--- 
a/ide/lexer.antlr4/src/org/netbeans/spi/lexer/antlr4/LexerInputCharStream.java
+++ 
b/ide/lexer.antlr4/src/org/netbeans/spi/lexer/antlr4/LexerInputCharStream.java
@@ -45,14 +45,14 @@ final class LexerInputCharStream implements CharStream {
         }
         int start = intrvl.a - tokenMark;
         int end = intrvl.b - tokenMark + 1;
-        int toread = end - start - input.readLength();
-        for (int i = 0; i < toread; i++) {
-            input.read();
-        }
-        String ret = String.valueOf(input.readText(start, end));
-        if (toread > 0) {
-            input.backup(toread);
+        int readCount = 0;
+        int next = 0;
+        while ((end > input.readLength()) && (next != EOF)) {
+            next = input.read();
+            readCount++;
         }
+        String ret = String.valueOf(input.readText(start, Math.min(end, 
input.readLength())));
+        input.backup(readCount);
         return ret;
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@netbeans.apache.org
For additional commands, e-mail: commits-h...@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to