diff --git a/sphinxbase-swig-4.2.0-array-typemap-fix.patch b/sphinxbase-swig-4.2.0-array-typemap-fix.patch new file mode 100644 index 0000000..668f34b --- /dev/null +++ b/sphinxbase-swig-4.2.0-array-typemap-fix.patch @@ -0,0 +1,67 @@ +--- sphinxbase-5prealpha/swig/typemaps.i 2016-09-24 23:34:08.000000000 +0100 ++++ sphinxbase-5prealpha-patched/swig/typemaps.i 2024-01-06 15:24:06.398900383 +0000 +@@ -46,6 +46,7 @@ + // Typemap for string arrays used in ngram API + #if SWIGPYTHON + ++#if SWIG_VERSION < 0x040200 + %typemap(in) (size_t n, char **ptr) { + /* Check if is a list */ + $1 = 0; +@@ -55,11 +56,14 @@ + $2 = (char **) calloc(($1 + 1), sizeof(char *)); + for (i = 0; i < $1; i++) { + PyObject *o = PyList_GetItem($input,i); +- $2[i] = SWIG_Python_str_AsChar(o); ++ const char *str = SWIG_Python_str_AsChar(o); ++ if (!str) ++ SWIG_fail; ++ $2[i] = (char *)str; + } + } else { + PyErr_SetString(PyExc_TypeError, "list type expected"); +- return NULL; ++ SWIG_fail; + } + } + +@@ -72,6 +76,39 @@ + free($2); + } + } ++#else ++%typemap(in) (size_t n, char **ptr)(PyObject **bytes_array = NULL) { ++ /* Check if is a list */ ++ $1 = 0; ++ if (PyList_Check($input)) { ++ int i; ++ $1 = PyList_Size($input); ++ $2 = (char **) calloc(($1 + 1), sizeof(char *)); ++ bytes_array = (PyObject **) calloc(($1 + 1), sizeof(PyObject *)); ++ for (i = 0; i < $1; i++) { ++ PyObject *o = PyList_GetItem($input,i); ++ const char *str = SWIG_PyUnicode_AsUTF8AndSize(o, NULL, &bytes_array[i]); ++ if (!str) ++ SWIG_fail; ++ $2[i] = (char *)str; ++ } ++ } else { ++ PyErr_SetString(PyExc_TypeError, "list type expected"); ++ SWIG_fail; ++ } ++} ++ ++%typemap(freearg) (size_t n, char **ptr) { ++ int i; ++ if ($2 != NULL) { ++ for (i = 0; $2[i] != NULL; i++) { ++ Py_XDECREF(bytes_array$argnum[i]); ++ } ++ free($2); ++ free(bytes_array$argnum); ++ } ++} ++#endif + + #elif SWIGJAVA + %typemap(in) (size_t n, char **ptr) { diff --git a/sphinxbase.spec b/sphinxbase.spec index 6b5a48a..baf63c2 100644 --- a/sphinxbase.spec +++ b/sphinxbase.spec @@ -8,7 +8,7 @@ Name: sphinxbase Version: 5 -Release: 0.17.%{extraver}%{?dist} +Release: 0.18.%{extraver}%{?dist} Epoch: 1 Summary: Common library for CMU Sphinx voice recognition products @@ -22,6 +22,9 @@ Patch0: sphinxbase-5prealpha-fix-doxy2swig.patch # https://github.com/cmusphinx/sphinxbase/pull/90 Patch1: sphinxbase-5prealpha-stdbool.patch +# Fix code for SWIG 4.2.0 +Patch2: sphinxbase-swig-4.2.0-array-typemap-fix.patch + BuildRequires: make BuildRequires: autoconf-archive BuildRequires: bison @@ -97,6 +100,7 @@ done %patch0 -p1 -b .fix-doxy2swig %patch1 -p1 -b .stdbool +%patch2 -p1 -b .swig420 %build export CPPFLAGS="-I %{_includedir}/%{blaslib}" @@ -163,6 +167,9 @@ rm -f %{buildroot}%{_libdir}/*.la %{python3_sitearch}/sphinxbase %changelog +* Thu Jan 25 2024 Jitka Plesnikova - 1:5-0.18.prealpha +- Fix for SWIG 4.2.0 update (BZ #2260324) + * Sat Jul 22 2023 Fedora Release Engineering - 1:5-0.17.prealpha - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild