2008-02-19 23:37 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/source/main/harbour.c
  * harbour/source/common/hbfsapi.c
    ! fixed hb_fsFNameSplit()/hb_fsFNameMerge() to respect path delimiter
     set by user

  * harbour/contrib/hbct/ctwfunc.c
    ! fixed WFORMAT() called without parameters - it should reset
      all existing margins
    ! fixed WSETSHADOW() to accept color also as character parameter
This commit is contained in:
Przemyslaw Czerpak
2008-02-19 22:37:53 +00:00
parent 3fce40bbeb
commit 719339e947
4 changed files with 72 additions and 30 deletions

View File

@@ -8,6 +8,17 @@
2002-12-01 13:30 UTC+0100 Foo Bar <foo.bar@foobar.org>
*/
2008-02-19 23:37 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/main/harbour.c
* harbour/source/common/hbfsapi.c
! fixed hb_fsFNameSplit()/hb_fsFNameMerge() to respect path delimiter
set by user
* harbour/contrib/hbct/ctwfunc.c
! fixed WFORMAT() called without parameters - it should reset
all existing margins
! fixed WSETSHADOW() to accept color also as character parameter
2008-02-18 12:12 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/rdd/dbfntx/dbfntx1.c
! fixed very bad typo in my last commit - thanks to Jorge and Enrico

View File

@@ -54,6 +54,21 @@
#include "hbapigt.h"
#include "ctwin.h"
static int hb_ctColorParam( int iParam, int iDefault )
{
int iColor;
if( ISNUM( iParam ) )
iColor = hb_parni( iParam );
else if( hb_parclen( iParam ) > 0 )
iColor = hb_gtColorToN( hb_parc( iParam ) );
else
iColor = iDefault;
return iColor;
}
HB_FUNC( CTWINIT )
{
hb_retl( hb_ctwInit() );
@@ -66,10 +81,10 @@ HB_FUNC( GETCLEARA )
HB_FUNC( SETCLEARA )
{
if( ISNUM( 1 ) )
hb_gtSetClearColor( hb_parni( 1 ) & 0xff );
else if( hb_parclen( 1 ) > 0 )
hb_gtSetClearColor( hb_gtColorToN( hb_parc( 1 ) ) );
int iColor = hb_ctColorParam( 1, -1 );
if( iColor >= 0 )
hb_gtSetClearColor( iColor & 0xff );
hb_retc( NULL );
}
@@ -97,7 +112,7 @@ HB_FUNC( GETCLEARB )
HB_FUNC( WSETSHADOW )
{
hb_retni( hb_ctwSetShadowAttr( ISNUM( 1 ) ? hb_parni( 1 ) : -2 ) );
hb_retni( hb_ctwSetShadowAttr( hb_ctColorParam( 1, -2 ) ) );
}
HB_FUNC( WSETMOVE )
@@ -132,7 +147,7 @@ HB_FUNC( WOPEN )
{
int iColor;
iColor = ISCHAR( 6 ) ? hb_gtColorToN( hb_parc( 6 ) ) : hb_parni( 6 );
iColor = hb_ctColorParam( 6, 0 ); /* Harbour extension */
hb_retni( hb_ctwCreateWindow( hb_parni( 1 ), hb_parni( 2 ),
hb_parni( 3 ), hb_parni( 4 ),
hb_parl( 5 ), iColor ) );
@@ -204,15 +219,31 @@ HB_FUNC( WBOX )
szBox = szBoxBuf;
}
iColor = ISCHAR( 2 ) ? hb_gtColorToN( hb_parc( 2 ) ) : hb_parni( 2 );
iColor = hb_ctColorParam( 2, 0 ); /* Harbour extension */
hb_retni( hb_ctwAddWindowBox( hb_ctwCurrentWindow(), szBox, iColor ) );
}
HB_FUNC( WFORMAT )
{
hb_retni( hb_ctwChangeMargins( hb_ctwCurrentWindow(),
hb_parni( 1 ), hb_parni( 2 ),
hb_parni( 3 ), hb_parni( 4 ) ) );
int iWindow = hb_ctwCurrentWindow();
int iTop, iLeft, iBottom, iRight;
if( hb_pcount() == 0 )
{
hb_ctwGetFormatCords( iWindow, TRUE, &iTop, &iLeft, &iBottom, &iRight );
iTop = -iTop;
iLeft = -iLeft;
iBottom = -iBottom;
iRight = -iRight;
}
else
{
iTop = hb_parni( 1 );
iLeft = hb_parni( 2 );
iBottom = hb_parni( 3 );
iRight = hb_parni( 4 );
}
hb_retni( hb_ctwChangeMargins( iWindow, iTop, iLeft, iBottom, iRight ) );
}
HB_FUNC( WROW )

