From a88197d809cb9c3a4e60796cb231b4d7e1581dda Mon Sep 17 00:00:00 2001 From: Dave Peticolas Date: Tue, 26 Jun 2001 21:43:15 +0000 Subject: [PATCH] 2001-06-26 Dave Peticolas * src/engine/sixtp-dom-parsers.c: same as below * src/engine/gnc-commodity-xml-v2.c: same as below * src/engine/gnc-account-xml-v2.c: don't use node content member directly -- if libxml was configured to use buffers, this won't work. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@4812 57a11ea4-9604-0410-9ed3-97b8803252fd --- ChangeLog | 8 +++++ src/engine/gnc-account-xml-v2.c | 7 ++++- src/engine/gnc-commodity-xml-v2.c | 6 +++- src/engine/sixtp-dom-parsers.c | 49 ++++++++++--------------------- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/ChangeLog b/ChangeLog index 32438ceb7f..cb638e915d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2001-06-26 Dave Peticolas + * src/engine/sixtp-dom-parsers.c: same as below + + * src/engine/gnc-commodity-xml-v2.c: same as below + + * src/engine/gnc-account-xml-v2.c: don't use node content member + directly -- if libxml was configured to use buffers, this won't + work. + * src/register/gnome/gnucash-sheet.c (gnucash_sheet_key_press_event): allow shift-pgup and shift-pgdn to go to top & bottom of register respectively. diff --git a/src/engine/gnc-account-xml-v2.c b/src/engine/gnc-account-xml-v2.c index 5567c5e9e8..1378255a1e 100644 --- a/src/engine/gnc-account-xml-v2.c +++ b/src/engine/gnc-account-xml-v2.c @@ -163,9 +163,14 @@ static gboolean account_type_handler (xmlNodePtr node, gpointer act) { int type; + char *string; + + string = xmlNodeGetContent (node->xmlChildrenNode); + xaccAccountStringToType(string, &type); + xmlFree (string); - xaccAccountStringToType(node->xmlChildrenNode->content, &type); xaccAccountSetType((Account*)act, type); + return TRUE; } diff --git a/src/engine/gnc-commodity-xml-v2.c b/src/engine/gnc-commodity-xml-v2.c index 9a5613c84c..664ffa3fb6 100644 --- a/src/engine/gnc-commodity-xml-v2.c +++ b/src/engine/gnc-commodity-xml-v2.c @@ -103,10 +103,14 @@ set_commodity_value(xmlNodePtr node, gnc_commodity* com) if(safe_strcmp(node->name, "cmdty:fraction") == 0) { gint64 val; - if(string_to_gint64(node->xmlChildrenNode->content, &val)) + char *string; + + string = xmlNodeGetContent (node->xmlChildrenNode); + if(string_to_gint64(string, &val)) { gnc_commodity_set_fraction(com, val); } + xmlFree (string); } else { diff --git a/src/engine/sixtp-dom-parsers.c b/src/engine/sixtp-dom-parsers.c index 97d35b706c..7763a98a40 100644 --- a/src/engine/sixtp-dom-parsers.c +++ b/src/engine/sixtp-dom-parsers.c @@ -54,12 +54,20 @@ dom_tree_to_guid(xmlNodePtr node) } { - char *type = node->properties->xmlAttrPropertyValue->content; + char *type; + + type = xmlNodeGetContent (node->properties->xmlAttrPropertyValue); + /* handle new and guid the same for the moment */ if((safe_strcmp("guid", type) == 0) || (safe_strcmp("new", type) == 0)) { GUID *gid = g_new(GUID, 1); - string_to_guid(node->xmlChildrenNode->content, gid); + char *guid_str; + + guid_str = xmlNodeGetContent (node->xmlChildrenNode); + string_to_guid(guid_str, gid); + xmlFree (guid_str); + xmlFree (type); return gid; } else @@ -68,6 +76,7 @@ dom_tree_to_guid(xmlNodePtr node) type ? type : "(null)", node->properties->name ? (char *) node->properties->name : "(null)"); + xmlFree (type); return NULL; } } @@ -403,10 +412,7 @@ dom_tree_to_text(xmlNodePtr tree) Ignores comment nodes and collapse text nodes into one string. Returns NULL if expectations are unsatisfied. - - If there are a lot of text sub-nodes, this algorithm may be - inefficient as it will reallocate a lot. */ - + */ gboolean ok = TRUE; xmlNodePtr current; gchar *result; @@ -419,34 +425,11 @@ dom_tree_to_text(xmlNodePtr tree) return g_strdup(""); } + temp = xmlNodeListGetString (NULL, tree->xmlChildrenNode, TRUE); + if (!temp) return 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); - g_free(result); - result = temp; - break; - case XML_COMMENT_NODE: - break; - default: - PERR("dom_tree_to_text: hit illegal node while extracting text."); - PERR(" (name %s) (type %d) (content %s)", - current->name ? (char *) current->name : "(null)", - current->type, - current->content ? (char *) current->content : "(null)"); - current = NULL; - ok = FALSE; - break; - }; - } - - if(!ok) { - if(result) g_free(result); - result = NULL; - } + result = g_strdup (temp); + xmlFree (temp); return result; }