Object table wandering is now correct

This commit is contained in:
Kolan Sh 2011-07-19 16:35:38 +04:00
parent 1e1bcf1236
commit c310bbc319
2 changed files with 20 additions and 8 deletions

View File

@ -57,7 +57,7 @@ void tex_parse(const char *source, size_t len, struct tex_struct_s **tex_struct,
/* stack checking */
if (tex_level + 1 == MAX_TEX_STACK_LEVEL) {
z_set_error(error, TEX_PARSER_DOMAIN, TEX_PARSER_ERROR_STACK,
z_set_error(error, TEX_PARSER_DOMAIN, TEX_PARSER_ERROR_STACKOVERFLOW,
"tex_parse(): stack overflow, symbol %c(0x%2.2x) at position %d",
source[i], (u_int8_t)source[i], i);
return;
@ -191,8 +191,19 @@ void tex_parse(const char *source, size_t len, struct tex_struct_s **tex_struct,
#endif
} else if (tex_level && where_stack[tex_level - 1] == IN_TAG_END
&& !strcmp(param, TEX_PARAM_TABLE)) {
object_stack[obj_level--] = OBJ_UNDEF;
&& !strcmp(param, TEX_PARAM_TABLE)) {
object_stack[obj_level--] = OBJ_UNDEF;
if (object_stack[obj_level] == OBJ_TABLE)
object_stack[obj_level--] = OBJ_UNDEF;
else {
z_set_error(error, TEX_PARSER_DOMAIN, TEX_PARSER_ERROR_STACKEMPTY,
"tex_parse(): IN_TAGPARM unexpected symbol %c(0x%2.2x) at position %d",
source[i], (u_int8_t)source[i], i);
return;
}
#ifdef __TEX_PARSER_DEBUG
puts("<-OBJ_UNDEF");
#endif
@ -248,10 +259,10 @@ void tex_parse(const char *source, size_t len, struct tex_struct_s **tex_struct,
} else if (c == '\\') {
switch (object_stack[obj_level]) {
case OBJ_TABLE:
object_stack[++obj_level] = OBJ_TABLE_SUBTABLE;
case OBJ_TABLE_PARAMS:
object_stack[obj_level] = OBJ_TABLE_SUBTABLE;
#ifdef __TEX_PARSER_DEBUG
puts("->OBJ_TABLE_SUBTABLE");
puts("=OBJ_TABLE_SUBTABLE");
#endif
break;

View File

@ -12,7 +12,7 @@
*
* @TEX_PARSER_NOERROR: Default state indicates no error.
* @TEX_PARSER_ERROR_UNKNOWN: Uncontrolled error happen
* @TEX_PARSER_ERROR_STACK: Stack overflow
* @TEX_PARSER_ERROR_STACKOVERFLOW: Stack overflow
* @TEX_PARSER_ERROR_PLACE_UNKNOWN: Unknown place (internal error)
* @TEX_PARSER_ERROR_UNEXPECTED_SYMBOL: Unexpected symbol for current place
*
@ -21,7 +21,8 @@
enum tex_parser_error {
TEX_PARSER_NOERROR = 0,
TEX_PARSER_ERROR_UNKNOWN,
TEX_PARSER_ERROR_STACK,
TEX_PARSER_ERROR_STACKOVERFLOW,
TEX_PARSER_ERROR_STACKEMPTY,
TEX_PARSER_ERROR_PLACE_UNKNOWN,
TEX_PARSER_ERROR_UNEXPECTED_SYMBOL,
};