diff --git a/src/backend/file/gnc-account-xml-v2.c b/src/backend/file/gnc-account-xml-v2.c index 821024474a..19eaeebfc5 100644 --- a/src/backend/file/gnc-account-xml-v2.c +++ b/src/backend/file/gnc-account-xml-v2.c @@ -276,15 +276,16 @@ account_non_standard_scu_handler (xmlNodePtr node, gpointer act_pdata) } /* ============================================================== */ -/* 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 @@ depricated_account_currency_handler (xmlNodePtr node, gpointer act_pdata) } 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 @@ static struct dom_tree_handler account_handlers_v2[] = { /* 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 } }; diff --git a/src/backend/file/test/test-real-data.sh b/src/backend/file/test/test-real-data.sh index a5d8c9eaf4..d9104f5f3d 100755 --- a/src/backend/file/test/test-real-data.sh +++ b/src/backend/file/test/test-real-data.sh @@ -14,8 +14,7 @@ for i in $SRCDIR/test-files/xml2/*.gml2 ; do 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 diff --git a/src/backend/file/test/test-xml-account.c b/src/backend/file/test/test-xml-account.c index 5b9eaf96f3..5d68c10777 100644 --- a/src/backend/file/test/test-xml-account.c +++ b/src/backend/file/test/test-xml-account.c @@ -159,6 +159,10 @@ node_and_account_equal(xmlNodePtr node, Account *act) 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 @@ node_and_account_equal(xmlNodePtr node, Account *act) static void delete_random_account(Account *act) { - gnc_commodity_destroy(xaccAccountGetCommodity(act)); - xaccAccountBeginEdit(act); xaccAccountDestroy(act); } @@ -364,7 +366,8 @@ main (int argc, char ** argv) { test_generation(); } - + + qof_session_destroy(session); print_test_results(); qof_close(); return 0;