From 3d627021e6c0ff05487e7b36fc758bbb6ca2fa52 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Mon, 11 Dec 2006 21:15:16 +0000 Subject: [PATCH] 2006-12-11 22:15 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rtl/memoline.c ! added fix sent to me by Randy Portnoff - it's a little bit differ then the one Randy sent to list but this one seems to be correct. I never used this function in Clipper and made only very basic tests. I believe that Randy make better tests and this fix will not break some other constructions. --- harbour/ChangeLog | 8 ++++++++ harbour/source/rtl/memoline.c | 10 +++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a1cc3cb7dd..a509ecffc2 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,14 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2006-12-11 22:15 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/rtl/memoline.c + ! added fix sent to me by Randy Portnoff - it's a little bit differ + then the one Randy sent to list but this one seems to be correct. + I never used this function in Clipper and made only very basic + tests. I believe that Randy make better tests and this fix will + not break some other constructions. + 2006-12-11 14:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/rdd_ads/ads1.c * harbour/contrib/rdd_ads/adsfunc.c diff --git a/harbour/source/rtl/memoline.c b/harbour/source/rtl/memoline.c index 9f13505fc5..a989bb93b3 100644 --- a/harbour/source/rtl/memoline.c +++ b/harbour/source/rtl/memoline.c @@ -59,10 +59,10 @@ HB_FUNC( MEMOLINE ) ULONG ulLineLength = ISNUM( 2 ) ? hb_parni( 2 ) : 79; ULONG ulLineNumber = ISNUM( 3 ) ? hb_parni( 3 ) : 1; ULONG ulTabLength = ISNUM( 4 ) ? hb_parni( 4 ) : 4; - ULONG ulLastSpace = 0; - ULONG ulCurLength = 0; BOOL bWordWrap = ISLOG( 5 ) ? hb_parl( 5 ) : TRUE; ULONG ulLen = hb_parclen( 1 ); + ULONG ulLastSpace = 0; + ULONG ulCurLength = 0; ULONG ulLines = 0; ULONG ulPos = 0; ULONG ulLineBegin; @@ -85,10 +85,8 @@ HB_FUNC( MEMOLINE ) while( ulPos < ulLen && ulLines < ulLineNumber ) { - switch( pszString[ ulPos ] ) { - case HB_CHAR_HT: ulCurLength = ( ( ULONG ) ( ulCurLength / ulTabLength ) * ulTabLength ) + ulTabLength; ulLastSpace = ulCurLength; @@ -147,6 +145,9 @@ HB_FUNC( MEMOLINE ) if( ulLines < ulLineNumber ) { + if( ulPos < ulLen && pszString[ ulPos ] == ' ' ) + ulPos++; /* Ignore a single trailing blank (same as Cl*pper) */ + ulLineBegin = ulPos - ulCurLength + 1; ulLineEnd = 0; } @@ -189,4 +190,3 @@ HB_FUNC( MEMOLINE ) else hb_retc( NULL ); } -