+2002-01-22 Peter Verthez <Peter.Verthez@advalvas.be>
+
+ * gedcom/gedcom.y, gedcom/compat.c, gedcom/compat.h: Added
+ compatibility handling for ftree.
+
2002-01-20 Peter Verthez <Peter.Verthez@advalvas.be>
* release 0.14
- specific parsing and checking of cross-references
- - provisions for "compatibility-mode" parsing, to allow for not-exactly-
- standard syntaxes used by other genealogy programs (only the hooks are
- in at the moment, not the actual compatibility)
+ - "compatibility-mode" parsing, to allow for not-exactly-standard syntaxes
+ used by other genealogy programs; currently, compatibility is added for:
+ - ftree
NOTE:
- NO BACKWARD COMPATIBILITY is guaranteed for 0.x releases !
To do list:
- specific parsing of other special values
- - C++ interface
- compatibility with other genealogy programs
- older/newer Gedcom standards ?
- ...
http://sourceforge.net/projects/gedcom-parse
Also, have a look at the 'Genes' program, from which this library is a
-spin-off, and which intends to use this library:
+spin-off, and which uses this library:
http://genes.sourceforge.net
http://sourceforge.net/projects/genes
interface.c \
date.c \
hash.c \
- xref.c
+ xref.c \
+ compat.c
libgedcom_la_LDFLAGS = -version-info $(LIBVERSION)
libgedcom_la_LIBADD = calendar/libcalendar.la
BUILT_SOURCES = lex.gedcom_1byte_.c \
multilex.h \
date.h \
hash.h \
- xref.h
+ xref.h \
+ compat.h
EXTRA_DIST = gedcom.y \
gedcom_date.y \
gedcom_1byte.lex \
--- /dev/null
+/* Compatibility handling for the GEDCOM parser.
+ Copyright (C) 2001, 2002 The Genes Development Team
+ This file is part of the Gedcom parser library.
+ Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
+
+ The Gedcom parser library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The Gedcom parser library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the Gedcom parser library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* $Id$ */
+/* $Name$ */
+
+#include "compat.h"
+#include "interface.h"
+#include "xref.h"
+#include "gedcom_internal.h"
+#include "gedcom.h"
+
+#define SUBMITTER_LINK "@__COMPAT__SUBM__@"
+#define DEFAULT_SUBMITTER_NAME "Submitter"
+
+/* Incompatibily list (with GEDCOM 5.5):
+
+ - ftree:
+ - no submitter record, no submitter link in the header
+ - INDI.ADDR instead of INDI.RESI.ADDR
+ - NOTE doesn't have a value
+
+ */
+
+void compat_generate_submitter_link(Gedcom_ctxt parent)
+{
+ struct xref_value *xr = gedcom_parse_xref(SUBMITTER_LINK, XREF_USED,
+ XREF_SUBM);
+ struct tag_struct ts;
+ Gedcom_ctxt self;
+
+ ts.string = "SUBM";
+ ts.value = TAG_SUBM;
+ self = start_element(ELT_HEAD_SUBM,
+ parent, 1, ts, SUBMITTER_LINK,
+ GEDCOM_MAKE_XREF_PTR(val1, xr));
+ end_element(ELT_HEAD_SUBM, parent, self, NULL);
+}
+
+void compat_generate_submitter()
+{
+ struct xref_value *xr = gedcom_parse_xref(SUBMITTER_LINK, XREF_DEFINED,
+ XREF_SUBM);
+ struct tag_struct ts;
+ Gedcom_ctxt self1, self2;
+
+ /* first generate "0 SUBM" */
+ ts.string = "SUBM";
+ ts.value = TAG_SUBM;
+ self1 = start_record(REC_SUBM, 0, GEDCOM_MAKE_XREF_PTR(val1, xr), ts,
+ NULL, GEDCOM_MAKE_NULL(val2));
+
+ /* then generate "1 NAME ..." */
+ ts.string = "NAME";
+ ts.value = TAG_NAME;
+ self2 = start_element(ELT_SUBM_NAME, self1, 1, ts, DEFAULT_SUBMITTER_NAME,
+ GEDCOM_MAKE_STRING(val1, DEFAULT_SUBMITTER_NAME));
+
+ /* close "1 NAME ..." */
+ end_element(ELT_SUBM_NAME, self1, self2, NULL);
+
+ /* close "0 SUBM" */
+ end_record(REC_SUBM, self1);
+}
+
+Gedcom_ctxt compat_generate_resi_start(Gedcom_ctxt parent)
+{
+ Gedcom_ctxt self;
+ struct tag_struct ts;
+
+ ts.string = "RESI";
+ ts.value = TAG_RESI;
+ self = start_element(ELT_SUB_INDIV_RESI, parent, 1, ts, NULL,
+ GEDCOM_MAKE_NULL(val1));
+ return self;
+}
+
+void compat_generate_resi_end(Gedcom_ctxt parent, Gedcom_ctxt self)
+{
+ end_element(ELT_SUB_INDIV_RESI, parent, self, NULL);
+}
--- /dev/null
+/* Header for compatibility handling for the GEDCOM parser.
+ Copyright (C) 2001, 2002 The Genes Development Team
+ This file is part of the Gedcom parser library.
+ Contributed by Peter Verthez <Peter.Verthez@advalvas.be>, 2001.
+
+ The Gedcom parser library is free software; you can redistribute it
+ and/or modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The Gedcom parser library is distributed in the hope that it will be
+ useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the Gedcom parser library; if not, write to the
+ Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+/* $Id$ */
+/* $Name$ */
+
+#ifndef __COMPAT_H
+#define __COMPAT_H
+
+#include "gedcom.h"
+
+void compat_generate_submitter_link(Gedcom_ctxt parent);
+void compat_generate_submitter();
+Gedcom_ctxt compat_generate_resi_start(Gedcom_ctxt parent);
+void compat_generate_resi_end(Gedcom_ctxt parent, Gedcom_ctxt self);
+
+#endif /* __COMPAT_H */
#include "interface.h"
#include "date.h"
#include "xref.h"
+#include "compat.h"
int count_level = 0;
int fail = 0;
#TAG, parenttag); \
HANDLE_ERROR; \
} \
- }
+ }
#define POP \
{ pop_countarray(); \
--count_level; \
NULL, GEDCOM_MAKE_NULL(val2));
START(HEAD, $<ctxt>$) }
head_subs
- { if (compat_mode(C_FTREE))
- CHECK3(SOUR, GEDC, CHAR)
+ { if (compat_mode(C_FTREE)) {
+ CHECK3(SOUR, GEDC, CHAR);
+ compat_generate_submitter_link($<ctxt>4);
+ }
else
CHECK4(SOUR, SUBM, GEDC, CHAR)
}
CLOSE
- { end_record(REC_HEAD, $<ctxt>4); }
+ { end_record(REC_HEAD, $<ctxt>4);
+ if (compat_mode(C_FTREE))
+ compat_generate_submitter();
+ }
;
head_subs : /* empty */
/* INDI.ADDR (Only for 'ftree' compatibility) */
ftree_addr_sect : OPEN DELIM TAG_ADDR opt_line_item
- { START(ADDR, NULL) } no_std_subs { CHECK0 } CLOSE { }
+ { Gedcom_ctxt par = compat_generate_resi_start(PARENT);
+ START(RESI, par);
+ $<ctxt>$
+ = start_element(ELT_SUB_ADDR,
+ par, $1 + 1, $3, $4,
+ GEDCOM_MAKE_NULL_OR_STRING(val2, $4));
+ START(ADDR, $<ctxt>$)
+ }
+ no_std_subs
+ { CHECK0 }
+ CLOSE
+ { Gedcom_ctxt par = PARENT;
+ end_element(ELT_SUB_ADDR, par, $<ctxt>5, NULL);
+ CHECK0;
+ compat_generate_resi_end(PARENT, par);
+ }
/*********************************************************************/
/**** Multimedia record ****/
| subm_subs subm_sub
;
-subm_sub : subm_name_sect { OCCUR2(NAME, 0, 1) }
+subm_sub : subm_name_sect { OCCUR2(NAME, 1, 1) }
| addr_struc_sub /* 0:1 */
| multim_link_sub /* 0:M */
| subm_lang_sect { OCCUR2(LANG, 0, 3) }
$$ = $2; }
;
-opt_line_item : /* empty */ { }
+opt_line_item : /* empty */ { $$ = NULL; }
| DELIM line_item { gedcom_debug_print("==Val: %s==", $2);
$$ = $2; }
;
#ifndef __INTERFACE_H
#define __INTERFACE_H
+#include "gedcom_internal.h"
#include "gedcom.h"
Gedcom_ctxt start_record(Gedcom_rec rec,