From 5d770d0f89235b28f9c75ea43df29ce48a94ffa5 Mon Sep 17 00:00:00 2001 From: Peter Verthez Date: Sun, 4 Nov 2001 13:36:40 +0000 Subject: [PATCH] Release 0.3 --- ChangeLog | 6 ++++++ Makefile | 2 ++ gedcom.h | 9 ++++++++- gedcom.lex | 27 ++++++++++++++++++--------- standalone.c | 34 ++++++++++++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec928dd..7ed5212 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2001-11-04 Peter Verthez + + * release 0.3 + + * Compatibility mode implemented. + 2001-11-01 Peter Verthez * release 0.2 diff --git a/Makefile b/Makefile index 737ba42..a0ca68a 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,8 @@ # $Id$ # $Name$ +CFLAGS=-Wall -pedantic + gedcom_parse: standalone.o lex.gedcom_.o gedcom.tab.o cc standalone.o lex.gedcom_.o gedcom.tab.o -o gedcom_parse diff --git a/gedcom.h b/gedcom.h index 742473c..2dc43b6 100644 --- a/gedcom.h +++ b/gedcom.h @@ -3,8 +3,11 @@ #include #include #include +#include -#define MAXGEDCOMLEVEL 99 +#define MAXGEDCLEVEL 99 +#define MAXGEDCLINELEN 256 +#define MAXGEDCTAGLEN 31 #define MAXSTDTAGLENGTH 4 #define GEDCOMTAGOFFSET 257 @@ -16,7 +19,11 @@ typedef enum _MECH { } MECHANISM; int gedcom_error(char* s, ...); +int gedcom_warning(char* s, ...); +int gedcom_debug_print(char* s, ...); void gedcom_enable_debug(); void gedcom_set_error_handling(MECHANISM mechanism); +void gedcom_set_compat_handling(int enable_compat); int gedcom_parse(); +int gedcom_lex(); extern int line_no; diff --git a/gedcom.lex b/gedcom.lex index 76bce78..7d3f2e2 100644 --- a/gedcom.lex +++ b/gedcom.lex @@ -29,7 +29,7 @@ pointer @{alphanum}{non_at}+@ %{ int current_level=-1; -int level_diff=MAXGEDCOMLEVEL; +int level_diff=MAXGEDCLEVEL; int line_no=1; %} @@ -71,6 +71,8 @@ int line_no=1; that returns "pending" tokens. */ %{ +char string_buf[MAXGEDCLINELEN+1]; + if (level_diff < 1) { level_diff++; return CLOSE; @@ -82,10 +84,12 @@ else if (level_diff == 1) { else { /* out of brackets... */ } - -#define MKTAGACTION(tag) { gedcom_lval.string = gedcom_text; \ - BEGIN(NORMAL); \ - return TAG_##tag; } + +#define MKTAGACTION(tag) \ + { gedcom_lval.string = gedcom_text; \ + BEGIN(NORMAL); \ + return TAG_##tag; } + %} {gen_delim}* /* ignore leading whitespace (also tabs) */ @@ -95,9 +99,9 @@ else { } {digit}+ { int level = atoi(gedcom_text); - if ((level < 0) || (level > MAXGEDCOMLEVEL)) { + if ((level < 0) || (level > MAXGEDCLEVEL)) { gedcom_error ("Level number out of range [0..%d]", - MAXGEDCOMLEVEL); + MAXGEDCLEVEL); return BADTOKEN; } level_diff = level - current_level; @@ -250,8 +254,13 @@ else { WIFE MKTAGACTION(WIFE) WILL MKTAGACTION(WILL) -{alphanum}+ { gedcom_lval.string = gedcom_text; - BEGIN(NORMAL); +{alphanum}+ { if (strlen(gedcom_text) > MAXGEDCTAGLEN) { + gedcom_error("Tag '%s' too long, max %d chars"); + return BADTOKEN; + } + strncpy(string_buf, gedcom_text, MAXGEDCTAGLEN+1); + gedcom_lval.string = string_buf; + BEGIN(NORMAL); return USERTAG; } diff --git a/standalone.c b/standalone.c index 7e9abc4..c54d46d 100644 --- a/standalone.c +++ b/standalone.c @@ -6,6 +6,7 @@ int main(int argc, char* argv[]) { MECHANISM mech = IMMED_FAIL; + int compat_enabled = 1; if (argc > 1) { int i; for (i=1; i