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().
This commit is contained in:
Viktor Szakats
2008-10-27 10:30:03 +00:00
parent bfd31350c2
commit b5e9969713
3 changed files with 15 additions and 7 deletions

View File

@@ -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

View File

@@ -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 */

View File

@@ -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;
}