From c241fd2658149a029f8c9119007341d17ffd748c Mon Sep 17 00:00:00 2001 From: Peter Verthez Date: Sat, 25 Jan 2003 20:20:51 +0000 Subject: [PATCH] Better handling of empty date values. --- gedcom/date.c | 24 +++++++++++++++++------- t/output/compat-lifelines.ref | 24 ++++++++++++++++-------- t/output/write_gom_compat-lifelines.ged | 4 ++-- t/output/write_gom_compat-lifelines.ref | 4 ++++ 4 files changed, 39 insertions(+), 17 deletions(-) diff --git a/gedcom/date.c b/gedcom/date.c index b28a129..3ce3783 100644 --- a/gedcom/date.c +++ b/gedcom/date.c @@ -24,6 +24,8 @@ #include "gedcom_internal.h" #include "sdncal.h" #include "buffer.h" +#include "compat.h" +#include #include "date.h" struct date_value dv_s; @@ -405,13 +407,21 @@ struct date_value gedcom_parse_date(const char* line_value) init_date(&date_s); init_date(&def_date); curr_line_value = line_value; - init_gedcom_date_lex(line_value); - gedcom_date_parse(); - close_gedcom_date_lex(); - if (dv_s.date1.cal != CAL_UNKNOWN) - numbers_to_sdn(&dv_s.date1); - if (dv_s.date2.cal != CAL_UNKNOWN) - numbers_to_sdn(&dv_s.date2); + if (compat_mode(C_NO_REQUIRED_VALUES) + && !strncmp(curr_line_value, "-", 2)) { + gedcom_date_error(_("Empty value changed to '-'")); + gedcom_date_error(_("Putting date in 'phrase' member")); + make_date_value(DV_PHRASE, &def_date, &def_date, curr_line_value); + } + else { + init_gedcom_date_lex(line_value); + gedcom_date_parse(); + close_gedcom_date_lex(); + if (dv_s.date1.cal != CAL_UNKNOWN) + numbers_to_sdn(&dv_s.date1); + if (dv_s.date2.cal != CAL_UNKNOWN) + numbers_to_sdn(&dv_s.date2); + } return dv_s; } diff --git a/t/output/compat-lifelines.ref b/t/output/compat-lifelines.ref index d7cfe69..87d834f 100644 --- a/t/output/compat-lifelines.ref +++ b/t/output/compat-lifelines.ref @@ -19,8 +19,10 @@ Submitter, xref is @__COMPAT__SUBM__@ Family start, xref is @F1@ == 1 HUSB (330) @I7@ (ctxt is 1, conversion failures: 0) == 1 MARR (339) (null) (ctxt is 1, conversion failures: 0) +WARNING: Warning on line 9: Empty value changed to '-' +WARNING: Warning on line 9: Putting date in 'phrase' member Contents of the date_value: - raw value: + raw value: - type: 11 date1: calendar type: 4 @@ -38,7 +40,7 @@ Contents of the date_value: date type: 0 sdn1: -1 sdn2: -1 - phrase: + phrase: - == 2 PLAC (358) - (ctxt is 1, conversion failures: 0) == 2 SOUR (377) name@domain.be (reclame voor genealogie boeken) (ctxt is 1, conversion failures: 0) Family end, xref is @F1@ @@ -70,8 +72,10 @@ Contents of the date_value: == 2 PLAC (358) - (ctxt is 333, conversion failures: 0) == 2 SOUR (377) ongeveer 1360 (ctxt is 333, conversion failures: 0) == 1 DEAT (307) (null) (ctxt is 333, conversion failures: 0) +WARNING: Warning on line 21: Empty value changed to '-' +WARNING: Warning on line 21: Putting date in 'phrase' member Contents of the date_value: - raw value: + raw value: - type: 11 date1: calendar type: 4 @@ -89,7 +93,7 @@ Contents of the date_value: date type: 0 sdn1: -1 sdn2: -1 - phrase: + phrase: - == 2 PLAC (358) - (ctxt is 333, conversion failures: 0) == 2 SOUR (377) - (ctxt is 333, conversion failures: 0) == 1 NOTE (348) Hij bouwde het Brusselse stadhuis in 1402. Hij bouwde ook kerken in (ctxt is 333, conversion failures: 0) @@ -118,8 +122,10 @@ Submitter, xref is @__COMPAT__SUBM__@ Family start, xref is @F1@ == 1 HUSB (330) @I7@ (ctxt is 2, conversion failures: 0) == 1 MARR (339) (null) (ctxt is 2, conversion failures: 0) +WARNING: Warning on line 9: Empty value changed to '-' +WARNING: Warning on line 9: Putting date in 'phrase' member Contents of the date_value: - raw value: + raw value: - type: 11 date1: calendar type: 4 @@ -137,7 +143,7 @@ Contents of the date_value: date type: 0 sdn1: -1 sdn2: -1 - phrase: + phrase: - == 2 PLAC (358) - (ctxt is 2, conversion failures: 0) == 2 SOUR (377) name@domain.be (reclame voor genealogie boeken) (ctxt is 2, conversion failures: 0) Family end, xref is @F1@ @@ -169,8 +175,10 @@ Contents of the date_value: == 2 PLAC (358) - (ctxt is 333, conversion failures: 0) == 2 SOUR (377) ongeveer 1360 (ctxt is 333, conversion failures: 0) == 1 DEAT (307) (null) (ctxt is 333, conversion failures: 0) +WARNING: Warning on line 21: Empty value changed to '-' +WARNING: Warning on line 21: Putting date in 'phrase' member Contents of the date_value: - raw value: + raw value: - type: 11 date1: calendar type: 4 @@ -188,7 +196,7 @@ Contents of the date_value: date type: 0 sdn1: -1 sdn2: -1 - phrase: + phrase: - == 2 PLAC (358) - (ctxt is 333, conversion failures: 0) == 2 SOUR (377) - (ctxt is 333, conversion failures: 0) == 1 NOTE (348) Hij bouwde het Brusselse stadhuis in 1402. Hij bouwde ook kerken in (ctxt is 333, conversion failures: 0) diff --git a/t/output/write_gom_compat-lifelines.ged b/t/output/write_gom_compat-lifelines.ged index bd70a4c..00db1b4 100644 --- a/t/output/write_gom_compat-lifelines.ged +++ b/t/output/write_gom_compat-lifelines.ged @@ -21,7 +21,7 @@ 2 PLAC - 2 SOUR ongeveer 1360 1 DEAT -2 DATE () +2 DATE (-) 2 PLAC - 2 SOUR - 1 FAMC @F1@ @@ -30,7 +30,7 @@ 1 NOTE Nederlandse tak ? in 1405 was de oudste vleugen klaar 0 @F1@ FAM 1 MARR -2 DATE () +2 DATE (-) 2 PLAC - 2 SOUR name@@domain.be (reclame voor genealogie boeken) 1 HUSB @I7@ diff --git a/t/output/write_gom_compat-lifelines.ref b/t/output/write_gom_compat-lifelines.ref index 26ebd18..a32f9f1 100644 --- a/t/output/write_gom_compat-lifelines.ref +++ b/t/output/write_gom_compat-lifelines.ref @@ -1,6 +1,10 @@ WARNING: Warning on line 2: Enabling compatibility with 'Lifelines' WARNING: Warning on line 5: Header change time lost in the compatibility WARNING: Warning on line 5: Adding link to submitter record with xref '@__COMPAT__SUBM__@' +WARNING: Warning on line 9: Empty value changed to '-' +WARNING: Warning on line 9: Putting date in 'phrase' member +WARNING: Warning on line 21: Empty value changed to '-' +WARNING: Warning on line 21: Putting date in 'phrase' member Writing file... Re-parsing file... Test succeeded -- 2.30.2