Article View: news.software.readers
Article #229537Lucky for me, Les Harris found a really crappy section of X.CPP.
From: Jeffβ²Relf
Date: Sat, 31 Jan 2009 20:41
Date: Sat, 31 Jan 2009 20:41
66 lines
3702 bytes
3702 bytes
Lucky for me, Les Harris found a really crappy section of X.CPP;
this code is now called β gFld() β ( for β Get Field β ).
A simple example of how it's used follows.
Suppose Windows Vista's clipboard has a Message-ID in it.
This sets β MID β ( a pointer to a string, LnP ) to that data:
β LnP P = 0, MID = gFld( P ); β.
When P is null, gFld() initializes it via
a call to gClip() ( for β Get Clipboard β ).
This code is from JeffRelf.F-M.FM/X.CPP, of course.
// When a Message-ID is in the clipboad,
// calling β MID = gFld( P ) β sets MID ( and BoFld )
// to the start of the MsgID ( EoFld is set to the end ).
//
// P would've been set to the next line, had a second line existed.
LnP BoFld, EoFld ;
LnP gClip() { BoFld = EoFld = L"";
if ( ! OpenClipboard ( Win ) ) {
Sh( L"%cClipboard is Locked", ChNew ); return BoFld ; }
HGLOBAL Mem = GetClipboardData ( CF_UNICODETEXT );
if ( ! Mem ) {
Sh( L"%cNo Text in the Clipboard", ChNew );
CloseClipboard (); return BoFld ; }
LnP P = ( LnP ) GlobalLock ( Mem );
int Len = ! P ? 0 : StrLen ( P ); if ( Len <= 2 ) goto Done ;
// MallocTmp() allocates from a very temporary heap.
BoFld = MallocTmp( ( Len + 999 ) * SzChar );
LnP B = P, D = BoFld - 1 ; int Ch, Ch2 ;
While ( Ch ) {
// Removing tabs as we copy the clipboard into BoFld.
* ++ D = Ch == 9 ? 32 : Ch ;
// A β . β at the start of a line becomes β .. β.
if ( Ch == '.' && ( P == B || P [ -1 ] == 10 ) )
* ++ D = '.' ; }
if ( * D != 10 )
// Insure that the line ends with: CR LF NUL.
* ++ D = 13, * ++ D = 10 ; * ++ D = 0 ;
wchar_t Pat [ 40 ];
// Removed any β article separator β that might be at the end.
// Sep == L"β "
int rv = Str( Pat, L"\r\n" Sep L"\r\n"); D -= rv ;
if ( Eq( D, Pat ) ) D [ 2 ] = 0 ;
Done: GlobalUnlock( Mem ); CloseClipboard(); return BoFld ; }
// As explained in news:Jeff_Relf@Seattle.2009_Jan.30|11.33am|K
LnP gFld( LnP & P ) {
if ( ! P ) P = gClip(); if ( ! * P ) return BoFld ;
LnP B = P ; int Ch, Ch2 ;
While( Ch == 32 ); if ( P == B && Ch == '.' && Ch2 == '.' ) P ++ ;
BoFld = B = P ; LnP E = FromStart( B, 10 );
if ( ! E || E > B + 120 ) {
if ( ! E ) E = FromStart( B, 0 ); P = B + er( 120, E - B ); }
else { WhileBac( P > B && Ch <= 32 ); if ( Ch > 32 ) P ++ ; }
EoFld = P, * P = 0, P = E ; if ( * P ) P ++ ; return BoFld ; }
Technical Details
Message-ID:
<Jeff_Relf@Seattle.2009_Jan.31|0.41pm|I>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!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mailReferences:
<z7ednbZD8-zrdh_UnZ2dnUVZ_q_inZ2d@giganews.com> <Jeff_Relf@Seattle.2009_Jan.30|7.30am|y> <Jeff_Relf@Seattle.2009_Jan.30|11.33am|K> <Jeff_Relf@Seattle.2009_Jan.30|0.30pm|a>Show Full Headers
Complete Article Headers
Message-ID: <Jeff_Relf@Seattle.2009_Jan.31|0.41pm|I> Subject: Lucky for me, Les Harris found a really crappy section of X.CPP. Date: Sat, 31 Jan 2009 20:41:12 +0000 From: Jeffβ²Relf <Jeff_Relf@Seattle.Test> References: <z7ednbZD8-zrdh_UnZ2dnUVZ_q_inZ2d@giganews.com> <Jeff_Relf@Seattle.2009_Jan.30|7.30am|y> <Jeff_Relf@Seattle.2009_Jan.30|11.33am|K> <Jeff_Relf@Seattle.2009_Jan.30|0.30pm|a> 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!newsfeed.freenet.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail Newsgroups: news.software.readers Lines: 66 Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Trace: individual.net cuFrFzE+2vauJ7WWz752nQHT+9ZevCv32gjriSrxohBMnx7Nqk Cancel-Lock: sha1:TGvO207jXEqFkwuFKTm48W+II10= User-Agent: JeffRelf.F-M.FM/X.ZIP