summaryrefslogtreecommitdiff
path: root/Build/source
diff options
context:
space:
mode:
authorAndreas Scherer <andreas_tex@freenet.de>2022-08-06 09:52:39 +0000
committerAndreas Scherer <andreas_tex@freenet.de>2022-08-06 09:52:39 +0000
commit32b3058046a1b773a2b3c0ec40a4ff819a1fe307 (patch)
treeef21f9bb1c0bd24b271f3cd71cd68b79d075ff21 /Build/source
parent156c42701d41f3980bbb9d36bc63027a0082f421 (diff)
[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'). git-svn-id: svn://tug.org/texlive/trunk@64063 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source')
-rw-r--r--Build/source/texk/web2c/ChangeLog4
-rw-r--r--Build/source/texk/web2c/weave.ch111
2 files changed, 115 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/ChangeLog b/Build/source/texk/web2c/ChangeLog
index a876a06acce..3a918c23bac 100644
--- a/Build/source/texk/web2c/ChangeLog
+++ b/Build/source/texk/web2c/ChangeLog
@@ -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@freefriends.org>
* tex.ch (25.369, <Suppress expansion ...>): disallow
diff --git a/Build/source/texk/web2c/weave.ch b/Build/source/texk/web2c/weave.ch
index 2a2ab230004..ab4115e6634 100644
--- a/Build/source/texk/web2c/weave.ch
+++ b/Build/source/texk/web2c/weave.ch
@@ -325,6 +325,89 @@ begin if no_xref then return;
if (reserved(p)or(byte_start[p]+1=byte_start[p+ww]))and
@z
+@x [148] Purify 'reduce' and 'squash'.
+@d production(#)==@!debug prod(#) gubed; goto found
+@d reduce(#)==red(#); production
+@d production_end(#)==@!debug prod(#) gubed; goto found;
+ end
+@d squash(#)==begin sq(#); production_end
+@y
+@d production(#)==@!debug prod(#) gubed; goto found; end
+@d reduce(#)==begin red(#); production
+@d squash(#)==begin sq(#); production
+@z
+
+@x [151] Special case 'k=0'.
+else if cat[pp+1]=simp then squash(pp+1,1,math,0)(4)
+@y
+else if cat[pp+1]=simp then reduce(pp+1,0,math,0)(4)
+@z
+
+@x [157] Special case 'k=0'.
+squash(pp,1,intro,-3)(14)
+@y
+reduce(pp,0,intro,-3)(14)
+@z
+
+@x [161] Special case 'k=0'.
+else squash(pp,1,simp,-2)(25)
+@y
+else reduce(pp,0,simp,-2)(25)
+@z
+
+@x [162] Special case 'k=0'.
+else if cat[pp+1]=simp then squash(pp+1,1,math,0)(35)
+@y
+else if cat[pp+1]=simp then reduce(pp+1,0,math,0)(35)
+@z
+
+@x [166] Special case 'k=0'.
+squash(pp,1,terminator,-3)(42)
+@y
+reduce(pp,0,terminator,-3)(42)
+@z
+
+@x [167] Special case 'k=0'.
+if cat[pp+1]=close then squash(pp,1,stmt,-2)(43)
+@y
+if cat[pp+1]=close then reduce(pp,0,stmt,-2)(43)
+@z
+
+@x
+ begin app(force); app(backup); app2(pp); reduce(pp,2,intro,-3)(44);
+@y
+ begin app(force); app(backup); squash(pp,2,intro,-3)(44);
+@z
+
+@x [169] Special case 'k=0'.
+squash(pp,1,stmt,-2)(50)
+@y
+reduce(pp,0,stmt,-2)(50)
+@z
+
+@x [170] Special case 'k=0'.
+if cat[pp+1]=beginning then squash(pp,1,stmt,-2)(51)
+@y
+if cat[pp+1]=beginning then reduce(pp,0,stmt,-2)(51)
+@z
+
+@x [172] Move special case 'k=1' from 'squash' to special case 'k=0' here.
+scrap list.
+@y
+scrap list. This procedure takes advantage of the simplification that
+occurs when |k=0|.
+@z
+
+@x
+begin cat[j]:=c; trans[j]:=text_ptr; freeze_text;
+@y
+begin cat[j]:=c;
+if k>0 then
+ begin
+ trans[j]:=text_ptr; freeze_text;
+ end;
+@z
+
@x [172] Fix spacing.
@<Change |pp| to $\max(|scrap_base|,|pp+d|)$@>;
@y
@@ -337,6 +420,34 @@ if (reserved(p)or(byte_start[p]+1=byte_start[p+ww]))and
@ @<Change |pp| to $\max(|scrap_base|,\,|pp+d|)$@>=
@z
+@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|.
+@y
+@ Similarly, the `|squash|' macro invokes a procedure called `|sq|', which
+combines |app|${}_k$ and |red| for matching numbers~|k|.
+@z
+
+@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;
+@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);
+@z
@x [239] omit index and module names if no_xref set
@<Phase III: Output the cross-reference index@>=
@y