From d2dbc2834cae06a5de0dec22c0e7a530b7dd1589 Mon Sep 17 00:00:00 2001 From: Peter Verthez Date: Wed, 5 Feb 2003 19:37:35 +0000 Subject: [PATCH] Keep parsed values in date if parse was OK, but no valid date. --- ChangeLog | 5 +++++ NEWS | 7 +++++++ doc/interface.html | 5 ++++- gedcom/compat.c | 6 +++++- gedcom/compat.h | 1 + gedcom/date.c | 4 +++- t/output/compat-famorig.ref | 20 ++++++++++---------- t/output/dates.ref | 20 ++++++++++---------- t/output/dates_gom.ref | 10 +++++----- 9 files changed, 50 insertions(+), 28 deletions(-) diff --git a/ChangeLog b/ChangeLog index f2f5dfa..6389139 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2003-02-05 Peter Verthez + + * gedcom/date.c (gedcom_parse_date): Keep parsed values in date if + parse was OK, but didn't result in a valid date. + 2003-02-02 Peter Verthez * release 0.90.0 diff --git a/NEWS b/NEWS index f5402a7..e55f711 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,12 @@ NOTE: NO BACKWARD COMPATIBILITY IS GUARANTEED FOR 0.x RELEASES !! +release 0.91.0 (NOT RELEASED YET): + + - If a date is parsed fine, but cannot be successfully converted to an + SDN, the parsed values are now kept in the returned date_value. This means + that a date of DV_PHRASE type can have meaningful values in the string + and number values (the sdn value will still be -1). + release 0.90.0 (2 February 2003): - The interface of libgedcom and libgedcom_gom should now be functionally diff --git a/doc/interface.html b/doc/interface.html index 2a90537..34f8b07 100644 --- a/doc/interface.html +++ b/doc/interface.html @@ -2303,7 +2303,9 @@ the value that is returned by GEDCOM_STRING(val) is always the s DV_PHRASE
- a free form date phrase
+ a free form date phrase +(date1 and date2 can contain meaningful values, if the dates could be parsed, +but did not result in a valid date; the sdn values will then still be -1)
phrase
@@ -2692,4 +2694,5 @@ An example would thus be: "@This is an xref_val@".



+
\ No newline at end of file diff --git a/gedcom/compat.c b/gedcom/compat.c index ef319ae..3997fe6 100644 --- a/gedcom/compat.c +++ b/gedcom/compat.c @@ -96,11 +96,13 @@ struct program_data data[] = { - no FAMC field in SLGC - uses tab character (will be converted to 8 spaces here) - lines too long + - non-standard date formats - Personal Ancestral File 2: - '@' not written as '@@' in values - COMM tag in submitter record - double dates written as e.g. '1815/1816' instead of '1815/16' + - non-standard date formats - Family Origins: - '@' not written as '@@' in values @@ -118,6 +120,7 @@ struct program_data data[] = { - '@' not written as '@@' in values - SUBM.CTRY instead of SUBM.ADDR.CTRY - lines too long + - non-standard date formats */ int compat_matrix[] = @@ -142,7 +145,8 @@ int compat_matrix[] = /* C_SUBM_CTRY */ C_PAF4, /* C_NOTE_TOO_LONG */ C_PAF4 | C_PAF5, /* C_NOTE_CONC_SOUR */ C_EASYTREE, - /* C_NONSTD_SOUR_TAGS */ C_EASYTREE + /* C_NONSTD_SOUR_TAGS */ C_EASYTREE, + /* C_PAF_DATES */ C_PAF2 | C_PAF4 | C_PAF5 }; union _COMPAT_STATE { diff --git a/gedcom/compat.h b/gedcom/compat.h index 088da5a..aaf8c49 100644 --- a/gedcom/compat.h +++ b/gedcom/compat.h @@ -49,6 +49,7 @@ typedef enum _COMPAT_RULES { C_NOTE_TOO_LONG, C_NOTE_CONC_SOUR, C_NONSTD_SOUR_TAGS, + C_PAF_DATES, C_NR_OF_RULES } Compat_rule; diff --git a/gedcom/date.c b/gedcom/date.c index 4f9878f..9c086e7 100644 --- a/gedcom/date.c +++ b/gedcom/date.c @@ -405,6 +405,8 @@ struct date_value* gedcom_new_date_value(const struct date_value* copy_from) struct date_value gedcom_parse_date(const char* line_value) { int result = 0; + init_date(&dv_s.date1); + init_date(&dv_s.date2); init_date(&date_s); init_date(&def_date); curr_line_value = line_value; @@ -424,7 +426,7 @@ struct date_value gedcom_parse_date(const char* line_value) } if (result != 0) { gedcom_date_error(_("Putting date in 'phrase' member")); - make_date_value(DV_PHRASE, &def_date, &def_date, curr_line_value); + make_date_value(DV_PHRASE, &dv_s.date1, &dv_s.date2, curr_line_value); } return dv_s; } diff --git a/t/output/compat-famorig.ref b/t/output/compat-famorig.ref index 1b338f7..5c6987b 100644 --- a/t/output/compat-famorig.ref +++ b/t/output/compat-famorig.ref @@ -146,11 +146,11 @@ Contents of the date_value: raw value: 29 FEB 1739 type: 11 date1: - calendar type: 4 - day: - month: - year: - date type: 0 + calendar type: 0 + day: 29 + month: FEB + year: 1739 + date type: 1 sdn1: -1 sdn2: -1 date2: @@ -360,11 +360,11 @@ Contents of the date_value: raw value: 29 FEB 1739 type: 11 date1: - calendar type: 4 - day: - month: - year: - date type: 0 + calendar type: 0 + day: 29 + month: FEB + year: 1739 + date type: 1 sdn1: -1 sdn2: -1 date2: diff --git a/t/output/dates.ref b/t/output/dates.ref index cbbfde0..b21599f 100644 --- a/t/output/dates.ref +++ b/t/output/dates.ref @@ -276,11 +276,11 @@ Contents of the date_value: raw value: 29 FEB 1739 type: 11 date1: - calendar type: 4 - day: - month: - year: - date type: 0 + calendar type: 0 + day: 29 + month: FEB + year: 1739 + date type: 1 sdn1: -1 sdn2: -1 date2: @@ -584,11 +584,11 @@ Contents of the date_value: raw value: 29 FEB 1739 type: 11 date1: - calendar type: 4 - day: - month: - year: - date type: 0 + calendar type: 0 + day: 29 + month: FEB + year: 1739 + date type: 1 sdn1: -1 sdn2: -1 date2: diff --git a/t/output/dates_gom.ref b/t/output/dates_gom.ref index fb8a002..576504f 100644 --- a/t/output/dates_gom.ref +++ b/t/output/dates_gom.ref @@ -892,12 +892,12 @@ Individual events: Date: type: 11 date1: - calendar type: 4 - day: '', -1 - month: '', -1 - year: '', -1 + calendar type: 0 + day: '29', 29 + month: 'FEB', 2 + year: '1739', 1739 year type: 0 - date type: 0 + date type: 1 sdn1: -1 sdn2: -1 date2: -- 2.30.2