Skip to content

Commit

Permalink
[CWEB] Disentangle 'reduce' and 'translate'.
Browse files Browse the repository at this point in the history
They both defined 'scrap_pointer i' and the uses got mixed in the
sections in between. Split into variables 'i' and 'j' respectively.

git-svn-id: svn://tug.org/texlive/trunk/Build/source@68357 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
Andreas Scherer committed Sep 24, 2023
1 parent 96c0804 commit cee81b0
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 34 deletions.
3 changes: 2 additions & 1 deletion texk/web2c/cwebdir/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
2023-09-24 Andreas Scherer <https://ascherer.github.io>

* cweave.w: Purge two scrap pointers.
* ctwill-{hint,mini}.ch,
* cweave.w: Disentangle 'reduce' and 'translate'.

2023-09-23 Andreas Scherer <https://ascherer.github.io>

Expand Down
14 changes: 12 additions & 2 deletions texk/web2c/cwebdir/ctwill-hint.ch
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ Section 155.
@$force_lines {CTWILL}155 =\\{flags}[\.{'f'}]@>
@z

Section 187.
Section 185.

@x
@ @<Print a snapsh...@>=
Expand All @@ -548,7 +548,17 @@ Section 187.
@-n@>
@%
@$n {CTWILL}182 \&{short}@>
@$n {CTWILL}183 \&{short}@>
@z

Section 187.

@x
@ If we get to the end of the scrap list, category codes equal to zero are
@y
@ If we get to the end of the scrap list, category codes equal to zero are
@-j@>
@%
@$j {CTWILL}188 \&{scrap\_pointer}@>
@z

Section 189.
Expand Down
16 changes: 13 additions & 3 deletions texk/web2c/cwebdir/ctwill-mini.ch
Original file line number Diff line number Diff line change
Expand Up @@ -1408,16 +1408,26 @@ Section 197.
@r @ Now here's the |reduce| procedure used in our code for productions,
@z
Section 202.
Section 200.
@x
@ @<Print a snapsh...@>=
@y
@r @ @<Print a snapsh...@>=
@ @<Print a snapsh...@>=
@-n@>
@%
@$n {CTWILL}197 \&{short}@>
@$n {CTWILL}198 \&{short}@>
@z
Section 202.
@x
@ If we get to the end of the scrap list, category codes equal to zero are
@y
@r @ If we get to the end of the scrap list, category codes equal to zero are
@-j@>
@%
@$j {CTWILL}203 \&{scrap\_pointer}@>
@z
Section 204.
Expand Down
55 changes: 27 additions & 28 deletions texk/web2c/cwebdir/cweave.w
Original file line number Diff line number Diff line change
Expand Up @@ -3242,6 +3242,32 @@ short d, short n)
reduce(j,k,c,d,n);
}

@ If \.{CWEAVE} is being run in debugging mode, the production numbers and
current stack categories will be printed out when |tracing| is set to |fully|;
a sequence of two or more irreducible scraps will be printed out when
|tracing| is set to |partly|.

@d off 0
@d partly 1
@d fully 2

@<Private...@>=
static int tracing=off; /* can be used to show parsing details */

@ @<Print a snapsh...@>=
if (tracing==fully) {
printf("\n%d:",n);
for (i=scrap_base; i<=lo_ptr; i++) {
putchar(i==pp?'*':' ');
if (i->mathness %4 == yes_math) putchar('+');
else if (i->mathness %4 == no_math) putchar('-');
print_cat(i->cat);
if (i->mathness /4 == yes_math) putchar('+');
else if (i->mathness /4 == no_math) putchar('-');
}
if (hi_ptr<=scrap_ptr) printf("..."); /* indicate that more is coming */
}

@ And here now is the code that applies productions as long as possible.
Before applying the production mechanism, we must make sure
it has good input (at least four scraps, the length of the lhs of the
Expand Down Expand Up @@ -3278,33 +3304,7 @@ stored, since zero does not match anything in a production.
if (lo_ptr<pp+3) {
while (hi_ptr<=scrap_ptr && lo_ptr!=pp+3)
*(++lo_ptr)=*(hi_ptr++);@^system dependencies@>
for (i=lo_ptr+1;i<=pp+3;i++) i->cat=0;
}

@ If \.{CWEAVE} is being run in debugging mode, the production numbers and
current stack categories will be printed out when |tracing| is set to |fully|;
a sequence of two or more irreducible scraps will be printed out when
|tracing| is set to |partly|.

@d off 0
@d partly 1
@d fully 2

@<Private...@>=
static int tracing=off; /* can be used to show parsing details */

@ @<Print a snapsh...@>=
if (tracing==fully) {
printf("\n%d:",n);
for (i=scrap_base; i<=lo_ptr; i++) {
putchar(i==pp?'*':' ');
if (i->mathness %4 == yes_math) putchar('+');
else if (i->mathness %4 == no_math) putchar('-');
print_cat(i->cat);
if (i->mathness /4 == yes_math) putchar('+');
else if (i->mathness /4 == no_math) putchar('-');
}
if (hi_ptr<=scrap_ptr) printf("..."); /* indicate that more is coming */
for (j=lo_ptr+1;j<=pp+3;j++) j->cat=0;
}

@ The |translate| function assumes that scraps have been stored in
Expand All @@ -3324,7 +3324,6 @@ for overflow.
static text_pointer
translate(void) /* converts a sequence of scraps */
{
scrap_pointer i; /* index into |cat| */
scrap_pointer j; /* runs through final scraps */
pp=scrap_base; lo_ptr=pp-1; hi_ptr=pp;
@<If tracing, print an indication of where we are@>@;
Expand Down

0 comments on commit cee81b0

Please sign in to comment.