-char string_buf[MAXGEDCLINELEN+1];
-
-#define TO_INTERNAL(str) to_internal(str, yyleng)
+#define TO_INTERNAL(STR,OUTBUF) \
+ to_internal(STR, yyleng, OUTBUF, sizeof(OUTBUF))
+
+#define INIT_LINE_LEN \
+ line_len = 0;
+
+#define CHECK_LINE_LEN \
+ { if (line_len != (size_t)-1) { \
+ line_len += strlen(yytext); \
+ if (line_len > MAXGEDCLINELEN * encoding_width) { \
+ gedcom_error("Line too long, max %d characters", \
+ MAXGEDCLINELEN); \
+ line_len = (size_t)-1; \
+ return BADTOKEN; \
+ } \
+ } \
+ }