r23557 - gnucash/trunk/src - Bug 719481 - GnuCash report crashes with Guile2

Geert Janssens gjanssens at code.gnucash.org
Fri Dec 13 15:22:02 EST 2013


Author: gjanssens
Date: 2013-12-13 15:22:01 -0500 (Fri, 13 Dec 2013)
New Revision: 23557
Trac: http://svn.gnucash.org/trac/changeset/23557

Added:
   gnucash/trunk/src/swig-utf8.patch
Modified:
   gnucash/trunk/src/app-utils/Makefile.am
   gnucash/trunk/src/core-utils/Makefile.am
   gnucash/trunk/src/engine/Makefile.am
   gnucash/trunk/src/gnc-module/Makefile.am
   gnucash/trunk/src/gnc-module/test/mod-bar/Makefile.am
   gnucash/trunk/src/gnc-module/test/mod-baz/Makefile.am
   gnucash/trunk/src/gnc-module/test/mod-foo/Makefile.am
   gnucash/trunk/src/gnome-utils/Makefile.am
   gnucash/trunk/src/gnome/Makefile.am
   gnucash/trunk/src/guile-mappings.h
   gnucash/trunk/src/html/Makefile.am
   gnucash/trunk/src/report/report-gnome/Makefile.am
   gnucash/trunk/src/report/report-system/Makefile.am
   gnucash/trunk/src/test-core/Makefile.am
Log:
Bug 719481 - GnuCash report crashes with Guile2

This is actually a bug in swig.
This commit works around it by patching the swig
generated source files until swig itself has been fixed.

Modified: gnucash/trunk/src/app-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/app-utils/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/app-utils/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -108,7 +108,10 @@
 if BUILDING_FROM_SCM
 swig-app-utils-guile.c: app-utils.i ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-	-I${top_srcdir}/src -o $@ $<
+	-I${top_srcdir}/src -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 swig-app-utils-python.c: app-utils.i ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -python -Wall -Werror $(SWIG_ARGS) \
 	-I${top_srcdir}/src -o $@ $<

Modified: gnucash/trunk/src/core-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/core-utils/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/core-utils/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -45,7 +45,10 @@
 if BUILDING_FROM_SCM
 swig-core-utils-guile.c: core-utils.i ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-	-I${top_srcdir}/src -o $@ $<
+	-I${top_srcdir}/src -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 swig-core-utils-python.c: core-utils.i ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -python -Wall -Werror $(SWIG_ARGS) \
 	-I${top_srcdir}/src -o $@ $<

Modified: gnucash/trunk/src/engine/Makefile.am
===================================================================
--- gnucash/trunk/src/engine/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/engine/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -204,7 +204,10 @@
                $(QOFHEADERS) \
                $(gncinclude_HEADERS) $(noinst_HEADERS)
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-	-I${top_srcdir}/src/libqof/qof -I${top_srcdir}/src -o $@ $<
+	-I${top_srcdir}/src/libqof/qof -I${top_srcdir}/src -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 iso-4217-currencies.c: iso-4217-currencies.scm iso-currencies-to-c

Modified: gnucash/trunk/src/gnc-module/Makefile.am
===================================================================
--- gnucash/trunk/src/gnc-module/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/gnc-module/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -32,7 +32,10 @@
 if BUILDING_FROM_SCM
 swig-gnc-module.c: gnc-module.i ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-	-I${top_srcdir}/src -o $@ $<
+	-I${top_srcdir}/src -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 EXTRA_DIST = \

Modified: gnucash/trunk/src/gnc-module/test/mod-bar/Makefile.am
===================================================================
--- gnucash/trunk/src/gnc-module/test/mod-bar/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/gnc-module/test/mod-bar/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -24,7 +24,10 @@
 
 if BUILDING_FROM_SCM
 swig-bar.c: bar.i
-	$(SWIG) -guile $(SWIG_ARGS) -Linkage module -o $@ $<
+	$(SWIG) -guile $(SWIG_ARGS) -Linkage module -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 EXTRA_DIST = \

