Allow elements out of context in GOM.
[gedcom-parse.git] / gom / user_rec.c
index a685f3def47c8f4bdaa7d2da41d918429e16dac8..9531cf144f58fd4cc28a34224c587daf53e81dec 100644 (file)
@@ -181,7 +181,7 @@ Gedcom_ctxt user_elt_start(_ELT_PARAMS_)
        data->xref_value = GEDCOM_XREF_PTR(parsed_value);
 
       if (! err) {
-       switch (ctxt->obj_type) {
+       switch (ctxt_obj_type(ctxt)) {
          case T_header:
            ADDFUNC2(header,user_data)(ctxt, data); break;
          case T_submission:
@@ -231,9 +231,9 @@ Gedcom_ctxt user_elt_start(_ELT_PARAMS_)
          case T_source_description:
            ADDFUNC2(source_description,user_data)(ctxt, data); break;
          default:
-           UNEXPECTED_CONTEXT(ctxt->ctxt_type);
+           UNEXPECTED_CONTEXT(ctxt_type(ctxt));
        }
-       result = make_gom_ctxt(elt, ctxt->obj_type, ctxt->ctxt_ptr);
+       result = dup_gom_ctxt(ctxt, elt);
       }
     }
   }
@@ -241,6 +241,12 @@ Gedcom_ctxt user_elt_start(_ELT_PARAMS_)
   return (Gedcom_ctxt)result;
 }
 
+DEFINE_SUB_MAKEFUNC(user_data)
+DEFINE_SUB_ADDFUNC(user_data)
+DEFINE_SUB_FINDFUNC(user_data)
+DEFINE_SUB_REMOVEFUNC(user_data)
+DEFINE_SUB_MOVEFUNC(user_data)
+     
 void user_rec_subscribe()
 {
   gedcom_subscribe_to_record(REC_USER, user_rec_start, def_rec_end);
@@ -317,13 +323,14 @@ int write_user_data(Gedcom_write_hndl hndl, struct user_data* data)
 
   if (!data) return 1;
 
-  for (obj = data; data; data = data->next) {
+  for (obj = data; obj; obj = obj->next) {
     if (obj->xref_value)
       result |= gedcom_write_user_xref(hndl, obj->level, obj->tag, NULL,
                                       obj->xref_value);
-    else
+    else {
       result |= gedcom_write_user_str(hndl, obj->level, obj->tag, NULL,
                                      obj->str_value);
+    }
   }
   return result;
 }