summaryrefslogtreecommitdiff
path: root/Lib/swig.swg
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/swig.swg')
-rw-r--r--Lib/swig.swg20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/swig.swg b/Lib/swig.swg
index 9f9d53349..f904f53c6 100644
--- a/Lib/swig.swg
+++ b/Lib/swig.swg
@@ -727,3 +727,23 @@ template <typename T> T SwigValueInit() {
%}
#endif
+%insert("runtime") %{
+/* C99 and C++11 should provide snprintf, but define SWIG_NO_SNPRINTF
+ * if you're missing it.
+ */
+#if ((defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L) || \
+ (defined __cplusplus && __cplusplus >= 201103L) || \
+ defined SWIG_HAVE_SNPRINTF) && \
+ !defined SWIG_NO_SNPRINTF
+# define SWIG_snprintf(O,S,F,A) snprintf(O,S,F,A)
+# define SWIG_snprintf2(O,S,F,A,B) snprintf(O,S,F,A,B)
+#else
+/* Fallback versions ignore the buffer size, but most of our uses either have a
+ * fixed maximum possible size or dynamically allocate a buffer that's large
+ * enough.
+ */
+# define SWIG_snprintf(O,S,F,A) sprintf(O,F,A)
+# define SWIG_snprintf2(O,S,F,A,B) sprintf(O,F,A,B)
+#endif
+
+%}