X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom%2Fgedcom.y;h=4a131b04a6718da38792cdd6af3dbdad1a4395bb;hb=dab74f78766b0878cbb85d07712588a2e3c16d3c;hp=702d1256dcba2c8f921ce3074776e0bc1f2c91d0;hpb=462b1197f07aac3181b8137e6844738d6c68774c;p=gedcom-parse.git diff --git a/gedcom/gedcom.y b/gedcom/gedcom.y index 702d125..4a131b0 100644 --- a/gedcom/gedcom.y +++ b/gedcom/gedcom.y @@ -164,6 +164,10 @@ struct safe_buffer line_item_buffer = { NULL, 0, NULL, 0, void cleanup_concat_buffer(); struct safe_buffer concat_buffer = { NULL, 0, NULL, 0, cleanup_concat_buffer }; + +void cleanup_usertag_buffer(); +struct safe_buffer usertag_buffer = { NULL, 0, NULL, 0, + cleanup_usertag_buffer}; /* These are defined at the bottom of the file */ void push_countarray(int level); @@ -210,7 +214,9 @@ void clean_up(); #TAG, parenttag); \ HANDLE_ERROR; \ } \ - } + } +#define CHK_COND(TAG) \ + check_occurrence(TAG_##TAG) #define POP \ { pop_countarray(); \ --count_level; \ @@ -444,22 +450,24 @@ head_sect : OPEN DELIM TAG_HEAD NULL, GEDCOM_MAKE_NULL(val2)); START(HEAD, $1, $$) } head_subs - { if (compat_mode(C_FTREE)) { - CHECK3(SOUR, GEDC, CHAR); - compat_generate_submitter_link($4); - } - else if (compat_mode(C_LIFELINES)) { - CHECK1(SOUR); + { if (compat_mode(C_NO_SUBMITTER) && ! CHK_COND(SUBM)) compat_generate_submitter_link($4); + else CHK(SUBM); + + if (compat_mode(C_NO_GEDC) && ! CHK_COND(GEDC)) compat_generate_gedcom($4); + else CHK(GEDC); + + if (compat_mode(C_NO_CHAR) && ! CHK_COND(CHAR)) { if (compat_generate_char($4)) HANDLE_ERROR; - } - else - CHECK4(SOUR, SUBM, GEDC, CHAR) + } + else CHK(CHAR); + + CHECK1(SOUR); } CLOSE { end_record(REC_HEAD, $4, GEDCOM_MAKE_NULL(val1)); - if (compat_mode(C_FTREE | C_LIFELINES)) + if (compat_mode(C_NO_SUBMITTER)) compat_generate_submitter(); } ; @@ -471,7 +479,7 @@ head_subs : /* empty */ head_sub : head_sour_sect { OCCUR2(SOUR, 1, 1) } | head_dest_sect { OCCUR2(DEST, 0, 1) } | head_date_sect { OCCUR2(DATE, 0, 1) } - | head_time_sect { if (!compat_mode(C_LIFELINES)) + | head_time_sect { if (!compat_mode(C_HEAD_TIME)) INVALID_TAG("TIME"); OCCUR2(TIME, 0, 1) } | head_subm_sect { OCCUR2(SUBM, 1, 1) } @@ -668,7 +676,7 @@ head_date_time_sect : OPEN DELIM TAG_TIME mand_line_item } ; -/* HEAD.TIME (Only for 'Lifelines' compatibility) */ +/* HEAD.TIME (Only for compatibility) */ /* Just ignore the time... */ head_time_sect : OPEN DELIM TAG_TIME opt_line_item CLOSE { gedcom_warning(_("Header change time lost in the compatibility")); @@ -1047,7 +1055,10 @@ indiv_rec : OPEN DELIM POINTER DELIM TAG_INDI indi_subs { CHECK0 } CLOSE - { end_record(REC_INDI, $6, GEDCOM_MAKE_NULL(val1)); } + { end_record(REC_INDI, $6, GEDCOM_MAKE_NULL(val1)); + if (compat_mode(C_NO_SLGC_FAMC)) + compat_generate_slgc_famc_fam(); + } ; indi_subs : /* empty */ @@ -1074,7 +1085,7 @@ indi_sub : indi_resn_sect { OCCUR2(RESN, 0, 1) } | indi_afn_sect /* 0:M */ | ident_struc_sub /* 0:1 */ | change_date_sub /* 0:1 */ - | ftree_addr_sect { if (!compat_mode(C_FTREE)) + | indi_addr_sect { if (!compat_mode(C_INDI_ADDR)) INVALID_TAG("ADDR"); } | no_std_sub @@ -1212,23 +1223,23 @@ indi_afn_sect : OPEN DELIM TAG_AFN mand_line_item } ; -/* INDI.ADDR (Only for 'ftree' compatibility) */ -ftree_addr_sect : OPEN DELIM TAG_ADDR opt_line_item - { if (compat_mode(C_FTREE)) { +/* INDI.ADDR (Only for compatibility) */ +indi_addr_sect : OPEN DELIM TAG_ADDR opt_line_item + { if (compat_mode(C_INDI_ADDR)) { Gedcom_ctxt par = compat_generate_resi_start(PARENT); START(RESI, $1, par); $$ = start_element(ELT_SUB_ADDR, par, $1 + 1, $3, $4, GEDCOM_MAKE_NULL_OR_STRING(val2, $4)); - START(ADDR, $1, $$); + START(ADDR, $1 + 1, $$); } else { START(ADDR, $1, NULL) } } ftree_addr_subs { CHECK0 } CLOSE - { if (compat_mode(C_FTREE)) { + { if (compat_mode(C_INDI_ADDR)) { Gedcom_ctxt par = PARENT; end_element(ELT_SUB_ADDR, par, $5, GEDCOM_MAKE_NULL(val1)); @@ -1403,7 +1414,7 @@ note_rec : OPEN DELIM POINTER DELIM TAG_NOTE note_line_item ; note_line_item : /* empty */ - { if (!compat_mode(C_FTREE)) { + { if (!compat_mode(C_NOTE_NO_VALUE)) { gedcom_error(_("Missing value")); YYERROR; } else { @@ -2883,7 +2894,11 @@ lio_slgc_sect : OPEN DELIM TAG_SLGC START(SLGC, $1, $$) } lio_slgc_subs - { CHECK1(FAMC) } + { if (compat_mode(C_NO_SLGC_FAMC) && ! CHK_COND(FAMC)) + compat_generate_slgc_famc_link($4); + else CHK(FAMC); + CHECK0; + } CLOSE { end_element(ELT_SUB_LIO_SLGC, PARENT, $4, GEDCOM_MAKE_NULL(val1)); @@ -3629,9 +3644,15 @@ no_std_rec : user_rec /* 0:M */ user_rec : OPEN DELIM opt_xref USERTAG { if ($4.string[0] != '_') { - gedcom_error(_("Undefined tag (and not a valid user tag): %s"), - $4); - YYERROR; + if (compat_mode(C_551_TAGS) + && compat_check_551_tag($4.string, &usertag_buffer)) { + $4.string = get_buf_string(&usertag_buffer); + } + else { + gedcom_error(_("Undefined tag (and not a valid user tag): %s"), + $4); + YYERROR; + } } } opt_value @@ -3653,9 +3674,15 @@ user_rec : OPEN DELIM opt_xref USERTAG ; user_sect : OPEN DELIM opt_xref USERTAG { if ($4.string[0] != '_') { - gedcom_error(_("Undefined tag (and not a valid user tag): %s"), - $4); - YYERROR; + if (compat_mode(C_551_TAGS) + && compat_check_551_tag($4.string, &usertag_buffer)) { + $4.string = get_buf_string(&usertag_buffer); + } + else { + gedcom_error(_("Undefined tag (and not a valid user tag): %s"), + $4); + YYERROR; + } } } opt_value @@ -3695,9 +3722,8 @@ mand_pointer : /* empty */ { gedcom_error(_("Missing pointer")); YYERROR; } ; mand_line_item : /* empty */ - { if (compat_mode(C_LIFELINES)) { - /* Lifelines tends to not care about mandatory values */ - gedcom_debug_print("==Val: =="); + { if (compat_mode(C_NO_REQUIRED_VALUES)) { + gedcom_debug_print("==Val: =="); $$ = ""; } else { @@ -4029,6 +4055,11 @@ void cleanup_line_item_buffer() cleanup_buffer(&line_item_buffer); } +void cleanup_usertag_buffer() +{ + cleanup_buffer(&usertag_buffer); +} + /* Enabling debug mode */ /* level 0: no debugging */ /* level 1: only internal */