version 1.29, 2015/02/21 22:01:32 |
version 1.32, 2015/02/23 12:28:20 |
Line 58 static void doinclude(struct texi *, enum texicmd, con |
|
Line 58 static void doinclude(struct texi *, enum texicmd, con |
|
static void doitem(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void doitem(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void doitemize(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void doitemize(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dolink(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void dolink(struct texi *, enum texicmd, const char *, size_t, size_t *); |
|
static void domacro(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void domath(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void domath(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void domultitable(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void domultitable(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void doquotation(struct texi *, enum texicmd, const char *, size_t, size_t *); |
static void doquotation(struct texi *, enum texicmd, const char *, size_t, size_t *); |
Line 150 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
Line 151 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
{ doinline, "file", 4 }, /* TEXICMD_FILE */ |
{ doinline, "file", 4 }, /* TEXICMD_FILE */ |
{ doignline, "finalout", 8 }, /* TEXICMD_FINALOUT */ |
{ doignline, "finalout", 8 }, /* TEXICMD_FINALOUT */ |
{ doignline, "findex", 6 }, /* TEXICMD_FINDEX */ |
{ doignline, "findex", 6 }, /* TEXICMD_FINDEX */ |
|
{ doignbracket, "footnote", 8 }, /* TEXICMD_FOOTNOTE */ |
{ dotable, "ftable", 6 }, /* TEXICMD_FTABLE */ |
{ dotable, "ftable", 6 }, /* TEXICMD_FTABLE */ |
{ dodisplay, "format", 6 }, /* TEXICMD_FORMAT */ |
{ dodisplay, "format", 6 }, /* TEXICMD_FORMAT */ |
{ doaccent, "`", 1 }, /* TEXICMD_GRAVE */ |
{ doaccent, "`", 1 }, /* TEXICMD_GRAVE */ |
Line 172 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
Line 174 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
{ doblock, "ifnotxml", 8 }, /* TEXICMD_IFNOTXML */ |
{ doblock, "ifnotxml", 8 }, /* TEXICMD_IFNOTXML */ |
{ doblock, "ifplaintext", 11 }, /* TEXICMD_IFPLAINTEXT */ |
{ doblock, "ifplaintext", 11 }, /* TEXICMD_IFPLAINTEXT */ |
{ doignblock, "iftex", 5 }, /* TEXICMD_IFTEX */ |
{ doignblock, "iftex", 5 }, /* TEXICMD_IFTEX */ |
{ doignblock, "ifset", 5 }, /* TEXICMD_IFSET */ |
{ dovalue, "ifset", 5 }, /* TEXICMD_IFSET */ |
{ doignblock, "ifxml", 5 }, /* TEXICMD_IFXML */ |
{ doignblock, "ifxml", 5 }, /* TEXICMD_IFXML */ |
{ doignblock, "ignore", 6 }, /* TEXICMD_IGNORE */ |
{ doignblock, "ignore", 6 }, /* TEXICMD_IGNORE */ |
{ doignbracket, "image", 5 }, /* TEXICMD_IMAGE */ |
{ doignbracket, "image", 5 }, /* TEXICMD_IMAGE */ |
{ doinclude, "include", 7 }, /* TEXICMD_INCLUDE */ |
{ doinclude, "include", 7 }, /* TEXICMD_INCLUDE */ |
{ dodisplay, "indentblock", 11 }, /* TEXICMD_INDENTBLOCK */ |
{ dodisplay, "indentblock", 11 }, /* TEXICMD_INDENTBLOCK */ |
{ doignline, "", 0 }, /* TEXICMD_INDEX */ |
{ doignline, "", 0 }, /* TEXICMD_USER_INDEX */ |
{ doignline, "insertcopying", 13 }, /* TEXICMD_INSERTCOPYING */ |
{ doignline, "insertcopying", 13 }, /* TEXICMD_INSERTCOPYING */ |
{ doitem, "item", 4 }, /* TEXICMD_ITEM */ |
{ doitem, "item", 4 }, /* TEXICMD_ITEM */ |
{ doitemize, "itemize", 7 }, /* TEXICMD_ITEMIZE */ |
{ doitemize, "itemize", 7 }, /* TEXICMD_ITEMIZE */ |
Line 188 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
Line 190 static const struct texitok __texitoks[TEXICMD__MAX] = |
|
{ doignline, "kindex", 6 }, /* TEXICMD_KINDEX */ |
{ doignline, "kindex", 6 }, /* TEXICMD_KINDEX */ |
{ dosymbol, "LaTeX", 5 }, /* TEXICMD_LATEX */ |
{ dosymbol, "LaTeX", 5 }, /* TEXICMD_LATEX */ |
{ dosecoffs, "lowersections", 13 }, /* TEXICMD_LOWERSECTIONS */ |
{ dosecoffs, "lowersections", 13 }, /* TEXICMD_LOWERSECTIONS */ |
|
{ domacro, "macro", 5 }, /* TEXICMD_MACRO */ |
{ domath, "math", 4 }, /* TEXICMD_MATH */ |
{ domath, "math", 4 }, /* TEXICMD_MATH */ |
{ doignblock, "menu", 4 }, /* TEXICMD_MENU */ |
{ doignblock, "menu", 4 }, /* TEXICMD_MENU */ |
{ dosymbol, "minus", 5 }, /* TEXICMD_MINUS */ |
{ dosymbol, "minus", 5 }, /* TEXICMD_MINUS */ |
Line 426 dodefn(struct texi *p, enum texicmd cmd, |
|
Line 429 dodefn(struct texi *p, enum texicmd cmd, |
|
} |
} |
|
|
static void |
static void |
|
domacro(struct texi *p, enum texicmd cmd, |
|
const char *buf, size_t sz, size_t *pos) |
|
{ |
|
size_t start, end, endtoksz, len; |
|
struct teximacro m; |
|
const char *endtok, *blk; |
|
|
|
memset(&m, 0, sizeof(struct teximacro)); |
|
|
|
while (*pos < sz && isws(buf[*pos])) |
|
advance(p, buf, pos); |
|
|
|
for (start = end = *pos; end < sz; end++) |
|
if (ismspace(buf[end]) || '{' == buf[end]) |
|
break; |
|
|
|
if (start == end) |
|
texierr(p, "zero-length macro name"); |
|
|
|
advanceto(p, buf, pos, end); |
|
|
|
m.key = malloc(end - start + 1); |
|
if (NULL == m.key) |
|
texiabort(p, NULL); |
|
memcpy(m.key, &buf[start], end - start); |
|
m.key[end - start] = '\0'; |
|
|
|
m.args = argparse(p, buf, sz, pos, &m.argsz, 0); |
|
advanceeoln(p, buf, sz, pos, 0); |
|
|
|
start = *pos; |
|
endtok = "\n@end macro\n"; |
|
endtoksz = strlen(endtok); |
|
blk = memmem(&buf[start], sz, endtok, endtoksz); |
|
if (NULL == blk) |
|
texierr(p, "unterminated macro body"); |
|
while (&buf[*pos] != blk) |
|
advance(p, buf, pos); |
|
assert('\n' == buf[*pos]); |
|
advance(p, buf, pos); |
|
len = blk - &buf[start]; |
|
m.value = malloc(len + 1); |
|
if (NULL == m.value) |
|
texiabort(p, NULL); |
|
memcpy(m.value, &buf[start], len); |
|
m.value[len] = '\0'; |
|
|
|
p->macros = realloc |
|
(p->macros, |
|
(p->macrosz + 1) * |
|
sizeof(struct teximacro)); |
|
if (NULL == p->macros) |
|
texiabort(p, NULL); |
|
|
|
p->macros[p->macrosz++] = m; |
|
advanceeoln(p, buf, sz, pos, 1); |
|
} |
|
|
|
static void |
doignblock(struct texi *p, enum texicmd cmd, |
doignblock(struct texi *p, enum texicmd cmd, |
const char *buf, size_t sz, size_t *pos) |
const char *buf, size_t sz, size_t *pos) |
{ |
{ |
Line 584 doverbinclude(struct texi *p, enum texicmd cmd, |
|
Line 646 doverbinclude(struct texi *p, enum texicmd cmd, |
|
advance(p, buf, pos); |
advance(p, buf, pos); |
continue; |
continue; |
} |
} |
type = texicmd(p, buf, *pos, sz, &end); |
type = texicmd(p, buf, *pos, sz, &end, NULL); |
advanceto(p, buf, pos, end); |
advanceto(p, buf, pos, end); |
if (TEXICMD_VALUE != type) |
if (TEXICMD_VALUE != type) |
texierr(p, "unknown verbatiminclude command"); |
texierr(p, "unknown verbatiminclude command"); |
Line 643 doinclude(struct texi *p, enum texicmd cmd, |
|
Line 705 doinclude(struct texi *p, enum texicmd cmd, |
|
advance(p, buf, pos); |
advance(p, buf, pos); |
continue; |
continue; |
} |
} |
type = texicmd(p, buf, *pos, sz, &end); |
type = texicmd(p, buf, *pos, sz, &end, NULL); |
advanceto(p, buf, pos, end); |
advanceto(p, buf, pos, end); |
if (TEXICMD_VALUE != type) |
if (TEXICMD_VALUE != type) |
texierr(p, "unknown include command"); |
texierr(p, "unknown include command"); |
Line 912 dosymbol(struct texi *p, enum texicmd cmd, |
|
Line 974 dosymbol(struct texi *p, enum texicmd cmd, |
|
case (TEXICMD_HYPHEN): |
case (TEXICMD_HYPHEN): |
break; |
break; |
default: |
default: |
texiwarn(p, "sym: %d", cmd); |
|
abort(); |
abort(); |
} |
} |
|
|
Line 1017 dovalue(struct texi *p, enum texicmd cmd, |
|
Line 1078 dovalue(struct texi *p, enum texicmd cmd, |
|
if (64 == p->valstackpos) |
if (64 == p->valstackpos) |
texierr(p, "too many nested values"); |
texierr(p, "too many nested values"); |
p->valstack[p->valstackpos++] = cp; |
p->valstack[p->valstackpos++] = cp; |
parseeof(p, cp, strlen(cp)); |
parsemembuf(p, cp, strlen(cp)); |
p->valstackpos--; |
p->valstackpos--; |
} else |
} else |
texiputchars(p, "{No value}"); |
texiputchars(p, "{No value}"); |
Line 1026 dovalue(struct texi *p, enum texicmd cmd, |
|
Line 1087 dovalue(struct texi *p, enum texicmd cmd, |
|
doignblock(p, cmd, buf, sz, pos); |
doignblock(p, cmd, buf, sz, pos); |
else |
else |
parseto(p, buf, sz, pos, texitoks[cmd].tok); |
parseto(p, buf, sz, pos, texitoks[cmd].tok); |
|
} else if (TEXICMD_IFSET == cmd) { |
|
if (NULL == valuellookup(p, buf, sz, pos)) |
|
doignblock(p, cmd, buf, sz, pos); |
|
else |
|
parseto(p, buf, sz, pos, texitoks[cmd].tok); |
} else if (TEXICMD_CLEAR == cmd) |
} else if (TEXICMD_CLEAR == cmd) |
valuelclear(p, buf, sz, pos); |
valuelclear(p, buf, sz, pos); |
} |
} |
Line 1286 domultitable(struct texi *p, enum texicmd cmd, |
|
Line 1352 domultitable(struct texi *p, enum texicmd cmd, |
|
const char *buf, size_t sz, size_t *pos) |
const char *buf, size_t sz, size_t *pos) |
{ |
{ |
enum texilist sv = p->list; |
enum texilist sv = p->list; |
|
int svliteral = p->literal; |
enum texicmd type; |
enum texicmd type; |
size_t i, end, columns; |
size_t i, end, columns; |
|
|
p->list = TEXILIST_TABLE; |
p->list = TEXILIST_TABLE; |
|
/* |
|
* TS/TE blocks aren't "in mdoc(7)", so we can disregard the |
|
* fact that we're in literal mode right now. |
|
*/ |
|
p->literal = 0; |
teximacro(p, "TS"); |
teximacro(p, "TS"); |
columns = 0; |
columns = 0; |
|
|
Line 1306 domultitable(struct texi *p, enum texicmd cmd, |
|
Line 1378 domultitable(struct texi *p, enum texicmd cmd, |
|
* arguments to set the number of columns that we'll |
* arguments to set the number of columns that we'll |
* have. |
* have. |
*/ |
*/ |
type = texicmd(p, buf, *pos, sz, &end); |
type = texicmd(p, buf, *pos, sz, &end, NULL); |
advanceto(p, buf, pos, end); |
advanceto(p, buf, pos, end); |
if (TEXICMD_COLUMNFRACTIONS != type) |
if (TEXICMD_COLUMNFRACTIONS != type) |
texierr(p, "unknown multitable command"); |
texierr(p, "unknown multitable command"); |
Line 1342 domultitable(struct texi *p, enum texicmd cmd, |
|
Line 1414 domultitable(struct texi *p, enum texicmd cmd, |
|
parseto(p, buf, sz, pos, texitoks[cmd].tok); |
parseto(p, buf, sz, pos, texitoks[cmd].tok); |
p->outmacro--; |
p->outmacro--; |
teximacro(p, "TE"); |
teximacro(p, "TE"); |
|
p->literal = svliteral; |
p->list = sv; |
p->list = sv; |
} |
} |
|
|