🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.free.newsservers
Article #146828

--

#146828
From: Jeff-Relf.Me
Date: Tue, 01 Jan 2013 17:46
67 lines
5346 bytes
<style>  :not(:link):not(:visited){color:rgb(255,111,111)} :link{color:rgb(155,155,155)}  :visited{color:rgb(155,155,0)}  </style> <body bgcolor=black style='margin: 0'><pre style='color: rgb(255,111,111); padding:0 1em 1em 1em; font-size: 15px;  font-family: DejaVu Sans Mono, Lucida Console, monospace, MS Mincho; background: black;'> 
As I said before, my diff routine skips past the unchanged part
at the beginning and ends of lines/files; top, bottom, left and right.
I call this "the Pinch".

Then it "peels off" ( and prints ) the differences at the ends...
Pinching and Peeling, from the edges to the middle.

Although the algorithm is simple, the finer deatials are not.
The core of it looks like this:

LnP F, _F ;  LnA BBx, EEx, _BBx, _EEx, BB_Sync, EE_Sync, _BB_Sync, _EE_Sync ;

#define white( P ) ( *P &lt;= 32 || *P == 0xA0 )
#define white⋀( P ) ( *P && *P &lt;= 32 || *P == 0xA0 )
#define  Same⋁Sync   ( Data⋁( F, EEx,  EE ), Data⋁( _F, _EEx,  _EE ), Same() )
#define  Same⋀Sync   ( Data⋀( F, BBx,  BB ), Data⋀( _F, _BBx,  _BB ), Same⋀() )

#define  Same⋁Pinch  ( Data⋁( F, BBx,  EE ), Data⋁( _F, _BBx,  _EE ), Same() )
#define  Same⋀Pinch  ( Data⋀( F, EEx, BBx ), Data⋀( _F, _EEx, _BBx ), Same⋀() )
          
Data⋁( LnP &amp;P, LnA &amp;PP, LnA EE ) { if ( P ) while( *P && white( P ) ) P++ ;
  while( ( !P || !*P ) && PP < EE ) P = ++PP >= EE ? 0 : *PP ;  }

Data⋀( LnP &amp;P, LnA &amp;PP, LnA BB ) { if ( P ) while( *P && white( P ) ) P++ ;
  while( ( !P || !*P ) && PP >= BB ) P = --PP < BB ? 0 : *PP ;  }

int Same() { if ( !F || !_F ) return 0 ; 
  while( *F && *F == *_F && !white( F ) ) F++, _F++ ;  return white( F ) && white( _F );  }

int Same⋀() { if ( !F || !_F ) return 0 ; 
  while( *F && *F == *_F && !white( F ) ) F++, _F++ ;  return !*F && !*_F || white⋀( F ) && white⋀( _F );  }

int SyncDwn( LnA BB, LnA EE, LnA _BB, LnA _EE ) { BB_Sync = BB, _BB_Sync = _BB ;
  F = _F = 0, EEx = BB - 1, _EEx = _BB - 1 ; while ( Same⋁Sync ) if ( !*F && !*_F ) return 1 ;  return 0 ;  }

int SyncUp( LnA BB, LnA EE, LnA _BB, LnA _EE ) { EE_Sync = EE, _EE_Sync = _EE ;
  F = _F = 0, BBx = EE, _BBx = _EE ; while ( Same⋀Sync ) if ( !*F && !*_F ) return 1 ;  return 0 ;  }

Pinch( LnA BB, LnA EE, LnA _BB, LnA _EE ) { F = _F = 0, BBx = BB - 1, _BBx = _BB - 1 ; while ( Same⋁Pinch );
  F = _F = 0, EEx = EE, _EEx = _EE ; while ( Same⋀Pinch );  EEx++, _EEx++ ;  }
          
#define EoFS_Dwn  ( S = BB_Slow < EE_Slow, _S = _BB_Slow < _EE_Slow, F = BB_Fast+1 < EE_Slow, _F = _BB_Fast+1 < _EE_Slow )
#define EoFS_Up   ( S = EE_Slow > BB_Slow, _S = _EE_Slow > _BB_Slow, F = EE_Fast-1 > BB_Slow, _F = _EE_Fast-1 > _BB_Slow )
#define Top_Fast  ( BB_Fast = BB_Slow, _BB_Fast = _BB_Slow )
#define Bot_Fast  ( EE_Fast = EE_Slow, _EE_Fast = _EE_Slow )

