2012-04-03 18:43 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
* harbour/include/hbapicdp.h
* harbour/src/rtl/cdpapi.c
+ added new C functions:
hb_cdpDupn(), hb_cdpStrDupU16(), hb_cdpnStrDupU16()
* harbour/include/hbwinuni.h
+ added new macros: HB_CHARDUP() and HB_CHARDUPN()
Warning: this macros uses HVM functions so cannot be used in
code which is executed without active HVM i.e. in
pure harbour compiler code (common library)
* harbour/src/rtl/filesys.c
* use hb_cdpStrDupU16()
* harbour/src/rtl/hbproces.c
! fixed double OS codepage conversion in hb_fsProcessRun()
* use HB_CHARDUP*() macros to respect _SET_CODEPAGE and _SET_OSCODEPAGE
in Windows builds
This commit is contained in:
@@ -16,6 +16,26 @@
|
||||
The license applies to all entries newer than 2009-04-28.
|
||||
*/
|
||||
|
||||
2012-04-03 18:43 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)
|
||||
* harbour/include/hbapicdp.h
|
||||
* harbour/src/rtl/cdpapi.c
|
||||
+ added new C functions:
|
||||
hb_cdpDupn(), hb_cdpStrDupU16(), hb_cdpnStrDupU16()
|
||||
|
||||
* harbour/include/hbwinuni.h
|
||||
+ added new macros: HB_CHARDUP() and HB_CHARDUPN()
|
||||
Warning: this macros uses HVM functions so cannot be used in
|
||||
code which is executed without active HVM i.e. in
|
||||
pure harbour compiler code (common library)
|
||||
|
||||
* harbour/src/rtl/filesys.c
|
||||
* use hb_cdpStrDupU16()
|
||||
|
||||
* harbour/src/rtl/hbproces.c
|
||||
! fixed double OS codepage conversion in hb_fsProcessRun()
|
||||
* use HB_CHARDUP*() macros to respect _SET_CODEPAGE and _SET_OSCODEPAGE
|
||||
in Windows builds
|
||||
|
||||
2012-04-03 12:08 UTC+0200 Viktor Szakats (harbour syenar.net)
|
||||
* contrib/rddads/rddads.hbx
|
||||
* contrib/rddads/adsfunc.c
|
||||
|
||||
@@ -404,6 +404,7 @@ extern HB_EXPORT int hb_cdpicmp( const char * szFirst, HB_SIZE nLenFirs
|
||||
extern HB_EXPORT const HB_UCHAR * hb_cdpGetSortTab( PHB_CODEPAGE cdp );
|
||||
|
||||
extern HB_EXPORT char * hb_cdpDup( const char *, PHB_CODEPAGE, PHB_CODEPAGE );
|
||||
extern HB_EXPORT char * hb_cdpDupn( const char *, HB_SIZE, PHB_CODEPAGE, PHB_CODEPAGE );
|
||||
extern HB_EXPORT char * hb_cdpnDup( const char *, HB_SIZE *, PHB_CODEPAGE, PHB_CODEPAGE );
|
||||
extern HB_EXPORT const char * hb_cdpnDup2( const char *, HB_SIZE, char *, HB_SIZE *, PHB_CODEPAGE, PHB_CODEPAGE );
|
||||
extern HB_EXPORT const char * hb_cdpnDup3( const char *, HB_SIZE, char *, HB_SIZE *, char **, HB_SIZE *, PHB_CODEPAGE, PHB_CODEPAGE );
|
||||
@@ -440,6 +441,9 @@ extern HB_EXPORT HB_SIZE hb_cdpU16AsStrLen( PHB_CODEPAGE cdp, const HB_WCHA
|
||||
extern HB_EXPORT HB_SIZE hb_cdpU16ToStr( PHB_CODEPAGE cdp, int iEndian, const HB_WCHAR * pSrc, HB_SIZE nSrc, char * pDst, HB_SIZE nDst );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpStrAsU16Len( PHB_CODEPAGE cdp, const char * pSrc, HB_SIZE nSrc, HB_SIZE nMax );
|
||||
extern HB_EXPORT HB_SIZE hb_cdpStrToU16( PHB_CODEPAGE cdp, int iEndian, const char * pSrc, HB_SIZE nSrc, HB_WCHAR * pDst, HB_SIZE nDst );
|
||||
extern HB_EXPORT HB_WCHAR * hb_cdpStrDupU16( PHB_CODEPAGE cdp, int iEndian, const char * pSrc );
|
||||
extern HB_EXPORT HB_WCHAR * hb_cdpStrDupnU16( PHB_CODEPAGE cdp, int iEndian, const char * pSrc, HB_SIZE nSrc );
|
||||
extern HB_EXPORT HB_WCHAR * hb_cdpnStrDupU16( PHB_CODEPAGE cdp, int iEndian, const char * pSrc, HB_SIZE nSrc, HB_SIZE * pnDst );
|
||||
|
||||
extern HB_EXPORT int hb_cdpUTF8CharSize( HB_WCHAR wc );
|
||||
extern HB_EXPORT int hb_cdpU16CharToUTF8( char * szUTF8, HB_WCHAR wc );
|
||||
|
||||
@@ -85,6 +85,8 @@
|
||||
#define HB_STRCMP( s1, s2 ) hb_wstrcmp( s1, s2 )
|
||||
#define HB_STRNCMP( s1, s2, len ) hb_wstrncmp( s1, s2, len )
|
||||
#define HB_FSNAMECONV( fname, pfree ) ( ( LPCTSTR ) ( *(pfree) = hb_fsNameConvU16( fname ) ) )
|
||||
#define HB_CHARDUP( str ) hb_cdpStrDupU16( hb_vmVDP(), HB_CDP_ENDIAN_NATIVE, str )
|
||||
#define HB_CHARDUPN( str, len ) hb_cdpStrDupnU16( hb_vmVDP(), HB_CDP_ENDIAN_NATIVE, str, len, NULL )
|
||||
#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 ) )
|
||||
@@ -111,6 +113,8 @@
|
||||
#define HB_STRCMP( s1, s2 ) strcmp( s1, s2 )
|
||||
#define HB_STRNCMP( s1, s2, len ) strncmp( s1, s2, len )
|
||||
#define HB_FSNAMECONV( fname, pfree ) hb_fsNameConv( fname, pfree )
|
||||
#define HB_CHARDUP( str ) hb_cdpDup( str, hb_vmVDP(), hb_setGetOSCP() )
|
||||
#define HB_CHARDUPN( str, len ) hb_cdpDupn( str, len, hb_vmVDP(), hb_setGetOSCP() )
|
||||
#endif
|
||||
|
||||
#endif /* HB_OS_WIN */
|
||||
|
||||
@@ -1609,6 +1609,28 @@ HB_SIZE hb_cdpStrToU16( PHB_CODEPAGE cdp, int iEndian,
|
||||
return ulD;
|
||||
}
|
||||
|
||||
HB_WCHAR * hb_cdpnStrDupU16( PHB_CODEPAGE cdp, int iEndian,
|
||||
const char * pSrc, HB_SIZE nSrc,
|
||||
HB_SIZE * pnDst )
|
||||
{
|
||||
HB_SIZE nLen = hb_cdpStrAsU16Len( cdp, pSrc, nSrc, 0 );
|
||||
HB_WCHAR * pDst = ( HB_WCHAR * ) hb_xgrab( ( nLen + 1 ) * sizeof( HB_WCHAR ) );
|
||||
hb_cdpStrToU16( cdp, iEndian, pSrc, nSrc, pDst, nLen + 1 );
|
||||
if( pnDst )
|
||||
* pnDst = nLen;
|
||||
return pDst;
|
||||
}
|
||||
|
||||
HB_WCHAR * hb_cdpStrDupU16( PHB_CODEPAGE cdp, int iEndian, const char * pSrc )
|
||||
{
|
||||
return hb_cdpnStrDupU16( cdp, iEndian, pSrc, strlen( pSrc ), NULL );
|
||||
}
|
||||
|
||||
HB_WCHAR * hb_cdpStrDupnU16( PHB_CODEPAGE cdp, int iEndian, const char * pSrc, HB_SIZE nLen )
|
||||
{
|
||||
return hb_cdpnStrDupU16( cdp, iEndian, pSrc, hb_strnlen( pSrc, nLen ), NULL );
|
||||
}
|
||||
|
||||
HB_SIZE hb_cdpU16AsStrLen( PHB_CODEPAGE cdp,
|
||||
const HB_WCHAR * pSrc, HB_SIZE nSrc,
|
||||
HB_SIZE nMax )
|
||||
@@ -2007,6 +2029,12 @@ char * hb_cdpDup( const char * pszSrc, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut )
|
||||
return hb_cdpnDup( pszSrc, &nLen, cdpIn, cdpOut );
|
||||
}
|
||||
|
||||
char * hb_cdpDupn( const char * pszSrc, HB_SIZE nLen, PHB_CODEPAGE cdpIn, PHB_CODEPAGE cdpOut )
|
||||
{
|
||||
nLen = hb_strnlen( pszSrc, nLen );
|
||||
return hb_cdpnDup( pszSrc, &nLen, cdpIn, cdpOut );
|
||||
}
|
||||
|
||||
char * hb_cdpnDupUpper( PHB_CODEPAGE cdp, const char * pszText, HB_SIZE * pnSize )
|
||||
{
|
||||
HB_SIZE nSize = pnSize ? *pnSize : strlen( pszText ), n;
|
||||
|
||||
@@ -3887,7 +3887,7 @@ HB_WCHAR * hb_fsNameConvU16( const char * szFileName )
|
||||
*/
|
||||
|
||||
if( !hb_stackId() )
|
||||
return hb_mbtowc( szFileName );
|
||||
return hb_mbtowc( szFileName ); /* No HVM stack */
|
||||
|
||||
cdp = hb_vmCDP();
|
||||
fTrim = hb_setGetTrimFileName();
|
||||
@@ -3983,10 +3983,7 @@ HB_WCHAR * hb_fsNameConvU16( const char * szFileName )
|
||||
hb_xfree( pszExt );
|
||||
}
|
||||
|
||||
nLen = hb_cdpStrAsU16Len( cdp, szFileName, strlen( szFileName ), 0 );
|
||||
lpwFileName = ( HB_WCHAR * ) hb_xgrab( ( nLen + 1 ) * sizeof( HB_WCHAR ) );
|
||||
hb_cdpStrToU16( cdp, HB_CDP_ENDIAN_NATIVE, szFileName, strlen( szFileName ),
|
||||
lpwFileName, nLen + 1 );
|
||||
lpwFileName = hb_cdpStrDupU16( cdp, HB_CDP_ENDIAN_NATIVE, szFileName );
|
||||
if( pszBuffer )
|
||||
hb_xfree( pszBuffer );
|
||||
|
||||
|
||||
@@ -100,12 +100,16 @@
|
||||
static char ** hb_buildArgs( const char *pszFilename )
|
||||
{
|
||||
const char * src;
|
||||
char ** argv, * dst, cQuote = 0;
|
||||
char ** argv, * dst, cQuote = 0, * pszFree = NULL;
|
||||
int argc = 0;
|
||||
|
||||
while( HB_ISSPACE( *pszFilename ) )
|
||||
++pszFilename;
|
||||
src = pszFilename;
|
||||
|
||||
pszFilename = hb_osEncodeCP( pszFilename, &pszFree, NULL );
|
||||
dst = pszFree ? pszFree : hb_strdup( pszFilename );
|
||||
|
||||
src = dst;
|
||||
while( *src )
|
||||
{
|
||||
#if defined( HB_OS_UNIX )
|
||||
@@ -136,14 +140,14 @@ static char ** hb_buildArgs( const char *pszFilename )
|
||||
}
|
||||
++src;
|
||||
}
|
||||
dst = ( char * ) hb_xgrab( strlen( pszFilename ) + 1 );
|
||||
|
||||
argv = ( char ** ) hb_xgrab( ( argc + 2 ) * sizeof( char * ) );
|
||||
argv[ 0 ] = dst;
|
||||
argv[ argc + 1 ] = NULL;
|
||||
argc = 0;
|
||||
|
||||
cQuote = 0;
|
||||
src = pszFilename;
|
||||
src = dst;
|
||||
while( *src )
|
||||
{
|
||||
#if defined( HB_OS_UNIX )
|
||||
@@ -193,9 +197,8 @@ static void hb_freeArgs( char ** argv )
|
||||
hb_xfree( argv );
|
||||
}
|
||||
|
||||
#endif
|
||||
#elif defined( HB_OS_WIN_CE )
|
||||
|
||||
#if defined( HB_OS_WIN_CE )
|
||||
static void hb_getCommand( const char *pszFilename,
|
||||
LPTSTR * lpAppName, LPTSTR * lpParams )
|
||||
{
|
||||
@@ -228,13 +231,8 @@ static void hb_getCommand( const char *pszFilename,
|
||||
++src;
|
||||
}
|
||||
|
||||
#if defined( UNICODE )
|
||||
*lpParams = params ? hb_mbtowc( params ) : NULL;
|
||||
*lpAppName = hb_mbntowc( pszFilename, ( HB_SIZE ) ( src - pszFilename ) );
|
||||
#else
|
||||
*lpParams = params ? hb_strdup( params ) : NULL;
|
||||
*lpAppName = hb_strndup( pszFilename, ( HB_SIZE ) ( src - pszFilename ) );
|
||||
#endif
|
||||
*lpParams = params ? HB_CHARDUP( params ) : NULL;
|
||||
*lpAppName = HB_CHARDUPN( pszFilename, src - pszFilename );
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -403,13 +401,9 @@ HB_FHANDLE hb_fsProcessOpen( const char * pszFilename,
|
||||
hPipeErr[ 2 ] = { FS_ERROR, FS_ERROR };
|
||||
HB_FHANDLE hResult = FS_ERROR;
|
||||
HB_BOOL fError = HB_FALSE;
|
||||
char * pszFree = NULL;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsProcessOpen(%s, %p, %p, %p, %d, %p)", pszFilename, phStdin, phStdout, phStderr, fDetach, pulPID));
|
||||
|
||||
pszFilename = hb_osEncodeCP( pszFilename, &pszFree, NULL );
|
||||
|
||||
|
||||
if( phStdin != NULL )
|
||||
fError = !hb_fsPipeCreate( hPipeIn );
|
||||
if( !fError && phStdout != NULL )
|
||||
@@ -432,11 +426,7 @@ HB_FHANDLE hb_fsProcessOpen( const char * pszFilename,
|
||||
PROCESS_INFORMATION pi;
|
||||
STARTUPINFO si;
|
||||
DWORD dwFlags = 0;
|
||||
# if defined( UNICODE )
|
||||
LPWSTR lpCommand = hb_mbtowc( pszFilename );
|
||||
# else
|
||||
char * lpCommand = hb_strdup( pszFilename );
|
||||
# endif
|
||||
LPWSTR lpCommand = HB_CHARDUP( pszFilename );
|
||||
|
||||
memset( &pi, 0, sizeof( pi ) );
|
||||
memset( &si, 0, sizeof( si ) );
|
||||
@@ -576,25 +566,15 @@ HB_FHANDLE hb_fsProcessOpen( const char * pszFilename,
|
||||
|
||||
/* execute command */
|
||||
{
|
||||
# if 0
|
||||
char * argv[4];
|
||||
|
||||
argv[0] = ( char * ) "sh";
|
||||
argv[1] = ( char * ) "-c";
|
||||
argv[2] = ( char * ) pszFilename;
|
||||
argv[3] = ( char * ) 0;
|
||||
execv( "/bin/sh", argv );
|
||||
# else
|
||||
char ** argv;
|
||||
|
||||
argv = hb_buildArgs( pszFilename );
|
||||
# if defined( __WATCOMC__ )
|
||||
# if defined( __WATCOMC__ )
|
||||
execvp( argv[ 0 ], ( const char ** ) argv );
|
||||
# else
|
||||
# else
|
||||
execvp( argv[ 0 ], argv );
|
||||
# endif
|
||||
hb_freeArgs( argv );
|
||||
# endif
|
||||
hb_freeArgs( argv );
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -705,9 +685,6 @@ HB_FHANDLE hb_fsProcessOpen( const char * pszFilename,
|
||||
hb_fsClose( hPipeErr[ 1 ] );
|
||||
}
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
|
||||
return hResult;
|
||||
}
|
||||
|
||||
@@ -894,13 +871,10 @@ int hb_fsProcessRun( const char * pszFilename,
|
||||
HB_FHANDLE hStdin, hStdout, hStderr, *phStdin, *phStdout, *phStderr;
|
||||
char * pOutBuf, *pErrBuf;
|
||||
HB_SIZE nOutSize, nErrSize, nOutBuf, nErrBuf;
|
||||
char * pszFree = NULL;
|
||||
int iResult;
|
||||
|
||||
HB_TRACE(HB_TR_DEBUG, ("hb_fsProcessRun(%s, %p, %" HB_PFS "u, %p, %p, %p, %p, %d)", pStdInBuf, pStdInBuf, nStdInLen, pStdOutPtr, pulStdOut, pStdErrPtr, pulStdErr, fDetach));
|
||||
|
||||
pszFilename = hb_osEncodeCP( pszFilename, &pszFree, NULL );
|
||||
|
||||
nOutBuf = nErrBuf = nOutSize = nErrSize = 0;
|
||||
pOutBuf = pErrBuf = NULL;
|
||||
hStdin = hStdout = hStderr = FS_ERROR;
|
||||
@@ -1240,9 +1214,6 @@ int hb_fsProcessRun( const char * pszFilename,
|
||||
*pulStdErr = nErrBuf;
|
||||
}
|
||||
|
||||
if( pszFree )
|
||||
hb_xfree( pszFree );
|
||||
|
||||
return iResult;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user