diff --git a/ChangeLog.txt b/ChangeLog.txt index 9e26d69ec2..edf1ca95af 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,35 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2015-07-27 16:36 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * src/rtl/chruni.c + * added new functions hb_BStuff() and hb_UStuff() + + * src/rtl/Makefile + - src/rtl/padc.c + - src/rtl/padl.c + - src/rtl/padr.c + + src/rtl/padx.c + * added new functions hb_BPadL(), hb_BPadR(), hb_BPadC(), + hb_UPadL(), hb_UPadR() and hb_UPadC() + + * include/harbour.hbx + * updated + + * src/rtl/memoedit.prg + * src/rtl/teditor.prg + * use hb_U*() functions for string manipulation - now it works + correctly with mulitbyte encodings even if HVM CP does enabled + character indexing, i.e. "UTF8" + + * src/rtl/vfile.c + * pacified BCC warnin + + * src/rtl/filesys.c + * src/rtl/fssize.c + * use GetFileAttributesEx() if available in given windows version + to get file size and time + 2015-07-24 18:55 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * src/rtl/vfile.c ! fixed typo in my last commit (Thanks to Viktor for verification) diff --git a/include/harbour.hbx b/include/harbour.hbx index 0471f744d5..26ab1c3137 100644 --- a/include/harbour.hbx +++ b/include/harbour.hbx @@ -162,7 +162,6 @@ DYNAMIC dbSkip DYNAMIC dbStruct DYNAMIC dbTableExt DYNAMIC dbUnlock -DYNAMIC dbUnlockAl DYNAMIC dbUnlockAll DYNAMIC dbUseArea DYNAMIC DefPath @@ -324,10 +323,14 @@ DYNAMIC hb_blowfishDecrypt_CFB DYNAMIC hb_blowfishEncrypt DYNAMIC hb_blowfishEncrypt_CFB DYNAMIC hb_blowfishKey +DYNAMIC hb_BPadC +DYNAMIC hb_BPadL +DYNAMIC hb_BPadR DYNAMIC hb_BPeek DYNAMIC hb_BPoke DYNAMIC hb_BRAt DYNAMIC hb_BRight +DYNAMIC hb_BStuff DYNAMIC hb_BSubStr DYNAMIC hb_BuildDate DYNAMIC hb_ByteSwapI @@ -865,11 +868,15 @@ DYNAMIC hb_UChar DYNAMIC hb_UCode DYNAMIC hb_ULeft DYNAMIC hb_ULen +DYNAMIC hb_UPadC +DYNAMIC hb_UPadL +DYNAMIC hb_UPadR DYNAMIC hb_UPeek DYNAMIC hb_UPoke DYNAMIC hb_URight DYNAMIC hb_UserLang DYNAMIC hb_UserName +DYNAMIC hb_UStuff DYNAMIC hb_USubStr DYNAMIC hb_UTCOffset DYNAMIC hb_utf8Asc diff --git a/src/rtl/Makefile b/src/rtl/Makefile index f999ded488..7d50ced620 100644 --- a/src/rtl/Makefile +++ b/src/rtl/Makefile @@ -148,9 +148,7 @@ C_SOURCES := \ oldbox.c \ oldclear.c \ pad.c \ - padc.c \ - padl.c \ - padr.c \ + padx.c \ philes.c \ philes53.c \ rat.c \ diff --git a/src/rtl/chruni.c b/src/rtl/chruni.c index f88b8f233f..0c7103d070 100644 --- a/src/rtl/chruni.c +++ b/src/rtl/chruni.c @@ -613,3 +613,97 @@ HB_FUNC( HB_BRAT ) hb_retns( nPos ); } + +/* hb_BStuff( , , , ) -> + */ +HB_FUNC( HB_BSTUFF ) +{ + const char * szText = hb_parc( 1 ); + const char * szIns = hb_parc( 4 ); + + if( szText && szIns && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) ) + { + HB_SIZE nLen = hb_parclen( 1 ); + HB_SIZE nPos = hb_parns( 2 ); + HB_SIZE nDel = hb_parns( 3 ); + HB_SIZE nIns = hb_parclen( 4 ); + HB_SIZE nTot; + + if( nPos ) + { + if( nPos < 1 || nPos > nLen ) + nPos = nLen; + else + nPos--; + } + if( nDel ) + { + if( nDel < 1 || nDel > nLen - nPos ) + nDel = nLen - nPos; + } + + if( ( nTot = nLen + nIns - nDel ) > 0 ) + { + char * szResult = ( char * ) hb_xgrab( nTot + 1 ); + + hb_xmemcpy( szResult, szText, nPos ); + hb_xmemcpy( szResult + nPos, szIns, nIns ); + hb_xmemcpy( szResult + nPos + nIns, szText + nPos + nDel, + nLen - ( nPos + nDel ) ); + hb_retclen_buffer( szResult, nTot ); + } + else + hb_retc_null(); + } + else + hb_retc_null(); +} + +/* hb_UStuff( , , , ) -> + */ +HB_FUNC( HB_USTUFF ) +{ + const char * szText = hb_parc( 1 ); + const char * szIns = hb_parc( 4 ); + + if( szText && szIns && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) ) + { + PHB_CODEPAGE cdp = hb_vmCDP(); + HB_SIZE nLen = hb_parclen( 1 ); + HB_SIZE nPos = hb_parns( 2 ); + HB_SIZE nDel = hb_parns( 3 ); + HB_SIZE nIns = hb_parclen( 4 ); + HB_SIZE nTot; + + if( nPos ) + nPos = nPos < 1 ? nLen : hb_cdpTextPos( cdp, szText, nLen, nPos - 1 ); + if( nDel ) + { + if( nPos < nLen ) + { + nDel = hb_cdpTextPos( cdp, szText + nPos, nLen - nPos, nDel ); + if( nDel == 0 ) + nDel = nLen - nPos; + } + else + nDel = 0; + } + + if( ( nTot = nLen + nIns - nDel ) > 0 ) + { + char * szResult = ( char * ) hb_xgrab( nTot + 1 ); + + hb_xmemcpy( szResult, szText, nPos ); + hb_xmemcpy( szResult + nPos, szIns, nIns ); + hb_xmemcpy( szResult + nPos + nIns, szText + nPos + nDel, + nLen - ( nPos + nDel ) ); + hb_retclen_buffer( szResult, nTot ); + } + else + hb_retc_null(); + } + else + hb_retc_null(); +} + +/* TODO: PadR(), PadC(), PadL() */ diff --git a/src/rtl/filesys.c b/src/rtl/filesys.c index b4a30fe2c4..6f8dd9f280 100644 --- a/src/rtl/filesys.c +++ b/src/rtl/filesys.c @@ -1347,44 +1347,64 @@ HB_BOOL hb_fsGetFileTime( const char * pszFileName, long * plJulian, long * plMi HB_TRACE( HB_TR_DEBUG, ( "hb_fsGetFileTime(%s, %p, %p)", pszFileName, plJulian, plMillisec ) ); fResult = HB_FALSE; + *plJulian = *plMillisec = 0; hb_vmUnlock(); #if defined( HB_OS_WIN ) { - HB_FHANDLE hFile = hb_fsOpen( pszFileName, FO_READ | FO_SHARED ); - FILETIME ft, local_ft; - SYSTEMTIME st; + typedef BOOL ( WINAPI * _HB_GETFILEATTRIBUTESEX )( LPCTSTR, GET_FILEEX_INFO_LEVELS, LPVOID ); + static _HB_GETFILEATTRIBUTESEX s_pGetFileAttributesEx = ( _HB_GETFILEATTRIBUTESEX ) -1; - if( hFile != FS_ERROR ) + if( s_pGetFileAttributesEx == ( _HB_GETFILEATTRIBUTESEX ) -1 ) { - if( GetFileTime( DosToWinHandle( hFile ), NULL, NULL, &ft ) && - FileTimeToLocalFileTime( &ft, &local_ft ) && - FileTimeToSystemTime( &local_ft, &st ) ) - { - *plJulian = hb_dateEncode( st.wYear, st.wMonth, st.wDay ); - *plMillisec = hb_timeEncode( st.wHour, st.wMinute, st.wSecond, st.wMilliseconds ); + HMODULE hModule = GetModuleHandle( TEXT( "kernel32.dll" ) ); + if( hModule ) + s_pGetFileAttributesEx = ( _HB_GETFILEATTRIBUTESEX ) + HB_WINAPI_GETPROCADDRESST( hModule, "GetFileAttributesEx" ); + else + s_pGetFileAttributesEx = NULL; + } - fResult = HB_TRUE; + if( s_pGetFileAttributesEx ) + { + LPCTSTR lpFileName; + LPTSTR lpFree; + WIN32_FILE_ATTRIBUTE_DATA attrex; + + lpFileName = HB_FSNAMECONV( pszFileName, &lpFree ); + + memset( &attrex, 0, sizeof( attrex ) ); + + if( GetFileAttributesEx( lpFileName, GetFileExInfoStandard, &attrex ) ) + { + FILETIME local_ft; + SYSTEMTIME st; + + if( FileTimeToLocalFileTime( &attrex.ftLastWriteTime, &local_ft ) && + FileTimeToSystemTime( &local_ft, &st ) ) + { + *plJulian = hb_dateEncode( st.wYear, st.wMonth, st.wDay ); + *plMillisec = hb_timeEncode( st.wHour, st.wMinute, st.wSecond, st.wMilliseconds ); + + fResult = HB_TRUE; + } } hb_fsSetIOError( fResult, 0 ); - hb_fsClose( hFile ); + + if( lpFree ) + hb_xfree( lpFree ); } else { - WIN32_FIND_DATA findFileData; - HANDLE hFindFile; - LPCTSTR lpFileName; - LPTSTR lpFree; + HB_FHANDLE hFile = hb_fsOpen( pszFileName, FO_READ | FO_SHARED ); + FILETIME ft, local_ft; + SYSTEMTIME st; - lpFileName = HB_FSNAMECONV( pszFileName, &lpFree ); - hFindFile = FindFirstFile( lpFileName, &findFileData ); - if( lpFree ) - hb_xfree( lpFree ); - - if( hFindFile != INVALID_HANDLE_VALUE ) + if( hFile != FS_ERROR ) { - if( FileTimeToLocalFileTime( &findFileData.ftLastWriteTime, &local_ft ) && + if( GetFileTime( DosToWinHandle( hFile ), NULL, NULL, &ft ) && + FileTimeToLocalFileTime( &ft, &local_ft ) && FileTimeToSystemTime( &local_ft, &st ) ) { *plJulian = hb_dateEncode( st.wYear, st.wMonth, st.wDay ); @@ -1393,7 +1413,33 @@ HB_BOOL hb_fsGetFileTime( const char * pszFileName, long * plJulian, long * plMi fResult = HB_TRUE; } hb_fsSetIOError( fResult, 0 ); - FindClose( hFindFile ); + hb_fsClose( hFile ); + } + else + { + WIN32_FIND_DATA findFileData; + HANDLE hFindFile; + LPCTSTR lpFileName; + LPTSTR lpFree; + + lpFileName = HB_FSNAMECONV( pszFileName, &lpFree ); + hFindFile = FindFirstFile( lpFileName, &findFileData ); + if( lpFree ) + hb_xfree( lpFree ); + + if( hFindFile != INVALID_HANDLE_VALUE ) + { + if( FileTimeToLocalFileTime( &findFileData.ftLastWriteTime, &local_ft ) && + FileTimeToSystemTime( &local_ft, &st ) ) + { + *plJulian = hb_dateEncode( st.wYear, st.wMonth, st.wDay ); + *plMillisec = hb_timeEncode( st.wHour, st.wMinute, st.wSecond, st.wMilliseconds ); + + fResult = HB_TRUE; + } + hb_fsSetIOError( fResult, 0 ); + FindClose( hFindFile ); + } } } } @@ -1438,8 +1484,6 @@ HB_BOOL hb_fsGetFileTime( const char * pszFileName, long * plJulian, long * plMi int iTODO; /* TODO: for given platform */ HB_SYMBOL_UNUSED( pszFileName ); - HB_SYMBOL_UNUSED( plJulian ); - HB_SYMBOL_UNUSED( plMillisec ); } #endif @@ -1531,7 +1575,6 @@ HB_BOOL hb_fsGetAttr( const char * pszFileName, HB_FATTR * pulAttr ) int iTODO; /* TODO: for given platform */ HB_SYMBOL_UNUSED( pszFileName ); - HB_SYMBOL_UNUSED( pulAttr ); } # endif if( pszFree ) diff --git a/src/rtl/fssize.c b/src/rtl/fssize.c index 7c031c1134..963cdcc9d7 100644 --- a/src/rtl/fssize.c +++ b/src/rtl/fssize.c @@ -55,7 +55,13 @@ #include "hbapifs.h" #include "hbvm.h" -#if ! defined( HB_OS_WIN_CE ) +#if defined( HB_OS_WIN ) +# include +# include "hbwinuni.h" +# if defined( HB_OS_WIN_CE ) +# include "hbwince.h" +# endif +#else # include # include #endif @@ -79,13 +85,47 @@ HB_FOFFSET hb_fsFSize( const char * pszFileName, HB_BOOL bUseDirEntry ) if( bUseDirEntry ) { #if defined( HB_OS_WIN ) - PHB_FFIND ffind = hb_fsFindFirst( pszFileName, HB_FA_ALL ); - hb_fsSetIOError( ffind != NULL, 0 ); - if( ffind ) + typedef BOOL ( WINAPI * _HB_GETFILEATTRIBUTESEX )( LPCTSTR, GET_FILEEX_INFO_LEVELS, LPVOID ); + static _HB_GETFILEATTRIBUTESEX s_pGetFileAttributesEx = ( _HB_GETFILEATTRIBUTESEX ) -1; + + if( s_pGetFileAttributesEx == ( _HB_GETFILEATTRIBUTESEX ) -1 ) { - HB_FOFFSET size = ffind->size; - hb_fsFindClose( ffind ); - return size; + HMODULE hModule = GetModuleHandle( TEXT( "kernel32.dll" ) ); + if( hModule ) + s_pGetFileAttributesEx = ( _HB_GETFILEATTRIBUTESEX ) + HB_WINAPI_GETPROCADDRESST( hModule, "GetFileAttributesEx" ); + else + s_pGetFileAttributesEx = NULL; + } + + if( s_pGetFileAttributesEx ) + { + LPCTSTR lpFileName; + LPTSTR lpFree; + WIN32_FILE_ATTRIBUTE_DATA attrex; + HB_BOOL fResult; + + lpFileName = HB_FSNAMECONV( pszFileName, &lpFree ); + memset( &attrex, 0, sizeof( attrex ) ); + fResult = GetFileAttributesEx( lpFileName, GetFileExInfoStandard, &attrex ) && + ( attrex.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) == 0; + hb_fsSetIOError( fResult, 0 ); + if( lpFree ) + hb_xfree( lpFree ); + if( fResult ) + return ( HB_FOFFSET ) attrex.nFileSizeLow + + ( ( HB_FOFFSET ) attrex.nFileSizeHigh << 32 ); + } + else + { + PHB_FFIND ffind = hb_fsFindFirst( pszFileName, HB_FA_ALL ); + hb_fsSetIOError( ffind != NULL, 0 ); + if( ffind ) + { + HB_FOFFSET size = ffind->size; + hb_fsFindClose( ffind ); + return size; + } } #elif defined( HB_USE_LARGEFILE64 ) char * pszFree; diff --git a/src/rtl/memoedit.prg b/src/rtl/memoedit.prg index 6dce6a40f6..a10b9435bb 100644 --- a/src/rtl/memoedit.prg +++ b/src/rtl/memoedit.prg @@ -218,7 +218,7 @@ METHOD HandleUserKey( nKey, nUdfReturn ) CLASS HBMemoEditor CASE nKey == K_ESC ::lSaved := .F. ::lExitEdit := .T. - CASE nKey <= 256 .OR. nKey == K_ALT_W .OR. Len( hb_keyChar( nKey ) ) > 0 + CASE nKey <= 256 .OR. nKey == K_ALT_W .OR. HB_ULen( hb_keyChar( nKey ) ) > 0 ::super:Edit( nKey ) ENDCASE ELSE @@ -228,7 +228,7 @@ METHOD HandleUserKey( nKey, nUdfReturn ) CLASS HBMemoEditor CASE ME_DATA IF HB_ISNUMERIC( nKey ) - IF nKey <= 256 .OR. Len( hb_keyChar( nKey ) ) > 0 + IF nKey <= 256 .OR. HB_ULen( hb_keyChar( nKey ) ) > 0 ::super:Edit( nKey ) ENDIF ELSE diff --git a/src/rtl/padc.c b/src/rtl/padc.c deleted file mode 100644 index 0f493d7e9d..0000000000 --- a/src/rtl/padc.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Harbour Project source code: - * PadC() function - * - * Copyright 2012 Przemyslaw Czerpak - * Copyright 1999 Matthew Hamilton - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.txt. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "hbapi.h" -#include "hbapiitm.h" -#include "hbapicdp.h" -#include "hbapierr.h" - -static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem ) -{ - HB_SIZE nLen = hb_itemGetCLen( pItem ); - - return nLen && HB_CDP_ISCHARIDX( cdp ) ? - hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen; -} - -static const char * s_hb_padGet( PHB_CODEPAGE cdp, HB_SIZE * pnPad ) -{ - const char * szPad = hb_parc( 3 ); - - *pnPad = 1; - if( szPad == NULL ) - szPad = " "; - else if( HB_CDP_ISCHARIDX( cdp ) ) - { - *pnPad = hb_cdpTextPos( cdp, szPad, hb_parclen( 3 ), 1 ); - if( *pnPad == 0 ) - szPad = ""; - } - return szPad; -} - -/* centre-pads a date, number, or string with spaces or supplied character */ -HB_FUNC( PADC ) -{ - HB_ISIZ nLen = hb_parns( 2 ); - - if( nLen > 0 ) - { - PHB_ITEM pItem = hb_param( 1, HB_IT_ANY ); - PHB_CODEPAGE cdp = hb_vmCDP(); - - if( pItem && HB_IS_STRING( pItem ) && - ( HB_SIZE ) nLen == hb_cdpItemLen( cdp, pItem ) ) - { - hb_itemReturn( pItem ); - } - else - { - HB_SIZE nSize; - HB_BOOL bFreeReq; - char * szText = hb_itemPadConv( pItem, &nSize, &bFreeReq ); - - if( szText ) - { - if( HB_CDP_ISCHARIDX( cdp ) ) - { - HB_SIZE nText = nLen; - nLen = hb_cdpTextPosEx( cdp, szText, nSize, &nText ); - nLen += nText; - } - - if( ( HB_SIZE ) nLen > nSize ) - { - HB_SIZE nPad = 0; - const char * szPad = s_hb_padGet( cdp, &nPad ); - char * szResult; - - if( nPad > 1 ) - { - HB_SIZE nRep = ( ( HB_SIZE ) nLen - nSize ) >> 1, nPos = 0; - nLen += ( nLen - nSize ) * ( nPad - 1 ); - szResult = ( char * ) hb_xgrab( nLen + 1 ); - while( nRep-- ) - { - hb_xmemcpy( szResult + nPos, szPad, nPad ); - nPos += nPad; - } - hb_xmemcpy( szResult + nPos, szText, nSize ); - nSize += nPos; - while( nSize < ( HB_SIZE ) nLen ) - { - hb_xmemcpy( szResult + nSize, szPad, nPad ); - nSize += nPad; - } - } - else - { - szResult = ( char * ) hb_xgrab( nLen + 1 ); - nPad = ( ( HB_SIZE ) nLen - nSize ) >> 1; - hb_xmemset( szResult, szPad[ 0 ], nPad ); - hb_xmemcpy( szResult + nPad, szText, nSize ); - hb_xmemset( szResult + nPad + nSize, szPad[ 0 ], - ( HB_SIZE ) nLen - nSize - nPad ); - } - - hb_retclen_buffer( szResult, ( HB_SIZE ) nLen ); - if( bFreeReq ) - hb_xfree( szText ); - } - else - { - if( bFreeReq ) - hb_retclen_buffer( szText, ( HB_SIZE ) nLen ); - else - hb_retclen( szText, nLen ); - } - } - else - hb_retc_null(); - } - } - else - hb_retc_null(); -} diff --git a/src/rtl/padl.c b/src/rtl/padl.c deleted file mode 100644 index 6f02eff423..0000000000 --- a/src/rtl/padl.c +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Harbour Project source code: - * PadL() function - * - * Copyright 2012 Przemyslaw Czerpak - * Copyright 1999 Matthew Hamilton - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.txt. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "hbapi.h" -#include "hbapiitm.h" -#include "hbapicdp.h" -#include "hbapierr.h" - -static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem ) -{ - HB_SIZE nLen = hb_itemGetCLen( pItem ); - - return nLen && HB_CDP_ISCHARIDX( cdp ) ? - hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen; -} - -static const char * s_hb_padGet( PHB_CODEPAGE cdp, HB_SIZE * pnPad ) -{ - const char * szPad = hb_parc( 3 ); - - *pnPad = 1; - if( szPad == NULL ) - szPad = " "; - else if( HB_CDP_ISCHARIDX( cdp ) ) - { - *pnPad = hb_cdpTextPos( cdp, szPad, hb_parclen( 3 ), 1 ); - if( *pnPad == 0 ) - szPad = ""; - } - return szPad; -} - -/* left-pads a date, number, or string with spaces or supplied character */ -HB_FUNC( PADL ) -{ - HB_ISIZ nLen = hb_parns( 2 ); - - if( nLen > 0 ) - { - PHB_ITEM pItem = hb_param( 1, HB_IT_ANY ); - PHB_CODEPAGE cdp = hb_vmCDP(); - - if( pItem && HB_IS_STRING( pItem ) && - ( HB_SIZE ) nLen == hb_cdpItemLen( cdp, pItem ) ) - { - hb_itemReturn( pItem ); - } - else - { - HB_SIZE nSize; - HB_BOOL bFreeReq; - char * szText = hb_itemPadConv( pItem, &nSize, &bFreeReq ); - - if( szText ) - { - if( HB_CDP_ISCHARIDX( cdp ) ) - { - HB_SIZE nText = nLen; - nLen = hb_cdpTextPosEx( cdp, szText, nSize, &nText ); - nLen += nText; - } - - if( ( HB_SIZE ) nLen > nSize ) - { - HB_SIZE nPad = 0; - const char * szPad = s_hb_padGet( cdp, &nPad ); - char * szResult; - - if( nPad > 1 ) - { - HB_SIZE nRep = ( ( HB_SIZE ) nLen - nSize ), nPos = 0; - nLen += nRep * ( nPad - 1 ); - szResult = ( char * ) hb_xgrab( nLen + 1 ); - while( nRep-- ) - { - hb_xmemcpy( szResult + nPos, szPad, nPad ); - nPos += nPad; - } - hb_xmemcpy( szResult + nPos, szText, nSize ); - } - else - { - szResult = ( char * ) hb_xgrab( nLen + 1 ); - hb_xmemset( szResult, szPad[ 0 ], ( HB_SIZE ) nLen - nSize ); - hb_xmemcpy( szResult + ( HB_SIZE ) nLen - nSize, szText, nSize ); - } - - hb_retclen_buffer( szResult, ( HB_SIZE ) nLen ); - if( bFreeReq ) - hb_xfree( szText ); - } - else - { - if( bFreeReq ) - hb_retclen_buffer( szText, ( HB_SIZE ) nLen ); - else - hb_retclen( szText, nLen ); - } - } - else - hb_retc_null(); - } - } - else - hb_retc_null(); -} diff --git a/src/rtl/padr.c b/src/rtl/padr.c deleted file mode 100644 index 7764f790ef..0000000000 --- a/src/rtl/padr.c +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Harbour Project source code: - * PadR() function - * - * Copyright 2012 Przemyslaw Czerpak - * Copyright 1999 Matthew Hamilton - * www - http://harbour-project.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.txt. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "hbapi.h" -#include "hbapiitm.h" -#include "hbapicdp.h" -#include "hbapierr.h" - -static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem ) -{ - HB_SIZE nLen = hb_itemGetCLen( pItem ); - - return nLen && HB_CDP_ISCHARIDX( cdp ) ? - hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen; -} - -static const char * s_hb_padGet( PHB_CODEPAGE cdp, HB_SIZE * pnPad ) -{ - const char * szPad = hb_parc( 3 ); - - *pnPad = 1; - if( szPad == NULL ) - szPad = " "; - else if( HB_CDP_ISCHARIDX( cdp ) ) - { - *pnPad = hb_cdpTextPos( cdp, szPad, hb_parclen( 3 ), 1 ); - if( *pnPad == 0 ) - szPad = ""; - } - return szPad; -} - -/* right-pads a date, number, or string with spaces or supplied character */ -HB_FUNC( PADR ) -{ - HB_ISIZ nLen = hb_parns( 2 ); - - if( nLen > 0 ) - { - PHB_ITEM pItem = hb_param( 1, HB_IT_ANY ); - PHB_CODEPAGE cdp = hb_vmCDP(); - - if( pItem && HB_IS_STRING( pItem ) && - ( HB_SIZE ) nLen == hb_cdpItemLen( cdp, pItem ) ) - { - hb_itemReturn( pItem ); - } - else - { - HB_SIZE nSize; - HB_BOOL bFreeReq; - char * szText = hb_itemPadConv( pItem, &nSize, &bFreeReq ); - - if( szText ) - { - if( HB_CDP_ISCHARIDX( cdp ) ) - { - HB_SIZE nText = nLen; - nLen = hb_cdpTextPosEx( cdp, szText, nSize, &nText ); - nLen += nText; - } - - if( ( HB_SIZE ) nLen > nSize ) - { - HB_SIZE nPad = 0; - const char * szPad = s_hb_padGet( cdp, &nPad ); - char * szResult; - - if( nPad > 1 ) - { - nLen += ( nLen - nSize ) * ( nPad - 1 ); - szResult = ( char * ) hb_xgrab( nLen + 1 ); - hb_xmemcpy( szResult, szText, nSize ); - while( nSize < ( HB_SIZE ) nLen ) - { - hb_xmemcpy( szResult + nSize, szPad, nPad ); - nSize += nPad; - } - } - else - { - szResult = ( char * ) hb_xgrab( nLen + 1 ); - hb_xmemcpy( szResult, szText, nSize ); - hb_xmemset( szResult + nSize, szPad[ 0 ], ( HB_SIZE ) nLen - nSize ); - } - - hb_retclen_buffer( szResult, ( HB_SIZE ) nLen ); - if( bFreeReq ) - hb_xfree( szText ); - } - else - { - if( bFreeReq ) - hb_retclen_buffer( szText, ( HB_SIZE ) nLen ); - else - hb_retclen( szText, nLen ); - } - } - else - hb_retc_null(); - } - } - else - hb_retc_null(); -} diff --git a/src/rtl/padx.c b/src/rtl/padx.c new file mode 100644 index 0000000000..c90c0371dc --- /dev/null +++ b/src/rtl/padx.c @@ -0,0 +1,284 @@ +/* + * Harbour Project source code: + * PadL(), PadR(), PadC() functions + * + * Copyright 2012 Przemyslaw Czerpak + * Copyright 1999 Matthew Hamilton + * www - http://harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.txt. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include "hbapi.h" +#include "hbapiitm.h" +#include "hbapicdp.h" +#include "hbapierr.h" + +static HB_SIZE hb_cdpItemLen( PHB_CODEPAGE cdp, PHB_ITEM pItem ) +{ + HB_SIZE nLen = hb_itemGetCLen( pItem ); + + return nLen && cdp ? + hb_cdpTextLen( cdp, hb_itemGetCPtr( pItem ), nLen ) : nLen; +} + +static const char * s_hb_padGet( PHB_CODEPAGE cdp, HB_SIZE * pnPad ) +{ + const char * szPad = hb_parc( 3 ); + + *pnPad = 1; + if( szPad == NULL ) + szPad = " "; + else if( cdp ) + { + *pnPad = hb_cdpTextPos( cdp, szPad, hb_parclen( 3 ), 1 ); + if( *pnPad == 0 ) + szPad = ""; + } + return szPad; +} + +#define HB_PAD_L 0 +#define HB_PAD_R 1 +#define HB_PAD_C 2 + +static void s_hb_strPad( int iMode, PHB_CODEPAGE cdp ) +{ + HB_ISIZ nLen = hb_parns( 2 ); + + if( nLen > 0 ) + { + PHB_ITEM pItem = hb_param( 1, HB_IT_ANY ); + + if( pItem && HB_IS_STRING( pItem ) && + ( HB_SIZE ) nLen == hb_cdpItemLen( cdp, pItem ) ) + { + hb_itemReturn( pItem ); + } + else + { + HB_SIZE nSize; + HB_BOOL bFreeReq; + char * szText = hb_itemPadConv( pItem, &nSize, &bFreeReq ); + + if( szText ) + { + if( cdp ) + { + HB_SIZE nText = nLen; + nLen = hb_cdpTextPosEx( cdp, szText, nSize, &nText ); + nLen += nText; + } + + if( ( HB_SIZE ) nLen > nSize ) + { + HB_SIZE nPad = 0; + const char * szPad = s_hb_padGet( cdp, &nPad ); + char * szResult; + + switch( iMode ) + { + case HB_PAD_L: + if( nPad > 1 ) + { + HB_SIZE nRep = ( ( HB_SIZE ) nLen - nSize ), nPos = 0; + nLen += nRep * ( nPad - 1 ); + szResult = ( char * ) hb_xgrab( nLen + 1 ); + while( nRep-- ) + { + hb_xmemcpy( szResult + nPos, szPad, nPad ); + nPos += nPad; + } + hb_xmemcpy( szResult + nPos, szText, nSize ); + } + else + { + szResult = ( char * ) hb_xgrab( nLen + 1 ); + hb_xmemset( szResult, szPad[ 0 ], ( HB_SIZE ) nLen - nSize ); + hb_xmemcpy( szResult + ( HB_SIZE ) nLen - nSize, szText, nSize ); + } + break; + case HB_PAD_R: + if( nPad > 1 ) + { + nLen += ( nLen - nSize ) * ( nPad - 1 ); + szResult = ( char * ) hb_xgrab( nLen + 1 ); + hb_xmemcpy( szResult, szText, nSize ); + while( nSize < ( HB_SIZE ) nLen ) + { + hb_xmemcpy( szResult + nSize, szPad, nPad ); + nSize += nPad; + } + } + else + { + szResult = ( char * ) hb_xgrab( nLen + 1 ); + hb_xmemcpy( szResult, szText, nSize ); + hb_xmemset( szResult + nSize, szPad[ 0 ], ( HB_SIZE ) nLen - nSize ); + } + break; + default: /* HB_PAD_C */ + if( nPad > 1 ) + { + HB_SIZE nRep = ( ( HB_SIZE ) nLen - nSize ) >> 1, nPos = 0; + nLen += ( nLen - nSize ) * ( nPad - 1 ); + szResult = ( char * ) hb_xgrab( nLen + 1 ); + while( nRep-- ) + { + hb_xmemcpy( szResult + nPos, szPad, nPad ); + nPos += nPad; + } + hb_xmemcpy( szResult + nPos, szText, nSize ); + nSize += nPos; + while( nSize < ( HB_SIZE ) nLen ) + { + hb_xmemcpy( szResult + nSize, szPad, nPad ); + nSize += nPad; + } + } + else + { + szResult = ( char * ) hb_xgrab( nLen + 1 ); + nPad = ( ( HB_SIZE ) nLen - nSize ) >> 1; + hb_xmemset( szResult, szPad[ 0 ], nPad ); + hb_xmemcpy( szResult + nPad, szText, nSize ); + hb_xmemset( szResult + nPad + nSize, szPad[ 0 ], + ( HB_SIZE ) nLen - nSize - nPad ); + } + break; + } + hb_retclen_buffer( szResult, ( HB_SIZE ) nLen ); + if( bFreeReq ) + hb_xfree( szText ); + } + else + { + if( bFreeReq ) + hb_retclen_buffer( szText, ( HB_SIZE ) nLen ); + else + hb_retclen( szText, nLen ); + } + } + else + hb_retc_null(); + } + } + else + hb_retc_null(); +} + +/* left-pads a date, number, or string with spaces or supplied character */ +HB_FUNC( PADL ) +{ + PHB_CODEPAGE cdp = hb_vmCDP(); + + if( ! HB_CDP_ISCHARIDX( cdp ) ) + cdp = NULL; + + s_hb_strPad( HB_PAD_L, cdp ); +} + +HB_FUNC( HB_BPADL ) +{ + s_hb_strPad( HB_PAD_L, NULL ); +} + +HB_FUNC( HB_UPADL ) +{ + PHB_CODEPAGE cdp = hb_vmCDP(); + + if( ! HB_CDP_ISCUSTOM( cdp ) ) + cdp = NULL; + + s_hb_strPad( HB_PAD_L, NULL ); +} + +/* right-pads a date, number, or string with spaces or supplied character */ +HB_FUNC( PADR ) +{ + PHB_CODEPAGE cdp = hb_vmCDP(); + + if( ! HB_CDP_ISCHARIDX( cdp ) ) + cdp = NULL; + + s_hb_strPad( HB_PAD_R, cdp ); +} + +HB_FUNC( HB_BPADR ) +{ + s_hb_strPad( HB_PAD_R, NULL ); +} + +HB_FUNC( HB_UPADR ) +{ + PHB_CODEPAGE cdp = hb_vmCDP(); + + if( ! HB_CDP_ISCUSTOM( cdp ) ) + cdp = NULL; + + s_hb_strPad( HB_PAD_R, NULL ); +} + +/* centre-pads a date, number, or string with spaces or supplied character */ +HB_FUNC( PADC ) +{ + PHB_CODEPAGE cdp = hb_vmCDP(); + + if( ! HB_CDP_ISCHARIDX( cdp ) ) + cdp = NULL; + + s_hb_strPad( HB_PAD_C, cdp ); +} + +HB_FUNC( HB_BPADC ) +{ + s_hb_strPad( HB_PAD_C, NULL ); +} + +HB_FUNC( HB_UPADC ) +{ + PHB_CODEPAGE cdp = hb_vmCDP(); + + if( ! HB_CDP_ISCUSTOM( cdp ) ) + cdp = NULL; + + s_hb_strPad( HB_PAD_C, NULL ); +} diff --git a/src/rtl/teditor.prg b/src/rtl/teditor.prg index 6ba33d0625..5ecadb4b08 100644 --- a/src/rtl/teditor.prg +++ b/src/rtl/teditor.prg @@ -247,7 +247,7 @@ METHOD GetLine( nRow ) CLASS HBEditor // Return text length of line n METHOD LineLen( nRow ) CLASS HBEditor - RETURN Len( ::GetLine( nRow ) ) + RETURN hb_ULen( ::GetLine( nRow ) ) // Converts an array of text lines to a String METHOD GetText( lSoftCR ) CLASS HBEditor @@ -271,7 +271,7 @@ METHOD GotoLine( nRow ) CLASS HBEditor RETURN ::Goto( nRow, ::nCol ) METHOD LineCount() CLASS HBEditor - RETURN Len( ::aText ) + RETURN hb_ULen( ::aText ) METHOD Display() CLASS HBEditor @@ -480,18 +480,18 @@ METHOD Edit( nPassedKey ) CLASS HBEditor CASE ( bKeyBlock := SetKey( nKeyStd ) ) != NIL Eval( bKeyBlock ) - CASE Len( cKey := iif( nKeyStd == K_TAB .AND. Set( _SET_INSERT ), ; + CASE hb_ULen( cKey := iif( nKeyStd == K_TAB .AND. Set( _SET_INSERT ), ; Space( TabCount( ::nTabWidth, ::nCol ) ), ; hb_keyChar( nKey ) ) ) > 0 ::lDirty := .T. oLine := ::aText[ ::nRow ] - IF ::nCol > Len( oLine:cText ) + 1 - oLine:cText += Space( ::nCol - Len( oLine:cText ) - 1 ) + IF ::nCol > hb_ULen( oLine:cText ) + 1 + oLine:cText += Space( ::nCol - hb_ULen( oLine:cText ) - 1 ) ENDIF - oLine:cText := Stuff( oLine:cText, ::nCol, ; + oLine:cText := hb_UStuff( oLine:cText, ::nCol, ; iif( Set( _SET_INSERT ), 0, 1 ), cKey ) - ::nCol += Len( cKey ) - IF ::lWordWrap .AND. Len( oLine:cText ) > ::nWordWrapCol + ::nCol += hb_ULen( cKey ) + IF ::lWordWrap .AND. hb_ULen( oLine:cText ) > ::nWordWrapCol ::ReformParagraph() ELSE ::GoTo( ::nRow, ::nCol, _REFRESH_LINE ) @@ -501,8 +501,8 @@ METHOD Edit( nPassedKey ) CLASS HBEditor IF Set( _SET_INSERT ) ::lDirty := .T. oLine := ::aText[ ::nRow ] - ::InsertLine( SubStr( oLine:cText, ::nCol ), oLine:lSoftCR, ::nRow + 1 ) - oLine:cText := Left( oLine:cText, ::nCol - 1 ) + ::InsertLine( hb_USubStr( oLine:cText, ::nCol ), oLine:lSoftCR, ::nRow + 1 ) + oLine:cText := hb_ULeft( oLine:cText, ::nCol - 1 ) oLine:lSoftCR := .F. ::Goto( ::nRow + 1, 1, _REFRESH_ALL ) ELSE @@ -519,7 +519,7 @@ METHOD Edit( nPassedKey ) CLASS HBEditor CASE nKeyStd == K_BS IF ::nCol > 1 ::lDirty := .T. - ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, --::nCol, 1, "" ) + ::aText[ ::nRow ]:cText := hb_UStuff( ::aText[ ::nRow ]:cText, --::nCol, 1, "" ) ::GoTo( ::nRow, ::nCol, _REFRESH_LINE ) ENDIF @@ -527,17 +527,17 @@ METHOD Edit( nPassedKey ) CLASS HBEditor IF ::nRow < ::LineCount .OR. ::nCol <= ::LineLen( ::nRow ) ::lDirty := .T. oLine := ::aText[ ::nRow ] - IF ::nCol <= Len( oLine:cText ) - oLine:cText := Stuff( oLine:cText, ::nCol, 1, "" ) + IF ::nCol <= hb_ULen( oLine:cText ) + oLine:cText := hb_UStuff( oLine:cText, ::nCol, 1, "" ) ::GoTo( ::nRow, ::nCol, _REFRESH_LINE ) ELSE - IF ::nCol > Len( oLine:cText ) + 1 - oLine:cText += Space( ::nCol - Len( oLine:cText ) - 1 ) + IF ::nCol > hb_ULen( oLine:cText ) + 1 + oLine:cText += Space( ::nCol - hb_ULen( oLine:cText ) - 1 ) ENDIF oLine:cText += ::aText[ ::nRow + 1 ]:cText oLine:lSoftCR := ::aText[ ::nRow + 1 ]:lSoftCR ::RemoveLine( ::nRow + 1 ) - IF ::lWordWrap .AND. Len( oLine:cText ) > ::nWordWrapCol + IF ::lWordWrap .AND. hb_ULen( oLine:cText ) > ::nWordWrapCol ::ReformParagraph() ELSE ::GoTo( ::nRow, ::nCol, _REFRESH_ALL ) @@ -558,7 +558,7 @@ METHOD Edit( nPassedKey ) CLASS HBEditor CASE nKeyStd == K_CTRL_T IF ( nPos := SkipWord( ::GetLine( ::nRow ), ::nCol ) - ::nCol ) > 0 ::lDirty := .T. - ::aText[ ::nRow ]:cText := Stuff( ::aText[ ::nRow ]:cText, ::nCol, nPos, "" ) + ::aText[ ::nRow ]:cText := hb_UStuff( ::aText[ ::nRow ]:cText, ::nCol, nPos, "" ) ::GoTo( ::nRow, ::nCol, _REFRESH_LINE ) ENDIF @@ -649,7 +649,7 @@ METHOD ReformParagraph() CLASS HBEditor LOCAL nLines LOCAL aPos - DO WHILE lNext .AND. ::nRow <= Len( ::aText ) + DO WHILE lNext .AND. ::nRow <= hb_ULen( ::aText ) cLine += ::aText[ ::nRow ]:cText lNext := ::aText[ ::nRow ]:lSoftCR ::RemoveLine( ::nRow ) @@ -696,7 +696,7 @@ METHOD Hilite() CLASS HBEditor hb_tokenGet( ::cColorSpec, 2, "," ) + "," + ; hb_tokenGet( ::cColorSpec, 1, "," ) - ::SetColor( cEnhanced + Right( ::cColorSpec, Len( ::cColorSpec ) - Len( cEnhanced ) ) ) + ::SetColor( cEnhanced + hb_URight( ::cColorSpec, hb_ULen( ::cColorSpec ) - hb_ULen( cEnhanced ) ) ) RETURN Self @@ -707,7 +707,7 @@ METHOD DeHilite() CLASS HBEditor hb_tokenGet( ::cColorSpec, 2, "," ) + "," + ; hb_tokenGet( ::cColorSpec, 1, "," ) - ::SetColor( cStandard + Right( ::cColorSpec, Len( ::cColorSpec ) - Len( cStandard ) ) ) + ::SetColor( cStandard + hb_URight( ::cColorSpec, hb_ULen( ::cColorSpec ) - hb_ULen( cStandard ) ) ) RETURN Self @@ -749,7 +749,7 @@ STATIC FUNCTION Text2Array( cText, nWordWrapCol, nTabWidth ) LOCAL nLine FOR EACH cLine IN hb_ATokens( cText, .T. ) - IF nWordWrapCol != NIL .AND. Len( cLine ) > nWordWrapCol + IF nWordWrapCol != NIL .AND. hb_ULen( cLine ) > nWordWrapCol nLines := MLCount( cLine, nWordWrapCol + 1, nTabWidth ) FOR nLine := 1 TO nLines AAdd( aArray, HBTextLine():New( MemoLine( cLine, nWordWrapCol + 1, nLine, nTabWidth,,, .F. ), ; @@ -766,28 +766,28 @@ STATIC FUNCTION Text2Array( cText, nWordWrapCol, nTabWidth ) RETURN aArray STATIC FUNCTION SubStrPad( cText, nFrom, nLen ) - RETURN PadR( SubStr( cText, nFrom, nLen ), nLen ) + RETURN hb_UPadR( hb_USubStr( cText, nFrom, nLen ), nLen ) STATIC FUNCTION TabCount( nTabWidth, nCol ) RETURN Int( nTabWidth - ( nCol - 1 ) % nTabWidth ) STATIC FUNCTION SkipWord( cText, nPos ) - DO WHILE nPos < Len( cText ) .AND. SubStr( cText, nPos, 1 ) == " " + DO WHILE nPos < hb_ULen( cText ) .AND. hb_USubStr( cText, nPos, 1 ) == " " ++nPos ENDDO - IF ( nPos := hb_At( " ", cText, nPos ) ) == 0 - nPos := Len( cText ) + 1 + IF ( nPos := hb_UAt( " ", cText, nPos ) ) == 0 + nPos := hb_ULen( cText ) + 1 ENDIF RETURN nPos STATIC FUNCTION NextWord( cText, nPos ) - IF ( nPos := hb_At( " ", cText, nPos ) ) == 0 - nPos := Len( cText ) + 1 + IF ( nPos := hb_UAt( " ", cText, nPos ) ) == 0 + nPos := hb_ULen( cText ) + 1 ELSE - DO WHILE SubStr( cText, ++nPos, 1 ) == " " + DO WHILE hb_USubStr( cText, ++nPos, 1 ) == " " ENDDO ENDIF @@ -795,9 +795,9 @@ STATIC FUNCTION NextWord( cText, nPos ) STATIC FUNCTION PrevWord( cText, nPos ) - DO WHILE nPos > 1 .AND. SubStr( cText, --nPos, 1 ) == " " + DO WHILE nPos > 1 .AND. hb_USubStr( cText, --nPos, 1 ) == " " ENDDO - DO WHILE nPos > 1 .AND. ! SubStr( cText, nPos - 1, 1 ) == " " + DO WHILE nPos > 1 .AND. ! hb_USubStr( cText, nPos - 1, 1 ) == " " --nPos ENDDO diff --git a/src/rtl/vfile.c b/src/rtl/vfile.c index d721e8a4c4..d2d3ed0583 100644 --- a/src/rtl/vfile.c +++ b/src/rtl/vfile.c @@ -754,7 +754,7 @@ HB_FUNC( HB_VFSIZE ) if( pszFile ) { - HB_ERRCODE uiError = 0; + HB_ERRCODE uiError; HB_FOFFSET nSize = 0; if( hb_parldef( 2, 1 ) )