From 96c080474c67c515641e5fcf10180a0d5d05e081 Mon Sep 17 00:00:00 2001 From: Andreas Scherer Date: Sun, 24 Sep 2023 13:13:07 +0000 Subject: [PATCH] [CWEB] Purge two scrap pointers. 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 --- texk/web2c/cwebdir/ChangeLog | 4 ++++ texk/web2c/cwebdir/cweave.w | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/texk/web2c/cwebdir/ChangeLog b/texk/web2c/cwebdir/ChangeLog index 6cae5fd47d..80fe8f4731 100644 --- a/texk/web2c/cwebdir/ChangeLog +++ b/texk/web2c/cwebdir/ChangeLog @@ -1,3 +1,7 @@ +2023-09-24 Andreas Scherer + + * cweave.w: Purge two scrap pointers. + 2023-09-23 Andreas Scherer * ctwill-mini.ch, diff --git a/texk/web2c/cwebdir/cweave.w b/texk/web2c/cwebdir/cweave.w index ceb46baf22..cef3de6454 100644 --- a/texk/web2c/cwebdir/cweave.w +++ b/texk/web2c/cwebdir/cweave.w @@ -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 @@ -3204,7 +3205,7 @@ 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; @@ -3212,8 +3213,8 @@ short d, short n) 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= 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 */ }