From 2a1929a261be45dc411f01011c8bc30243fd0fd8 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 20 Jul 2009 22:24:54 +0000 Subject: [PATCH] 2009-07-21 00:23 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * source/rtl/net.c ! Fixed NETNAME()/hb_netname() on dos/watcom platforms in error cases it was leaking 16 bytes of memory. (+ minor formatting) Please review me. + NETNAME(), HB_USERNAME() now do conversion from OS codepage. Couldn't test it, please review me. --- harbour/ChangeLog | 9 +++++++++ harbour/source/rtl/net.c | 19 +++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e32040c695..0562fbe21f 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,15 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-07-21 00:23 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * source/rtl/net.c + ! Fixed NETNAME()/hb_netname() on dos/watcom platforms + in error cases it was leaking 16 bytes of memory. + (+ minor formatting) + Please review me. + + NETNAME(), HB_USERNAME() now do conversion from OS + codepage. Couldn't test it, please review me. + 2009-07-20 17:45 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/win_reg.prg * contrib/hbwin/win_regc.c diff --git a/harbour/source/rtl/net.c b/harbour/source/rtl/net.c index d08dd0fd13..4d643e524d 100644 --- a/harbour/source/rtl/net.c +++ b/harbour/source/rtl/net.c @@ -129,21 +129,20 @@ char * hb_netname( void ) return pszValue; # else union REGS regs; + struct SREGS sregs; char * pszValue = ( char * ) hb_xgrab( 16 ); pszValue[ 0 ] = '\0'; regs.HB_XREGS.ax = 0x5E00; + regs.HB_XREGS.dx = FP_OFF( pszValue ); + sregs.ds = FP_SEG( pszValue ); - { - struct SREGS sregs; + HB_DOS_INT86X( 0x21, ®s, ®s, &sregs ); - regs.HB_XREGS.dx = FP_OFF( pszValue ); - sregs.ds = FP_SEG( pszValue ); + if( regs.h.ch == 0 ) + pszValue = '\0'; - HB_DOS_INT86X( 0x21, ®s, ®s, &sregs ); - } - - return regs.h.ch == 0 ? hb_strdup( "" ) : pszValue; + return pszValue; # endif #elif defined( HB_OS_WIN ) @@ -193,10 +192,10 @@ char * hb_username( void ) HB_FUNC( NETNAME ) { - hb_retc_buffer( hb_netname() ); + hb_retc_buffer( ( char * ) hb_osDecode( hb_netname(), NULL ) ); } HB_FUNC( HB_USERNAME ) { - hb_retc_buffer( hb_username() ); + hb_retc_buffer( ( char * ) hb_osDecode( hb_username(), NULL ) ); }