View File

@@ -60,6 +60,7 @@
#include "hbapi.h"
#include "hbapifs.h"
#include "hb_io.h"
#include "hbset.h"
#if defined( HB_OS_WIN_32 )
#if !defined( INVALID_FILE_ATTRIBUTES )
@@ -139,7 +140,7 @@ HB_EXPORT void hb_fsFreeSearchPath( HB_PATHNAMES * pSearchList )
HB_EXPORT PHB_FNAME hb_fsFNameSplit( const char * pszFileName )
{
PHB_FNAME pFileName;
char * pszPos;
char * pszPos, cDirSep;
int iSize, iPos;
HB_TRACE(HB_TR_DEBUG, ("hb_fsFNameSplit(%s)", pszFileName));
@@ -147,6 +148,7 @@ HB_EXPORT PHB_FNAME hb_fsFNameSplit( const char * pszFileName )
HB_TRACE(HB_TR_INFO, ("hb_fsFNameSplit: Filename: |%s|\n", pszFileName));
iPos = iSize = hb_strnlen( pszFileName, _POSIX_PATH_MAX );
cDirSep = ( char ) hb_setGetDirSeparator();
/* Grab memory, set defaults */
pFileName = ( PHB_FNAME ) hb_xgrab( sizeof( HB_FNAME ) );
@@ -161,7 +163,8 @@ HB_EXPORT PHB_FNAME hb_fsFNameSplit( const char * pszFileName )
while( --iPos >= 0 )
{
if( strchr( OS_PATH_DELIMITER_LIST, pszFileName[ iPos ] ) )
if( pszFileName[ iPos ] == cDirSep ||
strchr( OS_PATH_DELIMITER_LIST, pszFileName[ iPos ] ) )
{
pFileName->szPath = pszPos;
hb_strncpy( pszPos, pszFileName, iPos + 1 );
@@ -225,45 +228,37 @@ HB_EXPORT PHB_FNAME hb_fsFNameSplit( const char * pszFileName )
/* This function joins path, name and extension into a string with a filename */
HB_EXPORT char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName )
{
static const char s_szPathSep[] = { OS_PATH_DELIMITER, 0 }; /* see NOTE below */
char * pszName;
char * pszName, cDirSep;
HB_TRACE(HB_TR_DEBUG, ("hb_fsFNameMerge(%p, %p)", pszFileName, pFileName));
/* dir separator set by user */
cDirSep = ( char ) hb_setGetDirSeparator();
/* Set the result to an empty string */
pszFileName[ 0 ] = '\0';
/* Strip preceding path separators from the filename */
pszName = pFileName->szName;
if( pszName && pszName[ 0 ] != '\0' && strchr( OS_PATH_DELIMITER_LIST, pszName[ 0 ] ) != NULL )
if( pszName && pszName[ 0 ] != '\0' && ( pszName[ 0 ] == cDirSep ||
strchr( OS_PATH_DELIMITER_LIST, pszName[ 0 ] ) != NULL ) )
pszName++;
/* Add path if specified */
if( pFileName->szPath )
hb_strncat( pszFileName, pFileName->szPath, _POSIX_PATH_MAX - 1 );
/*
NOTE: be _very_ careful about "optimizing" this next section code!
(specifically, initialising s_szPathSep) as MSVC with /Ni
(or anything that infers it like /Ox) will cause you trouble.
*/
/* If we have a path, append a path separator to the path if there
was none. */
if( pszFileName[ 0 ] != '\0' && ( pszName || pFileName->szExtension ) )
{
int iLen = strlen( pszFileName ) - 1;
if( strchr( OS_PATH_DELIMITER_LIST, pszFileName[ iLen ] ) == NULL )
if( iLen < _POSIX_PATH_MAX - 1 && pszFileName[ iLen ] != cDirSep &&
strchr( OS_PATH_DELIMITER_LIST, pszFileName[ iLen ] ) == NULL )
{
/*
char s_szPathSep[ 2 ];
s_szPathSep[ 0 ] = OS_PATH_DELIMITER;
s_szPathSep[ 1 ] = '\0';
*/
hb_strncat( pszFileName, s_szPathSep, _POSIX_PATH_MAX - 1 );
pszFileName[ iLen ] = OS_PATH_DELIMITER;
pszFileName[ iLen + 1 ] = '\0';
}
}

View File

@@ -450,6 +450,11 @@ HB_EXPORT BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree )
return szFileName;
}
HB_EXPORT int hb_setGetDirSeparator( void )
{
return s_cDirSep;
}
static void hb_compChkFileSwitches( int argc, char * argv[] )
{
int i, n;