2023-01-15 11:17 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* contrib/hbwin/win_prn1.c
    ! fixed parameter type in font enum callback

  * include/harbour.hbx
  * src/harbour.def
  * src/rtl/hbgtcore.c
    + added two new PRG functions:
         hb_gtExists( <cGtName> ) -> <lExists>
         hb_gtList() -> <aGtNames>

  * src/rtl/hbgtcore.c
    * changed the order of defualt GT initialization. Now GT specified by -gt*
      hbmk2 option has higher priority then GT chosen by
         request HB_GT_<name>_DEFAULT

  * include/hbapi.h
  * src/vm/set.c
    + added two C functions for OS codepage translations:
         char * hb_osStrEncode2( const char * pszName,
                                 char * pszBuffer, HB_SIZE nSize );
         HB_WCHAR * hb_osStrU16Encode2( const char * pszName,
                                        HB_WCHAR * pszBufferW, HB_SIZE nSize );

  * include/hbwinuni.h
    + added HB_CHARDUP2() macro for UNICODE/ANSI OS codepage translation

  * src/common/hbgete.c
    ! fixed memory allocation in MS-Windows version of hb_getenv_buffer()

  * src/pp/hbpp.c
    ! added integer range to HB_VER_REVID definition to pacify warning

  * src/rtl/cdpapi.c
    * minor simplification
This commit is contained in:
Przemysław Czerpak
2023-01-15 11:17:33 +01:00
parent 889ef46369
commit 2975eadbba
11 changed files with 123 additions and 18 deletions

View File

@@ -7,6 +7,42 @@
Entries may not always be in chronological/commit order.
See license at the end of file. */
2023-01-15 11:17 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* contrib/hbwin/win_prn1.c
! fixed parameter type in font enum callback
* include/harbour.hbx
* src/harbour.def
* src/rtl/hbgtcore.c
+ added two new PRG functions:
hb_gtExists( <cGtName> ) -> <lExists>
hb_gtList() -> <aGtNames>
* src/rtl/hbgtcore.c
* changed the order of defualt GT initialization. Now GT specified by -gt*
hbmk2 option has higher priority then GT chosen by
request HB_GT_<name>_DEFAULT
* include/hbapi.h
* src/vm/set.c
+ added two C functions for OS codepage translations:
char * hb_osStrEncode2( const char * pszName,
char * pszBuffer, HB_SIZE nSize );
HB_WCHAR * hb_osStrU16Encode2( const char * pszName,
HB_WCHAR * pszBufferW, HB_SIZE nSize );
* include/hbwinuni.h
+ added HB_CHARDUP2() macro for UNICODE/ANSI OS codepage translation
* src/common/hbgete.c
! fixed memory allocation in MS-Windows version of hb_getenv_buffer()
* src/pp/hbpp.c
! added integer range to HB_VER_REVID definition to pacify warning
* src/rtl/cdpapi.c
* minor simplification
2022-11-25 18:14 UTC+0100 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* include/hbapi.h
* src/vm/cmdarg.c

View File

@@ -522,7 +522,7 @@ HB_FUNC( WIN_GETDOCUMENTPROPERTIES )
}
static int CALLBACK FontEnumCallBack( LOGFONT * lplf, TEXTMETRIC * lpntm,
DWORD dwFontType, LPVOID pArray )
DWORD dwFontType, LPARAM pArray )
{
PHB_ITEM pSubItems = hb_itemArrayNew( 4 );

View File

@@ -479,7 +479,9 @@ DYNAMIC hb_gfxPrimitive
DYNAMIC hb_gfxText
DYNAMIC hb_gtAlert
DYNAMIC hb_gtCreate
DYNAMIC hb_gtExists
DYNAMIC hb_gtInfo
DYNAMIC hb_gtList
DYNAMIC hb_gtLock
DYNAMIC hb_gtReload
DYNAMIC hb_gtSelect

View File

@@ -1226,11 +1226,13 @@ extern HB_EXPORT const char * hb_osDecodeCP( const char * szName, char ** pszFre
extern HB_EXPORT char * hb_osStrEncode( const char * pszName );
extern HB_EXPORT char * hb_osStrEncodeN( const char * pszName, HB_SIZE nLen );
extern HB_EXPORT char * hb_osStrEncode2( const char * pszName, char * pszBuffer, HB_SIZE nSize );
extern HB_EXPORT char * hb_osStrDecode( const char * pszName );
extern HB_EXPORT char * hb_osStrDecode2( const char * pszName, char * pszBuffer, HB_SIZE nSize );
#if defined( HB_OS_WIN )
extern HB_EXPORT HB_WCHAR * hb_osStrU16Encode( const char * pszName );
extern HB_EXPORT HB_WCHAR * hb_osStrU16EncodeN( const char * pszName, HB_SIZE nLen );
extern HB_EXPORT HB_WCHAR * hb_osStrU16Encode2( const char * pszName, HB_WCHAR * pszBufferW, HB_SIZE nSize );
extern HB_EXPORT char * hb_osStrU16Decode( const HB_WCHAR * pszNameW );
extern HB_EXPORT char * hb_osStrU16Decode2( const HB_WCHAR * pszNameW, char * pszBuffer, HB_SIZE nSize );
#endif

View File

@@ -81,6 +81,7 @@
#define HB_FSNAMECONV( fname, pfree ) ( ( LPCTSTR ) ( *( pfree ) = hb_fsNameConvU16( fname ) ) )
#define HB_CHARDUP( str ) hb_osStrU16Encode( str )
#define HB_CHARDUPN( str, len ) hb_osStrU16EncodeN( str, len )
#define HB_CHARDUP2( str, buf, len ) hb_osStrU16Encode2( str, buf, len )
#define HB_OSSTRDUP( str ) hb_osStrU16Decode( str )
#define HB_OSSTRDUP2( str, buf, len ) hb_osStrU16Decode2( str, buf, len )
#define HB_WINAPI_SYSTEM( cmd ) _wsystem( cmd )
@@ -120,6 +121,7 @@
#define HB_FSNAMECONV( fname, pfree ) hb_fsNameConv( fname, pfree )
#define HB_CHARDUP( str ) hb_osStrEncode( str )
#define HB_CHARDUPN( str, len ) hb_osStrEncodeN( str, len )
#define HB_CHARDUP2( str, buf, len ) hb_osStrEncode2( str, buf, len )
#define HB_OSSTRDUP( str ) hb_osStrDecode( str )
#define HB_OSSTRDUP2( str, buf, len ) hb_osStrDecode2( str, buf, len )
#define HB_WINAPI_SYSTEM( cmd ) system( cmd )

View File

@@ -121,15 +121,22 @@ HB_BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize )
#if defined( HB_OS_WIN )
{
LPTSTR lpName = HB_CHARDUP( szName ), lpBuffer;
TCHAR lpNameBuffer[ 64 ], lpDestBuffer[ HB_PATH_MAX ];
LPTSTR lpName = lpNameBuffer, lpBuffer = lpDestBuffer;
if( szBuffer != NULL || nSize > 0 )
lpBuffer = ( LPTSTR ) hb_xgrab( nSize * sizeof( TCHAR ) );
else
if( szBuffer == NULL || nSize == 0 )
lpBuffer = NULL;
else if( ( HB_SIZE ) nSize > HB_SIZEOFARRAY( lpDestBuffer ) )
lpBuffer = ( LPTSTR ) hb_xgrab( nSize * sizeof( TCHAR ) );
if( strlen( szName ) >= HB_SIZEOFARRAY( lpNameBuffer ) )
lpName = HB_CHARDUP( szName );
fRetVal = GetEnvironmentVariable( lpName, lpBuffer, nSize ) != 0;
if( lpName != lpNameBuffer )
hb_xfree( lpName );
if( lpBuffer )
{
if( fRetVal )
@@ -137,9 +144,9 @@ HB_BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize )
lpBuffer[ nSize - 1 ] = TEXT( '\0' );
HB_OSSTRDUP2( lpBuffer, szBuffer, nSize - 1 );
}
hb_xfree( lpBuffer );
if( lpBuffer != lpDestBuffer )
hb_xfree( lpBuffer );
}
hb_xfree( lpName );
}
#elif defined( HB_OS_OS2 )
{

View File

@@ -566,7 +566,9 @@ HB_FUN_HB_GFXPRIMITIVE
HB_FUN_HB_GFXTEXT
HB_FUN_HB_GTALERT
HB_FUN_HB_GTCREATE
HB_FUN_HB_GTEXISTS
HB_FUN_HB_GTINFO
HB_FUN_HB_GTLIST
HB_FUN_HB_GTLOCK
HB_FUN_HB_GTRELOAD
HB_FUN_HB_GTSELECT

View File

@@ -350,7 +350,7 @@ static int hb_pp_generateVerInfo( char * szVerFile,
" * and is covered by the same license as Harbour PP\n"
" */\n\n" );
fprintf( fout, "#define HB_VER_REVID %" PFHL "u\n", nRevID );
fprintf( fout, "#define HB_VER_REVID %" PFHL "u" PFHL "u\n", nRevID );
if( szChangeLogID )
{

View File

@@ -1999,8 +1999,6 @@ HB_SIZE hb_cdpU16ToStr( PHB_CODEPAGE cdp, int iEndian,
HB_SIZE hb_cdpTransLen( const char * pSrc, HB_SIZE nSrc, HB_SIZE nMax,
PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut )
{
HB_SIZE nSize;
if( cdpIn && cdpOut && cdpIn != cdpOut &&
( cdpIn->uniTable != cdpOut->uniTable ||
HB_CDP_ISCUSTOM( cdpIn ) || HB_CDP_ISCUSTOM( cdpOut ) ) )
@@ -2011,7 +2009,7 @@ HB_SIZE hb_cdpTransLen( const char * pSrc, HB_SIZE nSrc, HB_SIZE nMax,
return hb_cdpStrAsUTF8Len( cdpIn, pSrc, nSrc, nMax );
else if( HB_CDP_ISCUSTOM( cdpIn ) || HB_CDP_ISCUSTOM( cdpOut ) )
{
HB_SIZE nPosS;
HB_SIZE nPosS, nSize;
HB_WCHAR wc;
nPosS = nSize = 0;
@@ -2022,14 +2020,11 @@ HB_SIZE hb_cdpTransLen( const char * pSrc, HB_SIZE nSrc, HB_SIZE nMax,
break;
nSize += i;
}
return nSize;
}
else
nSize = ( nMax && nSrc > nMax ) ? nMax : nSrc;
}
else
nSize = ( nMax && nSrc > nMax ) ? nMax : nSrc;
return nSize;
return ( nMax && nSrc > nMax ) ? nMax : nSrc;
}
HB_SIZE hb_cdpTransTo( const char * pSrc, HB_SIZE nSrc,

View File

@@ -3935,7 +3935,8 @@ static HB_BOOL hb_gtTryInit( const char * szGtName, HB_BOOL fFree )
* pszStr = '\0';
}
hb_stackSetGT( hb_gtLoad( szGtName, NULL, NULL ) );
if( * szGtName )
hb_stackSetGT( hb_gtLoad( szGtName, NULL, NULL ) );
}
if( fFree )
@@ -3951,9 +3952,13 @@ void hb_gtStartupInit( void )
return;
if( hb_gtTryInit( hb_getenv( "HB_GT" ), HB_TRUE ) )
return;
if( s_szNameDefault == s_gtNameBuf &&
hb_gtTryInit( s_szNameDefault, HB_FALSE ) )
return;
if( hb_gtTryInit( hb_gt_FindDefault(), HB_FALSE ) )
return;
if( hb_gtTryInit( s_szNameDefault, HB_FALSE ) )
if( s_szNameDefault != s_gtNameBuf &&
hb_gtTryInit( s_szNameDefault, HB_FALSE ) )
return;
if( hb_dynsymFind( "HB_GT_NUL" ) ) /* GTNUL was explicitly REQUESTed */
@@ -4068,3 +4073,20 @@ HB_FUNC( HB_GTSELECT )
hb_retptrGC( gtHolder );
}
}
HB_FUNC( HB_GTEXISTS )
{
const char * pszGtName = hb_parc( 1 );
hb_retl( pszGtName && hb_gt_FindEntry( pszGtName ) >= -1 );
}
HB_FUNC( HB_GTLIST )
{
int iPos;
hb_reta( s_iGtCount + 1 );
hb_storvc( "NUL", -1, 1 );
for( iPos = 0; iPos < s_iGtCount; ++iPos )
hb_storvc( s_gtInit[ iPos ]->id, -1, iPos + 2 );
}

