🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.nn
Article #3253

Patch to fix "No Lines Header" woes.

#3253
From: Tony Luck
Date: Wed, 21 Oct 1992 19:31
87 lines
3541 bytes
I forget where I got this patch from ... maybe its the one that people say is
in the FAQ, maybe it came from some other article on Usenet.  Anyway, it deals
with those irritating question marks that turn up when there is no "Lines"
header in a posting.

If you run INN (or if all of your newsfeeds run INN) then you don't need this
patch (and you shouldn't be seeing question marks).  INN adds "Lines" headers
to articles that don't have them.

If you have a religious belief that articles without Lines headers are a
communist/facist plot to make you waste cpu time counting lines in news
articles ... then stop reading now.  Likewise if you believe that number
of lines is not a useful measure of article size.

This patch modifies nnmaster to count the lines in articles that have no
Lines header.  This shouldn't be much of an overhead because:

	a) more and more articles are arriving with Lines headers as INN
	   gets installed more places.

	b) most articles are small, so by the time nnmaster has read the
	   header, the rest of the article has been grabbed from disk, so
	   you don't have to do much extra i/o ... just count '\n' chars
	   that are already in memory.

This patch is to "news.c" of nn6.4.16 (which wasn't changed by patches 17
and 18 ... so it will work for these too).

Apply this patch, or don't ... I couldn't care less ... but can we stop
talking about whether "Lines" headers are a good or bad thing?

-Tony <aegl@ossi.com>

*** news.c.old	Wed Oct 21 11:18:37 1992
--- news.c	Mon Feb 10 09:46:54 1992
***************
*** 230,236 ****
      char *digest_buffer;
      char *parse_header();
      struct stat statb;
!     int retry;
      FILE *f;
  #ifdef NNTP
      int lazy;
--- 230,236 ----
      char *digest_buffer;
      char *parse_header();
      struct stat statb;
!     int c, retry;
      FILE *f;
  #ifdef NNTP
      int lazy;
***************
*** 299,310 ****
  
  	body = parse_header(f, art_hdr_field, modes, buffer1);
  
- 	news.ng_lines = news.ng_xlines ? atoi(news.ng_xlines) : -1;
  	if (news.ng_from == NULL) news.ng_from = news.ng_sender;
  
! 	if (modes & FILL_OFFSETS) {
  	    art->fpos = news.ng_fpos = ftell(f);
  
  	    fseek(f, (off_t)0, 2);
  	    news.ng_lpos = ftell(f);
  	}
--- 299,318 ----
  
  	body = parse_header(f, art_hdr_field, modes, buffer1);
  
  	if (news.ng_from == NULL) news.ng_from = news.ng_sender;
  
! 	if (modes & FILL_OFFSETS)
  	    art->fpos = news.ng_fpos = ftell(f);
  
+ 	if (news.ng_xlines)
+ 	    news.ng_lines = atoi(news.ng_xlines);
+ 	else {
+ 	    news.ng_lines = 0;
+ 	    while ((c = getc(f)) != EOF)
+ 		if (c == '\n')
+ 		    news.ng_lines++;
+ 	}
+ 	if (modes & FILL_OFFSETS) {
  	    fseek(f, (off_t)0, 2);
  	    news.ng_lpos = ftell(f);
  	}
Technical Details
Message-ID: <1c4b76INN5mr@nym.ossi.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!sparky!uunet!charon.amdahl.com!news.fai.com!news.ossi.com!not-for-mail
References: <1992Oct17.204328.20406@gallant.apple.com> <1172@jagubox.gsfc.nasa.gov> <bjKV?O?0@twinsun.com> <1179@jagubox.gsfc.nasa.gov>

Show Full Headers
Complete Article Headers
Message-ID: <1c4b76INN5mr@nym.ossi.com>
Subject: Patch to fix "No Lines Header" woes.
Date: Wed, 21 Oct 1992 19:31:50 +0000
From: aegl@ossi.com (Tony Luck)
References: <1992Oct17.204328.20406@gallant.apple.com> <1172@jagubox.gsfc.nasa.gov> <bjKV?O?0@twinsun.com> <1179@jagubox.gsfc.nasa.gov>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!archive!mbox2nntp-news.software.nn.mbox.zip!sparky!uunet!charon.amdahl.com!news.fai.com!news.ossi.com!not-for-mail
Newsgroups: news.software.nn
Organization: Open Systems Solutions Inc.
Lines: 87
NNTP-Posting-Host: nym.ossi.com