From b5e99697134e18c678ed254403bceff4aad67ce3 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 27 Oct 2008 10:30:03 +0000 Subject: [PATCH] 2008-10-27 11:29 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbapi.h * source/common/hbstr.c + Added return value to hb_snprintf(). --- harbour/ChangeLog | 5 +++++ harbour/include/hbapi.h | 2 +- harbour/source/common/hbstr.c | 15 +++++++++------ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 53fd080dbf..89603f6dbc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,11 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-27 11:29 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * include/hbapi.h + * source/common/hbstr.c + + Added return value to hb_snprintf(). + 2008-10-27 11:26 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * source/common/hbstr.c * Some tweaks to hb_snprintf(). It still doesn't work diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index c1edc93340..428f71a64d 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -827,7 +827,7 @@ extern HB_EXPORT BOOL hb_compStrToNum( const char * szNum, ULONG ulLen, HB_ extern HB_EXPORT BOOL hb_valStrnToNum( const char * szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal, int * piDec, int * piWidth ); /* converts string to number, sets iDec, iWidth and returns TRUE if results is double, used by VAL() */ extern HB_EXPORT BOOL hb_strToNum( const char * szNum, HB_LONG * plVal, double * pdVal ); /* converts string to number, returns TRUE if results is double */ extern HB_EXPORT BOOL hb_strnToNum( const char * szNum, ULONG ulLen, HB_LONG * plVal, double * pdVal ); /* converts string to number, returns TRUE if results is double */ -extern HB_EXPORT void hb_snprintf( char * buffer, ULONG nSize, const char * format, ... ); /* snprintf() wrapper */ +extern HB_EXPORT ULONG hb_snprintf( char * buffer, ULONG nSize, const char * format, ... ); /* snprintf() wrapper */ extern HB_EXPORT BOOL hb_strMatchFile( const char * pszString, const char * szPattern ); /* compare two strings using platform dependent rules for file matching */ extern HB_EXPORT BOOL hb_strMatchRegExp( const char * szString, const char * szPattern ); /* compare two strings using a regular expression pattern */ diff --git a/harbour/source/common/hbstr.c b/harbour/source/common/hbstr.c index 53fe4e37d6..6e47f27d7a 100644 --- a/harbour/source/common/hbstr.c +++ b/harbour/source/common/hbstr.c @@ -1112,8 +1112,9 @@ char * hb_compDecodeString( int iMethod, const char * szText, ULONG * pulLen ) #undef _HB_SNPRINTF_ADD_EOS #undef snprintf /* NOTE: The full size of the buffer is expected as nSize. [vszakats] */ -HB_EXPORT void hb_snprintf( char * buffer, ULONG nSize, const char * format, ... ) +HB_EXPORT ULONG hb_snprintf( char * buffer, ULONG nSize, const char * format, ... ) { + ULONG result; va_list arglist; va_start( arglist, format ); @@ -1121,20 +1122,22 @@ HB_EXPORT void hb_snprintf( char * buffer, ULONG nSize, const char * format, ... #if defined( __DJGPP__ ) && ( __DJGPP__ < 2 || ( __DJGPP__ == 2 && __DJGPP_MINOR__ <= 3 ) ) /* Use sprintf() for DJGPP <= 2.03. This is a temporary hack, should implement a C99 snprintf() ourselves. */ - sprintf( buffer, format, arglist ); + result = sprintf( buffer, format, arglist ); #elif defined( _MSC_VER ) && _MSC_VER >= 1400 - _snprintf_s( buffer, nSize, _TRUNCATE, format, arglist ); + result = _snprintf_s( buffer, nSize, _TRUNCATE, format, arglist ); #elif defined( _MSC_VER ) || defined( __DMC__ ) && !defined( __XCC__ ) - _snprintf( buffer, nSize, format, arglist ); + result = _snprintf( buffer, nSize, format, arglist ); #define _HB_SNPRINTF_ADD_EOS #elif defined( __WATCOMC__ ) && __WATCOMC__ < 1200 - _bprintf( buffer, nSize, format, arglist ); + result = _bprintf( buffer, nSize, format, arglist ); #else - snprintf( buffer, nSize, format, arglist ); + result = snprintf( buffer, nSize, format, arglist ); #endif #ifdef _HB_SNPRINTF_ADD_EOS if( buffer && nSize ) buffer[ nSize - 1 ] = '\0'; #endif + + return result; }