=================================================================== RCS file: /cvs/texi2mdoc/main.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -p -r1.32 -r1.33 --- texi2mdoc/main.c 2015/02/23 12:28:20 1.32 +++ texi2mdoc/main.c 2015/02/23 12:39:59 1.33 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.32 2015/02/23 12:28:20 kristaps Exp $ */ +/* $Id: main.c,v 1.33 2015/02/23 12:39:59 kristaps Exp $ */ /* * Copyright (c) 2015 Kristaps Dzonsons * @@ -74,6 +74,7 @@ static void dotab(struct texi *, enum texicmd, const c static void dotitle(struct texi *, enum texicmd, const char *, size_t, size_t *); static void dovalue(struct texi *, enum texicmd, const char *, size_t, size_t *); static void doverb(struct texi *, enum texicmd, const char *, size_t, size_t *); +static void doverbatim(struct texi *, enum texicmd, const char *, size_t, size_t *); static void doverbinclude(struct texi *, enum texicmd, const char *, size_t, size_t *); static const struct texitok __texitoks[TEXICMD__MAX] = { @@ -262,7 +263,8 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { dolink, "url", 3 }, /* TEXICMD_URL */ { dovalue, "value", 5 }, /* TEXICMD_VALUE */ { doinline, "var", 3 }, /* TEXICMD_VAR */ - { doverb, "verbatim", 8 }, /* TEXICMD_VERBATIM */ + { doverb, "verb", 4 }, /* TEXICMD_VERB */ + { doverbatim, "verbatim", 8 }, /* TEXICMD_VERBATIM */ { doverbinclude, "verbatiminclude", 15 }, /* TEXICMD_VERBATIMINCLUDE */ { doignline, "vindex", 6 }, /* TEXICMD_VINDEX */ { dosp, "vskip", 5 }, /* TEXICMD_VSKIP */ @@ -586,6 +588,42 @@ doinline(struct texi *p, enum texicmd cmd, static void doverb(struct texi *p, enum texicmd cmd, + const char *buf, size_t sz, size_t *pos) +{ + char delim; + + while (*pos < sz && isws(buf[*pos])) + advance(p, buf, pos); + if (*pos == sz || '{' != buf[*pos]) + return; + advance(p, buf, pos); + if (*pos == sz) + return; + + delim = buf[*pos]; + advance(p, buf, pos); + /* Make sure we flush out our initial whitespace... */ + if (p->seenws && p->outcol && 0 == p->literal) + texiputchar(p, ' '); + p->seenws = 0; + /* Read until we see the delimiter then end-brace. */ + while (*pos < sz - 1) { + if (buf[*pos] == delim && buf[*pos + 1] == '}') + break; + texiputchar(p, buf[*pos]); + advance(p, buf, pos); + } + if (*pos == sz - 1) + return; + /* Make sure we read after the end-brace. */ + assert(delim == buf[*pos]); + advance(p, buf, pos); + assert('}' == buf[*pos]); + advance(p, buf, pos); +} + +static void +doverbatim(struct texi *p, enum texicmd cmd, const char *buf, size_t sz, size_t *pos) { const char *end, *term;