PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Computer Folklore     

Oops... as usual, I found bugs after I posted code


VPN Service Provider

JeffRelf, A Individual.NET, X, 23, 2.7 A . Oops... as usual, I found bugs after I posted code.

Trim() wasn't responding correctly when given an UnBreakable-TooLong name. Also, now it also works for things like NewsReader names, not just emails. Use your deugger to see the results.

#pragma warning( disable: 4127 4430 4996 4706 ) typedef wchart * LnP ; #define FromEnd wcsrchr #define FromStart wcschr #define AlphaNumeric iswalnum #define Str swprintf #define LOOP while ( 1 ) #define LoopTo( StopCond ) while ( Ch && ( Ch = * ++ P ) && ! ( Ch2 = P 1 , StopCond ) ) const int SzChar = sizeof ( wchart );

LnP Find ( wchart C, LnP B, int N ) { LOOP if ( * ++ P == C ) return P ;

inline int Iden( wchart C ) {

Oops... as usual, I found bugs after I posted code. 8163
In comp.os.linux.advocacy, Kelsey Bjarnason wrote on Mon, 23 Jan 2006 09:13:06 -0800 It's getting a little complicated. Apparently the proper names are or some such. (This is new to me but...

LnP Trim ( int eMail, LnP B, int SizeLimit ) { LnP P = B, E = FromStart( P, 0 ) ; if ( eMail ) { else if ( Par ) Left = FromStart( B, '(' ); if ( Left ) wchart Ch = * P --, Ch2 = 0 ; if ( ! Ch ) return B ; LoopTo ( Iden( Ch ) ); LnP B = P, E = Find ( 0, B, SizeLimit ); if ( ! E ) E = P + SizeLimit ; int Blak = Iden( * E ); * E = 0 ; P = E ; if ( ! * B ) return L"."; P = B ; Ch = * P -- ; int Bad = 0 ; LoopTo( 0 ) if ( ! Iden ( Ch ) ) Bad ++ ; int Already = 0 ; E = P ; LoopTo( 0 ) { if ( Iden ( Ch ) ) { Already = Ch == ''; continue; } if ( ! Already ) Already = 1, * P = '' ; else memmove( P, P + 1, ( E - P ) * SzChar ), Ch = * P -- ; } } return B ; }

main() { const int MaxWanted = 15 ; wchart Buff 88 ; LnP Result ; Str( Buff, L"ReallyReallyReallyLong" ); Result = Trim( 0, Buff, MaxWanted ); Returns ReallyReallyR. Result = Trim( 1, Buff, MaxWanted ); Returns MrPeters. }


Linux | Previous | Next

Oops... as usual, I found bugs after I posted code. 8163

Linux Advocacy Newsgroups

Check out Trim... pbutt it a UTF16 Unicode email address