домой, пора домой...

This commit is contained in:
Kolan Sh 2011-06-10 19:03:50 +04:00
parent 0f3ecd8e70
commit 5ba787d4ce
2 changed files with 73 additions and 30 deletions

View File

@ -1,18 +1,74 @@
#include "tex_table.h"
#include "tex_table_tags.h"
#include <string.h>
#include <ctype.h>
#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";

View File

@ -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