Add init function for the lexer.
[gedcom-parse.git] / gedcom / gedcom_1byte.lex
index a4a5659df39a24977b2a067da5bffea39a304a50..6fa1d6b0293089b3f4573f8482d7ecd1e1d6eb4e 100644 (file)
@@ -1,11 +1,22 @@
-/*  This program is free software; you can redistribute it and/or modify  *
- *  it under the terms of the GNU General Public License as published by  *
- *  the Free Software Foundation; either version 2 of the License, or     *
- *  (at your option) any later version.                                   *
-
- (C) 2001 by The Genes Development Team
- Original author: Peter Verthez (Peter.Verthez@advalvas.be)
-*/
+/* Lexer for 1-byte encoding of Gedcom.
+   Copyright (C) 2001 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$ */
@@ -26,6 +37,7 @@ delim        " "
 tab          [\t]
 hash         #
 literal_at   @@
+normal_at    @
 otherchar    [\x21-\x22\x24-\x2F\x3A-\x3F\x5B-\x5E\x60\x7B-\x7E\x80-\xFE]
 terminator   \x0D|\x0A|\x0D\x0A|\x0A\x0D
 
@@ -198,12 +210,18 @@ ACTION_BEFORE_REGEXPS
 
 <<EOF>>                   ACTION_EOF
 
+{normal_at}               ACTION_NORMAL_AT
+
 .                         ACTION_UNEXPECTED
 
 %%
 
+static int exitfuncregistered = 0;
+
 int yywrap()
 {
+  if (! exitfuncregistered && atexit(yylex_cleanup) == 0)
+    exitfuncregistered = 1;
   return 1;
 }