From 1c660444770f4d5676ccc28dc3d0ec99594f505c Mon Sep 17 00:00:00 2001 From: Chen Kedem Date: Mon, 7 May 2007 08:04:19 +0000 Subject: [PATCH] 2007-05-07 11:04 UTC+0300 Chen Kedem --- harbour/ChangeLog | 6 ++++++ harbour/source/rtl/mlctopos.c | 16 +++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 38359176bc..f9f26363b9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,12 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ +2007-05-07 11:04 UTC+0300 Chen Kedem + * source/rtl/mlctopos.c + ! Fix bug#1635288 - Make the function MLCTOPOS() more Clipper + compatible. Also, the WordWrap value was taken from the wrong + parameter. + 2007-05-07 02:20 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/source/rdd/dbcmd.c * initialize lpaParent in DBRELINFO structure to pArea - please diff --git a/harbour/source/rtl/mlctopos.c b/harbour/source/rtl/mlctopos.c index 209c35df58..629e855293 100644 --- a/harbour/source/rtl/mlctopos.c +++ b/harbour/source/rtl/mlctopos.c @@ -61,9 +61,9 @@ HB_FUNC( MLCTOPOS ) ULONG ulTabLength = ISNUM( 5 ) ? hb_parni( 5 ) : 4; ULONG ulLastSpace = 0; ULONG ulCurLength = 0; - BOOL bWordWrap = ISLOG( 5 ) ? hb_parl( 5 ) : TRUE; + BOOL bWordWrap = ISLOG( 6 ) ? hb_parl( 6 ) : TRUE; ULONG ulLen = hb_parclen( 1 ); - ULONG ulLines = 0; + ULONG ulLines = 1; ULONG ulPos; ULONG ulBegOfLine = 0; ULONG ulLastLen = 0; @@ -124,15 +124,21 @@ HB_FUNC( MLCTOPOS ) if( ulCurLength > 0 ) { - ulLines++; ulBegOfLine = ulPos - ulCurLength; ulLastLen = ulCurLength ; } if( ulLine == ulLines ) { - ulLastLen--; /* Column is zero based */ - hb_retnl( ulBegOfLine + ( ( ulCol < ulLastLen ) ? ulCol : ulLastLen ) ); + if( ulLastLen ) + ulLastLen--; /* Column is zero based */ + ulPos = ulBegOfLine + 1 + ( ( ulCol < ulLastLen ) ? ulCol : ulLastLen ); + + /* When wordwrap is active, skip the first space if not on the first line */ + if( bWordWrap && !ulCol && ulLine > 1 ) + if( pszString[ ulPos - 1 ] == ' ' || pszString[ ulPos - 1 ] == HB_CHAR_HT ) + ulPos++; + hb_retnl( ulPos ); } else hb_retnl( ulLen );