2009-12-12 13:52 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbwinuni.h
    + added new macro HB_ITEMGETSTR()

  * harbour/src/rtl/gtwin/gtwin.c
    * modified to use new UNICODE API instead of HB_TCHAR_*()

  * harbour/contrib/hbwin/win_misc.c
    * rewritten WIN_GETCOMMANDLINEPARAM()
      New version does not use old HB_TCHAR_*() API and respect multiple
      quoting by "" (i.e. .\"myapp"li"cation".exe)

      TOFIX: WIN_ANSITOWIDE() and WIN_WIDETOANSI() are wrong and have
             to be fixed. Please remember that number of character
             after conversion to/from UNICODE can be different then
             original number of chars, i.e. multibyte characters
             can be replaced by single Unicode character or one Unicode
             character may use few bytes representation.
This commit is contained in:
Przemyslaw Czerpak
2009-12-12 12:52:56 +00:00
parent a7379d23f3
commit 1afd3ffcb6
4 changed files with 38 additions and 41 deletions

View File

@@ -17,6 +17,25 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-12-12 13:52 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbwinuni.h
+ added new macro HB_ITEMGETSTR()
* harbour/src/rtl/gtwin/gtwin.c
* modified to use new UNICODE API instead of HB_TCHAR_*()
* harbour/contrib/hbwin/win_misc.c
* rewritten WIN_GETCOMMANDLINEPARAM()
New version does not use old HB_TCHAR_*() API and respect multiple
quoting by "" (i.e. .\"myapp"li"cation".exe)
TOFIX: WIN_ANSITOWIDE() and WIN_WIDETOANSI() are wrong and have
to be fixed. Please remember that number of character
after conversion to/from UNICODE can be different then
original number of chars, i.e. multibyte characters
can be replaced by single Unicode character or one Unicode
character may use few bytes representation.
2009-12-12 12:48 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbqt/hbqt_hbqmainwindow.cpp
* Temporarily disabled mutex for HBMainWindow.

View File

@@ -165,45 +165,22 @@ HB_FUNC( WIN_LOADRESOURCE )
HB_FUNC( WIN_GETCOMMANDLINEPARAM )
{
char * buffer = HB_TCHAR_CONVFROM( GetCommandLine() );
LPCTSTR lpCmdLine = GetCommandLine();
HB_BOOL fQuote = HB_FALSE;
long pos;
/* Skip application path */
pos = 0;
if( buffer[ pos ] == '"' )
while( lpCmdLine[ pos ] && ( fQuote || !HB_ISSPACE( lpCmdLine[ pos ] ) ) )
{
/* If it contains spaces, it will be enclosed in quote chars,
skip this to get to the command line. */
if( lpCmdLine[ pos ] == '"' )
fQuote = !fQuote;
pos++;
while( buffer[ pos ] && buffer[ pos ] != '"' )
pos++;
if( buffer[ pos ] == '"' )
pos++;
}
else
{
/* If not, look for the next space for the beginning of the
command line. */
while( buffer[ pos ] && buffer[ pos ] != ' ' )
pos++;
}
if( buffer[ pos ] == ' ' )
while( HB_ISSPACE( lpCmdLine[ pos ] ) )
pos++;
{
/* Convert from OS codepage */
char * pszFree = NULL;
const char * pszResult = hb_osDecodeCP( buffer + pos, &pszFree, NULL );
if( pszFree )
hb_retc_buffer( pszFree );
else
hb_retc( pszResult );
}
HB_TCHAR_FREE( buffer );
HB_RETSTR( lpCmdLine + pos );
}
HB_FUNC( WIN_ANSITOWIDE )

View File

@@ -68,8 +68,9 @@
#define HB_STORSTRLEN( str, len, n ) hb_storstrlen_u16( HB_CDP_ENDIAN_NATIVE, str, len, n )
#define HB_ARRAYSETSTR( arr, n, str ) hb_arraySetStrU16( arr, n, HB_CDP_ENDIAN_NATIVE, str )
#define HB_ARRAYSETSTRLEN( arr, n, str, len ) hb_arraySetStrLenU16( arr, n, HB_CDP_ENDIAN_NATIVE, str, len )
#define HB_ITEMPUTSTR( p, str ) hb_itemPutStrU16( p, HB_CDP_ENDIAN_NATIVE, str )
#define HB_ITEMPUTSTRLEN( p, str, len ) hb_itemPutStrLenU16( p, HB_CDP_ENDIAN_NATIVE, str, len )
#define HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStrU16( itm, HB_CDP_ENDIAN_NATIVE, phstr, plen )
#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 )
#else
#define HB_PARSTR( n, h, len ) hb_parstr( n, hb_setGetOSCP(), h, len )
@@ -80,8 +81,9 @@
#define HB_STORSTRLEN( str, len, n ) hb_storstrlen( hb_setGetOSCP(), str, len, n )
#define HB_ARRAYSETSTR( arr, n, str ) hb_arraySetStr( arr, n, hb_setGetOSCP(), str )
#define HB_ARRAYSETSTRLEN( arr, n, str, len ) hb_arraySetStrLen( arr, n, hb_setGetOSCP(), str, len )
#define HB_ITEMPUTSTR( p, str ) hb_itemPutStr( p, hb_setGetOSCP(), str )
#define HB_ITEMPUTSTRLEN( p, str, len ) hb_itemPutStrLen( p, hb_setGetOSCP(), str, len )
#define HB_ITEMGETSTR( itm, phstr, plen ) hb_itemGetStr( itm, hb_setGetOSCP(), phstr, plen )
#define HB_ITEMPUTSTR( p, str ) hb_itemPutStr( itm, hb_setGetOSCP(), str )
#define HB_ITEMPUTSTRLEN( p, str, len ) hb_itemPutStrLen( itm, hb_setGetOSCP(), str, len )
#define HB_STRUNSHARE( h, str, len ) hb_strunshare( h, str, len )
#endif

View File

@@ -83,6 +83,7 @@
#include "hbinit.h"
#include "hbapiitm.h"
#include "hbapierr.h"
#include "hbwinuni.h"
#include "hbapicdp.h"
@@ -1611,18 +1612,16 @@ static BOOL hb_gt_win_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo )
case HB_GTI_WINTITLE:
{
TCHAR buff[ 256 ];
char * szTitle;
DWORD dwLen;
dwLen = GetConsoleTitle( buff, sizeof( buff ) / sizeof( TCHAR ) );
szTitle = ( char * ) hb_xgrab( dwLen + 1 );
HB_TCHAR_GETFROM( szTitle, buff, dwLen );
pInfo->pResult = hb_itemPutCLPtr( pInfo->pResult, szTitle, dwLen );
pInfo->pResult = HB_ITEMPUTSTRLEN( pInfo->pResult, buff, dwLen );
if( hb_itemType( pInfo->pNewVal ) & HB_IT_STRING )
{
LPTSTR lpTitle = HB_TCHAR_CONVTO( hb_itemGetCPtr( pInfo->pNewVal ) );
SetConsoleTitle( lpTitle );
HB_TCHAR_FREE( lpTitle );
void * hTitle;
SetConsoleTitle( HB_ITEMGETSTR( pInfo->pNewVal, &hTitle, NULL ) );
hb_strfree( hTitle );
}
break;
}