From 5ba787d4ce73fb89c1e7a534c7df95495f60f51e Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Fri, 10 Jun 2011 19:03:50 +0400 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=BC=D0=BE=D0=B9,=20=D0=BF=D0=BE?= =?UTF-8?q?=D1=80=D0=B0=20=D0=B4=D0=BE=D0=BC=D0=BE=D0=B9...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- c/tex_parser/tex_table.c | 64 ++++++++++++++++++++++++++++++++--- c/tex_parser/tex_table_tags.h | 39 +++++++-------------- 2 files changed, 73 insertions(+), 30 deletions(-) diff --git a/c/tex_parser/tex_table.c b/c/tex_parser/tex_table.c index 444387e..890c794 100644 --- a/c/tex_parser/tex_table.c +++ b/c/tex_parser/tex_table.c @@ -1,18 +1,74 @@ #include "tex_table.h" -#include "tex_table_tags.h" - #include +#include +#include "tex_table_tags.h" +#include "zmalloc.h" int parse_table(const char *table_source, size_t len, struct table_s *table, struct xerror_s *error) { if (!len) len = strlen(table_source); - for (size_t i = 0; i < len; i++) { + char *tag = NULL; + size_t i = 0; + + enum where_e + { + IN_GLOBAL, + IN_TAG, + IN_TAG_END, + IN_TAG_BEGIN_END, + IN_TAG_PARAM, + IN_TAG_BEGIN_PARAM + } where = IN_GLOBAL; + + /* Ищем первое вхождение + * \begin{longtable} + */ + for (i = 0; i < len; i++) { char c = table_source[i]; - c = c; + switch (where) { + case IN_GLOBAL: + if (c == '\\') { + zfree(&tag); + where = IN_TAG; + } + break; + + case IN_TAG: + if (!isalpha(c)) { + size_t len = zmalloc_getlen(tag); + zrealloc(&tag, len + 1); + tag[len] = c; + } else { + if (!strcmp(tag, TEX_TAG_BEGIN)) + where = IN_TAG_BEGIN_END; + else + where = IN_TAG_END; + } + + break; + + case IN_TAG_PARAM: + if () + + if (!isspace(c) || c == '{') + + + else if (isspace(c)) { + } else { + } + break; + + case IN_TAG_BEGIN_PARAM: + if (isalpha(c)) { + } else if (isspace(c)) { + } else { + } + break; + } } table->id = "Drossel1.Table1"; diff --git a/c/tex_parser/tex_table_tags.h b/c/tex_parser/tex_table_tags.h index 9db0e3a..fb8e5ff 100644 --- a/c/tex_parser/tex_table_tags.h +++ b/c/tex_parser/tex_table_tags.h @@ -1,28 +1,15 @@ -#ifndef TEX_TABLE_H -#define TEX_TABLE_H +#ifndef TEX_TABLE_TAGS_H +#define TEX_TABLE_TAGS_H -const char *TEX_TAG_BEGIN = "begin"; -const char *TEX_TAG_CLINE = "cline"; -const char *TEX_TAG_END = "end"; -const char *TEX_TAG_ENDFOOT = "endfoot"; -const char *TEX_TAG_ENDHEAD = "endhead"; -const char *TEX_TAG_HLINE = "hline"; -const char *TEX_TAG_HSPACE = "hspace"; -const char *TEX_TAG_MULTICOLUMN = "multicolumn"; -const char *TEX_TAG_MULTIROW = "multirow"; -const char *TEX_TAG_TABULARNEWLINE = "tabularnewline"; +const char * const TEX_TAG_BEGIN = "begin"; +const char * const TEX_TAG_CLINE = "cline"; +const char * const TEX_TAG_END = "end"; +const char * const TEX_TAG_ENDFOOT = "endfoot"; +const char * const TEX_TAG_ENDHEAD = "endhead"; +const char * const TEX_TAG_HLINE = "hline"; +const char * const TEX_TAG_HSPACE = "hspace"; +const char * const TEX_TAG_MULTICOLUMN = "multicolumn"; +const char * const TEX_TAG_MULTIROW = "multirow"; +const char * const TEX_TAG_TABULARNEWLINE = "tabularnewline"; -const char *ALL_TAGS[] { - TEX_TAG_BEGIN, - TEX_TAG_CLINE, - TEX_TAG_END, - TEX_TAG_ENDFOOT, - TEX_TAG_ENDHEAD, - TEX_TAG_HLINE, - TEX_TAG_HSPACE, - TEX_TAG_MULTICOLUMN, - TEX_TAG_MULTIROW, - TEX_TAG_TABULARNEWLINE -}; - -#endif // TEX_TABLE_H +#endif // TEX_TABLE_TAGS_H