[Gnucash-changes] r12330 - gnucash/trunk/src/backend/file - Don't let deprecated tags overwrite data from newer tags.

Chris Shoemaker chris at cvs.gnucash.org
Thu Jan 12 16:26:02 EST 2006


Author: chris
Date: 2006-01-12 16:26:01 -0500 (Thu, 12 Jan 2006)
New Revision: 12330
Trac: http://svn.gnucash.org/trac/changeset/12330

Modified:
   gnucash/trunk/src/backend/file/gnc-account-xml-v2.c
   gnucash/trunk/src/backend/file/test/test-real-data.sh
   gnucash/trunk/src/backend/file/test/test-xml-account.c
Log:
Don't let deprecated tags overwrite data from newer tags.
Avoid testing for match of deprecated tags.
Warn about deprecated tags not being preserved.
Plug another leak in test case.
Make successful test-xml-account less verbose.


Modified: gnucash/trunk/src/backend/file/gnc-account-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-account-xml-v2.c	2006-01-12 21:22:03 UTC (rev 12329)
+++ gnucash/trunk/src/backend/file/gnc-account-xml-v2.c	2006-01-12 21:26:01 UTC (rev 12330)
@@ -276,15 +276,16 @@
 }
 
 /* ============================================================== */
-/* The following depricated routines are here only to service 
+/* The following deprecated routines are here only to service 
  * older XML files. */
 
 static gboolean
-depricated_account_currency_handler (xmlNodePtr node, gpointer act_pdata)
+deprecated_account_currency_handler (xmlNodePtr node, gpointer act_pdata)
 {
     struct account_pdata *pdata = act_pdata;
     gnc_commodity *ref;
 
+    PWARN("Obsolete xml tag will not be preserved."); 
     ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
     DxaccAccountSetCurrency(pdata->account, ref);
 
@@ -292,31 +293,38 @@
 }
 
 static gboolean
-depricated_account_currency_scu_handler (xmlNodePtr node, gpointer act_pdata)
+deprecated_account_currency_scu_handler (xmlNodePtr node, gpointer act_pdata)
 {
+    PWARN("Obsolete xml tag will not be preserved."); 
     return TRUE;
 }
 
 static gboolean
-depricated_account_security_handler (xmlNodePtr node, gpointer act_pdata)
+deprecated_account_security_handler (xmlNodePtr node, gpointer act_pdata)
 {
     struct account_pdata *pdata = act_pdata;
     gnc_commodity *ref;
 
-    ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
-    xaccAccountSetCommodity(pdata->account, ref);
+    PWARN("Obsolete xml tag will not be preserved."); 
+    if (!xaccAccountGetCommodity(pdata->account)) {
+        ref = dom_tree_to_commodity_ref_no_engine(node, pdata->book);
+        xaccAccountSetCommodity(pdata->account, ref);
+    }
 
     return TRUE;
 }
 
 static gboolean
-depricated_account_security_scu_handler (xmlNodePtr node, gpointer act_pdata)
+deprecated_account_security_scu_handler (xmlNodePtr node, gpointer act_pdata)
 {
     struct account_pdata *pdata = act_pdata;
     gint64 val;
 
-    dom_tree_to_integer(node, &val);
-    xaccAccountSetCommoditySCU(pdata->account, val);
+    PWARN("Obsolete xml tag will not be preserved."); 
+    if (!xaccAccountGetCommoditySCU(pdata->account)) {
+        dom_tree_to_integer(node, &val);
+        xaccAccountSetCommoditySCU(pdata->account, val);
+    }
 
     return TRUE;
 }
@@ -418,10 +426,10 @@
     /* These should not appear in  newer xml files; only in old
      * (circa gnucash-1.6) xml files. We maintain them for backward 
      * compatibility. */
-    { act_currency_string, depricated_account_currency_handler, 0, 0 },
-    { act_currency_scu_string, depricated_account_currency_scu_handler, 0, 0 },
-    { act_security_string, depricated_account_security_handler, 0, 0 },
-    { act_security_scu_string, depricated_account_security_scu_handler, 0, 0 },
+    { act_currency_string, deprecated_account_currency_handler, 0, 0 },
+    { act_currency_scu_string, deprecated_account_currency_scu_handler, 0, 0 },
+    { act_security_string, deprecated_account_security_handler, 0, 0 },
+    { act_security_scu_string, deprecated_account_security_scu_handler, 0, 0 },
     { NULL, 0, 0, 0 }
 };
 

Modified: gnucash/trunk/src/backend/file/test/test-real-data.sh
===================================================================
--- gnucash/trunk/src/backend/file/test/test-real-data.sh	2006-01-12 21:22:03 UTC (rev 12329)
+++ gnucash/trunk/src/backend/file/test/test-real-data.sh	2006-01-12 21:26:01 UTC (rev 12330)
@@ -14,8 +14,7 @@
       mkdir $j
       FILES=`perl $SRCDIR/grab-types.pl "gnc:$j" $i "$j/dataXXX.xml"`
       if [ ! -z "$FILES" ] ; then
-        echo "Testing file `basename $i`, section $j"
-        echo "[./test-xml-$j $FILES # from file $i]:"
+        echo "Testing ./test-xml-$j $j/data*.xml # from `basename $i`:"
         eval "./test-xml-$j $FILES"
         if [ $? != 0 ] ; then
           EXIT_VALUE=1

Modified: gnucash/trunk/src/backend/file/test/test-xml-account.c
===================================================================
--- gnucash/trunk/src/backend/file/test/test-xml-account.c	2006-01-12 21:22:03 UTC (rev 12329)
+++ gnucash/trunk/src/backend/file/test/test-xml-account.c	2006-01-12 21:26:01 UTC (rev 12330)
@@ -159,6 +159,10 @@
                 return g_strdup("commodity scus differ");
             }
         }
+        else if (safe_strcmp((char*)mark->name, "act:security") == 0)
+        {
+            return NULL; // This tag is ignored.
+        }
         else
         {
             return g_strdup_printf("unknown node in dom tree: %s", mark->name);
@@ -171,8 +175,6 @@
 static void
 delete_random_account(Account *act)
 {
-    gnc_commodity_destroy(xaccAccountGetCommodity(act));
-
     xaccAccountBeginEdit(act);
     xaccAccountDestroy(act);
 }
@@ -364,7 +366,8 @@
     {
         test_generation();
     }
-        
+    
+    qof_session_destroy(session);        
     print_test_results();
     qof_close();
   return 0;



More information about the gnucash-changes mailing list