Article View: alt.free.newsservers
Article #146806Re: Most often, the best code ( for me, and only me ) is the code I wrote.
From: Brad Guth
Date: Mon, 31 Dec 2012 02:41
Date: Mon, 31 Dec 2012 02:41
52 lines
5204 bytes
5204 bytes
On Dec 30, 6:20Â pm, Jeff-Relf.Me <@.> wrote:
> Â Most often, the best code ( for me, and only me ) is the code I wrote. As a programmer, text comparison is like water; an essential, daily thing. So I wrote my own diff routine ( as part of X.EXE, my console/newsreader ). At it's heart, and right off the bat, my "diff" sort of "skips past" the unchanged part at the beginning and the ends of both lines and files. A run of whitespace, including "new lines" ( ASCII 13 and 10 ), is treated as if it were a single space ( ASCII 32 ). I could've stopped right there, if I wanted to, as that is (almost) good enough; but I didn't. The heart of the line/token comparison routine looks like this: #define white( P ) ( *P <= 32 || *P == 0xA0 ) #define Data ( ToData( P, EEx, EE, SyncCnt ), ToData( _P, _EEx, _EE, _SyncCnt ), EEx < EE && _EEx < _EE ) ToData( LnP &P, LnA &EEx, LnA EE, int &SyncCnt ) { if ( P ) while( *P && white( P ) ) P++ ; while( ( !P || !*P ) && EEx < EE ) ( ++EEx >= EE ? ( P = 0, 0 ) : ( P = *EEx, SyncCnt += !!*P ) ); } LnA BBx, EEx, _BBx, _EEx ; int SyncCnt, _SyncCnt ; int inSync( int minSyncCnt, LnA BB, LnA EE, LnA _BB, LnA _EE ) { int rv ; LnP P, _P ; LnA PP, _PP ; BBx = PP = EEx = BB, _BBx = _PP = _EEx = _BB, SyncCnt = _SyncCnt = 0, P = _P = 0, EEx--, _EEx-- ; while ( Data ) { while( *P && *P == *_P && !white( _P ) ) P++, _P++ ; if ( !white( P ) || !white( _P ) ) return 0 ; if ( !*P && !*_P && ( SyncCnt + _SyncCnt ) / 2 >= minSyncCnt ) return Data, 1 ; } return 0 ; } #define EoFS ( S = PPâ‹…Slow < EE, _S = _PPâ‹…Slow < _EE, F = PPâ‹…Fast < EE, _F = _PPâ‹…Fast < _EE ) ReSync( int minSyncCnt, LnA BB, LnA EE, LnA _BB, LnA _EE ) { int S, _S, F, _F ; LnA PPâ‹…Slow, PPâ‹…Fast, _PPâ‹…Slow, _PPâ‹…Fast ; PPâ‹…Slow = BB, _PPâ‹…Slow = _BB ; Top_: PPâ‹…Fast = BB, _PPâ‹…Fast = _BB ; Down: if ( EoFS, !S && !_S ) { BBx = EEx = EE, _BBx = _EEx = _EE ; return ; } if ( F && _S ) if ( inSync( minSyncCnt, PPâ‹…Fast, EE, _PPâ‹…Slow, _EE ) ) return; else PPâ‹…Fast++ ; if ( S && _F ) if ( inSync( minSyncCnt, PPâ‹…Slow, EE, _PPâ‹…Fast, _EE ) ) return; else _PPâ‹…Fast++ ; if ( EoFS, F && _S || S && _F ) goto Down ; PPâ‹…Slow += S, _PPâ‹…Slow += _S ; goto Top_ ; } â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹…â‹… WhileSynced: if ( Vx.PP >= Vx.ee || _Vx.PP >= _Vx.ee ) { VxPPă‚ ( Diffâ‹…Ch, Vx.ee, _Vx.ee ), Str( D, L"%s", D2 ); return Bâ‹…D ; } if ( rv = inSync( 99, Vx.PP, Vx.ee, _Vx.PP, _Vx.ee ), VxPPă‚ ( textâ‹…Ch, EEx, _EEx ), rv ) goto WhileSynced ; ReSync( 2, Vx.PP, Vx.ee, _Vx.PP, _Vx.ee ), VxPPă‚ ( Diffâ‹…Ch, BBx, _BBx ); goto WhileSynced ; }
Except to 99.9% of others thinking of reading your stuff. it looks and
reads like shit.
You should at least use Google Groups version of previewing how your
special context format looks to the vast majority of others. Perhaps
otherwise you should stick with computer code related newsgroups, and
totally drop "sci.physics" and "alt.astronomy" groups that could care
less..
Technical Details
Message-ID:
<4ff2a5f7-aa27-4424-a580-2faa8df160d3@f8g2000yqa.googlegroups.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!i2pn2.pugleaf.net!archive.newsdeef.eu!mbox2nntp-alt.free.newsservers.20150605.mbox.gz!border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-out.readnews.com!transit3.readnews.com!209.85.216.88.MISMATCH!ee4no8932160qab.0!news-out.google.com!k2ni3151qap.0!nntp.google.com!ee4no8932159qab.0!postnews.google.com!f8g2000yqa.googlegroups.com!not-for-mailReferences:
<Jeff-Relf.Me@Dec.30{6.20.PM.Seattle.2012}>Show Full Headers
Complete Article Headers
Message-ID: <4ff2a5f7-aa27-4424-a580-2faa8df160d3@f8g2000yqa.googlegroups.com>
Subject: Re: Most often, the best code ( for me, and only me ) is the code I wrote.
Date: Mon, 31 Dec 2012 02:41:12 +0000
From: Brad Guth <bradguth@gmail.com>
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-alt.free.newsservers.20150605.mbox.gz!border1.nntp.dca3.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-out.readnews.com!transit3.readnews.com!209.85.216.88.MISMATCH!ee4no8932160qab.0!news-out.google.com!k2ni3151qap.0!nntp.google.com!ee4no8932159qab.0!postnews.google.com!f8g2000yqa.googlegroups.com!not-for-mail
X-Received: by 10.224.181.140 with SMTP id by12mr21464971qab.0.1356921672749;
MIME-Version: 1.0
Received: by 10.49.1.162 with SMTP id 2mr2698265qen.2.1356921672722; Sun, 30
Newsgroups: comp.os.linux.advocacy, alt.free.newsservers, sci.physics, alt.astronomy
alt.astronomy
Complaints-To: groups-abuse@google.com
Injection-Info: f8g2000yqa.googlegroups.com; posting-host=98.125.213.204;
posting-account=nf79RwoAAABXjvy5ztMzmPxgY1WGoktI
NNTP-Posting-Host: 98.125.213.204
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.1;
Injection-Date: Mon, 31 Dec 2012 02:41:12 +0000
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Lines: 51
X-Original-Bytes: 4925