X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gom%2Fnote_sub.c;h=221dcfcf2a2f7b14ed41f8f79de976a5b389932a;hb=5b045164f4a11b1f4d709820e784e1ca77b61b3f;hp=bdfb1e692e1d4891593e1a64e1beea8f4eedc3ec;hpb=4c445928c8f7d30731a66522ffb9747fe13a3243;p=gedcom-parse.git diff --git a/gom/note_sub.c b/gom/note_sub.c index bdfb1e6..221dcfc 100644 --- a/gom/note_sub.c +++ b/gom/note_sub.c @@ -56,77 +56,85 @@ Gedcom_ctxt sub_note_start(_ELT_PARAMS_) if (! note) MEMORY_ERROR; else { - int err = 0; memset (note, 0, sizeof(struct note_sub)); - if (GEDCOM_IS_STRING(parsed_value)) { - note->text = strdup(GEDCOM_STRING(parsed_value)); - if (! note->text) { - MEMORY_ERROR; - free(note); - err = 1; - } - } - else if (GEDCOM_IS_XREF_PTR(parsed_value)) + if (GEDCOM_IS_XREF_PTR(parsed_value)) note->reference = GEDCOM_XREF_PTR(parsed_value); - if (! err) { - switch (ctxt->ctxt_type) { - case ELT_SUB_PLAC: - place_add_note(ctxt, note); break; - case ELT_SUB_FAM_EVT: - case ELT_SUB_FAM_EVT_EVEN: - case ELT_SUB_INDIV_ATTR: - case ELT_SUB_INDIV_RESI: - case ELT_SUB_INDIV_BIRT: - case ELT_SUB_INDIV_GEN: - case ELT_SUB_INDIV_ADOP: - case ELT_SUB_INDIV_EVEN: - event_add_note(ctxt, note); break; - case ELT_SUB_SOUR: - citation_add_note(ctxt, note); break; - case ELT_SUB_MULTIM_OBJE: - multimedia_link_add_note(ctxt, note); break; - case ELT_SUB_LSS_SLGS: - case ELT_SUB_LIO_BAPL: - case ELT_SUB_LIO_SLGC: - lds_event_add_note(ctxt, note); break; - case REC_FAM: - family_add_note(ctxt, note); break; - case ELT_SUB_CHAN: - change_date_add_note(ctxt, note); break; - case ELT_SUB_PERS_NAME: - name_add_note(ctxt, note); break; - case ELT_SUB_FAMC: - case ELT_SUB_FAMS: - family_link_add_note(ctxt, note); break; - case ELT_SUB_ASSO: - association_add_note(ctxt, note); break; - case REC_INDI: - individual_add_note(ctxt, note); break; - case REC_OBJE: - multimedia_add_note(ctxt, note); break; - case REC_REPO: - repository_add_note(ctxt, note); break; - case ELT_SOUR_DATA: - source_add_note_to_data(ctxt, note); break; - case ELT_SUB_REPO: - source_add_note_to_repo(ctxt, note); break; - case REC_SOUR: - source_add_note(ctxt, note); break; - default: - UNEXPECTED_CONTEXT(ctxt->ctxt_type); - } - result = MAKE_GOM_CTXT(elt, note_sub, note); + switch (ctxt->ctxt_type) { + case ELT_SUB_PLAC: + place_add_note(ctxt, note); break; + case ELT_SUB_FAM_EVT: + case ELT_SUB_FAM_EVT_EVEN: + case ELT_SUB_INDIV_ATTR: + case ELT_SUB_INDIV_RESI: + case ELT_SUB_INDIV_BIRT: + case ELT_SUB_INDIV_GEN: + case ELT_SUB_INDIV_ADOP: + case ELT_SUB_INDIV_EVEN: + event_add_note(ctxt, note); break; + case ELT_SUB_SOUR: + citation_add_note(ctxt, note); break; + case ELT_SUB_MULTIM_OBJE: + multimedia_link_add_note(ctxt, note); break; + case ELT_SUB_LSS_SLGS: + case ELT_SUB_LIO_BAPL: + case ELT_SUB_LIO_SLGC: + lds_event_add_note(ctxt, note); break; + case REC_FAM: + family_add_note(ctxt, note); break; + case ELT_SUB_CHAN: + change_date_add_note(ctxt, note); break; + case ELT_SUB_PERS_NAME: + name_add_note(ctxt, note); break; + case ELT_SUB_FAMC: + case ELT_SUB_FAMS: + family_link_add_note(ctxt, note); break; + case ELT_SUB_ASSO: + association_add_note(ctxt, note); break; + case REC_INDI: + individual_add_note(ctxt, note); break; + case REC_OBJE: + multimedia_add_note(ctxt, note); break; + case REC_REPO: + repository_add_note(ctxt, note); break; + case ELT_SOUR_DATA: + source_add_note_to_data(ctxt, note); break; + case ELT_SUB_REPO: + source_add_note_to_repo(ctxt, note); break; + case REC_SOUR: + source_add_note(ctxt, note); break; + default: + UNEXPECTED_CONTEXT(ctxt->ctxt_type); } + result = MAKE_GOM_CTXT(elt, note_sub, note); } } return (Gedcom_ctxt)result; } +void sub_note_end(_ELT_END_PARAMS_) +{ + Gom_ctxt ctxt = (Gom_ctxt)self; + + if (! ctxt) + NO_CONTEXT; + else { + struct note_sub *note = SAFE_CTXT_CAST(note_sub, ctxt); + if (note) { + char *str = GEDCOM_STRING(parsed_value); + char *newvalue = strdup(str); + if (! newvalue) + MEMORY_ERROR; + else + note->text = newvalue; + } + } +} + void note_sub_subscribe() { - gedcom_subscribe_to_element(ELT_SUB_NOTE, sub_note_start, def_elt_end); + gedcom_subscribe_to_element(ELT_SUB_NOTE, sub_note_start, sub_note_end); } void note_sub_add_citation(Gom_ctxt ctxt, struct source_citation* cit) @@ -136,18 +144,6 @@ void note_sub_add_citation(Gom_ctxt ctxt, struct source_citation* cit) LINK_CHAIN_ELT(source_citation, note->citation, cit); } -void note_sub_add_to_note(NL_TYPE type, Gom_ctxt ctxt, const char* str) -{ - struct note_sub *note = SAFE_CTXT_CAST(note_sub, ctxt); - if (note) { - char *newvalue = concat_strings (type, note->text, str); - if (newvalue) - note->text = newvalue; - else - MEMORY_ERROR; - } -} - void note_sub_add_user_data(Gom_ctxt ctxt, struct user_data* data) { struct note_sub *obj = SAFE_CTXT_CAST(note_sub, ctxt);