по сути работало неверно, изменил алгоритм входа в теги

This commit is contained in:
Kolan Sh 2011-06-28 12:23:33 +04:00
parent b3ed9f553c
commit 624e1322a2

View File

@ -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 */ /* read one character from input stream */
char c = table_source[i]; 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 */ /* looking at where_stack and encountered character */
switch (where_stack[tex_level]) { switch (where_stack[tex_level]) {
case IN_UNDEF: case IN_UNDEF:
@ -178,39 +180,25 @@ printf("tex_level = %lu, c = %c\n", tex_level, c);
#endif #endif
tag = zfree_null(tag); tag = zfree_null(tag);
} else if (c == '%') { } else {
#ifdef __TEX_TABLE_DEBUG #ifdef __TEX_TABLE_DEBUG
printf("\\%s\n", tag); printf("\\%s\n", tag);
#endif #endif
tag = zfree_null(tag); tag = zfree_null(tag);
where_stack[tex_level] = IN_TAG_UNKNOWN; 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 #ifdef __TEX_TABLE_DEBUG
printf("\\%s\n", tag); printf("\\%s\n", tag);
#endif #endif
tag = zfree_null(tag); tag = zfree_null(tag);
where_stack[tex_level] = IN_TAG_UNKNOWN; where_stack[tex_level] = IN_TAG_UNKNOWN;
where_stack[++tex_level] = IN_SPACE; where_stack[++tex_level] = IN_SPACE;
} else if (c == '\\' || c == '}'
} else { // unknown tag || c == ']' || c == '{'
#ifdef __TEX_TABLE_DEBUG || c == '[' || c == '%')
printf("\\%s\n", tag);
#endif
tag = zfree_null(tag);
where_stack[tex_level] = IN_TAG_UNKNOWN;
}
if (c == '\\' || c == '}' || c == ']')
i--; i--;
} }
break; break;