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.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@12330 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2006-01-12 21:26:01 +00:00
parent 7452d320be
commit 7c04d41562
3 changed files with 28 additions and 18 deletions

View File

@ -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 }
};

View File

@ -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

View File

@ -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;