Minor cleanups to gnc_counter_end_handler().

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@14026 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Chris Shoemaker 2006-05-12 00:28:34 +00:00
parent eff827a63b
commit e4092bb349

View File

@ -334,18 +334,15 @@ gnc_counter_end_handler(gpointer data_for_children,
xmlNodePtr tree = (xmlNodePtr)data_for_children; xmlNodePtr tree = (xmlNodePtr)data_for_children;
gxpf_data *gdata = (gxpf_data*)global_data; gxpf_data *gdata = (gxpf_data*)global_data;
sixtp_gdv2 *sixdata = (sixtp_gdv2*)gdata->parsedata; sixtp_gdv2 *sixdata = (sixtp_gdv2*)gdata->parsedata;
gboolean ret = TRUE;
if(parent_data) if (parent_data)
{
return TRUE; return TRUE;
}
/* OK. For some messed up reason this is getting called again with a /* OK. For some messed up reason this is getting called again with a
NULL tag. So we ignore those cases */ NULL tag. So we ignore those cases */
if(!tag) if (!tag)
{
return TRUE; return TRUE;
}
g_return_val_if_fail(tree, FALSE); g_return_val_if_fail(tree, FALSE);
@ -355,37 +352,33 @@ gnc_counter_end_handler(gpointer data_for_children,
* tag itself. This should be changed to 'type' at some point. */ * tag itself. This should be changed to 'type' at some point. */
type = (char*)xmlGetProp(tree, BAD_CAST "cd:type"); type = (char*)xmlGetProp(tree, BAD_CAST "cd:type");
strval = dom_tree_to_text(tree); strval = dom_tree_to_text(tree);
if(!string_to_gint64(strval, &val)) if (!string_to_gint64(strval, &val))
{ {
PERR ("string_to_gint64 failed with input: %s", PERR ("string_to_gint64 failed with input: %s",
strval ? strval : "(null)"); strval ? strval : "(null)");
g_free (strval); ret = FALSE;
xmlFree (type);
return FALSE;
} }
g_free (strval); else if (safe_strcmp(type, "transaction") == 0)
if(safe_strcmp(type, "transaction") == 0)
{ {
sixdata->counter.transactions_total = val; sixdata->counter.transactions_total = val;
} }
else if(safe_strcmp(type, "account") == 0) else if (safe_strcmp(type, "account") == 0)
{ {
sixdata->counter.accounts_total = val; sixdata->counter.accounts_total = val;
} }
else if(safe_strcmp(type, "book") == 0) else if (safe_strcmp(type, "book") == 0)
{ {
sixdata->counter.books_total = val; sixdata->counter.books_total = val;
} }
else if(safe_strcmp(type, "commodity") == 0) else if (safe_strcmp(type, "commodity") == 0)
{ {
sixdata->counter.commodities_total = val; sixdata->counter.commodities_total = val;
} }
else if(safe_strcmp(type, "schedxaction") == 0) else if (safe_strcmp(type, "schedxaction") == 0)
{ {
sixdata->counter.schedXactions_total = val; sixdata->counter.schedXactions_total = val;
} }
else if(safe_strcmp(type, "budget") == 0) else if (safe_strcmp(type, "budget") == 0)
{ {
sixdata->counter.budgets_total = val; sixdata->counter.budgets_total = val;
} }
@ -401,21 +394,20 @@ gnc_counter_end_handler(gpointer data_for_children,
if (be_data.ok == FALSE) if (be_data.ok == FALSE)
{ {
PERR("Unknown type: %s", type ? type : "(null)"); PERR("Unknown type: %s", type ? type : "(null)");
xmlFree (type);
/* Do *NOT* flag this as an error. Gnucash 1.8 writes invalid /* Do *NOT* flag this as an error. Gnucash 1.8 writes invalid
* xml by writing the 'cd:type' attribute without providing * xml by writing the 'cd:type' attribute without providing
* the namespace in the gnc:count-data tag. The parser is * the namespace in the gnc:count-data tag. The parser is
* entirely within its rights to refuse to read this bad * entirely within its rights to refuse to read this bad
* attribute. Gnucash will function correctly without the data * attribute. Gnucash will function correctly without the data
* in this tag, so just let the error pass. */ * in this tag, so just let the error pass. */
return TRUE; ret = FALSE;
} }
} }
g_free (strval);
xmlFree (type); xmlFree (type);
xmlFreeNode(tree); xmlFreeNode(tree);
return ret;
return TRUE;
} }
static sixtp* static sixtp*