- { CHECK_LINE_LEN; \
- gedcom_lval.string = TO_INTERNAL(yytext, str_buf); \
- /* Due to character conversions, it is possible that the current \
- character will be combined with the next, and so now we don't have a \
- character yet... \
- In principle, this is only applicable to the 1byte case (e.g. ANSEL), \
- but it doesn't harm the unicode case. \
- */ \
- if (strlen(gedcom_lval.string) > 0) \
- return ANYCHAR; \
+ { char* tmp; \
+ CHECK_LINE_LEN; \
+ tmp = TO_INTERNAL(yytext, str_buf); \
+ if (!tmp) { \
+ /* Something went wrong during conversion... */ \
+ gedcom_error(_("Invalid character for encoding: '%s' (0x%02x)"), \
+ yytext, yytext[0]); \
+ return BADTOKEN; \
+ } \
+ else { \
+ gedcom_lval.string = tmp; \
+ /* Due to character conversions, it is possible that the current \
+ character will be combined with the next, and so now we don't have a \
+ character yet... \
+ In principle, this is only applicable to the 1byte case (e.g. ANSEL),\
+ but it doesn't harm the unicode case. \
+ */ \
+ if (strlen(gedcom_lval.string) > 0) \
+ return ANYCHAR; \
+ } \