Path: utzoo!utstat!jarvis.csri.toronto.edu!mailrus!iuvax!watmath!looking!brad From: brad@looking.on.ca (Brad Templeton) Newsgroups: news.software.b Subject: Patch to do semi-truncation of the references line Message-ID: <50079@looking.on.ca> Date: 20 Nov 89 04:59:36 GMT Organization: Looking Glass Software Limited, Waterloo ON Lines: 89 Class: information,original I urge you all to apply the patch posted here that gives a 2K (or larger) buffer for the NEWSHEADER interpretation in rn. Here is another patch to the code that does the %R expansion. It is a kludge, but it gets the job done. If a references chain is too long, it deletes elements off the end, leaving the immediate parent. Deleted items are replaced with a 'dummy' message ID of where nn is a count of deleted ids. You can have more than one of these if you have to, but this patch will combine 'em. As far as I know, the won't break anything currently out there, although code that pruned such a tree could prune all such trees because this will not be a unique ID. If anybody knows of code that this would break, let me know, and we will make the @DEL.> ids unique in some way. This kludge works by assuming that %R is at the end of the expansion. That means you should update NEWSHEADER to put it at the end. I use the following in config.h: # define NEWSHEADER "Newsgroups: %F\nSubject: Re: %S\nSummary: \nFollowup-To: \nDistribution: %D\nOrganization: %o\nKeywords: %[keywords]\nReferences: %R\n\n" Note that if you increase the intrp buffer for followups to 2K, you may never end up using this code, unless chains get very long. Later I might put together some code to do this a little fancier. I decided it was better to delete from the end rather than the front after the root, as important nodes are more likely to be close to the root. Of course that's not always true. Sigh. Note that the dummy ID ends in a dot. I figure no real site name ends in dot, so this is a good syntax for special message-ids. *** old/intrp.c --- intrp.c ************** *** 697,702 *scrbuf = '\0'; if (!artid_buf) artid_buf = fetchlines(art,MESSID_LINE); if (artid_buf[0] == '<') safecat(scrbuf,artid_buf,sizeof(scrbuf)); else { --- 697,740 ----- *scrbuf = '\0'; if (!artid_buf) artid_buf = fetchlines(art,MESSID_LINE); + /* Remove stuff from scrbuf to be sure the final id + fits. The number 20 is a safety buffer, including + room for the 'DEL.' dummy entries, and only + works if you change the NEWSHEADER environment + variable to put the %R at or near the end of the + followup header. Use 150 if you don't change + NEWSHEADER in your config.h. + This is a KLUDGE */ + { + int lsofar, artilen; /* lengths of strings */ + char *backp; /* back pointer in scrbuf */ + int delcount; /* count deleted IDs */ + lsofar = strlen(scrbuf); + artilen = strlen(artid_buf); + + delcount = 0; + /* loop back to find room */ + while( destsize - lsofar - artilen < 20 && + (backp = rindex( scrbuf, ' ' ))){ + *backp = 0; + /* get count from other deletions! */ + if( strncmp( backp+4, "@DEL.>", 6 ) == 0 ) + delcount += atoi( backp+2 ); + else + delcount++; /* count number deleted */ + lsofar = backp-scrbuf; /* adjust length */ + } + /* if we never made it, use just the parent! */ + if( backp == (char *)0 && delcount > 0 ) { + *scrbuf = '\0'; + delcount++; + } + if( delcount ) { + char dcstring[16]; /* plenty of room for number */ + sprintf(dcstring, "<%02d@DEL.>", delcount); + safecat(scrbuf,dcstring,sizeof(scrbuf)); + } + } /* end mini-scope for locals */ if (artid_buf[0] == '<') safecat(scrbuf,artid_buf,sizeof(scrbuf)); else { -- Brad Templeton, ClariNet Communications Corp. -- Waterloo, Ontario 519/884-7473