[comp.sources.d] bugfix for latest version of vn

bobm@rtech.UUCP (Bob Mcqueer) (01/13/87)

The continuation of header lines has recently been brought to my attention.
I've never seen it before, so I assume it is a relatively recent addition.
Yes, indeed, there is a problem if the "Lines:" header line can't be found,
and a protection against division by 0 should be added in any case.

Andrew's patch looks like the right idea.  Thanks.  I'll check it out for
the "official" copy.

You might also change the decision from "line contains ':'" to "line is
empty".  This is a quick fix which remedies the problems being discussed,
although only the first line of a multi-line header will be found.
I hadn't originally used this rule because I was worried about chopping
off lines of articles if the empty line was missing.

When I saw Andrew's article this morning, I was going to publish the
following change in reader.c:

205c205,217
< 				percent = ((Rlines-Hlines-2)*100)/artlin;
---
> 			{
> 				/*
> 				** protect against division by zero - artlin
> 				** shouldn't actually come up zero at this
> 				** point if "Lines:" header line was found
> 				** and was correct.  "999" will let user
> 				** know the percentage is obviously wrong.
> 				*/
> 				if (artlin > 0)
> 					percent = ((Rlines-Hlines-2)*100)/artlin;
> 				else
> 					percent = 999;
> 			}
301c313
< 		if (index(buf,':') == NULL)
---
> 		if (buf[0] == '\n')
-- 

Bob McQueer
{amdahl, sun, mtxinu, hoptoad, cpsc6a}!rtech!bobm