mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-26 02:40:43 -06:00
James LewisMoss's patch.
* src/test/test-xml-account.c (delete_random_account): new func to cleanup commodities not generally freed at xaccAccountDestroy. (node_and_account_equal): complete func to compare account and the dom tree created. Looks good except for some warnings from dom_tree_to_text. * src/test/test-stuff.c (equals_node_val_vs_commodity): new func. (equals_node_val_vs_guid): New func. (equals_node_val_vs_string): new func. * src/engine/gnc-account-xml-v2.c (account_code_handler): Add func. (account_description_handler): Add func. Oops forgot a couple. (gnc_account_dom_tree_create): Move all string tags in file to const gchar*s. (account_slots_handler): Complete func. * make-gnucash-patch.in: Test to see if makepatch exists. * src/engine/sixtp-dom-parsers.c (dom_tree_to_text): same as below. Add NULL tests for arguments. Affected many functions in this file. * src/engine/gnc-pricedb-xml-v1.c (price_parse_xml_sub_node): Same as below. * src/engine/gnc-commodity-xml-v2.c (set_commodity_value): Convert dom_tree_to_text to act as rest looking at children on it's own. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3718 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
93ba986b30
commit
ce80ff48a2
30
ChangeLog
30
ChangeLog
@ -1,3 +1,33 @@
|
||||
2001-02-28 James LewisMoss <jimdres@mindspring.com>
|
||||
|
||||
* src/test/test-xml-account.c (delete_random_account): new func to
|
||||
cleanup commodities not generally freed at xaccAccountDestroy.
|
||||
(node_and_account_equal): complete func to compare account and the
|
||||
dom tree created. Looks good except for some warnings from
|
||||
dom_tree_to_text.
|
||||
|
||||
* src/test/test-stuff.c (equals_node_val_vs_commodity): new func.
|
||||
(equals_node_val_vs_guid): New func.
|
||||
(equals_node_val_vs_string): new func.
|
||||
|
||||
* src/engine/gnc-account-xml-v2.c (account_code_handler): Add func.
|
||||
(account_description_handler): Add func. Oops forgot a couple.
|
||||
(gnc_account_dom_tree_create): Move all string tags in file to
|
||||
const gchar*s.
|
||||
(account_slots_handler): Complete func.
|
||||
|
||||
* make-gnucash-patch.in: Test to see if makepatch exists.
|
||||
|
||||
* src/engine/sixtp-dom-parsers.c (dom_tree_to_text): same as
|
||||
below. Add NULL tests for arguments. Affected many functions in
|
||||
this file.
|
||||
|
||||
* src/engine/gnc-pricedb-xml-v1.c (price_parse_xml_sub_node): Same
|
||||
as below.
|
||||
|
||||
* src/engine/gnc-commodity-xml-v2.c (set_commodity_value): Convert
|
||||
dom_tree_to_text to act as rest looking at children on it's own.
|
||||
|
||||
2001-02-27 Dave Peticolas <dave@krondo.com>
|
||||
|
||||
* src/register/gnome/gnucash-scrolled-window.c: subclass of
|
||||
|
1
debian/rules
vendored
1
debian/rules
vendored
@ -23,7 +23,6 @@ Makefile: Makefile.in configure
|
||||
--sysconfdir=/etc \
|
||||
--infodir=/usr/share/info \
|
||||
--mandir=/usr/share/man \
|
||||
--enable-efence \
|
||||
--enable-error-on-warnings
|
||||
|
||||
# --enable-profile \
|
||||
|
@ -54,6 +54,28 @@ if($ENV{'GNC_MAKEPATCH_HOME_DIR'}) {
|
||||
$gnc_home = $ENV{'GNC_MAKEPATCH_HOME_DIR'};
|
||||
}
|
||||
|
||||
###########################################################
|
||||
# Make sure makepatch exists before going on #
|
||||
###########################################################
|
||||
|
||||
open(OLDOUT, ">&STDOUT");
|
||||
open(OLDERR, ">&STDERR");
|
||||
open(STDOUT, "> /dev/null") || die "Can't redirect stdout";
|
||||
open(STDERR, "> /dev/null") || die "Can't redirect stderr";
|
||||
my $test = system('makepatch', "-help");
|
||||
close(STDOUT);
|
||||
close(STDERR);
|
||||
open(STDOUT, ">&OLDOUT");
|
||||
open(STDERR, ">&OLDERR");
|
||||
close(OLDOUT);
|
||||
close(OLDERR);
|
||||
|
||||
if($test == -1) {
|
||||
print "No makepatch installed. Exiting\n";
|
||||
exit(10);
|
||||
}
|
||||
|
||||
|
||||
###########################################################
|
||||
# Now, check if anything specified on command line #
|
||||
###########################################################
|
||||
@ -179,6 +201,7 @@ open(STDOUT, "> diffs/$outfilename") || die "Can't redirect stdout";
|
||||
system('makepatch', @args);
|
||||
close(STDOUT);
|
||||
open(STDOUT, ">&OLDOUT");
|
||||
close(OLDOUT);
|
||||
print "makepatch done\n";
|
||||
|
||||
# Compress the patch if required
|
||||
|
@ -21,51 +21,63 @@
|
||||
|
||||
const gchar *account_version_string = "2.0.0";
|
||||
|
||||
/* ids */
|
||||
const char *gnc_account_string = "gnc:account";
|
||||
const char *act_name_string = "act:name";
|
||||
const char *act_id_string = "act:id";
|
||||
const char *act_type_string = "act:type";
|
||||
const char *act_currency_string = "act:currency";
|
||||
const char *act_code_string = "act:code";
|
||||
const char *act_description_string = "act:description";
|
||||
const char *act_security_string = "act:security";
|
||||
const char *act_slots_string = "act:slots";
|
||||
const char *act_parent_string = "act:parent";
|
||||
|
||||
xmlNodePtr
|
||||
gnc_account_dom_tree_create(Account *act)
|
||||
{
|
||||
xmlNodePtr ret;
|
||||
|
||||
ret = xmlNewNode(NULL, "gnc:account");
|
||||
ret = xmlNewNode(NULL, gnc_account_string);
|
||||
xmlSetProp(ret, "version", account_version_string);
|
||||
|
||||
xmlNewChild(ret, NULL, "act:name", xaccAccountGetName(act));
|
||||
xmlNewChild(ret, NULL, act_name_string, xaccAccountGetName(act));
|
||||
|
||||
xmlAddChild(ret, guid_to_dom_tree("act:id", xaccAccountGetGUID(act)));
|
||||
xmlAddChild(ret, guid_to_dom_tree(act_id_string, xaccAccountGetGUID(act)));
|
||||
|
||||
xmlNewChild(ret, NULL, "act:type",
|
||||
xmlNewChild(ret, NULL, act_type_string,
|
||||
xaccAccountTypeEnumAsString(xaccAccountGetType(act)));
|
||||
|
||||
xmlAddChild(ret, commodity_ref_to_dom_tree("act:currency",
|
||||
xmlAddChild(ret, commodity_ref_to_dom_tree(act_currency_string,
|
||||
xaccAccountGetCurrency(act)));
|
||||
|
||||
if(xaccAccountGetCode(act))
|
||||
{
|
||||
xmlNewChild(ret, NULL, "act:code", xaccAccountGetCode(act));
|
||||
xmlNewChild(ret, NULL, act_code_string, xaccAccountGetCode(act));
|
||||
}
|
||||
|
||||
if(xaccAccountGetDescription(act))
|
||||
{
|
||||
xmlNewChild(ret, NULL, "act:description",
|
||||
xmlNewChild(ret, NULL, act_description_string,
|
||||
xaccAccountGetDescription(act));
|
||||
}
|
||||
|
||||
if(xaccAccountGetSecurity(act))
|
||||
{
|
||||
xmlAddChild(ret, commodity_ref_to_dom_tree("act:security",
|
||||
xmlAddChild(ret, commodity_ref_to_dom_tree(act_security_string,
|
||||
xaccAccountGetSecurity(act)));
|
||||
}
|
||||
|
||||
if(xaccAccountGetSlots(act))
|
||||
{
|
||||
xmlAddChild(ret, kvp_frame_to_dom_tree("act:slots",
|
||||
xmlAddChild(ret, kvp_frame_to_dom_tree(act_slots_string,
|
||||
xaccAccountGetSlots(act)));
|
||||
}
|
||||
|
||||
if(xaccAccountGetParentAccount(act))
|
||||
{
|
||||
xmlAddChild(ret, guid_to_dom_tree(
|
||||
"act:parent",
|
||||
act_parent_string,
|
||||
xaccAccountGetGUID(xaccAccountGetParentAccount(act))));
|
||||
}
|
||||
|
||||
@ -76,15 +88,16 @@ gnc_account_dom_tree_create(Account *act)
|
||||
static gboolean
|
||||
account_name_handler (xmlNodePtr node, Account* act)
|
||||
{
|
||||
if(node->content != NULL)
|
||||
{
|
||||
xaccAccountSetName(act, node->xmlChildrenNode->content);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
gchar* txt;
|
||||
|
||||
txt = dom_tree_to_text(node);
|
||||
g_return_val_if_fail(txt, FALSE);
|
||||
|
||||
xaccAccountSetName(act, txt);
|
||||
|
||||
g_free(txt);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -130,7 +143,11 @@ account_security_handler (xmlNodePtr node, Account* act)
|
||||
static gboolean
|
||||
account_slots_handler (xmlNodePtr node, Account* act)
|
||||
{
|
||||
/* return dom_tree_handle_kvp(act->kvp_data, node); */
|
||||
kvp_frame *frm = dom_tree_to_kvp_frame(node);
|
||||
g_return_val_if_fail(frm, FALSE);
|
||||
|
||||
xaccAccountSetSlots_nc(act, frm);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -148,9 +165,41 @@ account_parent_handler (xmlNodePtr node, Account* act)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
account_code_handler(xmlNodePtr node, Account* act)
|
||||
{
|
||||
gchar* txt;
|
||||
|
||||
txt = dom_tree_to_text(node);
|
||||
g_return_val_if_fail(txt, FALSE);
|
||||
|
||||
xaccAccountSetCode(act, txt);
|
||||
|
||||
g_free(txt);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
static gboolean
|
||||
account_description_handler(xmlNodePtr node, Account *act)
|
||||
{
|
||||
gchar* txt;
|
||||
|
||||
txt = dom_tree_to_text(node);
|
||||
g_return_val_if_fail(txt, FALSE);
|
||||
|
||||
xaccAccountSetDescription(act, txt);
|
||||
|
||||
g_free(txt);
|
||||
|
||||
return TRUE;
|
||||
|
||||
}
|
||||
|
||||
struct dom_handlers
|
||||
{
|
||||
char *tag;
|
||||
const char *tag;
|
||||
|
||||
gboolean (*handler) (xmlNodePtr, Account*);
|
||||
|
||||
@ -163,6 +212,8 @@ static struct dom_handlers account_handlers_v2[] = {
|
||||
{ "act:id", account_id_handler, 1, 0 },
|
||||
{ "act:type", account_type_handler, 1, 0 },
|
||||
{ "act:currency", account_currency_handler, 1, 0 },
|
||||
{ "act:code", account_code_handler, 1, 0 },
|
||||
{ "act:description", account_description_handler, 1, 0},
|
||||
{ "act:security", account_security_handler, 0, 0 },
|
||||
{ "act:slots", account_slots_handler, 0, 0 },
|
||||
{ "act:parent", account_parent_handler, 0, 0 },
|
||||
|
@ -103,7 +103,7 @@ set_commodity_value(xmlNodePtr node, gnc_commodity* com)
|
||||
{
|
||||
if(safe_strcmp(mark->tag, node->name))
|
||||
{
|
||||
gchar* val = dom_tree_to_text(node->xmlChildrenNode);
|
||||
gchar* val = dom_tree_to_text(node);
|
||||
(mark->func)(com, val);
|
||||
g_free(val);
|
||||
break;
|
||||
|
@ -78,12 +78,12 @@ price_parse_xml_sub_node(GNCPrice *p, xmlNodePtr sub_node)
|
||||
gnc_price_set_time(p, t);
|
||||
g_free(t);
|
||||
} else if(safe_strcmp("price:source", sub_node->name) == 0) {
|
||||
char *text = dom_tree_to_text(sub_node->xmlChildrenNode);
|
||||
char *text = dom_tree_to_text(sub_node);
|
||||
if(!text) return FALSE;
|
||||
gnc_price_set_source(p, text);
|
||||
g_free(text);
|
||||
} else if(safe_strcmp("price:type", sub_node->name) == 0) {
|
||||
char *text = dom_tree_to_text(sub_node->xmlChildrenNode);
|
||||
char *text = dom_tree_to_text(sub_node);
|
||||
if(!text) return FALSE;
|
||||
gnc_price_set_type(p, text);
|
||||
g_free(text);
|
||||
|
@ -58,7 +58,7 @@ dom_tree_to_integer_kvp_value(xmlNodePtr node)
|
||||
gint64 daint;
|
||||
kvp_value* ret = NULL;
|
||||
|
||||
text = dom_tree_to_text(node->xmlChildrenNode);
|
||||
text = dom_tree_to_text(node);
|
||||
|
||||
if(string_to_gint64(text, &daint))
|
||||
{
|
||||
@ -74,7 +74,7 @@ dom_tree_to_integer(xmlNodePtr node, gint64 *daint)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
text = dom_tree_to_text(node->xmlChildrenNode);
|
||||
text = dom_tree_to_text(node);
|
||||
|
||||
if(string_to_gint64(text, daint))
|
||||
{
|
||||
@ -93,7 +93,7 @@ dom_tree_to_double_kvp_value(xmlNodePtr node)
|
||||
double dadoub;
|
||||
kvp_value *ret = NULL;
|
||||
|
||||
text = dom_tree_to_text(node->xmlChildrenNode);
|
||||
text = dom_tree_to_text(node);
|
||||
|
||||
if(string_to_double(text, &dadoub))
|
||||
{
|
||||
@ -129,7 +129,7 @@ dom_tree_to_string_kvp_value(xmlNodePtr node)
|
||||
gchar *datext;
|
||||
kvp_value *ret = NULL;
|
||||
|
||||
datext = dom_tree_to_text(node->xmlChildrenNode);
|
||||
datext = dom_tree_to_text(node);
|
||||
if(datext)
|
||||
{
|
||||
ret = kvp_value_new_string(datext);
|
||||
@ -203,7 +203,7 @@ dom_tree_to_binary_kvp_value(xmlNodePtr node)
|
||||
guint64 len;
|
||||
kvp_value *ret = NULL;
|
||||
|
||||
text = dom_tree_to_text(node->xmlChildrenNode);
|
||||
text = dom_tree_to_text(node);
|
||||
|
||||
if(string_to_binary(text, &val, &len))
|
||||
{
|
||||
@ -334,7 +334,7 @@ dom_tree_to_kvp_frame(xmlNodePtr node)
|
||||
{
|
||||
if(safe_strcmp(mark2->name, "slot:key") == 0)
|
||||
{
|
||||
key = dom_tree_to_text(mark2->xmlChildrenNode);
|
||||
key = dom_tree_to_text(mark2);
|
||||
}
|
||||
else if(safe_strcmp(mark2->name, "slot:value") == 0)
|
||||
{
|
||||
@ -382,10 +382,15 @@ dom_tree_to_text(xmlNodePtr tree)
|
||||
|
||||
gboolean ok = TRUE;
|
||||
xmlNodePtr current;
|
||||
gchar *result = g_strdup("");
|
||||
gchar *result;
|
||||
gchar *temp;
|
||||
|
||||
for(current = tree; current; current = current->next) {
|
||||
g_return_val_if_fail(tree, NULL);
|
||||
g_return_val_if_fail(tree->xmlChildrenNode, NULL);
|
||||
|
||||
result = g_strdup("");
|
||||
|
||||
for(current = tree->xmlChildrenNode; current; current = current->next) {
|
||||
switch(current->type) {
|
||||
case XML_TEXT_NODE:
|
||||
temp = g_strconcat(result, (gchar *) current->content, NULL);
|
||||
@ -414,7 +419,7 @@ dom_tree_to_text(xmlNodePtr tree)
|
||||
gnc_numeric*
|
||||
dom_tree_to_gnc_numeric(xmlNodePtr node)
|
||||
{
|
||||
gchar *content = dom_tree_to_text(node->xmlChildrenNode);
|
||||
gchar *content = dom_tree_to_text(node);
|
||||
gnc_numeric *ret;
|
||||
if(!content)
|
||||
return NULL;
|
||||
@ -479,7 +484,7 @@ dom_tree_to_timespec(xmlNodePtr node)
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *content = dom_tree_to_text(n->xmlChildrenNode);
|
||||
gchar *content = dom_tree_to_text(n);
|
||||
if(!content)
|
||||
{
|
||||
return timespec_failure(ret);
|
||||
@ -500,7 +505,7 @@ dom_tree_to_timespec(xmlNodePtr node)
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar *content = dom_tree_to_text(n->xmlChildrenNode);
|
||||
gchar *content = dom_tree_to_text(n);
|
||||
if(!content)
|
||||
{
|
||||
return timespec_failure(ret);
|
||||
@ -561,7 +566,7 @@ dom_tree_to_commodity_ref_no_engine(xmlNodePtr node)
|
||||
if(space_str) {
|
||||
return NULL;
|
||||
} else {
|
||||
gchar *content = dom_tree_to_text(n->xmlChildrenNode);
|
||||
gchar *content = dom_tree_to_text(n);
|
||||
if(!content) return NULL;
|
||||
space_str = content;
|
||||
}
|
||||
@ -569,7 +574,7 @@ dom_tree_to_commodity_ref_no_engine(xmlNodePtr node)
|
||||
if(id_str) {
|
||||
return NULL;
|
||||
} else {
|
||||
gchar *content = dom_tree_to_text(n->xmlChildrenNode);
|
||||
gchar *content = dom_tree_to_text(n);
|
||||
if(!content) return NULL;
|
||||
id_str = content;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user