Article View: alt.free.newsservers
Article #145840--
From: Jeff-Relf.Me
Date: Mon, 12 Nov 2012 07:51
Date: Mon, 12 Nov 2012 07:51
122 lines
5796 bytes
5796 bytes
ï»ż<PRE><H2>
Since you replied to me, Michaelâ
Moroney,
I'll explain some of my code to you, as if you cared.
Basically, "Eq30()" (below) returns "1" when the "left" block of lines
matches the "right" one. When there's enough text for it,
no less than 30 characters must match.
Leading/Trailing White Space is ignored and
each run of White Space, including newlines,
is treated as if it were a single space.
⊿ <A hRef="http://Jeff-Relf.Me/X.CPP">The Visual C++ 2010 source code, X.CPP</A>.
Basically, "»Blackâ«()" (below) sets "P" ( which points to a character ) to:
The first nonâ
whitespace.
â
ORâ
to the end of a line, when:
"Endâ
ofâ
File" is true. EoF is "!PP[1]", "PP" points to a line.
â
ORâ
30 or more characters have been compared.
#define »Blackâ«( P, PP, Pâ
W ) \
\
if ( Pâ
W = *P <= 32 ) \
while(1) { \
/* Scan the block of lines for a nonâ
white character. */ \
while( *P && *P <= 32 ) \
/* Scan current line for a nonâ
white */ \
P++ ; \
\
if ( *P || Sz >= 30 ) \
/* Break at nonâ
white â
ORâ
the end of the line/block. */ \
break ; \
\
if ( !PP[1] ) { \
/* "*P == 0", end of line, and "Pâ
W = -1", end of file. \
Block matches if "!*P && !*Q && Pâ
W == -1 && Qâ
W == -1" */ \
EoFâ
Diff = Pâ
W = -1 ; break ; } \
\
/* Get the next line in the block. */ \
P = *++PP ; }
LnA LLâ, RRâ, ll, rr ; int Match ;
// LL and RR, left and right, point to blocks of lines.
// The blocks are compared.
//
// "LLâ", a global, is the first line.
// "ll", also a global, is the last line of a match or misâ
match.
int Eq30( LnA LL, LnA RR ) {
int Leading = 1, Pâ
W, Qâ
W, Sz = 0 ;
// LLâ (a global) points to first line in the block,
// LL (returned) points the last one.
ll = LLâ = LL, rr = RRâ = RR ; LnP P = *LLâ, Q = *RRâ ;
if ( EoFâ
Diff = !P || !Q )
// EoFâ
Diff right away ! can't do anything.
return Match = 0 ;
while(1) {
// "ll", a global, advances through a block of lines.
»Blackâ«( P, ll, Pâ
W ) »Blackâ«( Q, rr, Qâ
W )
if ( *P != *Q || !Leading && Pâ
W != Qâ
W )
// No match. Either nonâ
whitespace didn't match
// or one block had whitespace and the other didn't.
return Match = 0 ;
if ( !Leading && Pâ
W )
// Count the virtual "ASCII 32" token.
Sz++ ;
Leading = 0 ;
if ( !*P )
// A match. Hit Endâ
ofâ
Line ( after one or more lines,
// >= 30 characters, â
ORâ
"Endâ
ofâ
File" ( !PP[1] ) ).
return Match = 1 ;
while( *P && *P == *Q && *P > 32 )
// Advance "P" and "Q" ( the left and right lines )
// to the next "ASCII 32" token â
ORâ
to the first mismatch.
Sz++, P++, Q++ ;
}
}
"Eq30()" is used like this:
if ( Eq30( L.PP, R.PP ), L.PP = ll, R.PP = rr, Match )
// The block of lines ( containing 30 or more characters ) match,
// Ignore them, go to the next pair of blocks.
goto Nextâ
Pair ;
cntâ
L = cntâ
R = Identical = 0 ;
{ Loop( 30 ) {
LL = L.PP, RR = R.PP + J ;
// Starting from the mismatched line, rightâ
side,
// check the next 30 lines, "Loop( 30 )".
//
// See if any of them are in the leftâ
side file,
// starting with the leftâ
side's mismatched line.
while( Eq30( LL++, RR ), !Match && !EoFâ
Diff ) ;
if ( Match ) { cntâ
L = !Match ? 0 : LLâ - L.PP ; break ; } } }
{ Loop( 30 ) { LL = L.PP + J, RR = R.PP ;
// Same as above, switching sides.
while( Eq30( LL, RR++ ), !Match && !EoFâ
Diff );
if ( Match ) { cntâ
R = !Match ? 0 : RRâ - R.PP ; break ; } } }
if ( L.PP--, cntâ
L ) {
Loop( cntâ
L )
// Print out the block of mismatched lines.
P = *++L.PP, Sh( L"%s%s%s", !J ? L"«-" : L" ", P, J + 1 == LLL ? L" »" : L"" );
Sh(0); }
if ( R.PP--, cntâ
R ) {
Loop( cntâ
R )
P = *++R.PP, Sh( L"%s%s%s", !J ? L"« " : L" ", P, J + 1 == LLL ? L" »" : L"" );
Sh(0); }
if ( cntâ
L || cntâ
R ) goto Nextâ
Pair ;
Some of this code will soon change, I expect.
Technical Details
Message-ID:
<Jeff-Relf.Me@Nov.11{11.51.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!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!novia!news.glorb.com!news-spur1.glorb.com!newsread.glorb.com!.POSTED!not-for-mailReferences:
<Jeff-Relf.Me@Nov.8{0.35.PM.Seattle.2012}> <k7i5f5$1gs$1@pcls6.std.com> <Jeff-Relf.Me@Nov.9{9.48.PM.Seattle.2012}> <k7lo68$904$1@pcls6.std.com> <Jeff-Relf.Me@Nov.10{2.16.PM.Seattle.2012}> <k7oq5j$o26$1@pcls6.std.com>Show Full Headers
Complete Article Headers
Message-ID: <Jeff-Relf.Me@Nov.11{11.51.PM.Seattle.2012}>
Subject: --
Date: Mon, 12 Nov 2012 07:51:30 +0000
From: Jeff-Relf.Me <@.>
References: <Jeff-Relf.Me@Nov.8{0.35.PM.Seattle.2012}> <k7i5f5$1gs$1@pcls6.std.com> <Jeff-Relf.Me@Nov.9{9.48.PM.Seattle.2012}> <k7lo68$904$1@pcls6.std.com> <Jeff-Relf.Me@Nov.10{2.16.PM.Seattle.2012}> <k7oq5j$o26$1@pcls6.std.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!border2.nntp.dca3.giganews.com!border4.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!novia!news.glorb.com!news-spur1.glorb.com!newsread.glorb.com!.POSTED!not-for-mail
Newsgroups: alt.free.newsservers,sci.physics,comp.os.linux.advocacy
Organization: Glorb Internet Services, http://www.glorb.com
Lines: 122
NNTP-Posting-Host: XJGH+5GM8EvggnDfgIBqtQ.257.posting.glorb.com
Content-Type: Text/HTML; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Complaints-To: abuse@glorb.com
NNTP-Posting-Date: Mon, 12 Nov 2012 07:51:30 +0000 (UTC)
User-Agent: Jeff-Relf.Me/X.TXT
X-Notice: Scanned by Mr. Bill
X-Original-Bytes: 5529