diff --git a/Lib/perl5/perlprimtypes.swg b/Lib/perl5/perlprimtypes.swg index 6844facae..5791a83f8 100644 --- a/Lib/perl5/perlprimtypes.swg +++ b/Lib/perl5/perlprimtypes.swg @@ -159,7 +159,7 @@ SWIG_From_dec(long long)(long long value) } else { char temp[256]; SV *obj = sv_newmortal(); - snprintf(temp, sizeof(temp),"%lld", value); + sprintf(temp, "%lld", value); sv_setpv(obj, temp); return obj; } @@ -222,7 +222,7 @@ SWIG_From_dec(unsigned long long)(unsigned long long value) } else { char temp[256]; SV *obj = sv_newmortal(); - snprintf(temp, sizeof(temp),"%llu", value); + sprintf(temp, "%llu", value); sv_setpv(obj, temp); return obj; } diff --git a/Lib/perl5/perlrun.swg b/Lib/perl5/perlrun.swg index 1ce07b0cb..0cfce575a 100644 --- a/Lib/perl5/perlrun.swg +++ b/Lib/perl5/perlrun.swg @@ -176,6 +176,10 @@ typedef int (*SwigMagicFuncHack)(struct interpreter *, SV *, MAGIC *); # endif #endif +#ifndef SvUOK +# define SvUOK(sv) SvIOK_UV(sv) +#endif + #include SWIGRUNTIME const char * diff --git a/Lib/python/pycontainer.swg b/Lib/python/pycontainer.swg index 053ddab78..2bbf6e606 100644 --- a/Lib/python/pycontainer.swg +++ b/Lib/python/pycontainer.swg @@ -285,7 +285,7 @@ namespace swig return swig::as(item, true); } catch (std::exception& e) { char msg[1024]; - snprintf(msg, sizeof(msg), "in sequence element %d ", _index); + sprintf(msg, "in sequence element %d ", _index); if (!PyErr_Occurred()) { %type_error(swig::type_name()); } @@ -485,7 +485,7 @@ namespace swig if (!swig::check(item)) { if (set_err) { char msg[1024]; - snprintf(msg, sizeof(msg), "in sequence element %d of type %s", i, swig::type_name()); + sprintf(msg, "in sequence element %d", i); SWIG_Error(SWIG_RuntimeError, msg); } return false; diff --git a/Lib/python/pyruntime.swg b/Lib/python/pyruntime.swg index cf18ceac1..9891bf7ee 100644 --- a/Lib/python/pyruntime.swg +++ b/Lib/python/pyruntime.swg @@ -4,7 +4,10 @@ /* Add PyOS_snprintf for old Pythons */ #if PY_VERSION_HEX < 0x02020000 -#define PyOS_snprintf snprintf +#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# define PyOS_snprintf _snprintf +#else +# define PyOS_snprintf snprintf #endif /* A crude PyString_FromFormat implementation for old Pythons */ diff --git a/Lib/tcl/tclprimtypes.swg b/Lib/tcl/tclprimtypes.swg index 93fd0522a..8cdca8aa1 100644 --- a/Lib/tcl/tclprimtypes.swg +++ b/Lib/tcl/tclprimtypes.swg @@ -61,7 +61,7 @@ SWIG_From_dec(unsigned long)(unsigned long value) return SWIG_From(long)(%numeric_cast(value, long)); } else { char temp[256]; - snprintf(temp, sizeof(temp),"%lu", value); + sprintf(temp, "%lu", value); return Tcl_NewStringObj(temp,-1); } } @@ -113,7 +113,7 @@ SWIG_From_dec(long long)(long long value) return SWIG_From(long)(%numeric_cast(value,long)); } else { char temp[256]; - snprintf(temp, sizeof(temp),"%lld", value); + sprintf(temp, "%lld", value); return Tcl_NewStringObj(temp,-1); } } @@ -162,7 +162,7 @@ SWIG_From_dec(unsigned long long)(unsigned long long value) return SWIG_From(long long)(%numeric_cast(value, long long)); } else { char temp[256]; - snprintf(temp, sizeof(temp),"%llu", value); + sprintf(temp, "%llu", value); return Tcl_NewStringObj(temp,-1); } } diff --git a/Lib/typemaps/fragments.swg b/Lib/typemaps/fragments.swg index 0ee77299e..6f290abed 100644 --- a/Lib/typemaps/fragments.swg +++ b/Lib/typemaps/fragments.swg @@ -343,15 +343,21 @@ %fragment("","header") %{ #include #if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) +# ifndef snprintf # define snprintf _snprintf +# endif #endif %} %fragment("","header") %{ #include #ifdef _MSC_VER +# ifndef strtoull # define strtoull _strtoui64 +# endif +# ifndef strtoll # define strtoll _strtoi64 +# endif #endif %}