[Gnucash-changes] r13122 - gnucash/trunk - use g_strdup -- cannot feed SCM_STRING_CHARS() back into guile.

Derek Atkins warlord at cvs.gnucash.org
Sun Feb 5 14:58:20 EST 2006


Author: warlord
Date: 2006-02-05 14:58:20 -0500 (Sun, 05 Feb 2006)
New Revision: 13122
Trac: http://svn.gnucash.org/trac/changeset/13122

Modified:
   gnucash/trunk/ChangeLog
   gnucash/trunk/src/app-utils/test/test-scm-query-string.c
Log:
use g_strdup -- cannot feed SCM_STRING_CHARS() back into guile.
(fixes a weird test-case failure in some cases).



Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog	2006-02-05 19:06:56 UTC (rev 13121)
+++ gnucash/trunk/ChangeLog	2006-02-05 19:58:20 UTC (rev 13122)
@@ -2,6 +2,10 @@
 
 	* src/backend/file/test/Makefile.am: link against libcore-utils.
 
+	* src/app-utils/test/test-scm-query-string.c:
+	  use g_strdup -- cannot feed SCM_STRING_CHARS() back into guile.
+	  (fixes a weird test-case failure in some cases).
+
 2006-02-05  Neil Williams <linux at codehelp.co.uk>
 
 	* lib/libqof/qof/qoflog.c :

Modified: gnucash/trunk/src/app-utils/test/test-scm-query-string.c
===================================================================
--- gnucash/trunk/src/app-utils/test/test-scm-query-string.c	2006-02-05 19:06:56 UTC (rev 13121)
+++ gnucash/trunk/src/app-utils/test/test-scm-query-string.c	2006-02-05 19:58:20 UTC (rev 13122)
@@ -20,6 +20,7 @@
   SCM args = SCM_EOL;
   Query *q2;
   const gchar * str;
+  gchar *str2 = NULL;
 
   scm_q = gnc_query2scm (q);
   args = scm_cons (scm_q, SCM_EOL);
@@ -29,9 +30,9 @@
   str_q = scm_string_append (args);
 
   str = SCM_STRING_CHARS (str_q);
-
-  if (str) {
-    res_q = scm_c_eval_string (str);
+  if (str) str2 = g_strdup(str);
+  if (str2) {
+    res_q = scm_c_eval_string (str2);
   } else {
     res_q = SCM_BOOL_F;
   }
@@ -41,16 +42,18 @@
   if (!xaccQueryEqual (q, q2))
   {
     failure ("queries don't match");
-    fprintf (stderr, "%s\n\n", str ? str : "(null)");
+    fprintf (stderr, "%s\n\n", str2 ? str2 : "(null)");
     scm_q = gnc_query2scm (q2);
     scm_display (scm_q, SCM_UNDEFINED);
     scm_newline (SCM_UNDEFINED);
+    if (str2) g_free(str2);
     exit (1);
   }
   else
   {
     success ("queries match");
   }
+  if (str2) g_free(str2);
   if (q2) xaccFreeQuery (q2);
 }
 



More information about the gnucash-changes mailing list