Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > sci.physics > #611294
| From | Jeff-Relf.Me <@.> |
|---|---|
| Newsgroups | comp.lang.c++, comp.os.linux.advocacy, sci.physics |
| Subject | #define came from God himself, it's sacred. |
| Date | 2017-01-01 23:51 -0800 |
| Organization | Glorb Internet Services, http://www.glorb.com |
| Message-ID | <Jeff-Relf.Me@Jan.1--11.51P.Seattle.2017> (permalink) |
| References | (1 earlier) <Jeff-Relf.Me@Dec.26--0.36P.Seattle.2016> <rIadnbKYnc9nFfzFnZ2dnUU78U_NnZ2d@giganews.com> <Jeff-Relf.Me@Dec.26--1.51P.Seattle.2016> <6d043fba-f4c8-45c2-aecc-63e780516fd1@googlegroups.com> <o4c7pt$ib$1@news.xmission.com> |
Cross-posted to 3 groups.
#define came from God himself, it's sacred.
For example: At times, my code needs to set flags; to wit:
#define TopFlags ( S = BB_Slow <= EE_Slow, \
_S = _BB_Slow <= _EE_Slow, \
F = BB_Fast <= EE_Fast, \
_F = _BB_Fast <= _EE_Fast )
#define BtmFlags ( S = EE_Slow >= BB_Slow, \
_S = _EE_Slow >= _BB_Slow, \
F = EE_Fast >= BB_Fast, \
_F = _EE_Fast >= _BB_Fast )
I'd much rather see "TopFlags", in places, then the expansion.
The best code ( for me, and only me )
is the code I designed and wrote myself.
As a programmer, text file comparison is essential, like water.
So I wrote my own diff routines
( ScreenShot: http://Jeff-Relf.Me/Diff.PNG ).
[ See X.EXE, X.HTM and X.CPP in http://Jeff-Relf.Me/X.ZIP ]
Diff scans ( comparing "Tokens"[*] ) from four directions at once
( LeftOlder: to Top, to Bottom; RightNewer: to Top, to Bottom ).
[ *: "Lines" in files, "Words" in lines ]
At it's heart, and right off the bat,
Diff skips unchanged Tokens at the start and/or end.
I call this "the Pinch".
Then it "peels off" MisMatches from the ends ( the "diffs" )...
Stopping when it finds MatchCount matches[*]...
Pinching and Peeling, from the edges to the middle.
[ *: MatchCount is 1 for normal, nearby matches,
not counting BlankLines. Otherwise, WhiteSpace matters. ]
The "diffs" are then sorted by line number and printed...
both the lines in the files and the words in the lines...
green for the new stuff, red for the old stuff.
This way, I can easily focus on the red and green words,
(mostly) ingnoring the rest.
Peel(), below, peels off diffs from the tops and bottoms
of LeftOlder and RightNewer text files.
BB is a pointer to start of a dynamic array of lines ( pointers );
EE points to the end of the array.
Already, BB and EE point to "diffs" (mismatches lines).
BB and EE are from the LeftOlder file.
_BB and _EE are from the RightNewer file.
void Peel( LnA BB, LnA EE, LnA _BB, LnA _EE ) { int rv, S, _S, F, _F ;
LnP t, _t ; LnA BB_Slow, _BB_Slow, BB_Fast, _BB_Fast, EE_Slow, _EE_Slow, EE_Fast, _EE_Fast ;
TopMatch = BtmMatch = 0, BB_Slow = BB, _BB_Slow = _BB, EE_Slow = EE, _EE_Slow = _EE, ReSetBB_Fast, ReSetEE_Fast ;
Top: if ( TopMatch ) if ( BtmMatch ) goto Done ; else goto Btm ;
if ( TopFlags, TopMatch = !S && !_S ) {
// Done scaning the top of LeftOlder and RightNewer, no matches.
BB_Match = 0 ; goto Btm ; }
if ( F && _S ) if ( !gTopMatch( BB_Fast - BB_Slow, BB_Fast, EE, _BB_Slow, _EE ) ) BB_Fast++ ; else goto Btm ;
if ( _F && S ) if ( !gTopMatch( _BB_Fast - _BB_Slow, BB_Slow, EE, _BB_Fast, _EE ) ) _BB_Fast++ ; else goto Btm ;
// Lower the top of LeftOlder and RightNewer.
if ( TopFlags, !( F && _S || _F && S ) ) BB_Slow += S, _BB_Slow += _S, ReSetBB_Fast ; goto Btm ;
Btm: if ( BtmMatch ) if ( TopMatch ) goto Done ; else goto Top ;
if ( BtmFlags, BtmMatch = !S && !_S ) {
// Done scaning the bottom of LeftOlder and RightNewer, no matches.
EE_Match = 0 ; goto Top ; }
if ( F && _S ) if ( !gBtmMatch( EE_Slow - EE_Fast, BB, EE_Fast, _BB, _EE_Slow ) ) EE_Fast-- ; else goto Top ;
if ( _F && S ) if ( !gBtmMatch( _EE_Slow - _EE_Fast, BB, EE_Slow, _BB, _EE_Fast ) ) _EE_Fast-- ; else goto Top ;
// Raise the bottom of LeftOlder and RightNewer.
if ( BtmFlags, !( F && _S || _F && S ) ) EE_Slow -= S, _EE_Slow -= _S, ReSetEE_Fast ; goto Top ;
Done: BB_Match = BB_Match && EE_Match ? BB_Match : EE_Match ? ( _BB_Match = _EE_Match, EE_Match ) : ( _BB_Match = _EE, EE );
EE_Match = BB_Match && EE_Match ? EE_Match : BB_Match ? ( _EE_Match = _BB_Match, BB_Match ) : ( _EE_Match = _BB, BB ); }
Globals:
int TopMatch, BtmMatch ; LnP F, _F ;
LnA BBx, EEx, _BBx, _EEx, BB_Match, EE_Match, _BB_Match, _EE_Match ;
#define TokensMatch ( F && _F && F[-1] == _F[-1] && Eq( F, _F ) )
#define ReSetBB_Fast ( BB_Fast = BB_Slow, _BB_Fast = _BB_Slow )
#define ReSetEE_Fast ( EE_Fast = EE_Slow, _EE_Fast = _EE_Slow )
#define ShaveDown ( goDown( F, EEx, EE ), goDown( _F, _EEx, _EE ), TokensMatch )
#define PinchDown ( goDown( F, BBx, EE ), goDown( _F, _BBx, _EE ), TokensMatch )
#define goDown( P, PP, EE ) ( P = ++PP >= EE ? 0 : *PP )
int gTopMatch( int Wander, LnA BB, LnA EE, LnA _BB, LnA _EE ) {
BB_Match = EEx = BB, _BB_Match = _EEx = _BB, EEx--, _EEx-- ;
Loop( 1 + Wander/99 ) if ( ShaveDown ) eJ += !*F ; else return 0 ;
return TopMatch = 1 ; }
#define ShaveUp ( goUp( F, BBx, BB ), goUp( _F, _BBx, _BB ), TokensMatch )
#define PinchUp ( goUp( F, EEx, BBx ), goUp( _F, _EEx, _BBx ), TokensMatch )
#define goUp( P, PP, BB ) ( P = --PP < BB ? 0 : *PP )
int gBtmMatch( int Wander, LnA BB, LnA EE, LnA _BB, LnA _EE ) {
EE_Match = BBx = EE, _EE_Match = _BBx = _EE ;
Loop( 1 + Wander/99 ) if ( ShaveUp ) eJ += !*F ; else return 0 ;
return BtmMatch = 1 ; }
Far Globals:
#define Loop( N ) int eJ = ( N ) - 1, J = -1 ; while ( ++J <= eJ )
typedef wchar_t wchar ; typedef wchar *LnP ; typedef LnP *LnA ;
Back to sci.physics | Previous | Next — Next in thread | Find similar | Unroll thread
#define came from God himself, it's sacred. Jeff-Relf.Me <@.> - 2017-01-01 23:51 -0800
#define came from God himself, it's sacred. Jeff-Relf.Me <@..yep> - 2017-01-02 08:00 +0000
Re: #define came from God himself, it's sacred. moroney@world.std.spaamtrap.com (Michael Moroney) - 2017-01-03 03:58 +0000
I completely reWrote it, of course. Jeff-Relf.Me <@.> - 2017-01-03 00:46 -0800
I completely reWrote it, of course. Jeff-Relf.Me <@..sour> - 2017-01-03 08:51 +0000
Re: I completely reWrote it, of course. Double-A <double-a3@hush.com> - 2017-01-05 16:12 -0800
Re: I completely reWrote it, of course. Peter Köhlmann <peter-koehlmann@t-online.de> - 2017-01-03 12:13 +0100
Re: I completely reWrote it, of course. Melzzzzz <mel@zzzzz.com> - 2017-01-03 12:28 +0100
Re: I completely reWrote it, of course. chrisv <chrisv@nospam.invalid> - 2017-01-03 07:32 -0600
Ezekiel lives in your head RENT FREE!! LOL!!! GreyCloud <mist@cumulus.com> - 2017-01-03 12:16 -0700
With "warnings as errors", turn off these warnings. Jeff-Relf.Me <@.> - 2017-01-03 13:00 -0800
Re: I completely reWrote it, of course. GreyCloud <mist@cumulus.com> - 2017-01-03 12:16 -0700
Re: I completely reWrote it, of course. red floyd <dont.bother@its.invalid> - 2017-01-03 12:30 -0800
If you're retarded then, yes, _Loop() is "undefined". Jeff-Relf.Me <@.> - 2017-01-16 11:06 -0800
Re: I completely reWrote it, of course. scott@slp53.sl.home (Scott Lurndal) - 2017-01-04 13:33 +0000
Re: I completely reWrote it, of course. chrisv <chrisv@nospam.invalid> - 2017-01-04 07:45 -0600
Re: I completely reWrote it, of course. scott@slp53.sl.home (Scott Lurndal) - 2017-01-04 14:54 +0000
The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). Jeff-Relf.Me <@.> - 2017-01-04 10:17 -0800
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). Peter Köhlmann <peter-koehlmann@t-online.de> - 2017-01-04 19:19 +0100
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). noTthaTguY <abu.kuanysh05@gmail.com> - 2017-01-04 16:33 -0800
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). noTthaTguY <abu.kuanysh05@gmail.com> - 2017-01-09 16:23 -0800
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). moroney@world.std.spaamtrap.com (Michael Moroney) - 2017-01-05 03:34 +0000
The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). Jeff-Relf.Me <@.> - 2017-01-04 22:26 -0800
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). Anonymous <anonymous@invalid.tld> - 2017-01-05 08:18 +0000
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). Peter Köhlmann <peter-koehlmann@t-online.de> - 2017-01-05 09:24 +0100
PostScript is my thing. Jeff-Relf.Me <@.> - 2017-01-05 01:08 -0800
My diffs now _perfectly match MicroSoft's WinMerge. Jeff-Relf.Me <@.> - 2017-01-07 03:56 -0800
Re: My diffs now _perfectly match MicroSoft's WinMerge. Peter Köhlmann <peter-koehlmann@t-online.de> - 2017-01-07 13:09 +0100
Re: My diffs now _perfectly match MicroSoft's WinMerge. moroney@world.std.spaamtrap.com (Michael Moroney) - 2017-01-07 20:25 +0000
Like a compiler that compiles itself, my Diff app diffs itself. Jeff-Relf.Me <@.> - 2017-01-07 17:53 -0800
Re: My diffs now _perfectly match MicroSoft's WinMerge. Christian Gollwitzer <auriocus@gmx.de> - 2017-01-10 22:15 +0100
Text file comparison is essential. Jeff-Relf.Me <@.> - 2017-01-16 11:23 -0800
Re: Text file comparison is essential. noTthaTguY <abu.kuanysh05@gmail.com> - 2017-01-17 11:22 -0800
Nothing to compare, left and right, old and new. Jeff-Relf.Me <@.> - 2017-01-19 04:12 -0800
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). jmfbahciv <See.above@aol.com> - 2017-01-05 14:08 +0000
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). Vir Campestris <vir.campestris@invalid.invalid> - 2017-01-05 21:09 +0000
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). legalize+jeeves@mail.xmission.com (Richard) - 2017-01-05 21:19 +0000
"Functional" programming is "Tree Crawling". Jeff-Relf.Me <@.> - 2017-01-05 14:53 -0800
Re: The Longest Common Sequence ( NonContiguous ) algorithm ( recursive ). Lofty Goat <rlwatkins@gmail.com> - 2017-01-05 17:43 -0600
Re: I completely reWrote it, of course. jmfbahciv <See.above@aol.com> - 2017-01-05 14:08 +0000
What about you, GreyCloud ? Jeff-Relf.Me <@.> - 2017-01-16 11:02 -0800
Re: What about you, GreyCloud ? GreyCloud <mist@cumulus.com> - 2017-01-16 19:46 -0700
Health issues ? Jeff-Relf.Me <@.> - 2017-01-16 20:39 -0800
Re: Health issues ? GreyCloud <mist@cumulus.com> - 2017-01-17 11:50 -0700
Re: Health issues ? noTthaTguY <abu.kuanysh05@gmail.com> - 2017-01-17 14:19 -0800
Re: Health issues ? noTthaTguY <abu.kuanysh05@gmail.com> - 2017-01-17 18:44 -0800
Negative Interest Rates. Jeff-Relf.Me <@.> - 2017-01-19 04:25 -0800
Re: Negative Interest Rates. GreyCloud <mist@cumulus.com> - 2017-01-19 11:47 -0700
Negative Interest Rates "rips off" rich people, not the poor. Jeff-Relf.Me <@.> - 2017-01-19 19:23 -0800
Re: Negative Interest Rates "rips off" rich people, not the poor. GreyCloud <mist@cumulus.com> - 2017-01-20 16:17 -0700
Tons of people have reviewed the code, source and object. Jeff-Relf.Me <@.> - 2017-01-19 04:02 -0800
Building a complex system can't be done when you're drunk and horny. Jeff-Relf.Me <@.> - 2017-01-19 04:17 -0800
Re: Building a complex system can't be done when you're drunk and horny. David Brown <david.brown@hesbynett.no> - 2017-01-19 13:59 +0100
No one is here to learn at your feet, sorry. Jeff-Relf.Me <@.> - 2017-01-19 05:30 -0800
Re: Building a complex system can't be done when you're drunk and horny. chrisv <chrisv@nospam.invalid> - 2017-01-19 07:37 -0600
Building a complex system can't be done when you're drunk and horny. Jeff-Relf.Me <@.> - 2017-01-19 05:43 -0800
Re: Building a complex system can't be done when you're drunk and horny. noTthaTguY <abu.kuanysh05@gmail.com> - 2017-01-19 10:06 -0800
Re: Building a complex system can't be done when you're drunk and horny. moroney@world.std.spaamtrap.com (Michael Moroney) - 2017-01-20 04:32 +0000
Usenet isn't WikiPedia; here, it's all play and no work, anything goes. Jeff-Relf.Me <@.> - 2017-01-19 21:02 -0800
yeah, you can always prefer your preferred header noTthaTguY <abu.kuanysh05@gmail.com> - 2017-01-19 21:22 -0800
The "Least Longest" diffs. Jeff-Relf.Me <@.> - 2017-01-03 03:04 -0800
csiph-web