texlive[64063] Build/source/texk/web2c: [WEB] Rewrite 'squash' to

commits+ascherer at tug.org commits+ascherer at tug.org
Sat Aug 6 11:52:39 CEST 2022


Revision: 64063
          http://tug.org/svn/texlive?view=revision&revision=64063
Author:   ascherer
Date:     2022-08-06 11:52:39 +0200 (Sat, 06 Aug 2022)
Log Message:
-----------
[WEB] Rewrite 'squash' to match description in section 148.

The original special case 'squash(..,1,..)' was /not/ a combination of
'app1()' and 'reduce(..,1,..)' as advertised in section 148; instead, it
was an ultra-compact variant of 'reduce'.

Moving the special case 'k==1' from 'sq' to 'red' as separate case
'k==0' makes 'squash(..,k,..)' consistent for 'k=1,2,3' (and it makes
use of the otherwise abandoned 'confusion' macro).  Curiously enough,
now there's no 'squash(..,1,..)' anymore, but CWEAVE has at least two
rules that apply this case (and it even works for 'k=4').

Modified Paths:
--------------
    trunk/Build/source/texk/web2c/ChangeLog
    trunk/Build/source/texk/web2c/weave.ch

Modified: trunk/Build/source/texk/web2c/ChangeLog
===================================================================
--- trunk/Build/source/texk/web2c/ChangeLog	2022-08-05 23:49:22 UTC (rev 64062)
+++ trunk/Build/source/texk/web2c/ChangeLog	2022-08-06 09:52:39 UTC (rev 64063)
@@ -1,3 +1,7 @@
+2022-08-06  Andreas Scherer  <https://ascherer.github.io>
+
+	* weave.ch: Rewrite 'squash' to match description in section 148.
+
 2022-07-16  Karl Berry  <karl at freefriends.org>
 
 	* tex.ch (25.369, <Suppress expansion ...>): disallow

Modified: trunk/Build/source/texk/web2c/weave.ch
===================================================================
--- trunk/Build/source/texk/web2c/weave.ch	2022-08-05 23:49:22 UTC (rev 64062)
+++ trunk/Build/source/texk/web2c/weave.ch	2022-08-06 09:52:39 UTC (rev 64063)
@@ -325,6 +325,89 @@
 if (reserved(p)or(byte_start[p]+1=byte_start[p+ww]))and
 @z
 
+ at x [148] Purify 'reduce' and 'squash'.
+ at d production(#)==@!debug prod(#) gubed; goto found
+ at d reduce(#)==red(#); production
+ at d production_end(#)==@!debug prod(#) gubed; goto found;
+  end
+ at d squash(#)==begin sq(#); production_end
+ at y
+ at d production(#)==@!debug prod(#) gubed; goto found; end
+ at d reduce(#)==begin red(#); production
+ at d squash(#)==begin sq(#); production
+ at z
+
+ at x [151] Special case 'k=0'.
+else if cat[pp+1]=simp then squash(pp+1,1,math,0)(4)
+ at y
+else if cat[pp+1]=simp then reduce(pp+1,0,math,0)(4)
+ at z
+
+ at x [157] Special case 'k=0'.
+squash(pp,1,intro,-3)(14)
+ at y
+reduce(pp,0,intro,-3)(14)
+ at z
+
+ at x [161] Special case 'k=0'.
+else squash(pp,1,simp,-2)(25)
+ at y
+else reduce(pp,0,simp,-2)(25)
+ at z
+
+ at x [162] Special case 'k=0'.
+else if cat[pp+1]=simp then squash(pp+1,1,math,0)(35)
+ at y
+else if cat[pp+1]=simp then reduce(pp+1,0,math,0)(35)
+ at z
+
+ at x [166] Special case 'k=0'.
+squash(pp,1,terminator,-3)(42)
+ at y
+reduce(pp,0,terminator,-3)(42)
+ at z
+
+ at x [167] Special case 'k=0'.
+if cat[pp+1]=close then squash(pp,1,stmt,-2)(43)
+ at y
+if cat[pp+1]=close then reduce(pp,0,stmt,-2)(43)
+ at z
+
+ at x
+  begin app(force); app(backup); app2(pp); reduce(pp,2,intro,-3)(44);
+ at y
+  begin app(force); app(backup); squash(pp,2,intro,-3)(44);
+ at z
+
+ at x [169] Special case 'k=0'.
+squash(pp,1,stmt,-2)(50)
+ at y
+reduce(pp,0,stmt,-2)(50)
+ at z
+
+ at x [170] Special case 'k=0'.
+if cat[pp+1]=beginning then squash(pp,1,stmt,-2)(51)
+ at y
+if cat[pp+1]=beginning then reduce(pp,0,stmt,-2)(51)
+ at z
+
+ at x [172] Move special case 'k=1' from 'squash' to special case 'k=0' here.
+scrap list.
+ at y
+scrap list.  This procedure takes advantage of the simplification that
+occurs when |k=0|.
+ at z
+
+ at x
+begin cat[j]:=c; trans[j]:=text_ptr; freeze_text;
+ at y
+begin cat[j]:=c;
+if k>0 then
+  begin
+    trans[j]:=text_ptr; freeze_text;
+  end;
+ at z
+
 @x [172] Fix spacing.
 @<Change |pp| to $\max(|scrap_base|,|pp+d|)$@>;
 @y
@@ -337,6 +420,34 @@
 @ @<Change |pp| to $\max(|scrap_base|,\,|pp+d|)$@>=
 @z
 
+ at x [174] Rewrite 'squash' to match description in section [148].
+@ Similarly, the `|squash|' macro invokes a procedure called `|sq|'. This
+procedure takes advantage of the simplification that occurs when |k=1|.
+ at y
+@ Similarly, the `|squash|' macro invokes a procedure called `|sq|', which
+combines |app|${}_k$ and |red| for matching numbers~|k|.
+ at z
+
+ at x
+var i:0..max_scraps; {index into scrap memory}
+begin if k=1 then
+  begin cat[j]:=c; @<Change |pp|...@>;
+  end
+else  begin for i:=j to j+k-1 do
+    begin app1(i);
+    end;
+  red(j,k,c,d);
+  end;
+ at y
+begin
+  case k of
+  1: begin app1(j);@+ end;
+  2: begin app2(j);@+ end;
+  3: begin app3(j);@+ end;
+  othercases confusion('squash')
+  endcases;@/
+  red(j,k,c,d);
+ at z
 @x [239] omit index and module names if no_xref set
 @<Phase III: Output the cross-reference index@>=
 @y



More information about the tex-live-commits mailing list.