Change to output routine code breaks latex afterpage package

Karl Berry karl at freefriends.org
Sun Mar 24 23:44:46 CET 2024


    an \aftergroup in the output routine is simply lost 

DRF quickly came up with a fix (below). Committed in r70752. I'll also
attach my -ini test file, for the record (also committed to the repo).

In hopes that this is sufficient, I've set up a branch for rebuilding
the binaries and will write tlbuild next.

If anyone else can look at the change / confirm the fix, all to the
good, of course ... --thanks, karl.

Date: Sun, 24 Mar 2024 17:45:02 -0400
From: David Fuchs

OK, first, my apologies to one and all.
The issue is from where I swapped two lines of DEK code, which I know
is fraught with danger, and I thought I'd run down every possible
consequence.  Obviously not.
[...] the fix is to not swap the two lines, and instead hit the
original problem with a hammer.

--- unbalanced-braces.ch	(revision 70742)
+++ unbalanced-braces.ch	(working copy)
@@ -47,7 +47,7 @@
         begin decr(param_ptr);
         flush_list(param_stack[param_ptr]);
         end
-    else if (token_type=output_text)and(output_active) then
+    else if (token_type=output_text)and(not output_can_end) then
       fatal_error("Unbalanced output routine");
 @.Unbalanced output routine@>
 @z
@@ -103,6 +103,19 @@ while (loc=null)and(token_type<>v_template)
 % that we were just finished with it, so it's where the brace
 % came from.
 
+ at x [45.989] l.19364 p.B417
+@!output_active:boolean; {are we in the midst of an output routine?}
+ at y
+@!output_active:boolean; {are we in the midst of an output routine?}
+@!output_can_end:boolean; {is this an auspicious time for it to end?}
+ at z
+
+ at x [45.989] l.19367 p.B417
+output_active:=false; insert_penalties:=0;
+ at y
+output_active:=false; output_can_end:=false; insert_penalties:=0;
+ at z
+
 % In <Resume the page builder after an output routine has come to an end>:
 @x [45.1026] l.19938 p.B432
 begin if (loc<>null) or
@@ -121,8 +134,10 @@ begin
 end_token_list; {conserve stack space in case more outputs are triggered}
 end_graf; unsave; output_active:=false; insert_penalties:=0;@/
 @y
+output_can_end:=true;
+end_token_list; {conserve stack space in case more outputs are triggered}
+output_can_end:=false;
 end_graf; unsave; output_active:=false; insert_penalties:=0;@/
-end_token_list; {conserve stack space in case more outputs are triggered}
 @z
 
 % <Expand macros in the token list and...> had set mode:=0 while

I don't think there's any chance of this failing.  Perhaps I've learned
my lesson.  If there are any costs to defray, or if there's anything
else I can do in penance, please advise.  -drf

-------------- next part --------------
A non-text attachment was scrubbed...
Name: aftergroupout.tex
Type: application/octet-stream
Size: 564 bytes
Desc: not available
URL: <https://tug.org/pipermail/tex-live/attachments/20240324/9dc923f8/attachment.obj>


More information about the tex-live mailing list.