diff --git a/harbour/ChangeLog b/harbour/ChangeLog index ad0021534a..63903f7646 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,25 @@ The license applies to all entries newer than 2009-04-28. */ +2011-12-29 23:51 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * harbour/include/hbapistr.h + * harbour/src/vm/strapi.c + + added new C functions: + hb_wstrncpy(), hb_wstrncat() + + * harbour/src/common/hbstr.c + ; minor updated in comment + + * harbour/include/hbwinuni.h + + added new macros: + HB_STRLEN(), HB_STRNLEN(), HB_STRDUP(), HB_STRNDUP(), + HB_STRNCPY(), HB_STRNCAT(), HB_STRCMP(), HB_STRNCMP() + + * harbour/src/rtl/disksphb.c + * harbour/src/rtl/gtwvt/gtwvt.h + * harbour/src/rtl/gtwvt/gtwvt.c + * eliminated HB_TCHAR_*() macros + 2011-12-29 16:17 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * harbour/contrib/gtwvg/gtwvg.h ! added missing 'void * hText' member to HB_GOBJS struct diff --git a/harbour/include/hbapistr.h b/harbour/include/hbapistr.h index 8ed3635369..46a4e1ae7b 100644 --- a/harbour/include/hbapistr.h +++ b/harbour/include/hbapistr.h @@ -62,6 +62,8 @@ extern HB_EXPORT HB_SIZE hb_wstrlen( const HB_WCHAR * szText ); extern HB_EXPORT HB_SIZE hb_wstrnlen( const HB_WCHAR * szText, HB_SIZE nCount ); extern HB_EXPORT int hb_wstrcmp( const HB_WCHAR * s1, const HB_WCHAR * s2 ); extern HB_EXPORT int hb_wstrncmp( const HB_WCHAR * s1, const HB_WCHAR * s2, HB_SIZE nCount ); +extern HB_EXPORT HB_WCHAR * hb_wstrncpy( HB_WCHAR * pDest, const HB_WCHAR * pSource, HB_SIZE nLen ); +extern HB_EXPORT HB_WCHAR * hb_wstrncat( HB_WCHAR * pDest, const HB_WCHAR * pSource, HB_SIZE nLen ); extern HB_EXPORT HB_WCHAR * hb_wstrdup( const HB_WCHAR * szText ); extern HB_EXPORT HB_WCHAR * hb_wstrndup( const HB_WCHAR * szText, HB_SIZE nLen ); diff --git a/harbour/include/hbwinuni.h b/harbour/include/hbwinuni.h index 493103db8c..5d583af3a3 100644 --- a/harbour/include/hbwinuni.h +++ b/harbour/include/hbwinuni.h @@ -74,6 +74,14 @@ #define HB_ITEMPUTSTR( itm, str ) hb_itemPutStrU16( itm, HB_CDP_ENDIAN_NATIVE, str ) #define HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLenU16( itm, HB_CDP_ENDIAN_NATIVE, str, len ) #define HB_STRUNSHARE( h, str, len ) hb_wstrunshare( h, str, len ) + #define HB_STRLEN( str ) hb_wstrlen( str ) + #define HB_STRNLEN( str, len ) hb_wstrnlen( str, len ) + #define HB_STRDUP( str ) hb_wstrdup( str ) + #define HB_STRNDUP( str, len ) hb_wstrndup( str, len ) + #define HB_STRNCPY( dst, src, len ) hb_wstrncpy( dst, src, len ) + #define HB_STRNCAT( dst, src, len ) hb_wstrncat( dst, src, len ) + #define HB_STRCMP( s1, s2 ) hb_wstrcmp( s1, s2 ) + #define HB_STRNCMP( s1, s2, len ) hb_wstrncmp( s1, s2, len ) #else #define HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len ) #define HB_PARSTRDEF( n, h, len ) hb_strnull( hb_parstr( n, hb_setGetOSCP(), h, len ) ) @@ -89,6 +97,14 @@ #define HB_ITEMPUTSTR( itm, str ) hb_itemPutStr( itm, hb_setGetOSCP(), str ) #define HB_ITEMPUTSTRLEN( itm, str, len ) hb_itemPutStrLen( itm, hb_setGetOSCP(), str, len ) #define HB_STRUNSHARE( h, str, len ) hb_strunshare( h, str, len ) + #define HB_STRLEN( str ) strlen( str ) + #define HB_STRNLEN( str, len ) hb_strnlen( str, len ) + #define HB_STRDUP( str ) hb_strdup( str ) + #define HB_STRNDUP( str, len ) hb_strndup( str, len ) + #define HB_STRNCPY( dst, src, len ) hb_strncpy( dst, src, len ) + #define HB_STRNCAT( dst, src, len ) hb_strncat( dst, src, len ) + #define HB_STRCMP( s1, s2 ) strcmp( s1, s2 ) + #define HB_STRNCMP( s1, s2, len ) strncmp( s1, s2, len ) #endif #endif /* HB_OS_WIN */ diff --git a/harbour/src/common/hbstr.c b/harbour/src/common/hbstr.c index a12da047e3..2f37008370 100644 --- a/harbour/src/common/hbstr.c +++ b/harbour/src/common/hbstr.c @@ -800,7 +800,7 @@ char * hb_numToStr( char * szBuf, HB_SIZE nSize, HB_MAXINT lNumber ) /* * This function copies szText to destination buffer. * NOTE: Unlike the documentation for strncpy, this routine will always append - * a null + * a null and the nLen param is pDest size not pSource limit */ char * hb_strncpy( char * pDest, const char * pSource, HB_SIZE nLen ) { diff --git a/harbour/src/rtl/disksphb.c b/harbour/src/rtl/disksphb.c index 4695931990..4d981ddbb4 100644 --- a/harbour/src/rtl/disksphb.c +++ b/harbour/src/rtl/disksphb.c @@ -66,6 +66,7 @@ #include #endif #elif defined( HB_OS_WIN ) + #include "hbwinuni.h" #include #if defined( HB_OS_WIN_CE ) #include "hbwince.h" @@ -80,40 +81,168 @@ HB_FUNC( HB_DISKSPACE ) { - char szPathBuf[ 4 ]; - const char * szPath = hb_parc( 1 ); HB_USHORT uiType = ( HB_USHORT ) hb_parnidef( 2, HB_DISK_AVAIL ); double dSpace = 0.0; if( uiType > HB_DISK_TOTAL ) uiType = HB_DISK_AVAIL; - if( !szPath ) +#if defined( HB_OS_WIN ) { -#ifdef HB_OS_HAS_DRIVE_LETTER - if( HB_ISNUM( 1 ) ) +#if defined( _MSC_VER ) || defined( __LCC__ ) || \ + ( defined( __GNUC__ ) && !defined( __RSXNT__ ) ) + +# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).LowPart + \ + ( double ) (v).HighPart * \ + ( ( ( double ) 0xFFFFFFFF ) + 1 ) ) + +#else + /* NOTE: Borland doesn't seem to deal with the un-named + struct that is part of ULARGE_INTEGER + [pt] */ +# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).u.LowPart + \ + ( double ) (v).u.HighPart * \ + ( ( ( double ) 0xFFFFFFFF ) + 1 ) ) +#endif + ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes; + UINT uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS ); + HB_BOOL fResult; + void * hPath; + LPCTSTR lpPath = HB_PARSTR( 1, &hPath, NULL ); + TCHAR szPathBuf[ 4 ]; + + if( !lpPath ) { - szPathBuf[ 0 ] = ( char ) hb_parni( 1 ) + 'A' - 1; - szPathBuf[ 1 ] = HB_OS_DRIVE_DELIM_CHR; - szPathBuf[ 2 ] = HB_OS_PATH_DELIM_CHR; - szPathBuf[ 3 ] = '\0'; +#ifdef HB_OS_HAS_DRIVE_LETTER + if( HB_ISNUM( 1 ) ) + { + szPathBuf[ 0 ] = ( TCHAR ) hb_parni( 1 ) + 'A' - 1; + szPathBuf[ 1 ] = HB_OS_DRIVE_DELIM_CHR; + szPathBuf[ 2 ] = HB_OS_PATH_DELIM_CHR; + szPathBuf[ 3 ] = '\0'; + } + else +#endif + { + szPathBuf[ 0 ] = HB_OS_PATH_DELIM_CHR; + szPathBuf[ 1 ] = '\0'; + } + lpPath = szPathBuf; + } + +#if !defined( HB_OS_WIN_CE ) && !defined( HB_OS_WIN_64 ) + + /* NOTE: We need to call this function dynamically to maintain support + Win95 first edition. It was introduced in Win95B (aka OSR2) [vszakats] */ + typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER, + PULARGE_INTEGER, PULARGE_INTEGER ); + static P_GDFSE s_pGetDiskFreeSpaceEx = NULL; + static HB_BOOL s_fInit = HB_FALSE; + + if( ! s_fInit ) + { + s_pGetDiskFreeSpaceEx = ( P_GDFSE ) +#if defined( UNICODE ) + GetProcAddress( GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ), + "GetDiskFreeSpaceExW" ); +#else + GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ), + "GetDiskFreeSpaceExA" ); +#endif + s_fInit = HB_TRUE; + } + + if( !s_pGetDiskFreeSpaceEx ) + { + DWORD dwSectorsPerCluster; + DWORD dwBytesPerSector; + DWORD dwNumberOfFreeClusters; + DWORD dwTotalNumberOfClusters; + + fResult = GetDiskFreeSpace( lpPath, + &dwSectorsPerCluster, + &dwBytesPerSector, + &dwNumberOfFreeClusters, + &dwTotalNumberOfClusters ) ? HB_TRUE : HB_FALSE; + hb_fsSetIOError( fResult, 0 ); + + if( fResult ) + { + switch( uiType ) + { + case HB_DISK_AVAIL: + case HB_DISK_FREE: + dSpace = ( double ) dwNumberOfFreeClusters * + ( double ) dwSectorsPerCluster * + ( double ) dwBytesPerSector; + break; + + case HB_DISK_USED: + case HB_DISK_TOTAL: + dSpace = ( double ) dwTotalNumberOfClusters * + ( double ) dwSectorsPerCluster * + ( double ) dwBytesPerSector; + + if( uiType == HB_DISK_USED ) + dSpace -= ( double ) dwNumberOfFreeClusters * + ( double ) dwSectorsPerCluster * + ( double ) dwBytesPerSector; + break; + } + } } else #endif { - szPathBuf[ 0 ] = HB_OS_PATH_DELIM_CHR; - szPathBuf[ 1 ] = '\0'; - } - szPath = szPathBuf; - } + fResult = GetDiskFreeSpaceEx( lpPath, + ( PULARGE_INTEGER ) &i64FreeBytesToCaller, + ( PULARGE_INTEGER ) &i64TotalBytes, + ( PULARGE_INTEGER ) &i64FreeBytes ); + hb_fsSetIOError( fResult, 0 ); -#if defined( HB_OS_DOS ) + if( fResult ) + { + switch( uiType ) + { + case HB_DISK_AVAIL: + dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller ); + break; + + case HB_DISK_FREE: + dSpace = HB_GET_LARGE_UINT( i64FreeBytes ); + break; + + case HB_DISK_TOTAL: + dSpace = HB_GET_LARGE_UINT( i64TotalBytes ); + break; + + case HB_DISK_USED: + dSpace = HB_GET_LARGE_UINT( i64TotalBytes ) - + HB_GET_LARGE_UINT( i64FreeBytes ); + break; + } + } + } + hb_strfree( hPath ); + SetErrorMode( uiErrMode ); + } +#elif defined( HB_OS_DOS ) || defined( HB_OS_OS2 ) { - HB_USHORT uiDrive = szPath[ 1 ] != HB_OS_DRIVE_DELIM_CHR ? 0 : - ( szPath[ 0 ] >= 'A' && szPath[ 0 ] <= 'Z' ? - szPath[ 0 ] - 'A' + 1 : - ( szPath[ 0 ] >= 'a' && szPath[ 0 ] <= 'z' ? - szPath[ 0 ] - 'a' + 1 : 0 ) ); + HB_USHORT uiDrive; + + if( HB_ISNUM( 1 ) ) + uiDrive = ( HB_USHORT ) hb_parni( 1 ); + else + { + const char * szPath = hb_parc( 1 ); + uiDrive = szPath == NULL || szPath[ 0 ] == 0 || + szPath[ 1 ] != HB_OS_DRIVE_DELIM_CHR ? 0 : + ( szPath[ 0 ] >= 'A' && szPath[ 0 ] <= 'Z' ? + szPath[ 0 ] - 'A' + 1 : + ( szPath[ 0 ] >= 'a' && szPath[ 0 ] <= 'z' ? + szPath[ 0 ] - 'a' + 1 : 0 ) ); + } +#if defined( HB_OS_DOS ) for( ;; ) { union REGS regs; @@ -158,171 +287,9 @@ HB_FUNC( HB_DISKSPACE ) } break; } - } -#elif defined( HB_OS_WIN ) - { -#if defined( _MSC_VER ) || defined( __LCC__ ) || \ - ( defined( __GNUC__ ) && !defined( __RSXNT__ ) ) - -# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).LowPart + \ - ( double ) (v).HighPart * \ - ( ( ( double ) 0xFFFFFFFF ) + 1 ) ) - -#else - /* NOTE: Borland doesn't seem to deal with the un-named - struct that is part of ULARGE_INTEGER - [pt] */ -# define HB_GET_LARGE_UINT( v ) ( ( double ) (v).u.LowPart + \ - ( double ) (v).u.HighPart * \ - ( ( ( double ) 0xFFFFFFFF ) + 1 ) ) -#endif - - for( ;; ) - { - ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes; - UINT uiErrMode = SetErrorMode( SEM_FAILCRITICALERRORS ); - HB_BOOL fResult; - - LPTSTR lpPath = HB_TCHAR_CONVTO( szPath ); - -#if defined( HB_OS_WIN_CE ) - - fResult = GetDiskFreeSpaceEx( lpPath, - ( PULARGE_INTEGER ) &i64FreeBytesToCaller, - ( PULARGE_INTEGER ) &i64TotalBytes, - ( PULARGE_INTEGER ) &i64FreeBytes ); - hb_fsSetIOError( fResult, 0 ); - - if( fResult ) - { - switch( uiType ) - { - case HB_DISK_AVAIL: - dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller ); - break; - - case HB_DISK_FREE: - dSpace = HB_GET_LARGE_UINT( i64FreeBytes ); - break; - - case HB_DISK_TOTAL: - dSpace = HB_GET_LARGE_UINT( i64TotalBytes ); - break; - - case HB_DISK_USED: - dSpace = HB_GET_LARGE_UINT( i64TotalBytes ) - - HB_GET_LARGE_UINT( i64FreeBytes ); - break; - } - } -#else - /* NOTE: We need to call this function dynamically to maintain support - Win95 first edition. It was introduced in Win95B (aka OSR2) [vszakats] */ - { - typedef BOOL ( WINAPI * P_GDFSE )( LPCTSTR, PULARGE_INTEGER, - PULARGE_INTEGER, PULARGE_INTEGER ); - - static P_GDFSE s_pGetDiskFreeSpaceEx = NULL; - static HB_BOOL s_fInit = HB_FALSE; - - if( ! s_fInit ) - { - s_pGetDiskFreeSpaceEx = ( P_GDFSE ) -#if defined( UNICODE ) - GetProcAddress( GetModuleHandle( hb_iswin9x() ? TEXT( "unicows.dll" ) : TEXT( "kernel32.dll" ) ), - "GetDiskFreeSpaceExW" ); -#else - GetProcAddress( GetModuleHandle( TEXT( "kernel32.dll" ) ), - "GetDiskFreeSpaceExA" ); -#endif - s_fInit = HB_TRUE; - } - if( s_pGetDiskFreeSpaceEx ) - { - fResult = s_pGetDiskFreeSpaceEx( lpPath, - ( PULARGE_INTEGER ) &i64FreeBytesToCaller, - ( PULARGE_INTEGER ) &i64TotalBytes, - ( PULARGE_INTEGER ) &i64FreeBytes ) ? HB_TRUE : HB_FALSE; - hb_fsSetIOError( fResult, 0 ); - if( fResult ) - { - switch( uiType ) - { - case HB_DISK_AVAIL: - dSpace = HB_GET_LARGE_UINT( i64FreeBytesToCaller ); - break; - - case HB_DISK_FREE: - dSpace = HB_GET_LARGE_UINT( i64FreeBytes ); - break; - - case HB_DISK_TOTAL: - dSpace = HB_GET_LARGE_UINT( i64TotalBytes ); - break; - - case HB_DISK_USED: - dSpace = HB_GET_LARGE_UINT( i64TotalBytes ) - - HB_GET_LARGE_UINT( i64FreeBytes ); - break; - } - } - } - else - { - DWORD dwSectorsPerCluster; - DWORD dwBytesPerSector; - DWORD dwNumberOfFreeClusters; - DWORD dwTotalNumberOfClusters; - - fResult = GetDiskFreeSpace( lpPath, - &dwSectorsPerCluster, - &dwBytesPerSector, - &dwNumberOfFreeClusters, - &dwTotalNumberOfClusters ) ? HB_TRUE : HB_FALSE; - hb_fsSetIOError( fResult, 0 ); - - if( fResult ) - { - switch( uiType ) - { - case HB_DISK_AVAIL: - case HB_DISK_FREE: - dSpace = ( double ) dwNumberOfFreeClusters * - ( double ) dwSectorsPerCluster * - ( double ) dwBytesPerSector; - break; - - case HB_DISK_USED: - case HB_DISK_TOTAL: - dSpace = ( double ) dwTotalNumberOfClusters * - ( double ) dwSectorsPerCluster * - ( double ) dwBytesPerSector; - - if( uiType == HB_DISK_USED ) - dSpace -= ( double ) dwNumberOfFreeClusters * - ( double ) dwSectorsPerCluster * - ( double ) dwBytesPerSector; - break; - } - } - } - } -#endif - HB_TCHAR_FREE( lpPath ); - SetErrorMode( uiErrMode ); - break; - } - } -#elif defined( HB_OS_OS2 ) - { +#else /* HB_OS_OS2 */ struct _FSALLOCATE fsa; USHORT rc; - USHORT uiDrive = szPath[ 1 ] != HB_OS_DRIVE_DELIM_CHR ? 0 : - ( szPath[ 0 ] >= 'A' && szPath[ 0 ] <= 'Z' ? - szPath[ 0 ] - 'A' + 1 : - ( szPath[ 0 ] >= 'a' && szPath[ 0 ] <= 'z' ? - szPath[ 0 ] - 'a' + 1 : 0 ) ); - /* Query level 1 info from filesystem */ while( ( rc = DosQueryFSInfo( uiDrive, 1, &fsa, sizeof( fsa ) ) ) != 0 ) { @@ -330,6 +297,8 @@ HB_FUNC( HB_DISKSPACE ) break; } + hb_fsSetIOError( rc == 0, 0 ); + if( rc == 0 ) { switch( uiType ) @@ -353,12 +322,12 @@ HB_FUNC( HB_DISKSPACE ) ( double ) fsa.cbSector; break; } - hb_fsSetIOError( HB_TRUE, 0 ); } - else - hb_fsSetIOError( HB_FALSE, 0 ); +#endif } -#elif defined( HB_OS_UNIX ) && !( defined( __WATCOMC__ ) || defined( __CEGCC__ ) || defined( HB_OS_SYMBIAN ) ) + +#elif defined( HB_OS_UNIX ) && \ + !( defined( __WATCOMC__ ) || defined( __CEGCC__ ) || defined( HB_OS_SYMBIAN ) ) { #if defined( HB_OS_DARWIN ) || defined( HB_OS_ANDROID ) || \ defined( HB_OS_VXWORKS ) @@ -368,6 +337,28 @@ HB_FUNC( HB_DISKSPACE ) #endif char * pszFree; + char szPathBuf[ 4 ]; + const char * szPath = hb_parc( 1 ); + + if( !szPath ) + { +#ifdef HB_OS_HAS_DRIVE_LETTER + if( HB_ISNUM( 1 ) ) + { + szPathBuf[ 0 ] = ( char ) hb_parni( 1 ) + 'A' - 1; + szPathBuf[ 1 ] = HB_OS_DRIVE_DELIM_CHR; + szPathBuf[ 2 ] = HB_OS_PATH_DELIM_CHR; + szPathBuf[ 3 ] = '\0'; + } + else +#endif + { + szPathBuf[ 0 ] = HB_OS_PATH_DELIM_CHR; + szPathBuf[ 1 ] = '\0'; + } + szPath = szPathBuf; + } + szPath = hb_fsNameConv( szPath, &pszFree ); #if defined( HB_OS_DARWIN ) || defined( HB_OS_ANDROID ) || \ @@ -408,7 +399,6 @@ HB_FUNC( HB_DISKSPACE ) { int iTODO; - HB_SYMBOL_UNUSED( szPath ); HB_SYMBOL_UNUSED( uiType ); } #endif diff --git a/harbour/src/rtl/gtwvt/gtwvt.c b/harbour/src/rtl/gtwvt/gtwvt.c index 061dec461f..e62f21344e 100644 --- a/harbour/src/rtl/gtwvt/gtwvt.c +++ b/harbour/src/rtl/gtwvt/gtwvt.c @@ -323,7 +323,7 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) pWVT->fontHeight = WVT_DEFAULT_FONT_HEIGHT; pWVT->fontWeight = FW_NORMAL; pWVT->fontQuality = DEFAULT_QUALITY; - hb_strncpy( pWVT->fontFace, WVT_DEFAULT_FONT_NAME, HB_SIZEOFARRAY( pWVT->fontFace ) - 1 ); + HB_STRNCPY( pWVT->fontFace, WVT_DEFAULT_FONT_NAME, HB_SIZEOFARRAY( pWVT->fontFace ) - 1 ); pWVT->CaretExist = HB_FALSE; pWVT->CaretHidden = HB_TRUE; @@ -396,7 +396,7 @@ static PHB_GTWVT hb_gt_wvt_New( PHB_GT pGT, HINSTANCE hInstance, int iCmdShow ) /* * use the standard fixed OEM font, unless the caller has requested set size fonts */ -static HFONT hb_gt_wvt_GetFont( const char * pszFace, int iHeight, int iWidth, int iWeight, int iQuality, int iCodePage ) +static HFONT hb_gt_wvt_GetFont( LPCTSTR lpFace, int iHeight, int iWidth, int iWeight, int iQuality, int iCodePage ) { if( iHeight > 0 ) { @@ -417,7 +417,7 @@ static HFONT hb_gt_wvt_GetFont( const char * pszFace, int iHeight, int iWidth, i logfont.lfHeight = iHeight; logfont.lfWidth = iWidth < 0 ? -iWidth : iWidth; - HB_TCHAR_COPYTO( logfont.lfFaceName, pszFace, HB_SIZEOFARRAY( logfont.lfFaceName ) - 1 ); + HB_STRNCPY( logfont.lfFaceName, lpFace, HB_SIZEOFARRAY( logfont.lfFaceName ) - 1 ); return CreateFontIndirect( &logfont ); } @@ -2407,9 +2407,9 @@ static HB_BOOL hb_gt_wvt_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) break; case HB_GTI_FONTNAME: - pInfo->pResult = hb_itemPutC( pInfo->pResult, pWVT->fontFace ); - if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) /* TODO */ - hb_strncpy( pWVT->fontFace, hb_itemGetCPtr( pInfo->pNewVal ), HB_SIZEOFARRAY( pWVT->fontFace ) - 1 ); + pInfo->pResult = HB_ITEMPUTSTR( pInfo->pResult, pWVT->fontFace ); + if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING ) + HB_ITEMCOPYSTR( pInfo->pNewVal, pWVT->fontFace, HB_SIZEOFARRAY( pWVT->fontFace ) ); break; case HB_GTI_FONTWEIGHT: diff --git a/harbour/src/rtl/gtwvt/gtwvt.h b/harbour/src/rtl/gtwvt/gtwvt.h index 98b34b85ae..14ef2e55d3 100644 --- a/harbour/src/rtl/gtwvt/gtwvt.h +++ b/harbour/src/rtl/gtwvt/gtwvt.h @@ -87,7 +87,7 @@ # define WVT_DEFAULT_FONT_HEIGHT 20 # define WVT_DEFAULT_FONT_WIDTH 10 #endif -#define WVT_DEFAULT_FONT_NAME "Courier New" +#define WVT_DEFAULT_FONT_NAME TEXT( "Courier New" ) #define BLACK RGB( 0x00, 0x00, 0x00 ) #define BLUE RGB( 0x00, 0x00, 0xAA ) @@ -143,7 +143,7 @@ typedef struct int fontWidth; /* requested font width */ int fontWeight; /* Bold level */ int fontQuality; /* requested font quality */ - char fontFace[ LF_FACESIZE ]; /* requested font face name LF_FACESIZE #defined in wingdi.h */ + TCHAR fontFace[ LF_FACESIZE ]; /* requested font face name LF_FACESIZE #defined in wingdi.h */ HFONT hFont; /* current font handle */ #if ! defined( UNICODE ) HFONT hFontBox; /* current font handle to draw lines */ diff --git a/harbour/src/vm/strapi.c b/harbour/src/vm/strapi.c index 8a0a56087b..8dd7a03b41 100644 --- a/harbour/src/vm/strapi.c +++ b/harbour/src/vm/strapi.c @@ -134,6 +134,40 @@ int hb_wstrncmp( const HB_WCHAR * s1, const HB_WCHAR * s2, HB_SIZE nCount ) return rc; } +HB_WCHAR * hb_wstrncpy( HB_WCHAR * pDest, const HB_WCHAR * pSource, HB_SIZE nLen ) +{ + HB_WCHAR * pBuf = pDest; + + HB_TRACE(HB_TR_DEBUG, ("hb_wstrncpy(%p, %p, %" HB_PFS "u)", pDest, pSource, nLen)); + + pDest[ nLen ] = '\0'; + + while( nLen && ( *pDest++ = *pSource++ ) != '\0' ) + nLen--; + + return pBuf; +} + +HB_WCHAR * hb_wstrncat( HB_WCHAR * pDest, const HB_WCHAR * pSource, HB_SIZE nLen ) +{ + HB_WCHAR * pBuf = pDest; + + HB_TRACE(HB_TR_DEBUG, ("hb_strncat(%p, %p, %" HB_PFS "u)", pDest, pSource, nLen)); + + pDest[ nLen ] = '\0'; + + while( nLen && *pDest ) + { + pDest++; + nLen--; + } + + while( nLen && ( *pDest++ = *pSource++ ) != '\0' ) + nLen--; + + return pBuf; +} + HB_WCHAR * hb_wstrdup( const HB_WCHAR * szText ) { HB_WCHAR * pszDest;