From: Peter Verthez Date: Sat, 18 Jan 2003 17:01:10 +0000 (+0000) Subject: Pass date values via pointers instead of on stack. X-Git-Url: https://git.dlugolecki.net.pl/?a=commitdiff_plain;h=91f4b16412ad3d902d415d570b7d24d52543e41c;p=gedcom-parse.git Pass date values via pointers instead of on stack. --- diff --git a/gedcom/date.c b/gedcom/date.c index 5deab78..b28a129 100644 --- a/gedcom/date.c +++ b/gedcom/date.c @@ -106,9 +106,9 @@ int checkedSdnToCal(Calendar_type cal, long int sdn, return 0; } -void copy_date(struct date *to, struct date from) +void copy_date(struct date *to, struct date *from) { - memcpy(to, &from, sizeof(struct date)); + memcpy(to, from, sizeof(struct date)); } void init_date(struct date *d) @@ -126,14 +126,14 @@ void init_date(struct date *d) d->sdn2 = -1; } -struct date_value make_date_value(Date_value_type t, struct date d1, - struct date d2, const char* p) +struct date_value* make_date_value(Date_value_type t, struct date *d1, + struct date *d2, const char* p) { dv_s.type = t; copy_date(&dv_s.date1, d1); copy_date(&dv_s.date2, d2); strncpy(dv_s.phrase, p, MAX_PHRASE_LEN + 1); - return dv_s; + return &dv_s; } /* PRE: d->cal != CAL_UNKNOWN @@ -151,10 +151,10 @@ int numbers_to_sdn(struct date *d) else { struct date begin_date; struct date end_date; - copy_date(&begin_date, *d); + copy_date(&begin_date, d); if (d->day == -1 || d->month == -1 || d->year == -1) { d->type = DATE_BOUNDED; - copy_date(&end_date, *d); + copy_date(&end_date, d); if (begin_date.month == -1) { begin_date.month = 1; end_date.month = 1; begin_date.day = 1; end_date.day = 1; @@ -180,7 +180,8 @@ int numbers_to_sdn(struct date *d) d->sdn1 = checkedCalToSdn(d->cal, begin_date.year, begin_date.month, begin_date.day); if (d->sdn1 == -1) { - gedcom_error(_("Error converting date")); + gedcom_error(_("Error converting date: year %d, month %d, day %d"), + begin_date.year, begin_date.month, begin_date.day); result = 1; } else @@ -188,7 +189,8 @@ int numbers_to_sdn(struct date *d) d->sdn2 = checkedCalToSdn(d->cal, end_date.year, end_date.month, end_date.day); if (d->sdn2 == -1) { - gedcom_error(_("Error converting date")); + gedcom_error(_("Error converting date: year %d, month %d, day %d"), + end_date.year, end_date.month, end_date.day); result = 1; } else @@ -218,7 +220,7 @@ int sdn_to_numbers(struct date *d) result = 1; } else { - copy_date(&begin_date, *d); + copy_date(&begin_date, d); if (!checkedSdnToCal(d->cal, d->sdn1, &begin_date.year, &begin_date.month, &begin_date.day)) { gedcom_error(_("SDN 1 isn't a valid date in the given calendar")); @@ -242,7 +244,7 @@ int sdn_to_numbers(struct date *d) result = 1; } else { - copy_date(&end_date, *d); + copy_date(&end_date, d); if (!checkedSdnToCal(d->cal, d->sdn2, &end_date.year, &end_date.month, &end_date.day)) { gedcom_error(_("SDN 2 isn't a valid date in the given calendar")); diff --git a/gedcom/date.h b/gedcom/date.h index ccf5a7f..d903c12 100644 --- a/gedcom/date.h +++ b/gedcom/date.h @@ -29,6 +29,7 @@ #include "gedcom.h" #define gedcom_date_error gedcom_error +#define gedcom_date_warning gedcom_warning #define MAX_DATE_TOKEN 10 extern struct date_value dv_s; @@ -50,9 +51,9 @@ int get_year_num(const char* input, Year_type* ytype); void init_gedcom_date_lex(const char* string); void close_gedcom_date_lex(); -struct date_value make_date_value(Date_value_type t, struct date d1, - struct date d2, const char* p); -void copy_date(struct date *to, struct date from); +struct date_value* make_date_value(Date_value_type t, struct date *d1, + struct date *d2, const char* p); +void copy_date(struct date *to, struct date *from); #define GEDCOM_MAKE_DATE(VAR, DATE) \ GEDCOM_MAKE(VAR, DATE, GV_DATE_VALUE, date_val)