View File

@@ -2867,6 +2867,27 @@ char * hb_osStrEncodeN( const char * pszName, HB_SIZE nLen )
return hb_strndup( pszName, nLen );
}
char * hb_osStrEncode2( const char * pszName, char * pszBuffer, HB_SIZE nSize )
{
if( hb_vmIsReady() )
{
HB_STACK_TLS_PRELOAD
PHB_CODEPAGE cdpOS = ( PHB_CODEPAGE ) hb_stackSetStruct()->hb_set_oscp;
if( cdpOS )
{
PHB_CODEPAGE cdpHost = hb_vmCDP();
if( cdpHost && cdpHost != cdpOS )
{
pszBuffer[ nSize ] = 0;
hb_cdpnDup2( pszName, strlen( pszName ), pszBuffer, &nSize, cdpHost, cdpOS );
return pszBuffer;
}
}
}
return hb_strncpy( pszBuffer, pszName, nSize );
}
char * hb_osStrDecode( const char * pszName )
{
if( hb_vmIsReady() )
@@ -2948,6 +2969,22 @@ HB_WCHAR * hb_osStrU16EncodeN( const char * pszName, HB_SIZE nLen )
return hb_mbntowc( pszName, nLen ); /* No HVM stack */
}
HB_WCHAR * hb_osStrU16Encode2( const char * pszName, HB_WCHAR * pszBufferW, HB_SIZE nSize )
{
if( hb_vmIsReady() )
{
PHB_CODEPAGE cdp = hb_vmCDP();
if( cdp )
{
hb_cdpStrToU16( cdp, HB_CDP_ENDIAN_NATIVE, pszName, strlen( pszName ), pszBufferW, nSize + 1 );
pszBufferW[ nSize ] = 0;
return pszBufferW;
}
}
hb_mbntowccpy( pszBufferW, pszName, nSize ); /* No HVM stack */
return pszBufferW;
}
char * hb_osStrU16Decode( const HB_WCHAR * pszNameW )
{
if( hb_vmIsReady() )