From d1dc70f971b96238eb3e765eee9f7d8209781516 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 27 Oct 2008 11:11:02 +0000 Subject: [PATCH] 2008-10-27 12:03 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * make_vc.mak * contrib/mtpl_vc.mak - Removed no longer necessary '-D_CRT_SECURE_NO_DEPRECATE' for MSVS 2005 and upper. * include/hbsetup.h * Mapping snprintf() calls to hb_snprintf(). ; TODO: Replace the calls in source code. * source/common/hbstr.c ! Fixed hb_snprintf(). Please verify on your platforms. ; TODO: It may need further tweaking to smooth out the platform implementation differences. --- harbour/ChangeLog | 15 +++++++++++++++ harbour/contrib/mtpl_vc.mak | 2 +- harbour/include/hbsetup.h | 19 ++++--------------- harbour/make_vc.mak | 4 ++-- harbour/source/common/hbstr.c | 16 ++++++++-------- 5 files changed, 30 insertions(+), 26 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 89603f6dbc..dc0f680fe1 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,6 +8,21 @@ 2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org) */ +2008-10-27 12:03 UTC+0200 Viktor Szakats (harbour.01 syenar hu) + * make_vc.mak + * contrib/mtpl_vc.mak + - Removed no longer necessary '-D_CRT_SECURE_NO_DEPRECATE' + for MSVS 2005 and upper. + + * include/hbsetup.h + * Mapping snprintf() calls to hb_snprintf(). + ; TODO: Replace the calls in source code. + + * source/common/hbstr.c + ! Fixed hb_snprintf(). Please verify on your platforms. + ; TODO: It may need further tweaking to smooth out the + platform implementation differences. + 2008-10-27 11:29 UTC+0200 Viktor Szakats (harbour.01 syenar hu) * include/hbapi.h * source/common/hbstr.c diff --git a/harbour/contrib/mtpl_vc.mak b/harbour/contrib/mtpl_vc.mak index 655f0f1594..60199266fb 100644 --- a/harbour/contrib/mtpl_vc.mak +++ b/harbour/contrib/mtpl_vc.mak @@ -109,7 +109,7 @@ HB_VISUALC_VER = 80 # C Compiler Flags !if $(HB_VISUALC_VER) >= 80 -CFLAGS_VER = -Ot2b1 -EHs-c- -D_CRT_SECURE_NO_DEPRECATE +CFLAGS_VER = -Ot2b1 -EHs-c- !else CFLAGS_VER = -Ogt2yb1p -GX- -G6 -YX !endif diff --git a/harbour/include/hbsetup.h b/harbour/include/hbsetup.h index 202d276cf9..9478b9d67d 100644 --- a/harbour/include/hbsetup.h +++ b/harbour/include/hbsetup.h @@ -55,6 +55,7 @@ #include + /* *********************************************************************** * Include settings common for .prg and .c files */ @@ -396,24 +397,12 @@ */ #if defined( __DJGPP__ ) - /* Fix DJGPP in call to: toupper(), tolower(), is...() - */ + /* Fix DJGPP in call to: toupper(), tolower(), is...() */ #include "hbfixdj.h" - - /* Substitute snprintf() by sprintf() for DJGPP <= 2.03. - * This is a temporary hack, should implement a C99 snprintf() ourselves. - */ - #if ( __DJGPP__ < 2 || ( __DJGPP__ == 2 && __DJGPP_MINOR__ <= 3 ) ) - #define snprintf(s, len, args...) sprintf( (s), ##args ) - #endif -#elif defined( _MSC_VER ) || defined( __DMC__ ) && !defined( __XCC__ ) - #define snprintf _snprintf -#elif defined( __WATCOMC__ ) - #if __WATCOMC__ < 1200 - #define snprintf _bprintf - #endif #endif +#define snprintf hb_snprintf + /* *********************************************************************** * Extern "C" detection */ diff --git a/harbour/make_vc.mak b/harbour/make_vc.mak index 457d77a7e9..61e66d48ff 100644 --- a/harbour/make_vc.mak +++ b/harbour/make_vc.mak @@ -99,7 +99,7 @@ VMMT_LIB_OBJS = $(VM_LIB_OBJS:obj\vc=obj\vc_mt) !if "$(HB_BUILD_WINCE)" == "yes" !if $(HB_VISUALC_VER) >= 80 -CFLAGS_VER = -Od -Os -Gy -GS- -EHsc- -Gm -Zi -GR- -D_CRT_SECURE_NO_DEPRECATE +CFLAGS_VER = -Od -Os -Gy -GS- -EHsc- -Gm -Zi -GR- !else CFLAGS_VER = -Oxsb1 -EHsc -YX -GF !endif @@ -126,7 +126,7 @@ DBGMARKER = d # NOTE: See here: http://msdn.microsoft.com/en-us/library/fwkeyyhe.aspx !if $(HB_VISUALC_VER) >= 80 -CFLAGS_VER = -Ot2b1 -EHs-c- -D_CRT_SECURE_NO_DEPRECATE +CFLAGS_VER = -Ot2b1 -EHs-c- !else CFLAGS_VER = -Ogt2yb1p -GX- -G6 -YX !endif diff --git a/harbour/source/common/hbstr.c b/harbour/source/common/hbstr.c index 6e47f27d7a..a6b35d61cf 100644 --- a/harbour/source/common/hbstr.c +++ b/harbour/source/common/hbstr.c @@ -1112,26 +1112,26 @@ 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 ULONG hb_snprintf( char * buffer, ULONG nSize, const char * format, ... ) +ULONG hb_snprintf( char * buffer, ULONG nSize, const char * format, ... ) { - ULONG result; va_list arglist; + ULONG result; va_start( arglist, format ); #if defined( __DJGPP__ ) && ( __DJGPP__ < 2 || ( __DJGPP__ == 2 && __DJGPP_MINOR__ <= 3 ) ) - /* Use sprintf() for DJGPP <= 2.03. + /* Use vsprintf() for DJGPP <= 2.03. This is a temporary hack, should implement a C99 snprintf() ourselves. */ - result = sprintf( buffer, format, arglist ); + result = vsprintf( buffer, format, arglist ); #elif defined( _MSC_VER ) && _MSC_VER >= 1400 - result = _snprintf_s( buffer, nSize, _TRUNCATE, format, arglist ); + result = _vsnprintf_s( buffer, nSize, _TRUNCATE, format, arglist ); #elif defined( _MSC_VER ) || defined( __DMC__ ) && !defined( __XCC__ ) - result = _snprintf( buffer, nSize, format, arglist ); + result = _vsnprintf( buffer, nSize, format, arglist ); #define _HB_SNPRINTF_ADD_EOS #elif defined( __WATCOMC__ ) && __WATCOMC__ < 1200 - result = _bprintf( buffer, nSize, format, arglist ); + result = _vbprintf( buffer, nSize, format, arglist ); #else - result = snprintf( buffer, nSize, format, arglist ); + result = vsnprintf( buffer, nSize, format, arglist ); #endif #ifdef _HB_SNPRINTF_ADD_EOS