diff --git a/texk/web2c/cwebdir/ChangeLog b/texk/web2c/cwebdir/ChangeLog index 80fe8f4731..8a74ad881d 100644 --- a/texk/web2c/cwebdir/ChangeLog +++ b/texk/web2c/cwebdir/ChangeLog @@ -1,6 +1,7 @@ 2023-09-24 Andreas Scherer - * cweave.w: Purge two scrap pointers. + * ctwill-{hint,mini}.ch, + * cweave.w: Disentangle 'reduce' and 'translate'. 2023-09-23 Andreas Scherer diff --git a/texk/web2c/cwebdir/ctwill-hint.ch b/texk/web2c/cwebdir/ctwill-hint.ch index ee200c4939..59366ed8c1 100644 --- a/texk/web2c/cwebdir/ctwill-hint.ch +++ b/texk/web2c/cwebdir/ctwill-hint.ch @@ -539,7 +539,7 @@ Section 155. @$force_lines {CTWILL}155 =\\{flags}[\.{'f'}]@> @z -Section 187. +Section 185. @x @ @= @@ -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. diff --git a/texk/web2c/cwebdir/ctwill-mini.ch b/texk/web2c/cwebdir/ctwill-mini.ch index 396d46cbd9..3184d6cf1c 100644 --- a/texk/web2c/cwebdir/ctwill-mini.ch +++ b/texk/web2c/cwebdir/ctwill-mini.ch @@ -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 @ @= @y -@r @ @= +@ @= @-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. diff --git a/texk/web2c/cwebdir/cweave.w b/texk/web2c/cwebdir/cweave.w index cef3de6454..a7b8b81031 100644 --- a/texk/web2c/cwebdir/cweave.w +++ b/texk/web2c/cwebdir/cweave.w @@ -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 + +@= +static int tracing=off; /* can be used to show parsing details */ + +@ @= +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 @@ -3278,33 +3304,7 @@ stored, since zero does not match anything in a production. if (lo_ptr - 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 - -@= -static int tracing=off; /* can be used to show parsing details */ - -@ @= -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 @@ -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; @@;