From 955e90fe595372e695c0f6684b84ba42be9e6edf Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Thu, 19 May 2011 15:15:59 +0000 Subject: [PATCH] 2011-05-19 17:15 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/arc4.c ! fixed for watcom (getpid) ! cast for msvc ! fixed for dmc (ms struct missing for win seed) ! fixed for bcc (inline disabled for this dead compiler, getpid) ! fixed warning for all non-unix, non-win targets ; TOFIX: it's also broken for watcom/dos and watcom/linux Tamas, can you take a look at it? * utils/hbmk2/hbmk2.prg + use HB_RAND32() --- harbour/ChangeLog | 14 ++++++++++++++ harbour/src/rtl/arc4.c | 19 +++++++++++++------ harbour/utils/hbmk2/hbmk2.prg | 2 +- 3 files changed, 28 insertions(+), 7 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 9af7672636..fcac368e3b 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,20 @@ The license applies to all entries newer than 2009-04-28. */ +2011-05-19 17:15 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * src/rtl/arc4.c + ! fixed for watcom (getpid) + ! cast for msvc + ! fixed for dmc (ms struct missing for win seed) + ! fixed for bcc (inline disabled for this dead compiler, getpid) + ! fixed warning for all non-unix, non-win targets + + ; TOFIX: it's also broken for watcom/dos and watcom/linux + Tamas, can you take a look at it? + + * utils/hbmk2/hbmk2.prg + + use HB_RAND32() + 2011-05-19 16:31 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * src/rtl/Makefile * src/rtl/hbrandom.c diff --git a/harbour/src/rtl/arc4.c b/harbour/src/rtl/arc4.c index a3c1750da8..e85004bc90 100644 --- a/harbour/src/rtl/arc4.c +++ b/harbour/src/rtl/arc4.c @@ -95,7 +95,9 @@ struct arc4_stream }; #if defined( HB_OS_WIN ) -# define getpid _getpid +# if ! defined( __BORLANDC__ ) && ! defined( __WATCOMC__ ) +# define getpid _getpid +# endif # define pid_t int #endif @@ -108,14 +110,19 @@ static HB_CRITICAL_NEW( arc4_lock ); #define _ARC4_LOCK() hb_threadEnterCriticalSection( &arc4_lock ) #define _ARC4_UNLOCK() hb_threadLeaveCriticalSection( &arc4_lock ) +#if defined( __BORLANDC__ ) && defined( _HB_INLINE_ ) +#undef _HB_INLINE_ +#define _HB_INLINE_ +#endif + static _HB_INLINE_ HB_U8 arc4_getbyte( void ); static _HB_INLINE_ void arc4_init( void ) { int n; - for( n = 0; n < 256; n++ ) - rs.s[ n ] = n; + for( n = 0; n < 256; ++n ) + rs.s[ n ] = ( HB_U8 ) n; rs.i = rs.j = 0; } @@ -126,7 +133,7 @@ static _HB_INLINE_ void arc4_addrandom( const HB_U8 * dat, int datlen ) HB_U8 si; rs.i--; - for( n = 0; n < 256; n++ ) + for( n = 0; n < 256; ++n ) { rs.i = ( rs.i + 1 ); si = rs.s[ rs.i ]; @@ -137,7 +144,7 @@ static _HB_INLINE_ void arc4_addrandom( const HB_U8 * dat, int datlen ) rs.j = rs.i; } -#if ! defined( HB_OS_WIN ) +#if defined( HB_OS_UNIX ) static HB_ISIZ read_all( int fd, HB_U8 * buf, size_t count ) { HB_SIZE numread = 0; @@ -159,7 +166,7 @@ static HB_ISIZ read_all( int fd, HB_U8 * buf, size_t count ) } #endif /* ! HB_OS_WIN */ -#if defined( HB_OS_WIN ) +#if defined( HB_OS_WIN ) && ! defined( __DMC__ ) #define TRY_SEED_MS_CRYPTOAPI static int arc4_seed_win32( void ) diff --git a/harbour/utils/hbmk2/hbmk2.prg b/harbour/utils/hbmk2/hbmk2.prg index 5392241525..eacd374100 100644 --- a/harbour/utils/hbmk2/hbmk2.prg +++ b/harbour/utils/hbmk2/hbmk2.prg @@ -932,7 +932,7 @@ FUNCTION hbmk2( aArgs, nArgTarget, /* @ */ lPause, nLevel ) LOCAL lHBMAINDLLP IF s_cSecToken == NIL - s_cSecToken := StrZero( hb_Random( 1, 4294967294 ), 10, 0 ) + s_cSecToken := StrZero( hb_rand32(), 10, 0 ) ENDIF hbmk[ _HBMK_cBUILD ] := ""