From db50dc8154c5c63593e80c5cc5f96d6303dd0214 Mon Sep 17 00:00:00 2001 From: Olly Betts Date: Fri, 12 Jan 2024 14:08:35 +1300 Subject: [PATCH] [Ruby,Tcl] Fix -external-runtime output Fix -external-runtime output to define SWIG_snprintf (bug introduced in 4.2.0). Fixes #2751 --- CHANGES.current | 4 ++++ Lib/swig.swg | 21 --------------------- Lib/swigrun.swg | 17 +++++++++++++++++ 3 files changed, 21 insertions(+), 21 deletions(-) #diff --git a/CHANGES.current b/CHANGES.current #index fefa0f942..8d68a9687 100644 #--- a/CHANGES.current #+++ b/CHANGES.current #@@ -7,6 +7,10 @@ the issue number to the end of the URL: https://github.com/swig/swig/issues/ # Version 4.2.1 (in progress) # =========================== # #+2024-01-12: olly #+ [Ruby,Tcl] #2751 Fix -external-runtime output to define #+ SWIG_snprintf (bug introduced in 4.2.0). #+ # 2024-01-12: olly # Improve preprocessor warning for use of an undefined function-like # macro. SWIG now warns: diff --git a/Lib/swig.swg b/Lib/swig.swg index ce5163685..faa75baa9 100644 --- a/Lib/swig.swg +++ b/Lib/swig.swg @@ -710,24 +710,3 @@ template T SwigValueInit() { #endif %} #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 - -%} diff --git a/Lib/swigrun.swg b/Lib/swigrun.swg index 824185c02..80e41bb50 100644 --- a/Lib/swigrun.swg +++ b/Lib/swigrun.swg @@ -181,6 +181,23 @@ 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 -- 2.43.0