From e5c3f1f0faaf6210d32cda85a4fd530211df428f Mon Sep 17 00:00:00 2001 From: Andreas Scherer Date: Tue, 18 Jul 2023 15:13:33 +0000 Subject: [PATCH] [CWEB] Discard rest of overfull input lines. 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 --- texk/web2c/ChangeLog | 4 ++++ texk/web2c/cwebboot.cin | 6 +++--- texk/web2c/cwebdir/ChangeLog | 7 +++++++ texk/web2c/cwebdir/comm-mac.ch | 8 ++++---- texk/web2c/cwebdir/comm-w2c.ch | 4 ++-- texk/web2c/cwebdir/common.c | 6 +++--- texk/web2c/cwebdir/common.w | 6 +++--- 7 files changed, 26 insertions(+), 15 deletions(-) diff --git a/texk/web2c/ChangeLog b/texk/web2c/ChangeLog index 2cdc40a1a2..ecf6989ac1 100644 --- a/texk/web2c/ChangeLog +++ b/texk/web2c/ChangeLog @@ -1,3 +1,7 @@ +2023-07-18 Andreas Scherer + + * cwebboot.cin: Discard rest of overfull input line. + 2023-07-17 Andreas Scherer * weave.ch: Deal with malign user input. diff --git a/texk/web2c/cwebboot.cin b/texk/web2c/cwebboot.cin index 78788c9a5f..adc605332d 100644 --- a/texk/web2c/cwebboot.cin +++ b/texk/web2c/cwebboot.cin @@ -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" } diff --git a/texk/web2c/cwebdir/ChangeLog b/texk/web2c/cwebdir/ChangeLog index fa92f4560a..0c494d4b87 100644 --- a/texk/web2c/cwebdir/ChangeLog +++ b/texk/web2c/cwebdir/ChangeLog @@ -1,3 +1,10 @@ +2023-07-18 Andreas Scherer + + * 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 * cweave.w: Deal with malign user input. diff --git a/texk/web2c/cwebdir/comm-mac.ch b/texk/web2c/cwebdir/comm-mac.ch index 2fe2dcb2a9..d5529f3b2a 100644 --- a/texk/web2c/cwebdir/comm-mac.ch +++ b/texk/web2c/cwebdir/comm-mac.ch @@ -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 @@ -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@> } diff --git a/texk/web2c/cwebdir/comm-w2c.ch b/texk/web2c/cwebdir/comm-w2c.ch index 9f6dd38940..1b38a53881 100644 --- a/texk/web2c/cwebdir/comm-w2c.ch +++ b/texk/web2c/cwebdir/comm-w2c.ch @@ -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 diff --git a/texk/web2c/cwebdir/common.c b/texk/web2c/cwebdir/common.c index 324cd0ee4b..49cfa476d3 100644 --- a/texk/web2c/cwebdir/common.c +++ b/texk/web2c/cwebdir/common.c @@ -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; diff --git a/texk/web2c/cwebdir/common.w b/texk/web2c/cwebdir/common.w index c3d82f3c94..3251688049 100644 --- a/texk/web2c/cwebdir/common.w +++ b/texk/web2c/cwebdir/common.w @@ -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