Don't lose the HEAD.TIME section of Lifelines.
authorPeter Verthez <Peter.Verthez@advalvas.be>
Tue, 28 Jan 2003 17:33:18 +0000 (17:33 +0000)
committerPeter Verthez <Peter.Verthez@advalvas.be>
Tue, 28 Jan 2003 17:33:18 +0000 (17:33 +0000)
gedcom/compat.c
gedcom/compat.h

index 196113ffe1b576dd59ba476cb0ce3d22a42c02a1..15f6b06d1190a3f445650c0cac5e49e8c2e6332d 100644 (file)
@@ -135,7 +135,10 @@ int compat_matrix[] =
   /* C_TAB_CHARACTER */       C_PAF5
 };
 
-int compat_state[C_NR_OF_RULES];
+union _COMPAT_STATE {
+  int i;
+  void* vp;
+} compat_state[C_NR_OF_RULES];
 
 /* Compatibility handling */
 
@@ -200,7 +203,7 @@ void compute_compatibility()
   default_charset = "";
   compatibility = 0;
   for (i = 0; i < C_NR_OF_RULES; i++)
-    compat_state[i] = 0;
+    compat_state[i].i = 0;
 
   switch (compatibility_program) {
     case CP_PAF:
@@ -266,12 +269,12 @@ void compat_generate_submitter_link(Gedcom_ctxt parent)
                       parent, 1, ts, SUBMITTER_LINK,
                       GEDCOM_MAKE_XREF_PTR(val1, xr));
   end_element(ELT_HEAD_SUBM, parent, self, NULL);
-  compat_state[C_NO_SUBMITTER] = 1;
+  compat_state[C_NO_SUBMITTER].i = 1;
 }
 
 void compat_generate_submitter()
 {
-  if (compat_state[C_NO_SUBMITTER]) {
+  if (compat_state[C_NO_SUBMITTER].i) {
     struct xref_value *xr = gedcom_parse_xref(SUBMITTER_LINK, XREF_DEFINED,
                                              XREF_SUBM);
     struct tag_struct ts;
@@ -294,7 +297,7 @@ void compat_generate_submitter()
     
     /* close "0 SUBM" */
     end_record(REC_SUBM, self1, NULL);
-    compat_state[C_NO_SUBMITTER] = 0;
+    compat_state[C_NO_SUBMITTER].i = 0;
   }
 }
 
@@ -383,6 +386,37 @@ int compat_generate_char(Gedcom_ctxt parent)
     return 0;
 }
 
+/********************************************************************/
+/*  C_HEAD_TIME                                                     */
+/********************************************************************/
+
+void compat_save_head_date_context(Gedcom_ctxt parent)
+{
+  compat_state[C_HEAD_TIME].vp = parent;
+}
+
+Gedcom_ctxt compat_generate_head_time_start(int level, struct tag_struct ts,
+                                           char* value)
+{
+  Gedcom_ctxt parent = compat_state[C_HEAD_TIME].vp;
+  if (!value)
+    value = "-";
+  if (parent)
+    return start_element(ELT_HEAD_DATE_TIME,
+                        parent, level, ts, value,
+                        GEDCOM_MAKE_STRING(val1, value));
+  else
+    return NULL;
+}
+
+void compat_generate_head_time_end(Gedcom_ctxt self)
+{
+  Gedcom_ctxt parent = compat_state[C_HEAD_TIME].vp;
+  if (parent)
+    end_element(ELT_HEAD_DATE_TIME,
+               parent, self, GEDCOM_MAKE_NULL(val1));
+}
+
 /********************************************************************/
 /*  C_INDI_ADDR                                                     */
 /********************************************************************/
@@ -453,13 +487,13 @@ void compat_generate_slgc_famc_link(Gedcom_ctxt parent)
                       parent, 2, ts, SLGC_FAMC_LINK,
                       GEDCOM_MAKE_XREF_PTR(val1, xr));
   end_element(ELT_SUB_LIO_SLGC_FAMC, parent, self, NULL);
