🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #74539

[slrn] correct threading of multi-part binaries

#74539
From: jurriaan kalkman
Date: Wed, 28 Mar 2001 19:39
113 lines
5259 bytes
I'm eagerly awaiting 0.9.7.0 (as we are all, I guess) and then I will
try to get (some of) these patches incorporated.

The current patch does what it should do, except for these headers:


slrn 0.9.6.3 ** Press '?' for help, 'q' to quit. ** Server: newszilla
 1  - 7501:[RS          ]    ZOEgirl - 02 - Anything Is Possible.mp3 (04/17)-[02/11]-[224K]
 2  - 7501:[RS          ]    ZOEgirl - 02 - Anything Is Possible.mp3 (05/17)-[02/11]-[224K]
 3  - 7501:[RS          ]    ZOEgirl - 02 - Anything Is Possible.mp3 (06/17)-[02/11]-[224K]
13  - 7501:[RS          ]    ZOEgirl - 02 - Anything Is Possible.mp3 (16/17)-[02/11]-[224K]
14  - 2561:[RS          ]    ZOEgirl - 02 - Anything Is Possible.mp3 (17/17)-[02/11]-[224K]
15  - 7502:[RS          ]    ZOEgirl - 03 - Suddenly.mp3 (01/23)-[03/11]-[224K]
16  - 7501:[RS          ]    ZOEgirl - 03 - Suddenly.mp3 (02/23)-[03/11]-[224K]
17  - 7501:[RS          ]    ZOEgirl - 03 - Suddenly.mp3 (03/23)-[03/11]-[224K]

and I must say, some real interesting person has come up with these. I
don't think I will bother to try and correct this case - over 100,000
other headers worked fine.


Now the patch:
(please not that you can just insert the function in art.c somewhere,
then change the lines at the bottom - what lines should be obvious).

#ifdef SLRN_HAS_MULTIPART_THREADING
static int subject_multipart_cmp (unsigned char *sa,
                                  unsigned char *sb) /*{{{*/
{
   /* we want to intercept headings like
    * file 1 (1/9)
    * file 2 (2/9)
    * etc. and thread them into one thread.
    * but since we also have file [1/3] part (1/9), file [1/3] part (2/9)
    * just blind checking for 1/3 won't work. The headers are looked at
    * starting at the last character to prevent this. If both headers match the
    * regexp, all text before the regexp must also match for them to be part of
    * the same thread. In any other case, the headers are not part of the same
    * thread.
    *
    * detailed explanation: this is a catch-all regexp, I'll explain the details:
    * [^0-9] - a non-numerical character
    * [(\\[] - the delimiter, a ( or [ character
    * [0-9]+ - a possible number.
    * /      - the delimiter. So far, I've only seen / used for this.
    * [0-9]+ - multiple number chars after the delimiter
    * [)\\]] - the expression must also end with a delimiter.
    *
    */
   static char *multipart_sign = "[^0-9][(\\[][0-9]*/[0-9]+[)\\]]";
   char compiled_pattern_buf[256];
   SLRegexp_Type re;
   register unsigned char *h1, *h2;
   int len1, len2;

   re.pat = (unsigned char *) multipart_sign;
   re.buf = compiled_pattern_buf;
   re.case_sensitive = 0;
   re.buf_len = sizeof (compiled_pattern_buf);
   (void) SLang_regexp_compile(&re);

   h1 = sa + strlen (sa);
   h2 = sb + strlen (sb);
   while (1) 
    {
      *h1--;
      *h2--;
      /* we have run out of subject? */
      if ( (h1 == sa) || (h2 == sb) )
        {
           return 1;
        }
      if ( (NULL != slrn_regexp_match(&re, h1)) &&
           (NULL != slrn_regexp_match(&re, h2)) )
        {
           len1 = strlen(sa) - strlen(slrn_regexp_match(&re, h1));
           len2 = strlen(sb) - strlen(slrn_regexp_match(&re, h2));
           /* the regexp is longer that the subject or the part of the subject
            * before the regexp isn't equally long?
            */
           if ((len1 < 0) || (len2 < 0) || (len1 != len2))
             {
                return 1;
             }
           /* if the regexps have matched, and the part before the regexps
            * is the same, we win!
            */
           if (!strncmp(sa, sb, len1))
             {
                return 0;
             }
           return 1;
        }
    }
   return 1;
}
#endif

#ifdef SLRN_HAS_MULTIPART_THREADING
        if  ( (0 == subject_cmp (h->subject, h1->subject)) ||
              (0 == subject_multipart_cmp (h->subject, h1->subject)) )
#else
        if (0 == subject_cmp (h->subject, h1->subject))
#endif

Good luck,
Jurriaan
-- 
BOFH excuse #185:

system consumed all the paper for paging
GNU/Linux 2.4.2-ac26 SMP/ReiserFS 2x1743 bogomips load av: 0.00 0.00 0.04
Technical Details
Message-ID: <slrn9c4e3r.3p1._hate_spam_thunder7@middle.of.nowhere>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.tele.dk!194.109.133.3!transit.news.xs4all.nl!no_spam_here

Show Full Headers
Complete Article Headers
Message-ID: <slrn9c4e3r.3p1._hate_spam_thunder7@middle.of.nowhere>
Subject: [slrn] correct threading of multi-part binaries
Date: Wed, 28 Mar 2001 19:39:45 +0000
From: _hate_spam_thunder7@xs4all.nl (jurriaan kalkman)
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.mbox.zip!supernews.google.com!sn-xit-03!supernews.com!logbridge.uoregon.edu!news.tele.dk!194.109.133.3!transit.news.xs4all.nl!no_spam_here
Newsgroups: news.software.readers
Organization: XS4ALL Internet BV
Lines: 112
NNTP-Posting-Host: rivierenland.xs4all.nl
X-Trace: news1.xs4all.nl 985808385 21997 194.109.14.47 (28 Mar 2001 19:39:45 GMT)
X-Complaints-To: abuse@xs4all.nl
NNTP-Posting-Date: 28 Mar 2001 19:39:45 GMT
X-Face: b$-F+98,@$_I=*ODq'<K2(OA)qC&,(GP=z2^`4dwQwy&e;!|R?>")k9FH3?YC+%*kF\=<Rx"Hy2_eyMtnFSiO8
User-Agent: slrn/0.9.6.4pl4 (GNU/Linux)