X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom%2Fdate.c;h=4f9878fb624553fd7255fce6ad84a1bcf15b86da;hb=a549f1db4f3cd24e46cacf05cb4bec6eecce6570;hp=4f61ccabbeace3c45f69f80671efc789203e12ad;hpb=359ac00a8a5a1d69804380ff5c97c3d01036d1a9;p=gedcom-parse.git diff --git a/gedcom/date.c b/gedcom/date.c index 4f61cca..4f9878f 100644 --- a/gedcom/date.c +++ b/gedcom/date.c @@ -336,7 +336,7 @@ int numbers_to_strings(struct date *d) if (d->day != -1) sprintf(d->day_str, "%d", d->day); - if (d->month != -1) + if (d->month > 0 && d->month <= max_month[d->cal]) strcpy(d->month_str, month_name[d->cal][d->month - 1]); if (d->year_type == YEAR_SINGLE) @@ -383,7 +383,7 @@ int gedcom_normalize_date(Date_input input, struct date_value *val) return result; } -struct date_value* gedcom_new_date_value(struct date_value* copy_from) +struct date_value* gedcom_new_date_value(const struct date_value* copy_from) { struct date_value* dv_ptr; dv_ptr = (struct date_value*) malloc(sizeof(struct date_value)); @@ -409,8 +409,8 @@ struct date_value gedcom_parse_date(const char* line_value) init_date(&def_date); curr_line_value = line_value; if (compat_mode(C_NO_REQUIRED_VALUES) - && !strncmp(curr_line_value, "-", 2)) { - gedcom_date_error(_("Empty value changed to '-'")); + && !strncmp(curr_line_value, VALUE_IF_MISSING, 2)) { + gedcom_date_error(_("Empty value changed to '%s'"), VALUE_IF_MISSING); result = 1; } else { @@ -429,7 +429,7 @@ struct date_value gedcom_parse_date(const char* line_value) return dv_s; } -void write_date(struct date* d) +void write_date(const struct date* d) { if (! d->year_str[0] || d->year <= 0 || d->sdn1 <= 0) gedcom_error(_("Date is not normalized: some fields are invalid")); @@ -455,7 +455,7 @@ void write_date(struct date* d) } } -char* gedcom_date_to_string(struct date_value* val) +char* gedcom_date_to_string(const struct date_value* val) { init_buffer(&date_buffer); reset_buffer(&date_buffer);