-  compat_state[C_NO_SLGC_FAMC]++;
+  compat_state[C_NO_SLGC_FAMC].i++;
 }
 
 void compat_generate_slgc_famc_fam()
 {
   /* If bigger than 1, then the FAM record has already been generated */
-  if (compat_state[C_NO_SLGC_FAMC] == 1) {
+  if (compat_state[C_NO_SLGC_FAMC].i == 1) {
     struct xref_value *xr = gedcom_parse_xref(SLGC_FAMC_LINK, XREF_DEFINED,
                                              XREF_FAM);
     struct tag_struct ts;
@@ -489,7 +523,7 @@ int compat_check_subm_comm(const char* tag, const char* parent_tag,
     safe_buf_append(b, tag);
     gedcom_warning(_("Converting non-standard tag '%s' to user tag '%s'"),
                   tag, get_buf_string(b));
-    compat_state[C_SUBM_COMM] = 1;
+    compat_state[C_SUBM_COMM].i = 1;
     return 1;
   }
   else
@@ -498,13 +532,13 @@ int compat_check_subm_comm(const char* tag, const char* parent_tag,
 
 void compat_close_subm_comm()
 {
-  compat_state[C_SUBM_COMM] = 0;
+  compat_state[C_SUBM_COMM].i = 0;
 }
 
 int compat_check_subm_comm_cont(const char* tag)
 {
-  if (compat_state[C_SUBM_COMM] && !strcmp(tag, "CONT")) {
-    compat_state[C_SUBM_COMM] = 2;
+  if (compat_state[C_SUBM_COMM].i && !strcmp(tag, "CONT")) {
+    compat_state[C_SUBM_COMM].i = 2;
     return 1;
   }
   else
@@ -516,7 +550,7 @@ Gedcom_ctxt compat_subm_comm_cont_start(Gedcom_ctxt parent, char* str)
   Gedcom_ctxt self = NULL;
   struct tag_struct ts;
 
-  if (compat_state[C_SUBM_COMM] == 2) {
+  if (compat_state[C_SUBM_COMM].i == 2) {
     ts.string = "_CONT";
     ts.value  = USERTAG;
     self = start_element(ELT_USER, parent, 2, ts, str, &val2);
@@ -527,8 +561,8 @@ Gedcom_ctxt compat_subm_comm_cont_start(Gedcom_ctxt parent, char* str)
 
 void compat_subm_comm_cont_end(Gedcom_ctxt parent, Gedcom_ctxt self)
 {
-  if (compat_state[C_SUBM_COMM] == 2) {
+  if (compat_state[C_SUBM_COMM].i == 2) {
     end_element(ELT_USER, parent, self, NULL);
-    compat_state[C_SUBM_COMM] = 1;
+    compat_state[C_SUBM_COMM].i = 1;
   }
 }
index 1d598228f2af73391ee20a161b490d60d8cace94..a8c2a071ce13cd432d218ee5fa52cc8219fa1408 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "buffer.h"
 #include "gedcom.h"
+#include "gedcom_internal.h"
 
 typedef enum _COMPAT_RULES {
   C_NO_SUBMITTER,
@@ -52,22 +53,35 @@ void set_compatibility_version(const char* version);
 void compute_compatibility();
 int  compat_mode(Compat_rule rule);
 
+/* C_NO_SUBMITTER */
 void compat_generate_submitter_link(Gedcom_ctxt parent);
 void compat_generate_submitter();
 
+/* C_NO_GEDC, C_NO_GEDC_FORM */
 void compat_generate_gedcom(Gedcom_ctxt parent);
 void compat_generate_gedcom_form(Gedcom_ctxt parent);
 
+/* C_NO_CHAR */
 int  compat_generate_char(Gedcom_ctxt parent);
 
+/* C_HEAD_TIME */
+void compat_save_head_date_context(Gedcom_ctxt parent);
+Gedcom_ctxt compat_generate_head_time_start(int level, struct tag_struct ts,
+                                           char* value);
+void compat_generate_head_time_end(Gedcom_ctxt self);
+
+/* C_INDI_ATTR */
 Gedcom_ctxt compat_generate_resi_start(Gedcom_ctxt parent);
 void compat_generate_resi_end(Gedcom_ctxt parent, Gedcom_ctxt self);
 
+/* C_551_TAGS */
 int  compat_check_551_tag(const char* tag, struct safe_buffer* b);
 
+/* C_NO_SLGC_FAMC */
 void compat_generate_slgc_famc_link(Gedcom_ctxt parent);
 void compat_generate_slgc_famc_fam();
 
+/* C_SUBM_COMM */
 int  compat_check_subm_comm(const char* tag, const char* parent_tag,
                            struct safe_buffer* b);
 void compat_close_subm_comm();