109 lines
3.5 KiB
Diff
109 lines
3.5 KiB
Diff
From 84a2c45d66f0334f8fe67077311383af11a2d5c8 Mon Sep 17 00:00:00 2001
|
|
From: Olly Betts <olly@survex.com>
|
|
Date: Fri, 12 Jan 2024 16:15:31 +1300
|
|
Subject: [PATCH] Adjust -external-runtime fix
|
|
|
|
The original fix broke C#, D and Java which don't seem to include
|
|
swigrun.swg, so split out the SWIG_snprintf macros into a new file
|
|
and explicitly include it for the external runtime.
|
|
|
|
See #2751.
|
|
---
|
|
Lib/swig.swg | 2 ++
|
|
Lib/swigcompat.swg | 23 +++++++++++++++++++++++
|
|
Lib/swigrun.swg | 17 -----------------
|
|
Source/Modules/main.cxx | 9 +++++++++
|
|
4 files changed, 34 insertions(+), 17 deletions(-)
|
|
create mode 100644 Lib/swigcompat.swg
|
|
|
|
diff --git a/Lib/swig.swg b/Lib/swig.swg
|
|
index faa75baa9..db7e08cf6 100644
|
|
--- a/Lib/swig.swg
|
|
+++ b/Lib/swig.swg
|
|
@@ -710,3 +710,5 @@ template <typename T> T SwigValueInit() {
|
|
#endif
|
|
%}
|
|
#endif
|
|
+
|
|
+%insert("runtime") "swigcompat.swg"
|
|
diff --git a/Lib/swigcompat.swg b/Lib/swigcompat.swg
|
|
new file mode 100644
|
|
index 000000000..7d29b7539
|
|
--- /dev/null
|
|
+++ b/Lib/swigcompat.swg
|
|
@@ -0,0 +1,23 @@
|
|
+/* -----------------------------------------------------------------------------
|
|
+ * swigcompat.swg
|
|
+ *
|
|
+ * Macros to provide support compatibility with older C and C++ standards.
|
|
+ * ----------------------------------------------------------------------------- */
|
|
+
|
|
+/* 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
|
|
diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg
|
|
index 80e41bb50..824185c02 100644
|
|
--- a/Lib/swigrun.swg
|
|
+++ b/Lib/swigrun.swg
|
|
@@ -181,23 +181,6 @@ SWIGINTERNINLINE int SWIG_CheckState(int r) {
|
|
# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
|
|
#endif
|
|
|
|
-/* 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
|
|
|
|
#include <string.h>
|
|
|
|
diff --git a/Source/Modules/main.cxx b/Source/Modules/main.cxx
|
|
index 8a44921ad..76b4f9d28 100644
|
|
--- a/Source/Modules/main.cxx
|
|
+++ b/Source/Modules/main.cxx
|
|
@@ -379,6 +379,15 @@ static void SWIG_dump_runtime() {
|
|
Swig_banner(runtime);
|
|
Printf(runtime, "\n");
|
|
|
|
+ s = Swig_include_sys("swigcompat.swg");
|
|
+ if (!s) {
|
|
+ Printf(stderr, "*** Unable to open 'swigcompat.swg'\n");
|
|
+ Delete(runtime);
|
|
+ Exit(EXIT_FAILURE);
|
|
+ }
|
|
+ Printf(runtime, "%s", s);
|
|
+ Delete(s);
|
|
+
|
|
s = Swig_include_sys("swiglabels.swg");
|
|
if (!s) {
|
|
Printf(stderr, "*** Unable to open 'swiglabels.swg'\n");
|
|
--
|
|
2.43.0
|
|
|