Modified: gnucash/trunk/src/gnc-module/test/mod-baz/Makefile.am
===================================================================
--- gnucash/trunk/src/gnc-module/test/mod-baz/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/gnc-module/test/mod-baz/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -28,7 +28,10 @@
 
 if BUILDING_FROM_SCM
 swig-baz.c: baz.i
-	$(SWIG) -guile $(SWIG_ARGS) -Linkage module -o $@ $<
+	$(SWIG) -guile $(SWIG_ARGS) -Linkage module -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 EXTRA_DIST = \

Modified: gnucash/trunk/src/gnc-module/test/mod-foo/Makefile.am
===================================================================
--- gnucash/trunk/src/gnc-module/test/mod-foo/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/gnc-module/test/mod-foo/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -29,7 +29,10 @@
 
 if BUILDING_FROM_SCM
 swig-foo.c: foo.i
-	$(SWIG) -guile $(SWIG_ARGS) -Linkage module -o $@ $<
+	$(SWIG) -guile $(SWIG_ARGS) -Linkage module -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 BUILT_SOURCES = swig-foo.c

Modified: gnucash/trunk/src/gnome/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/gnome/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -114,7 +114,10 @@
 if BUILDING_FROM_SCM
 swig-gnome.c: gnome.i dialog-progress.h ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-	-I${top_srcdir}/src -o $@ $<
+	-I${top_srcdir}/src -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 EXTRA_DIST = \

Modified: gnucash/trunk/src/gnome-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/gnome-utils/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/gnome-utils/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -227,7 +227,10 @@
 swig-gnome-utils.c: gnome-utils.i \
                     ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-	-I${top_srcdir}/src -o $@ $<
+	-I${top_srcdir}/src -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash

Modified: gnucash/trunk/src/guile-mappings.h
===================================================================
--- gnucash/trunk/src/guile-mappings.h	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/guile-mappings.h	2013-12-13 20:22:01 UTC (rev 23557)
@@ -22,6 +22,8 @@
 /* Give Guile 1.8 a 2.0-like interface */
 #if (SCM_MAJOR_VERSION < 2)
 # define scm_c_string_length scm_i_string_length
+#endif
+#ifndef scm_from_utf8_string
 # define scm_from_utf8_string scm_from_locale_string
 # define scm_to_utf8_string scm_to_locale_string
 #endif

Modified: gnucash/trunk/src/html/Makefile.am
===================================================================
--- gnucash/trunk/src/html/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/html/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -58,7 +58,10 @@
 swig-gnc-html.c: gnc-html.i gnc-html.h \
                     ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-	-I${top_srcdir}/src -o $@ $<
+	-I${top_srcdir}/src -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 EXTRA_DIST = \

Modified: gnucash/trunk/src/report/report-gnome/Makefile.am
===================================================================
--- gnucash/trunk/src/report/report-gnome/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/report/report-gnome/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -52,7 +52,10 @@
 if BUILDING_FROM_SCM
 swig-report-gnome.c: report-gnome.i ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-	-I${top_srcdir}/src -o $@ $<
+	-I${top_srcdir}/src -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 gncmoddir = ${GNC_SHAREDIR}/guile-modules/gnucash/report

Modified: gnucash/trunk/src/report/report-system/Makefile.am
===================================================================
--- gnucash/trunk/src/report/report-system/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/report/report-system/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -24,7 +24,10 @@
 if BUILDING_FROM_SCM
 swig-report-system.c: report-system.i ${top_srcdir}/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
-	-I${top_srcdir}/src -o $@ $<
+	-I${top_srcdir}/src -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 endif
 
 AM_CPPFLAGS = \

