r16233 - gnucash/trunk/src - Fix bad writing of invalid FreqSpec, then disable writing FreqSpecs altogether. :p

Josh Sled jsled at cvs.gnucash.org
Sat Jun 30 09:36:02 EDT 2007


Author: jsled
Date: 2007-06-30 09:36:02 -0400 (Sat, 30 Jun 2007)
New Revision: 16233
Trac: http://svn.gnucash.org/trac/changeset/16233

Modified:
   gnucash/trunk/src/backend/file/gnc-freqspec-xml-v2.c
   gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c
   gnucash/trunk/src/doc/sx.rst
Log:
Fix bad writing of invalid FreqSpec, then disable writing FreqSpecs altogether. :p


Modified: gnucash/trunk/src/backend/file/gnc-freqspec-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-freqspec-xml-v2.c	2007-06-30 13:32:58 UTC (rev 16232)
+++ gnucash/trunk/src/backend/file/gnc-freqspec-xml-v2.c	2007-06-30 13:36:02 UTC (rev 16233)
@@ -174,29 +174,37 @@
 
         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: {

Modified: gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c
===================================================================
--- gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c	2007-06-30 13:32:58 UTC (rev 16232)
+++ gnucash/trunk/src/backend/file/gnc-schedxaction-xml-v2.c	2007-06-30 13:36:02 UTC (rev 16233)
@@ -155,14 +155,14 @@
     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 @@
 
     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 @@
 		 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);

Modified: gnucash/trunk/src/doc/sx.rst
===================================================================
--- gnucash/trunk/src/doc/sx.rst	2007-06-30 13:32:58 UTC (rev 16232)
+++ gnucash/trunk/src/doc/sx.rst	2007-06-30 13:36:02 UTC (rev 16233)
@@ -220,6 +220,8 @@
 
   - [ ] remove FreqSpec code
 
+    - [x] don't write FreqSpecs out.
+
     - [ ] SX code
 
       - [ ] engine



More information about the gnucash-changes mailing list