<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Aug 29, 2019 at 2:42 PM Marcel Fabian Krüger <<a href="mailto:tex@2krueger.de">tex@2krueger.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
in current versions of LuaTeX, `runtoks` does not preserve token lists<br>
of ongoing assignments. Therefore running `runtoks` inside of `\edef`<br>
or similar replace the definition with the defined value of the last<br>
inner assignment.<br>
<br>
For example:<br>
<br>
\toks0{\def\innermacro{inner}}<br>
\edef\outermacro{outer\directlua{tex.runtoks(0)}}<br>
\show\outermacro<br>
\bye<br>
<br>
in plain TeX should show<br>
<br>
> \outermacro=macro:<br>
->outer.<br>
<br>
but currently does show<br>
<br>
> \outermacro=macro:<br>
->inner.<br>
<br>
instead.<br>
<br>
(As a side effect the reference count isn't updated, so for example<br>
<br>
\toks0{\def\innermacro{inner}\let\innermacro\undefined}<br>
\edef\outermacro{outer\directlua{tex.runtoks(0)}}<br>
\show\outermacro<br>
\bye<br>
<br>
starts printing hyphenation patterns on my system.)<br>
<br>
This can be fixed by saving scanner_status, warning_index and def_ref<br>
when entering local_control:<br>
<br>
diff --git a/source/texk/web2c/luatexdir/tex/maincontrol.c b/source/texk/web2c/luatexdir/tex/maincontrol.c<br>
index b01931dd1..284fb0ae3 100644<br>
--- a/source/texk/web2c/luatexdir/tex/maincontrol.c<br>
+++ b/source/texk/web2c/luatexdir/tex/maincontrol.c<br>
@@ -1055,6 +1055,10 @@ extern void local_control_message(const char *s)<br>
 void local_control(void)<br>
 {<br>
     int ll = local_level;<br>
+    int save_scanner_status = scanner_status;<br>
+    halfword save_def_ref = def_ref;<br>
+    halfword save_warning_index = warning_index;<br>
+<br>
     main_control_state = goto_next;<br>
     local_level += 1;<br>
     while (1) {<br>
@@ -1077,14 +1081,17 @@ void local_control(void)<br>
             if (tracing_nesting_par > 2) {<br>
                 local_control_message("leaving due to level change");<br>
             }<br>
-            return ;<br>
+            break;<br>
         } else if (main_control_state == goto_return) {<br>
             if (tracing_nesting_par > 2) {<br>
                 local_control_message("leaving due to triggering");<br>
             }<br>
-            return;<br>
+            break;<br>
         }<br>
     }<br>
+    scanner_status = save_scanner_status;<br>
+    def_ref = save_def_ref;<br>
+    warning_index = save_warning_index;<br>
     return;<br>
 }<br></blockquote><div><br></div><div><br></div><div>we are seeing it. </div></div><div><br></div>-- <br><div dir="ltr" class="gmail_signature">luigi<br></div></div>