From 2fb61a5d3ffec21d16adfa03a89f01cd8235ccae Mon Sep 17 00:00:00 2001 From: Peter Verthez Date: Sat, 29 Dec 2001 15:19:46 +0000 Subject: [PATCH] Added graceful fallback for date parse errors: put everything as a 'date phrase' if format not recognized. --- gedcom/date.c | 3 +++ gedcom/date.h | 1 + gedcom/gedcom_date.y | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/gedcom/date.c b/gedcom/date.c index a14522a..d057408 100644 --- a/gedcom/date.c +++ b/gedcom/date.c @@ -32,6 +32,8 @@ struct date date_s; struct date_value def_date_val; struct date def_date; +char* curr_line_value; + int max_month[] = { 12, /* CAL_GREGORIAN */ 12, /* CAL_JULIAN */ 13, /* CAL_HEBREW */ @@ -118,6 +120,7 @@ struct date_value gedcom_parse_date(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(); diff --git a/gedcom/date.h b/gedcom/date.h index 3db5829..430fe7b 100644 --- a/gedcom/date.h +++ b/gedcom/date.h @@ -34,6 +34,7 @@ extern struct date_value dv_s; extern struct date date_s; extern struct date def_date; +extern char* curr_line_value; int gedcom_date_parse(); int gedcom_date_lex(); diff --git a/gedcom/gedcom_date.y b/gedcom/gedcom_date.y index 60b1016..282b864 100644 --- a/gedcom/gedcom_date.y +++ b/gedcom/gedcom_date.y @@ -109,6 +109,10 @@ date_value : date { make_date_value(DV_NO_MODIFIER, | date_interpr | date_phrase { make_date_value(DV_PHRASE, def_date, def_date, $1); } + | error { /* On error: put entire string in 'phrase' member + as fallback */ + make_date_value(DV_PHRASE, + def_date, def_date, curr_line_value); } ; date : ESC_DATE_GREG date_greg { copy_date(&$$, date_s); -- 2.30.2