Added: gnucash/trunk/src/swig-utf8.patch
===================================================================
--- gnucash/trunk/src/swig-utf8.patch	                        (rev 0)
+++ gnucash/trunk/src/swig-utf8.patch	2013-12-13 20:22:01 UTC (rev 23557)
@@ -0,0 +1,60 @@
+--- guile_scm_run.swg
++++ guile_scm_run.swg
+@@ -41,10 +41,14 @@ typedef struct swig_guile_clientdata {
+   SCM goops_class;
+ } swig_guile_clientdata;
+ 
++#if SCM_MAJOR_VERSION <= 2
++#define scm_to_utf8_string scm_to_locale_string
++#define scm_from_utf8_string scm_from_locale_string
++#endif
+ #define SWIG_scm2str(s) \
+   SWIG_Guile_scm2newstr(s, NULL)
+ #define SWIG_str02scm(str) \
+-  str ? scm_from_locale_string(str) : SCM_BOOL_F 
++  str ? scm_from_utf8_string(str) : SCM_BOOL_F 
+ # define SWIG_malloc(size) \
+   scm_malloc(size)
+ # define SWIG_free(mem) \
+@@ -84,21 +88,13 @@ SWIGINTERN char *
+ SWIG_Guile_scm2newstr(SCM str, size_t *len) {
+ #define FUNC_NAME "SWIG_Guile_scm2newstr"
+   char *ret;
+-  char *tmp;
+-  size_t l;
+ 
+   SCM_ASSERT (scm_is_string(str), str, 1, FUNC_NAME);
+-  l = scm_c_string_length(str);
+ 
+-  ret = (char *) SWIG_malloc( (l + 1) * sizeof(char));
++  ret = scm_to_utf8_string(str);
+   if (!ret) return NULL;
+ 
+-  tmp = scm_to_locale_string(str);
+-  memcpy(ret, tmp, l);
+-  free(tmp);
+-
+-  ret[l] = '\0';
+-  if (len) *len = l;
++  if (len) *len = strlen(ret) - 1;
+   return ret;
+ #undef FUNC_NAME
+ }
+@@ -473,7 +469,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
+   int num_args_passed = 0;
+   for (i = 0; i<reqargs; i++) {
+     if (!SCM_CONSP(rest))
+-      scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure"));
++      scm_wrong_num_args(scm_from_utf8_string(procname ? (char *) procname : "unknown procedure"));
+     *dest++ = SCM_CAR(rest);
+     rest = SCM_CDR(rest);
+     num_args_passed++;
+@@ -486,7 +482,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
+   for (; i<optargs; i++)
+     *dest++ = SCM_UNDEFINED;
+   if (!SCM_NULLP(rest))
+-      scm_wrong_num_args(scm_from_locale_string(procname ? (char *) procname : "unknown procedure"));
++      scm_wrong_num_args(scm_from_utf8_string(procname ? (char *) procname : "unknown procedure"));
+   return num_args_passed;
+ }
+ 

Modified: gnucash/trunk/src/test-core/Makefile.am
===================================================================
--- gnucash/trunk/src/test-core/Makefile.am	2013-12-13 20:21:41 UTC (rev 23556)
+++ gnucash/trunk/src/test-core/Makefile.am	2013-12-13 20:22:01 UTC (rev 23557)
@@ -27,7 +27,10 @@
 swig-unittest-support-guile.c: unittest-support.i $(top_srcdir)/src/base-typemaps.i
 	$(SWIG) -guile $(SWIG_ARGS) -Linkage module \
 	-I${top_srcdir}/src \
-	${AM_CPPFLAGS} -o $@ $<
+	${AM_CPPFLAGS} -o $@ $<; \
+	if ! `grep "define scm_from_utf8_string" $@ > /dev/null 2>&1`; then \
+	  patch $@ $(top_srcdir)/src/swig-utf8.patch; \
+	fi
 
 swig-unittest-support-python.c: unittest-support.i $(top_srcdir)/src/base-typemaps.i
 	$(SWIG) -python  -Wall -Werror $(SWIG_ARGS) \



More information about the gnucash-changes mailing list