From 6ee471aee868ed6a1bd44541e2bb03205029104a Mon Sep 17 00:00:00 2001 From: Joshua Sled Date: Sat, 30 Jun 2007 13:36:02 +0000 Subject: [PATCH] Fix bad writing of invalid FreqSpec, then disable writing FreqSpecs altogether. :p git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@16233 57a11ea4-9604-0410-9ed3-97b8803252fd --- src/backend/file/gnc-freqspec-xml-v2.c | 40 +++++++++++++--------- src/backend/file/gnc-schedxaction-xml-v2.c | 21 +++++++----- src/doc/sx.rst | 2 ++ 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/src/backend/file/gnc-freqspec-xml-v2.c b/src/backend/file/gnc-freqspec-xml-v2.c index 3b5861e821..8c4aae68ec 100644 --- a/src/backend/file/gnc-freqspec-xml-v2.c +++ b/src/backend/file/gnc-freqspec-xml-v2.c @@ -174,29 +174,37 @@ gnc_freqSpec_dom_tree_create( FreqSpec *fs ) case INVALID: { xmlSub = xmlNewNode( NULL, BAD_CAST "fs:none" ); + xmlAddChild( ret, xmlSub ); } break; case ONCE: { - xmlSub = xmlNewNode( NULL, BAD_CAST "fs:once" ); - xmlAddChild( xmlSub, - gdate_to_dom_tree( "fs:date", - &fs->s.once.date ) ); + if (!g_date_valid(&fs->s.once.date)) + { + xmlSub = xmlNewNode(NULL, BAD_CAST "fs:none"); + } + else + { + xmlSub = xmlNewNode( NULL, BAD_CAST "fs:once" ); + xmlAddChild( xmlSub, + gdate_to_dom_tree( "fs:date", + &fs->s.once.date ) ); + } xmlAddChild( ret, xmlSub ); } break; case DAILY: { - xmlSub = xmlNewNode( NULL, BAD_CAST "fs:daily" ); - xmlAddChild( xmlSub, - guint_to_dom_tree( - "fs:interval", - fs->s.daily.interval_days ) - ); - xmlAddChild( xmlSub, - guint_to_dom_tree( - "fs:offset", - fs->s.daily.offset_from_epoch ) - ); - xmlAddChild( ret, xmlSub ); + xmlSub = xmlNewNode( NULL, BAD_CAST "fs:daily" ); + xmlAddChild( xmlSub, + guint_to_dom_tree( + "fs:interval", + fs->s.daily.interval_days ) + ); + xmlAddChild( xmlSub, + guint_to_dom_tree( + "fs:offset", + fs->s.daily.offset_from_epoch ) + ); + xmlAddChild( ret, xmlSub ); } break; case WEEKLY: { diff --git a/src/backend/file/gnc-schedxaction-xml-v2.c b/src/backend/file/gnc-schedxaction-xml-v2.c index c9e668f75e..c5cecfb0e1 100644 --- a/src/backend/file/gnc-schedxaction-xml-v2.c +++ b/src/backend/file/gnc-schedxaction-xml-v2.c @@ -155,14 +155,14 @@ gnc_schedXaction_dom_tree_create(SchedXaction *sx) GDate *date; gint instCount; const GUID *templ_acc_guid; - gboolean allow_incompat = TRUE; + gboolean allow_2_2_incompat = TRUE; templ_acc_guid = xaccAccountGetGUID(sx->template_acct); /* FIXME: this should be the same as the def in io-gncxml-v2.c */ ret = xmlNewNode( NULL, BAD_CAST GNC_SCHEDXACTION_TAG ); - if (allow_incompat) + if (allow_2_2_incompat) xmlSetProp(ret, BAD_CAST "version", BAD_CAST schedxaction_version2_string); else xmlSetProp(ret, BAD_CAST "version", BAD_CAST schedxaction_version_string); @@ -173,7 +173,7 @@ gnc_schedXaction_dom_tree_create(SchedXaction *sx) xmlNewTextChild( ret, NULL, BAD_CAST SX_NAME, BAD_CAST xaccSchedXactionGetName(sx) ); - if (allow_incompat) + if (allow_2_2_incompat) { xmlNewTextChild( ret, NULL, BAD_CAST SX_ENABLED, BAD_CAST ( sx->enabled ? "y" : "n" ) ); @@ -219,14 +219,17 @@ gnc_schedXaction_dom_tree_create(SchedXaction *sx) guid_to_dom_tree(SX_TEMPL_ACCT, templ_acc_guid)); - /* output freq spec */ - fsNode = xmlNewNode(NULL, BAD_CAST SX_FREQSPEC); - xmlAddChild( fsNode, - gnc_freqSpec_dom_tree_create( + if (!allow_2_2_incompat) + { + /* output freq spec */ + fsNode = xmlNewNode(NULL, BAD_CAST SX_FREQSPEC); + xmlAddChild( fsNode, + gnc_freqSpec_dom_tree_create( xaccSchedXactionGetFreqSpec(sx)) ); - xmlAddChild( ret, fsNode ); + xmlAddChild( ret, fsNode ); + } - if (allow_incompat) + if (allow_2_2_incompat) { xmlNodePtr schedule_node = xmlNewNode(NULL, "sx:schedule"); GList *schedule = gnc_sx_get_schedule(sx); diff --git a/src/doc/sx.rst b/src/doc/sx.rst index 1cb2ac0084..a4dfb613cb 100644 --- a/src/doc/sx.rst +++ b/src/doc/sx.rst @@ -220,6 +220,8 @@ TODO - [ ] remove FreqSpec code + - [x] don't write FreqSpecs out. + - [ ] SX code - [ ] engine