Skip to content

Commit

Permalink
[CWEB] Discard rest of overfull input lines.
Browse files Browse the repository at this point in the history
In the context of the recent bug fix, I noticed that CWEAVE produced
significantly different output than WEAVE from my test case for overfull
lines, which -- in part -- had to be broken.

Although I am aware that Silvio Levy changed CWEAVE's behaviour already
in CWEB 0.5 (1987), I apply this new change in order to revert to DEK's
idea in WEAVE. Now the resulting TeX output has correctly placed comment
markers at the beginning of the broken lines. (To date, CWEAVE issued
material beyond 'buf_size' in overfull lines without such '%' markers.)

Of course, the resulting TeX output might not be processed as expected
because of the discarded material beyond 'buf_size', but the user has
been warned accordingly. :o).

git-svn-id: svn://tug.org/texlive/trunk/Build/source@67662 c570f23f-e606-0410-a88d-b1316a301751
  • Loading branch information
Andreas Scherer committed Jul 18, 2023
1 parent c63680f commit e5c3f1f
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 15 deletions.
4 changes: 4 additions & 0 deletions texk/web2c/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2023-07-18 Andreas Scherer <https://ascherer.github.io>

* cwebboot.cin: Discard rest of overfull input line.

2023-07-17 Andreas Scherer <https://ascherer.github.io>

* weave.ch: Deal with malign user input.
Expand Down
6 changes: 3 additions & 3 deletions texk/web2c/cwebboot.cin
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,10 @@ while(k<=buffer_end&&(c= getc(fp))!=EOF&&c!='\n')
#line 92 "cwebdir/comm-w2c.ch"
if((*(k++)= c)!=' '&&c!='\r')limit= k;
#line 166 "cwebdir/common.w"
if(k> buffer_end)
if((c= getc(fp))!=EOF&&c!='\n'){
if(k> buffer_end){
while((c= getc(fp))!=EOF&&c!='\n');
#line 98 "cwebdir/comm-w2c.ch"
ungetc(c,fp);loc= buffer;err_print(_("! Input line too long"));
loc= buffer;err_print(_("! Input line too long"));
#line 169 "cwebdir/common.w"

}
Expand Down
7 changes: 7 additions & 0 deletions texk/web2c/cwebdir/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2023-07-18 Andreas Scherer <https://ascherer.github.io>

* cwebdir/comm-mac.ch,
* cwebdir/comm-w2c.ch,
* cwebdir/common.c,
* cwebdir/common.w: Discard rest of overfull input line.

2023-07-17 Andreas Scherer <https://ascherer.github.io>

* cweave.w: Deal with malign user input.
Expand Down
8 changes: 4 additions & 4 deletions texk/web2c/cwebdir/comm-mac.ch
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ FILE *fp) /* what file to read from */
limit = k = buffer; /* beginning of buffer */
while (k<=buffer_end && (c=getc(fp)) != EOF && c!='\n')
if ((*(k++) = c) != ' ') limit = k;
if (k>buffer_end)
if ((c=getc(fp))!=EOF && c!='\n') {
ungetc(c,fp); loc=buffer; err_print("! Input line too long");
if (k>buffer_end) {
while ((c=getc(fp))!=EOF && c!='\n'); /* discard rest of line */
loc=buffer; err_print("! Input line too long");
@.Input line too long@>
}
if (c==EOF && limit==buffer) return false; /* there was nothing after
Expand Down Expand Up @@ -61,7 +61,7 @@ FILE *fp) /* what file to read from */
return true;
}
else if (k>buffer_end) {
ungetc(c,fp); loc=buffer; err_print("! Input line too long");
while ((c=getc(fp))!=EOF && c!='\n' && c!='\r'); /* discard rest of line */
return true;
@.Input line too long@>
}
Expand Down
4 changes: 2 additions & 2 deletions texk/web2c/cwebdir/comm-w2c.ch
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ cweb program; /* \.{CTANGLE} or \.{CWEAVE} or \.{CTWILL}? */
@z

@x
ungetc(c,fp); loc=buffer; err_print("! Input line too long");
loc=buffer; err_print("! Input line too long");
@y
ungetc(c,fp); loc=buffer; err_print(_("! Input line too long"));
loc=buffer; err_print(_("! Input line too long"));
@z

@x
Expand Down
6 changes: 3 additions & 3 deletions texk/web2c/cwebdir/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,9 +459,9 @@ if(feof(fp))return false;
limit= k= buffer;
while(k<=buffer_end&&(c= getc(fp))!=EOF&&c!='\n')
if((*(k++)= c)!=' ')limit= k;
if(k> buffer_end)
if((c= getc(fp))!=EOF&&c!='\n'){
ungetc(c,fp);loc= buffer;err_print("! Input line too long");
if(k> buffer_end){
while((c= getc(fp))!=EOF&&c!='\n');
loc= buffer;err_print("! Input line too long");

}
if(c==EOF&&limit==buffer)return false;
Expand Down
6 changes: 3 additions & 3 deletions texk/web2c/cwebdir/common.w
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ FILE *fp) /* what file to read from */
limit = k = buffer; /* beginning of buffer */
while (k<=buffer_end && (c=getc(fp)) != EOF && c!='\n')
if ((*(k++) = c) != ' ') limit = k;
if (k>buffer_end)
if ((c=getc(fp))!=EOF && c!='\n') {
ungetc(c,fp); loc=buffer; err_print("! Input line too long");
if (k>buffer_end) {
while ((c=getc(fp))!=EOF && c!='\n'); /* discard rest of line */
loc=buffer; err_print("! Input line too long");
@.Input line too long@>
}
if (c==EOF && limit==buffer) return false; /* there was nothing after
Expand Down

0 comments on commit e5c3f1f

Please sign in to comment.