X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=gedcom%2Fgedcom_lex_common.c;fp=gedcom%2Fgedcom_lex_common.c;h=149a8a8bda9630855cb7fed8115ac38bd1fdfcec;hb=9d87c36948e5cc9c90c14bd09b5007c519ed8b4b;hp=68db840b4f645da43fcbd372fd474111bd95d99c;hpb=afb412554732d2b908fe257697d89cb5d71ba1eb;p=gedcom-parse.git diff --git a/gedcom/gedcom_lex_common.c b/gedcom/gedcom_lex_common.c index 68db840..149a8a8 100644 --- a/gedcom/gedcom_lex_common.c +++ b/gedcom/gedcom_lex_common.c @@ -35,6 +35,7 @@ static size_t encoding_width; static int current_level = -1; static int level_diff=MAXGEDCLEVEL; static size_t line_len = 0; +static int tab_space = 0; static struct conv_buffer* ptr_buffer = NULL; static struct conv_buffer* tag_buffer = NULL; @@ -136,6 +137,11 @@ static void error_at_character() gedcom_error(_("'@' character should be written as '@@' in values")); } +static void error_tab_character() +{ + gedcom_error(_("Tab character is not allowed in values")); +} + static void error_unexpected_character(const char* str, char ch) { gedcom_error(_("Unexpected character: '%s' (0x%02x)"), str, ch); @@ -164,6 +170,12 @@ static int dummy_conv = 0; } \ } +#define GENERATE_TAB_SPACE \ + { gedcom_lval.string = " "; \ + tab_space--; \ + return DELIM; \ + } + #define MKTAGACTION(THETAG) \ { CHECK_LINE_LEN; \ gedcom_lval.tag.string = TO_INTERNAL(yytext, tag_buffer); \ @@ -206,10 +218,16 @@ static int dummy_conv = 0; But because this means that one token is converted into a series of tokens, there is some initial code following immediately here - that returns "pending" tokens. */ + that returns "pending" tokens. + + Also, for compatibility tabs are converted into spaces, which is + also handled here */ #define ACTION_BEFORE_REGEXPS \ - { if (level_diff < 1) { \ + { if (compat_mode(C_TAB_CHARACTER) && tab_space-- > 0) { \ + GENERATE_TAB_SPACE; \ + } \ + else if (level_diff < 1) { \ level_diff++; \ return CLOSE; \ } \ @@ -383,6 +401,17 @@ static int dummy_conv = 0; } \ } +#define ACTION_TAB \ + { if (compat_mode(C_TAB_CHARACTER)) { \ + tab_space = 8; \ + GENERATE_TAB_SPACE; \ + } \ + else { \ + error_tab_character(); \ + return BADTOKEN; \ + } \ + } + #define ACTION_UNEXPECTED \ { error_unexpected_character(yytext, yytext[0]); \ return BADTOKEN; \