diff --git a/c/tex_parser/tex_table.c b/c/tex_parser/tex_table.c index 8037c46..41ca5af 100644 --- a/c/tex_parser/tex_table.c +++ b/c/tex_parser/tex_table.c @@ -59,7 +59,9 @@ int parse_table(const char *table_source, size_t len, struct table_s *table, str /* read one character from input stream */ char c = table_source[i]; -printf("tex_level = %lu, c = %c\n", tex_level, c); + #ifdef __TEX_TABLE_DEBUG + printf("tex_level = %lu, c = %c\n", tex_level, c); + #endif /* looking at where_stack and encountered character */ switch (where_stack[tex_level]) { case IN_UNDEF: @@ -178,39 +180,25 @@ printf("tex_level = %lu, c = %c\n", tex_level, c); #endif tag = zfree_null(tag); - } else if (c == '%') { + } else { #ifdef __TEX_TABLE_DEBUG printf("\\%s\n", tag); #endif tag = zfree_null(tag); where_stack[tex_level] = IN_TAG_UNKNOWN; - where_stack[++tex_level] = IN_COMMENT; - } else if (c == '{' || c == '[') { - #ifdef __TEX_TABLE_DEBUG - printf("\\%s\n", tag); - #endif - tag = zfree_null(tag); - where_stack[tex_level] = IN_TAG_UNKNOWN; - where_stack[++tex_level] = IN_TAGPARM; + } - } else if (isspace(c)) { // \tag { for example + if (isspace(c)) { // \tag { for example #ifdef __TEX_TABLE_DEBUG printf("\\%s\n", tag); #endif tag = zfree_null(tag); where_stack[tex_level] = IN_TAG_UNKNOWN; where_stack[++tex_level] = IN_SPACE; - - } else { // unknown tag - #ifdef __TEX_TABLE_DEBUG - printf("\\%s\n", tag); - #endif - tag = zfree_null(tag); - where_stack[tex_level] = IN_TAG_UNKNOWN; - } - - if (c == '\\' || c == '}' || c == ']') + } else if (c == '\\' || c == '}' + || c == ']' || c == '{' + || c == '[' || c == '%') i--; } break;