Skip to content

Commit

Permalink
[CWEB] Purge two scrap pointers.
Browse files Browse the repository at this point in the history
Make the 'shift' arithmetic in section 182 clearer (without 'i1'/'o')
and avoid shadowing variable/parameter 'k' in section 187.

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

* cweave.w: Purge two scrap pointers.

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

* ctwill-mini.ch,
Expand Down
24 changes: 12 additions & 12 deletions texk/web2c/cwebdir/cweave.w
Original file line number Diff line number Diff line change
Expand Up @@ -3195,7 +3195,8 @@ static void reduce(scrap_pointer,short,eight_bits,short,short);@/
static void squash(scrap_pointer,short,eight_bits,short,short);

@ Now here's the |reduce| procedure used in our code for productions,
which takes advantage of the simplification that occurs when |k==0|.
which takes advantage of the simplifications that occur when |k==0|
or |k==1|.

@c
static void
Expand All @@ -3204,16 +3205,16 @@ scrap_pointer j, short k,
eight_bits c,
short d, short n)
{
scrap_pointer i, o; /* pointers into scrap memory */
scrap_pointer i; /* pointer into scrap memory */
j->cat=c;
if (k>0) {
j->trans=text_ptr;
j->mathness=4*cur_mathness+init_mathness;
freeze_text();
}
if (k>1) {
for (i=j+k, o=j+1; i<=lo_ptr; i++, o++)
*o=*i;@^system dependencies@>
for (i=j+k; i<=lo_ptr; i++)
*(i-k+1)=*i;@^system dependencies@>
lo_ptr=lo_ptr-k+1;
}
pp=(pp+d<scrap_base? scrap_base: pp+d);
Expand Down Expand Up @@ -3294,15 +3295,14 @@ static int tracing=off; /* can be used to show parsing details */

@ @<Print a snapsh...@>=
if (tracing==fully) {
scrap_pointer k; /* pointer into |scrap_info|; shadows |short k| */
printf("\n%d:",n);
for (k=scrap_base; k<=lo_ptr; k++) {
if (k==pp) putchar('*'); else putchar(' ');
if (k->mathness %4 == yes_math) putchar('+');
else if (k->mathness %4 == no_math) putchar('-');
print_cat(k->cat);
if (k->mathness /4 == yes_math) putchar('+');
else if (k->mathness /4 == no_math) putchar('-');
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 */
}
Expand Down

0 comments on commit 96c0804

Please sign in to comment.