2011-03-10 20:23 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/src/common/hbtrace.c
    ! use hb_getenv_buffer() instead of hb_getenv() to not allocate
      memory when trace system is activated and added protection
      against recursive calls.

  * harbour/src/common/hbprintf.c
    ! use internal function _hb_strnlen() instead of hb_strnlen()
      to avoid recursive calls in Harbour trace system
This commit is contained in:
Przemyslaw Czerpak
2011-03-10 19:23:26 +00:00
parent a33e7c2ce8
commit cfb7a9917a
3 changed files with 38 additions and 28 deletions

View File

@@ -16,6 +16,16 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-03-10 20:23 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/src/common/hbtrace.c
! use hb_getenv_buffer() instead of hb_getenv() to not allocate
memory when trace system is activated and added protection
against recursive calls.
* harbour/src/common/hbprintf.c
! use internal function _hb_strnlen() instead of hb_strnlen()
to avoid recursive calls in Harbour trace system
2011-03-10 19:04 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* bin/hb3rdpat.hbs
+ Added -validate option

View File

@@ -695,6 +695,16 @@ static size_t put_hex( char *buffer, size_t bufsize, size_t size,
return size;
}
static int _hb_strnlen( const char * str, int len )
{
int i = 0;
while( len-- && *str++ )
++i;
return i;
}
static size_t put_str( char *buffer, size_t bufsize, size_t size,
const char * str, int flags, int width, int precision )
{
@@ -703,7 +713,7 @@ static size_t put_str( char *buffer, size_t bufsize, size_t size,
if( precision < 0 )
precision = ( int ) strlen( str );
else if( precision > 0 )
precision = ( int ) hb_strnlen( str, precision );
precision = ( int ) _hb_strnlen( str, precision );
width -= precision;
if( ( flags & _F_LEFTADJUSTED ) == 0 ) while( width > 0 )

View File

@@ -161,7 +161,11 @@ int hb_tr_level( void )
{
if( s_level == -1 )
{
char * env;
char env[ HB_PATH_MAX ];
int enabled = s_enabled;
/* protection against recursive or concurrent calls */
s_enabled = 0;
s_level = HB_TR_DEFAULT;
@@ -169,8 +173,8 @@ int hb_tr_level( void )
if( s_fp == NULL )
{
env = hb_getenv( "HB_TR_OUTPUT" );
if( env != NULL && env[ 0 ] != '\0' )
if( hb_getenv_buffer( "HB_TR_OUTPUT", env, sizeof( env ) ) &&
env[ 0 ] != '\0' )
{
s_fp = hb_fopen( env, "w" );
@@ -179,15 +183,12 @@ int hb_tr_level( void )
}
else
s_fp = stderr;
if( env )
hb_xfree( env );
}
/* ; */
env = hb_getenv( "HB_TR_LEVEL" );
if( env != NULL && env[ 0 ] != '\0' )
if( hb_getenv_buffer( "HB_TR_LEVEL", env, sizeof( env ) ) &&
env[ 0 ] != '\0' )
{
int i;
@@ -202,36 +203,25 @@ int hb_tr_level( void )
}
}
if( env )
hb_xfree( env );
/* ; */
if( s_sysout < 0 )
{
env = hb_getenv( "HB_TR_SYSOUT" );
if( env != NULL && env[ 0 ] != '\0' )
s_sysout = 1;
else
s_sysout = 0;
if( env )
hb_xfree( env );
s_sysout = ( hb_getenv_buffer( "HB_TR_SYSOUT", env, sizeof( env ) ) &&
env[ 0 ] != '\0' ) ? 1 : 0;
}
/* ; */
if( s_flush < 0 )
{
env = hb_getenv( "HB_TR_FLUSH" );
if( env != NULL && env[ 0 ] != '\0' )
s_flush = 1;
else
s_flush = 0;
if( env )
hb_xfree( env );
s_flush = ( hb_getenv_buffer( "HB_TR_FLUSH", env, sizeof( env ) ) &&
env[ 0 ] != '\0' ) ? 1 : 0;
}
/* ; */
s_enabled = enabled;
}
return s_level;