домой выгоняют

This commit is contained in:
Kolan Sh 2011-06-23 19:57:17 +04:00
parent 4f1cde3f8f
commit ba528486cb
2 changed files with 77 additions and 42 deletions

View File

@ -89,8 +89,82 @@ int parse_table(const char *table_source, size_t len, struct table_s *table, str
break;
case IN_TAG:
if (isalpha(c) || isdigit(c) || (!tag && c == '\\')) { // test for char, digit and newline tag "\\"
if (isalnum(c)) {
tag = zalloc_append8_str(tag, c);
} else if (!tag && c == '\\')) { // newline tag
where_stack[tex_level--] = IN_UNDEF;
} else if (!tag) {
error->code = TEX_PARSING_ERROR_UNDEF;
error->message = TEX_PARSING_ERROR_UNDEF_STR;
return error->code;
} else if (!strcmp(tag, TEX_TAG_BEGIN)) {
where_stack[tex_level] = IN_TAG_BEGIN;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_CLINE)) {
where_stack[tex_level] = IN_TAG_CLINE;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_END)) {
where_stack[tex_level] = IN_TAG_END;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_ENDFOOT)) {
where_stack[tex_level] = IN_TAG_ENDFOOT;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_ENDHEAD)) {
where_stack[tex_level] = IN_TAG_ENDHEAD;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_HLINE)) {
where_stack[tex_level] = IN_TAG_HLINE;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_HSPACE)) {
where_stack[tex_level] = IN_TAG_HSPACE;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_MULTICOLUMN)) {
where_stack[tex_level] = IN_TAG_MULTICOLUMN;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_MULTIROW)) {
where_stack[tex_level] = IN_TAG_MULTIROW;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_TABULARNEWLINE)) {
where_stack[tex_level] = IN_TAG_TABULARNEWLINE;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (!strcmp(tag, TEX_TAG_SLASH)) {
where_stack[tex_level] = IN_TAG_SLASH;
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else { // unknown tag
printf("\\%s\n", tag);
tag = zfree_null(tag);
} else if (c == '{' || c == '[') {
where_stack[++tex_level] = IN_TAGPARM;
} else if (isspace(c)) {
} else if (c == '{' || c == '[') {
@ -104,44 +178,7 @@ int parse_table(const char *table_source, size_t len, struct table_s *table, str
error->message = TEX_PARSING_ERROR_UNDEF_STR;
return error->code;
} else {
if (!strcmp(tag, TEX_TAG_BEGIN)) {
where_stack[tex_level] = IN_TAG_BEGIN;
} else if (!strcmp(tag, TEX_TAG_CLINE)) {
where_stack[tex_level] = IN_TAG_CLINE;
} else if (!strcmp(tag, TEX_TAG_END)) {
where_stack[tex_level] = IN_TAG_END;
} else if (!strcmp(tag, TEX_TAG_ENDFOOT)) {
where_stack[tex_level] = IN_TAG_ENDFOOT;
} else if (!strcmp(tag, TEX_TAG_ENDHEAD)) {
where_stack[tex_level] = IN_TAG_ENDHEAD;
} else if (!strcmp(tag, TEX_TAG_HLINE)) {
where_stack[tex_level] = IN_TAG_HLINE;
} else if (!strcmp(tag, TEX_TAG_HSPACE)) {
where_stack[tex_level] = IN_TAG_HSPACE;
} else if (!strcmp(tag, TEX_TAG_MULTICOLUMN)) {
where_stack[tex_level] = IN_TAG_MULTICOLUMN;
} else if (!strcmp(tag, TEX_TAG_MULTIROW)) {
where_stack[tex_level] = IN_TAG_MULTIROW;
} else if (!strcmp(tag, TEX_TAG_TABULARNEWLINE)) {
where_stack[tex_level] = IN_TAG_TABULARNEWLINE;
} else if (!strcmp(tag, TEX_TAG_SLASH)) {
where_stack[tex_level] = IN_TAG_SLASH;
} else { // unknown tag
}
printf("\\%s\n", tag);
tag = zfree_null(tag);
}
break;

View File

@ -17,14 +17,12 @@ long_line_column=72
[files]
current_page=1
FILE_NAME_0=709;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_test.c;0
FILE_NAME_1=4568;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.c;0
FILE_NAME_0=1029;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_test.c;0
FILE_NAME_1=2132;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.c;0
FILE_NAME_2=119;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table.h;0
FILE_NAME_3=1762;C;0;16;1;1;1;/home/kolan/projects/include/zalloc_ext.h;0
FILE_NAME_4=634;C;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tex_table_tags.h;0
FILE_NAME_5=1859;Make;0;16;1;1;1;/home/kolan/dev/c/tex_parser/Makefile;0
FILE_NAME_6=0;LaTeX;0;53;1;1;1;/home/kolan/dev/c/tex_parser/tables5.tex;0
FILE_NAME_7=0;Пустой;0;16;1;1;1;/home/kolan/dev/c/tex_parser/tables4.aux;0
[build-menu]
NF_00_LB=_Сделать