Peel( LnA BB, LnA EE, LnA _BB, LnA _EE ) { int rv, Top, Bot, S, _S, F, _F ;  LnP t, _t ;  
  LnA  BB_Slow, _BB_Slow,  BB_Fast, _BB_Fast,   EE_Slow, _EE_Slow, EE_Fast, _EE_Fast ;
  Top = Bot = 0, BB_Slow = BB, _BB_Slow = _BB, EE_Slow = EE, _EE_Slow = _EE, Top_Fast, Bot_Fast ;
   
  ⋅Top:    if ( Top ) goto ⋅Bot ;  EoFS_Dwn ;
  if ( !S && !_S ) { Top = 1, BB_Sync = BB_Slow, _BB_Sync = _BB_Slow ; goto ⋅Bot ;  }
  if ( F && _S ) if ( SyncDwn( BB_Fast, EE, _BB_Slow, _EE ) ) { Top = 1 ; goto ⋅Bot ;  } else BB_Fast++ ;
  if ( S && _F ) if ( rv = SyncDwn( BB_Slow, EE, _BB_Fast, _EE ) ) { Top = 1 ; goto ⋅Bot ;  } else _BB_Fast++ ;
  if ( EoFS_Dwn, !( F && _S || S && _F ) ) BB_Slow += S, _BB_Slow += _S, Top_Fast ;

  ⋅Bot:    if ( Bot ) goto Skip ;  EoFS_Up ; 
  if ( !S && !_S ) { Bot = 1, EE_Sync = EE_Slow, _EE_Sync = _EE_Slow ; goto ⋅Top ;  }
  if ( F && _S ) if ( SyncUp( BB, EE_Fast, _BB, _EE_Slow ) ) { Bot = 1 ; goto ⋅Top ;  } else EE_Fast-- ;
  if ( S && _F ) if ( rv = SyncUp( BB, EE_Slow, _BB, _EE_Fast ) ) { Bot = 1 ;  goto ⋅Top ;  } else _EE_Fast-- ;
  if ( EoFS_Up, !( F && _S || S && _F ) ) EE_Slow -= S, _EE_Slow -= _S, Bot_Fast ;
        
  Skip:    if ( Top && Bot ) return ;  goto ⋅Top ;  }

  <img Src="http://Jeff-Relf.Me/Diff.PNG" Alt="Text Comparison">
Technical Details
Message-ID: <Jeff-Relf.Me@Jan.1{9.46.AM.Seattle.2013}>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.os.linux.advocacy.mbox.zip!i11ni345817wiw.0!nntp.google.com!goblin3!goblin1!goblin.stu.neva.ru!news.glorb.com!news-spur1.glorb.com!newsread.glorb.com!.POSTED!not-for-mail
References: <Jeff-Relf.Me@Dec.30{6.20.PM.Seattle.2012}>

Show Full Headers
Complete Article Headers
Message-ID: <Jeff-Relf.Me@Jan.1{9.46.AM.Seattle.2013}>
Subject: --
Date: Tue, 01 Jan 2013 17:46:01 +0000
From: Jeff-Relf.Me <@.>
References: <Jeff-Relf.Me@Dec.30{6.20.PM.Seattle.2012}>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-comp.os.linux.advocacy.mbox.zip!i11ni345817wiw.0!nntp.google.com!goblin3!goblin1!goblin.stu.neva.ru!news.glorb.com!news-spur1.glorb.com!newsread.glorb.com!.POSTED!not-for-mail
X-Received: by 10.180.97.198 with SMTP id ec6mr9966000wib.5.1357062358556;
MIME-Version: 1.0
Newsgroups: alt.free.newsservers,comp.os.linux.advocacy,sci.physics,alt.astronomy
Organization: Glorb Internet Services, http://www.glorb.com
Lines: 66
NNTP-Posting-Host: XJGH+5GM8EvggnDfgIBqtQ.151.posting.glorb.com
X-Complaints-To: abuse@glorb.com
NNTP-Posting-Date: Tue, 1 Jan 2013 17:45:57 +0000 (UTC)
User-Agent: Jeff-Relf.Me/X.HTM
X-Notice: Scanned by Mr. Bill
Content-Type: Text/HTML; charset=UTF-8
Content-Transfer-Encoding: 8bit