Article View: news.software.nn
Article #10570here's a patch to trim long References: lines automatically
From: Alan J Rosenthal
Date: Tue, 08 Feb 2005 16:06
Date: Tue, 08 Feb 2005 16:06
88 lines
4125 bytes
4125 bytes
hi folks,
In newsgroups with long-running threads, some things seem to start messing
up when the References: line exceeds 512 bytes in length. This byte limit is
arguably implied by RFC 977. One solution is to break up the References line
into multiple lines (with leading white space on the continuation lines),
but really, you don't need all those message-ids after a while.
Son-of-1036 states a proper way to shorten References: lines: You keep the
first entry, because that is the base article which identifies the thread;
then you remove message-ids immediately after that, so that you keep as
many recent entries as possible too.
Here's a patch to do just that. It makes the references: line always be under
512 bytes. I've been using it for months. It is a patch against nn 6.6.5.
*** answer.c.orig Fri Jun 21 01:27:25 2002
--- answer.c Mon Jul 5 12:18:15 2004
***************
*** 134,140 ****
if (news.ng_ref == NULL && news.ng_ident == NULL) return;
fputs("References:", t);
! if (news.ng_ref) fprintf(t, " %s", news.ng_ref);
if (news.ng_ident) fprintf(t, " %s", news.ng_ident);
putc(NL, t);
ed_line++;
--- 134,192 ----
if (news.ng_ref == NULL && news.ng_ident == NULL) return;
fputs("References:", t);
!
! /*
! * code by flaps to trim too-long references: lines (some news servers
! * break lines at 512 bytes).
! * The first References: item must remain the base article id.
! * Then delete as many as necessary, then output the tail.
! */
! if (news.ng_ref) {
! int pos = 11; /* output position, currently strlen("References:") */
! char *p = news.ng_ref;
! /* maximum position is 512 minus the \0 and maybe minus news.ng_ident,
! * which if output is preceded by a space */
! int maxpos = (news.ng_ident ? 511 - (1 + strlen(news.ng_ident)) : 511);
! int rlen;
!
! /* First, output the base article's message id. */
! /* First output a space between "References:" and the message id. */
! putc(' ', t);
! pos++;
! /* Skip leading white space. */
! while (*p && isascii(*p) && isspace(*p))
! p++;
! /* Output through next white space. */
! while (*p && !(isascii(*p) && isspace(*p))) {
! putc(*p++, t);
! pos++;
! }
!
! /*
! * Now, the rest of the previous article's references, but maybe
! * leaving some of them out to avoid exceeding 512 bytes.
! */
! rlen = strlen(p); /* number of bytes remaining */
! if (pos + rlen <= maxpos) {
! fputs(p, t);
! } else {
! /* Find message id at which to start. Jump into the middle and
! * then find a valid starting place. */
! p += rlen - (maxpos - pos);
! /* find next '<' */
! while (*p && *p != '<')
! p++;
! if (*p)
! fputs(p - 1, t);
! /* go back to include one white space character. This
! * is guaranteed to stay within the array because
! * maxpos-pos is strictly less than rlen, therefore
! * rlen - (maxpos - pos) is positive, therefore p is
! * greater than it was before this enclosing 'else'.
! */
! }
! }
!
if (news.ng_ident) fprintf(t, " %s", news.ng_ident);
putc(NL, t);
ed_line++;
Technical Details
Message-ID:
<2005Feb8.110636.424@jarvis.cs.toronto.edu>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nn.20140326.mbox.gz!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nf3.bellglobal.com!snoopy.risq.qc.ca!newsflash.concordia.ca!canopus.cc.umanitoba.ca!utnut!utcsri!flapsShow Full Headers
Complete Article Headers
Message-ID: <2005Feb8.110636.424@jarvis.cs.toronto.edu> Subject: here's a patch to trim long References: lines automatically Date: Tue, 08 Feb 2005 16:06:36 +0000 From: flaps@dgp.toronto.edu (Alan J Rosenthal) Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nn.20140326.mbox.gz!number1.nntp.ams.giganews.com!number1.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nf3.bellglobal.com!snoopy.risq.qc.ca!newsflash.concordia.ca!canopus.cc.umanitoba.ca!utnut!utcsri!flaps Newsgroups: news.software.nn X-Nntp-Posting-Host: zeus.dgp.toronto.edu User-Agent: nn/6.6.5 X-No-Ahbou: yes Organization: Dynamic Graphics Project, University of Toronto Lines: 88