[net.news.b] Another fix for the article truncation problem

ra@rlgvax.UUCP (Rick Adams) (11/02/83)

As we all know by now, if an article begins with whitespace and you
haven't installed the fix, the first few lines of an article are lost.

The problem we have is that not all sites have installed the fix, so if
someone submits an article beginning with whitespace, somewhere down
the line it will probably get chopped.

The solution I have installed is not to let any articles leave this
machine beginning with whitespace.  I insert an extra newline as the
first character of the message if necessary.

So, if you install the following fix to inews.c, and an article passes
through your site, it will be "fixed" and not be truncated somewhere
else.

If enough of the major sites install this (even though they may have
already installed the other fix), we can significantly reduce the
number of truncated articles.

Rick Adams
{seismo|allegra|ihnp4}!rlgvax!ra

*** inews.c.old	Tue Nov  1 22:07:30 1983
--- inews.c	Tue Nov  1 21:50:28 1983
***************
*** 557,562
  {
  	register char *ptr;
  	register FILE *tfp;
  	int badgroup = 0, goodgroup = 0;

  	/* Fill up the rest of header. */

--- 557,563 -----
  {
  	register char *ptr;
  	register FILE *tfp;
+ 	char c;
  	int badgroup = 0, goodgroup = 0;

  	/* Fill up the rest of header. */
***************
*** 572,577

  	/* Write article to temp file. */
  	tfp = xfopen(mktemp(ARTICLE), "w");
  	lhwrite(&header, tfp);
  	while (fgets(bfr, BUFLEN, infp) != NULL) {
  		/*

--- 573,582 -----

  	/* Write article to temp file. */
  	tfp = xfopen(mktemp(ARTICLE), "w");
+ 	if ( (c=getc(infp)) == ' ' || c == '\t' ) {
+ 		header.intnumlines++;
+ 		sprintf(header.numlines,"%d",header.intnumlines);
+ 	}
  	lhwrite(&header, tfp);
  	/* Kludge to get around article truncation problem */
  	if (c == ' ' || c == '\t' )
***************
*** 573,578
  	/* Write article to temp file. */
  	tfp = xfopen(mktemp(ARTICLE), "w");
  	lhwrite(&header, tfp);
  	while (fgets(bfr, BUFLEN, infp) != NULL) {
  		/*
  		if (!strncmp(bfr, "From ", 5))

--- 578,587 -----
  		sprintf(header.numlines,"%d",header.intnumlines);
  	}
  	lhwrite(&header, tfp);
+ 	/* Kludge to get around article truncation problem */
+ 	if (c == ' ' || c == '\t' )
+ 		putc('\n', tfp);
+ 	putc(c,tfp);
  	while (fgets(bfr, BUFLEN, infp) != NULL) {
  		/*
  		if (!strncmp(bfr, "From ", 5))