Pass encoding terminator to encoding state.
[gedcom-parse.git] / gedcom / gedcom_lex_common.c
index 902225f2f64b678827152cf8dc210ddf83d12059..703a9de9d3f21987ec3b22f51d267218603b596e 100644 (file)
@@ -29,7 +29,6 @@
 #include "gedcom.h"
 #include "gedcom.tabgen.h"
 #include "compat.h"
-#include "utf8.h"
 
 static size_t encoding_width;
 static int current_level = -1;
@@ -47,7 +46,6 @@ static struct conv_buffer* str_buffer = NULL;
 #ifdef LEXER_TEST 
 YYSTYPE gedcom_lval;
 int line_no = 1;
-int compat_at = 0;
 
 int gedcom_lex();
 
@@ -93,9 +91,10 @@ int test_loop(ENCODING enc, const char* code)
 /* These are defined as functions here, because xgettext has trouble
    extracting the strings out of long pre-processor defined */
 
-static void error_line_too_long()
+static void error_line_too_long(const char *line)
 {
-  gedcom_error(_("Line too long, max %d characters allowed"), MAXGEDCLINELEN); 
+  gedcom_error(_("Line too long, max %d characters allowed: %s"),
+              MAXGEDCLINELEN, line); 
 }
 
 static void error_level_leading_zero()
@@ -157,7 +156,7 @@ static int dummy_conv = 0;
   { if (line_len != (size_t)-1) {                                             \
       line_len += strlen(yytext);                                             \
       if (line_len > MAXGEDCLINELEN * encoding_width) {                       \
-        error_line_too_long();                                                \
+        error_line_too_long(yytext);                                          \
         line_len = (size_t)-1;                                                \
         return BADTOKEN;                                                      \
       }                                                                       \
@@ -337,6 +336,8 @@ static int dummy_conv = 0;
 #define ACTION_TERMINATOR                                                     \
   { CHECK_LINE_LEN;                                                           \
     INIT_LINE_LEN;                                                            \
+    if (line_no == 1)                                                         \
+      set_encoding_terminator(TO_INTERNAL(yytext, str_buffer));               \
     BEGIN(INITIAL);                                                           \
   }
 
@@ -362,7 +363,7 @@ static int dummy_conv = 0;
   } 
 
 #define ACTION_NORMAL_AT                                                      \
-  { if (compat_at) {                                                          \
+  { if (compat_mode(C_NO_DOUBLE_AT)) {                                        \
       int i, j;                                                               \
       char *yycopy = strdup(yytext);                                          \
       if (yycopy) {                                                           \