From 07e94aea452c58132f3b64ce9b7bb89d49dcb63d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jindra=20Pet=C5=99=C3=ADk?= Date: Fri, 13 Jan 2023 22:09:22 +0100 Subject: [PATCH] Fixed AS3 - line numbering on pushback string on regexp --- CHANGELOG.md | 1 + libsrc/ffdec_lib/lexers/actionscript3_script.flex | 3 +++ .../flash/abc/avm2/parser/script/ActionScriptLexer.java | 5 ++++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d8ee6fc6..b511b45ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ All notable changes to this project will be documented in this file. - AS3 - local registers type declarations vs for..in clause - [#1888] AS3 - Coerce to int when Number - AS3 - super properties resolving +- AS3 - line numbering on pushback string on regexp ## [18.3.2] - 2023-01-10 ### Removed diff --git a/libsrc/ffdec_lib/lexers/actionscript3_script.flex b/libsrc/ffdec_lib/lexers/actionscript3_script.flex index c2a0e8784..24d63e88d 100644 --- a/libsrc/ffdec_lib/lexers/actionscript3_script.flex +++ b/libsrc/ffdec_lib/lexers/actionscript3_script.flex @@ -45,9 +45,12 @@ import java.math.BigInteger; public void yypushbackstr(String s, int state) { + int numLines = count(s, "\n"); + int newYyline = yyline - numLines; sourceCode = s + sourceCode.substring(yychar + yylength()); yyreset(new StringReader(sourceCode)); yybegin(state); + yyline = newYyline; } public void yypushbackstr(String s) diff --git a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java index 8f78877ab..f21a88efb 100644 --- a/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java +++ b/libsrc/ffdec_lib/src/com/jpexs/decompiler/flash/abc/avm2/parser/script/ActionScriptLexer.java @@ -19,10 +19,10 @@ package com.jpexs.decompiler.flash.abc.avm2.parser.script; import com.jpexs.decompiler.flash.abc.avm2.parser.AVM2ParseException; import java.io.StringReader; -import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import java.util.Stack; +import java.math.BigInteger; /** @@ -938,9 +938,12 @@ public final class ActionScriptLexer { public void yypushbackstr(String s, int state) { + int numLines = count(s, "\n"); + int newYyline = yyline - numLines; sourceCode = s + sourceCode.substring(yychar + yylength()); yyreset(new StringReader(sourceCode)); yybegin(state); + yyline = newYyline; } public void yypushbackstr(String s)