=================================================================== RCS file: /cvs/texi2mdoc/main.c,v retrieving revision 1.34 retrieving revision 1.38 diff -u -p -r1.34 -r1.38 --- texi2mdoc/main.c 2015/02/23 14:36:03 1.34 +++ texi2mdoc/main.c 2015/02/23 20:52:45 1.38 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.34 2015/02/23 14:36:03 kristaps Exp $ */ +/* $Id: main.c,v 1.38 2015/02/23 20:52:45 kristaps Exp $ */ /* * Copyright (c) 2015 Kristaps Dzonsons * @@ -14,6 +14,9 @@ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#if defined(__linux__) || defined(__MINT__) +# define _GNU_SOURCE /* memmem */ +#endif #include #include @@ -106,6 +109,7 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { doinline, "code", 4 }, /* TEXICMD_CODE */ { dosymbol, ":", 1 }, /* TEXICMD_COLON */ { NULL, "columnfractions", 15 }, /* TEXICMD_COLUMNFRACTIONS */ + { dosymbol, "comma", 5 }, /* TEXICMD_COMMA */ { doinline, "command", 7 }, /* TEXICMD_COMMAND */ { doignline, "c", 1 }, /* TEXICMD_COMMENT */ { doignline, "comment", 7 }, /* TEXICMD_COMMENT_LONG */ @@ -225,6 +229,7 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { dosection, "section", 7 }, /* TEXICMD_SECTION */ { dovalue, "set", 3 }, /* TEXICMD_SET */ { doignline, "setchapternewpage", 17 }, /* TEXICMD_SETCHAPNEWPAGE */ + { doignline, "setcontentsaftertitlepage", 25 }, /* TEXICMD_SETCONTENTSAFTER */ { doignline, "setfilename", 11 }, /* TEXICMD_SETFILENAME */ { dotitle, "settitle", 8 }, /* TEXICMD_SETTITLE */ { doignline, "shortcontents", 13 }, /* TEXICMD_SHORTCONTENTS */ @@ -239,6 +244,7 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { dodisplay, "smallindentblock", 16 }, /* TEXICMD_SMALLINDENTBLOCK */ { dosymbol, "{", 1 }, /* TEXICMD_SQUIGGLE_LEFT */ { dosymbol, "}", 1 }, /* TEXICMD_SQUIGGLE_RIGHT */ + { dosymbol, "ss", 2 }, /* TEXICMD_SS */ { doinline, "strong", 6 }, /* TEXICMD_STRONG */ { dosubsection, "subheading", 10 }, /* TEXICMD_SUBHEADING */ { dosubsection, "subsection", 10 }, /* TEXICMD_SUBSECTION */ @@ -254,6 +260,7 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { dotable, "table", 5 }, /* TEXICMD_TABLE */ { doignblock, "tex", 3 }, /* TEXICMD_TEX */ { dosymbol, "TeX", 3 }, /* TEXICMD_TEXSYM */ + { dosymbol, "tie", 3 }, /* TEXICMD_TIE */ { doaccent, "~", 1 }, /* TEXICMD_TILDE */ { doignline, "tindex", 6 }, /* TEXICMD_TINDEX */ { doignline, "title", 5 }, /* TEXICMD_TITLE */ @@ -323,6 +330,7 @@ dodefn(struct texi *p, enum texicmd cmd, blk = NULL; switch (cmd) { case (TEXICMD_DEFFN): + case (TEXICMD_DEFMAC): case (TEXICMD_DEFTP): case (TEXICMD_DEFTYPEFN): case (TEXICMD_DEFTYPEFUN): @@ -527,7 +535,7 @@ doignblock(struct texi *p, enum texicmd cmd, */ term = memmem(&buf[*pos], sz, end, endsz); endpos = NULL == term ? sz : - *pos + term - &buf[*pos]; + *pos + (size_t)(term - &buf[*pos]); assert(endpos <= sz); while (*pos < endpos) advance(p, buf, pos); @@ -659,7 +667,7 @@ doverbatim(struct texi *p, enum texicmd cmd, */ term = memmem(&buf[*pos], sz, end, endsz); endpos = NULL == term ? sz : - *pos + term - &buf[*pos]; + *pos + (size_t)(term - &buf[*pos]); teximacro(p, "Bd -literal -offset indent"); assert(endpos <= sz); @@ -1010,6 +1018,9 @@ dosymbol(struct texi *p, enum texicmd cmd, case (TEXICMD_BULLET): texiputchars(p, "\\(bu"); break; + case (TEXICMD_COMMA): + texiputchar(p, ','); + break; case (TEXICMD_COPYRIGHT): texiputchars(p, "\\(co"); break; @@ -1044,6 +1055,9 @@ dosymbol(struct texi *p, enum texicmd cmd, case (TEXICMD_SLASH): texiputchar(p, '/'); break; + case (TEXICMD_SS): + texiputchars(p, "\\(ss"); + break; case (TEXICMD_SQUIGGLE_LEFT): texiputchars(p, "{"); break; @@ -1053,6 +1067,9 @@ dosymbol(struct texi *p, enum texicmd cmd, case (TEXICMD_TEXSYM): texiputchars(p, "TeX"); break; + case (TEXICMD_TIE): + texiputchars(p, "\\ "); + break; case (TEXICMD_COLON): case (TEXICMD_HYPHEN): break; @@ -1341,7 +1358,10 @@ dosp(struct texi *p, enum texicmd cmd, const char *buf, size_t sz, size_t *pos) { - texivspace(p); + if (p->literal) + texiputchar(p, '\n'); + else + texivspace(p); /* FIXME: ignore and parseeoln. */ advanceeoln(p, buf, sz, pos, 1); } @@ -1617,7 +1637,7 @@ main(int argc, char *argv[]) { struct texi texi; int c; - char *path, *dir; + char *dirpath, *dir, *ccp; const char *progname, *Idir, *cp; progname = strrchr(argv[0], '/'); @@ -1642,13 +1662,11 @@ main(int argc, char *argv[]) if (0 == (argc -= optind)) goto usage; - if (NULL == (path = strdup(argv[0]))) + if (NULL == (dirpath = strdup(argv[0]))) texiabort(&texi, NULL); - else if (NULL == (dir = dirname(path))) + if (NULL == (dir = dirname(dirpath))) texiabort(&texi, NULL); - free(path); - if (NULL != (cp = strrchr(argv[0], '/'))) texi.title = strdup(cp + 1); else @@ -1656,11 +1674,12 @@ main(int argc, char *argv[]) if (NULL == texi.title) texiabort(&texi, NULL); - else if (NULL != (path = strchr(texi.title, '.'))) - *path = '\0'; + else if (NULL != (ccp = strchr(texi.title, '.'))) + *ccp = '\0'; texi.ign = 1; texi.dirs = parsedirs(&texi, dir, Idir, &texi.dirsz); + free(dirpath); parsefile(&texi, argv[0], 1); /* We shouldn't get here. */ texiexit(&texi);