🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: news.software.readers
Article #230383

Those of us who code newsReaders ..

#230383
From: Jeff▲Relf
Date: Wed, 18 Feb 2009 04:31
113 lines
5632 bytes
Those of us who code newsReaders might like to know about how
I muffle ( instead of outright kill ) nyms and >-quoted lines.

I read all “ replies ” to me, up to 5 levels away.
I allow 3 unRead posts per “ Muffled ” nym ( the 3 most-recent ).

For a block of >-quoted lines, including “ attribution lines ”,
I allow only the last two lines.

X.EXE could autoDelete a []-delimited statement at the start of a post,
but it happens so rarely that I don't worry it.

Personally, I like it when people show code;
and, more often than not, listing code helps me improve it.
>From JeffRelf.F-M.FM/X.CPP, attribution lines are muffled this way:

  #define  >Quoted  ( Ch == '>' )
  #define  >Snip  ( >Quoted || EqiN( B+1, L"Snip", 4 ) )
  const int _HTML = 2, Filtered_ = 1 ;
Filter( int _Filtered, LnA BB, LnA EE ) {  LnA  PP = BB - 1 ;  LnP  B, P ;  
  if ( ! _Filtered ) {
    while ( ++ PP < EE && ( P = B = * PP ) )
      //  Print all lines, unFiltered.
      Sh( L"%s", B );
    return ;  }
  int NeedBB = 1 ;
  Loop( 10 ) {  
    //  Scanning through the first 10 lines of a post or eMail,
    //  looking for a good place to start printing lines.
    if ( ++ PP >= EE || ! ( P = B = * PP  ) )  break;
    if ( NeedBB ) {
      //  Looking for a nonBlank line to start the post.
      WhileWhite;  if ( ! Ch )  continue ;
      //  BB points to the array of nonBlank lines that starts the post.
      BB = PP, NeedBB = 0 ;  }
    if ( EqN( B, L"-----BEGIN PGP", 14 ) ) {
      //  Xns9BB19489DD7E82362352@127.0.0.1
      //  Kill nonBlank lines.
      while ( ++ PP < EE && ( P = B = * PP ) && ( Ch = * B ) );
      //  Kill Blank lines.
      while ( ++ PP < EE && ( P = B = * PP ) && !( Ch = * B ) );
      //  BB starts the post.
      BB = PP ;  }
    if ( EqN( B, L"--", 2 ) ) break;  }
  if ( NeedBB )
    //  No lines to print, we're done.
    return ;  
  if ( _Filtered == _HTML || EqiN( B = * BB, L"<HTML", 5 )
  || EqiN( B, L"<!DOCTYPE", 9 ) || EqiN( B, L"<META", 5 ) )
    //  An HTML-only post or eMail, very rare these days.
    goto HTML_Only ;
    
  if ( MimeHeader )
    //  Handle the MINE attachment, see X.CPP.
    goto Attach ;
    
  MimeSep = 0 ;
  //  1c54b35eae63492f355dfdd8d0274b21np@mypost.invalid
  //  slrngpbe5a.6v5.wookie@aces.localdomain    
  PP = BB - 1 ;  const int MaxAttribLns = 5 ;
  while ( ++ PP < EE && PP - BB <= MaxAttribLns
  && ( P = B = * PP ) && ( Ch = * B, Ch && !>Snip ) )
    //  looking for a block of nonBlank lines
    //  terminated by either a >-quoted line ( or a <Snip> line )
    //  or a blank line followed by a >-quoted line ( or <Snip> ).
    ;
  if ( >Snip
  || ++ PP < EE && ( P = B = * PP ) && ( Ch = * B, >Snip ) )
    //  The post starts here, on the ( soon-to-be-muffled )
    //  >-quoted line or the <Snip> line, after the attribution lines.
    BB = PP + 1 ;
    
  PP = BB - 1 ; int Pgp = 0, SawBl = 1 ; LnP  prvQ = 0, prvQ2 = 0 ;
  while ( ++ PP < EE && ( P = B = * PP ) ) {
    //  Scan though each line of the body, selectively printing.
    if ( *B == '-' ) {
      if ( B[1] == '-' && ( ! B[2] || B[2] == 32 && ! B[3] ) )
        //  a “ --␣ ” or “ -- ” sigDelimiter, we're done.
        return ;
      if ( Eq( B + 1, L" -- " ) )
        //  a “ -␣--␣ ”sigDelimiter, we're done printing.
        return ;  }
    if ( EqN( B, L"-----BEGIN PGP SIGNA", 20 ) ) {
        Pgp = 1 ; continue ;  }
    if ( Pgp ) {
      if ( EqN( B, L"-----END PGP", 12 ) ) {
        Pgp = 0 ;  Sh( L"_PGP_Killed_" );  }  continue ;  }

    if ( Ch = * B, >Quoted ) {
      //  Muffle >-quoted lines, remember the last two lines.
      prvQ2 = prvQ, prvQ = B ;  continue ;  }
    //  Find the first nonWhiteSpace.
    WhileWhite;
    if ( Ch )
      //  The line wasn't blank.
      SawBl = 0 ;
    else {
      //  The line was blank.
      if ( SawBl )
        //  Kill blank lines beween blocks of
        //  ( usually removed ) >-quoted lines.
        continue ;
      SawBl = 1 ;  }
    if ( prvQ ) {
      //  A >-quoted line(s) preceeds original content.
      if ( prvQ2 && prvQ2[1] )
        //  Print the second-to-last >-quoted line of the block.
        Sh( L"%s", prvQ2 );
      //  Print the last >-quoted line of the block.
      Sh( L"%s\n\n", prvQ ), prvQ = prvQ2 = 0 ;  }
    //  A line of original content, print it.
    Sh( L"%s", B );  }  return ;
 ...
Technical Details
Message-ID: <Jeff_Relf@Seattle.2009_Feb.17|8.31pm|G>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!multikabel.net!newsfeed20.multikabel.net!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
References: <ph5pnd7ephwo.s8bhvrsivspj$.dlg@40tude.net> <Jeff_Relf@Seattle.2009_Feb.10|4.07am|w> <16es3xfv6kxul.1vmu6wduog57$.dlg@40tude.net> <Jeff_Relf@Seattle.2009_Feb.10|8.08am|m> <Jeff_Relf@Seattle.2009_Feb.17|11.44am|L> <slrngpm9mc.vns.pjr@pjr.gotdns.org>

Show Full Headers
Complete Article Headers
Message-ID: <Jeff_Relf@Seattle.2009_Feb.17|8.31pm|G>
Subject: Those of us who code newsReaders ..
Date: Wed, 18 Feb 2009 04:31:09 +0000
From: Jeff▲Relf <Jeff_Relf@Seattle.TEST>
References: <ph5pnd7ephwo.s8bhvrsivspj$.dlg@40tude.net> <Jeff_Relf@Seattle.2009_Feb.10|4.07am|w> <16es3xfv6kxul.1vmu6wduog57$.dlg@40tude.net> <Jeff_Relf@Seattle.2009_Feb.10|8.08am|m> <Jeff_Relf@Seattle.2009_Feb.17|11.44am|L> <slrngpm9mc.vns.pjr@pjr.gotdns.org>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.readers.20140922.mbox.gz!border1.nntp.ams.giganews.com!nntp.giganews.com!multikabel.net!newsfeed20.multikabel.net!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
Newsgroups: news.software.readers
Lines: 113
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Trace: individual.net JjE6221+AkZ19b9xVqReoAGwKoZlXkX97zI/QAPLt1A//fjxBF
Cancel-Lock: sha1:PDugTo9s0Vd9jAni3v/CVGYq6UA=
User-Agent: JeffRelf.F-M.FM/X.ZIP