yes: too many differences for me:
Code: Select all
HB_FUNC( MEMOLINE )
{
HB_MLC_INFO MLC;
HB_ISIZ nLine = hb_parnsdef( 3, 1 );
char * szLine = NULL;
HB_SIZE nIndex, nLen = 0, nSize, nCol;
if( nLine >= 1 )
{
if( hb_mlInit( &MLC, 1 ) )
{
while( --nLine )
{
if( ! hb_mlGetLine( &MLC ) )
break;
}
if( nLine == 0 )
{
nIndex = MLC.nOffset;
/* CA-Cl*pper also does not check if line exists and always
* fill one line more, i.e.:
* for i := 0 to 4
* ? "[" + MemoLine( " ", 20, i ) + "]"
* next
* [druzus]
*/
hb_mlGetLine( &MLC );
if( MLC.cdp )
nSize = ( MLC.nOffset - nIndex ) + MLC.nLineLength;
else
nSize = MLC.nLineLength;
szLine = ( char * ) hb_xgrab( nSize + 1 );
nCol = 0;
while( nIndex < MLC.nLen && nCol < MLC.nCol )
{
if( MLC.pszString[ nIndex ] == HB_CHAR_SOFT1 &&
MLC.pszString[ nIndex + 1 ] == HB_CHAR_SOFT2 )
nIndex += 2 ;
else
{
HB_WCHAR wc;
if( MLC.cdp )
{
if( ! HB_CDPCHAR_GET( MLC.cdp, MLC.pszString, MLC.nLen, &nIndex, &wc ) )
break;
}
else
wc = MLC.pszString[ nIndex++ ];
if( wc == HB_CHAR_HT )
{
HB_SIZE n = MLC.nTabSize - ( nLen % MLC.nTabSize );
do
{
szLine[ nLen++ ] = ' ';
}
while( ++nCol < MLC.nCol && --n );
}
else
{
if( MLC.cdp )
{
if( ! HB_CDPCHAR_PUT( MLC.cdp, szLine, nSize, &nLen, wc ) )
break;
}
else
szLine[ nLen++ ] = ( char ) wc;
++nCol;
}
}
}
if( nCol < MLC.nLineLength )
{
nCol = MLC.nLineLength - nCol;
if( nCol > nSize - nLen )
nCol = nSize - nLen;
memset( szLine + nLen, ' ', nCol );
nLen += nCol;
}
}
hb_mlExit( &MLC );
}
}
if( szLine == NULL )
hb_retc_null();
else
hb_retclen_buffer( szLine, nLen );
}