=================================================================== RCS file: /cvs/texi2mdoc/main.c,v retrieving revision 1.25 retrieving revision 1.33 diff -u -p -r1.25 -r1.33 --- texi2mdoc/main.c 2015/02/20 12:25:25 1.25 +++ texi2mdoc/main.c 2015/02/23 12:39:59 1.33 @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.25 2015/02/20 12:25:25 kristaps Exp $ */ +/* $Id: main.c,v 1.33 2015/02/23 12:39:59 kristaps Exp $ */ /* * Copyright (c) 2015 Kristaps Dzonsons * @@ -44,6 +44,7 @@ static void doaccent(struct texi *, enum texicmd, cons static void doblock(struct texi *, enum texicmd, const char *, size_t, size_t *); static void dobracket(struct texi *, enum texicmd, const char *, size_t, size_t *); static void dobye(struct texi *, enum texicmd, const char *, size_t, size_t *); +static void dodefindex(struct texi *, enum texicmd, const char *, size_t, size_t *); static void dodefn(struct texi *, enum texicmd, const char *, size_t, size_t *); static void dodisplay(struct texi *, enum texicmd, const char *, size_t, size_t *); static void doenumerate(struct texi *, enum texicmd, const char *, size_t, size_t *); @@ -57,6 +58,7 @@ static void doinclude(struct texi *, enum texicmd, con 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 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 domultitable(struct texi *, enum texicmd, const char *, size_t, size_t *); static void doquotation(struct texi *, enum texicmd, const char *, size_t, size_t *); @@ -72,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] = { @@ -107,8 +110,10 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { doignline, "contents", 8 }, /* TEXICMD_CONTENTS */ { doignblock, "copying", 7 }, /* TEXICMD_COPYING */ { dosymbol, "copyright", 9 }, /* TEXICMD_COPYRIGHT */ + { dodefindex, "defcodeindex", 12 }, /* TEXICMD_DEFCODEINDEX */ { dodefn, "deffn", 5 }, /* TEXICMD_DEFFN */ { dodefn, "deffnx", 6 }, /* TEXICMD_DEFFNX */ + { dodefindex, "defindex", 8 }, /* TEXICMD_DEFINDEX */ { dodefn, "defmac", 6 }, /* TEXICMD_DEFMAC */ { dodefn, "defmacx", 7 }, /* TEXICMD_DEFMACX */ { dodefn, "deftp", 5 }, /* TEXICMD_DEFTP */ @@ -132,12 +137,14 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { doignline, "dircategory", 11 }, /* TEXICMD_DIRCATEGORY */ { doignblock, "direntry", 8 }, /* TEXICMD_DIRENTRY */ { dodisplay, "display", 7 }, /* TEXICMD_DISPLAY */ + { doignbracket, "dmn", 3 }, /* TEXICMD_DMN */ { dosymbol, "dots", 4 }, /* TEXICMD_DOTS */ { dolink, "email", 5 }, /* TEXICMD_EMAIL */ { doinline, "emph", 4 }, /* TEXICMD_EMPH */ { NULL, "end", 3 }, /* TEXICMD_END */ { doenumerate, "enumerate", 9 }, /* TEXICMD_ENUMERATE */ { doinline, "env", 3 }, /* TEXICMD_ENV */ + { dosymbol, "equiv", 5 }, /* TEXICMD_EQUIV */ { dosymbol, "error", 5 }, /* TEXICMD_ERROR */ { doexample, "example", 7 }, /* TEXICMD_EXAMPLE */ { doignline, "exdent", 6 }, /* TEXICMD_EXDENT */ @@ -145,6 +152,7 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { doinline, "file", 4 }, /* TEXICMD_FILE */ { doignline, "finalout", 8 }, /* TEXICMD_FINALOUT */ { doignline, "findex", 6 }, /* TEXICMD_FINDEX */ + { doignbracket, "footnote", 8 }, /* TEXICMD_FOOTNOTE */ { dotable, "ftable", 6 }, /* TEXICMD_FTABLE */ { dodisplay, "format", 6 }, /* TEXICMD_FORMAT */ { doaccent, "`", 1 }, /* TEXICMD_GRAVE */ @@ -158,7 +166,7 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { dovalue, "ifclear", 7 }, /* TEXICMD_IFCLEAR */ { doignblock, "ifdocbook", 9 }, /* TEXICMD_IFDOCBOOK */ { doignblock, "ifhtml", 6 }, /* TEXICMD_IFHTML */ - { doignblock, "ifinfo", 6 }, /* TEXICMD_IFINFO */ + { doblock, "ifinfo", 6 }, /* TEXICMD_IFINFO */ { doblock, "ifnotdocbook", 12 }, /* TEXICMD_IFNOTDOCBOOK */ { doblock, "ifnothtml", 9 }, /* TEXICMD_IFNOTHTML */ { doblock, "ifnotinfo", 9 }, /* TEXICMD_IFNOTINFO */ @@ -167,12 +175,13 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { doblock, "ifnotxml", 8 }, /* TEXICMD_IFNOTXML */ { doblock, "ifplaintext", 11 }, /* TEXICMD_IFPLAINTEXT */ { doignblock, "iftex", 5 }, /* TEXICMD_IFTEX */ - { doignblock, "ifset", 5 }, /* TEXICMD_IFSET */ + { dovalue, "ifset", 5 }, /* TEXICMD_IFSET */ { doignblock, "ifxml", 5 }, /* TEXICMD_IFXML */ { doignblock, "ignore", 6 }, /* TEXICMD_IGNORE */ { doignbracket, "image", 5 }, /* TEXICMD_IMAGE */ { doinclude, "include", 7 }, /* TEXICMD_INCLUDE */ { dodisplay, "indentblock", 11 }, /* TEXICMD_INDENTBLOCK */ + { doignline, "", 0 }, /* TEXICMD_USER_INDEX */ { doignline, "insertcopying", 13 }, /* TEXICMD_INSERTCOPYING */ { doitem, "item", 4 }, /* TEXICMD_ITEM */ { doitemize, "itemize", 7 }, /* TEXICMD_ITEMIZE */ @@ -182,6 +191,7 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { doignline, "kindex", 6 }, /* TEXICMD_KINDEX */ { dosymbol, "LaTeX", 5 }, /* TEXICMD_LATEX */ { dosecoffs, "lowersections", 13 }, /* TEXICMD_LOWERSECTIONS */ + { domacro, "macro", 5 }, /* TEXICMD_MACRO */ { domath, "math", 4 }, /* TEXICMD_MATH */ { doignblock, "menu", 4 }, /* TEXICMD_MENU */ { dosymbol, "minus", 5 }, /* TEXICMD_MINUS */ @@ -197,10 +207,12 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { doignline, "page", 4 }, /* TEXICMD_PAGE */ { doignline, "paragraphindent", 15 }, /* TEXICMD_PARINDENT */ { dosymbol, ".", 1 }, /* TEXICMD_PERIOD */ + { doignline, "pindex", 6 }, /* TEXICMD_PINDEX */ { doignline, "printindex", 10 }, /* TEXICMD_PRINTINDEX */ { doinline, "r", 1 }, /* TEXICMD_R */ { dosecoffs, "raisesections", 13 }, /* TEXICMD_RAISESECTIONS */ { dobracket, "ref", 3 }, /* TEXICMD_REF */ + { doignline, "refill", 6 }, /* TEXICMD_REFILL */ { dosymbol, "result", 6 }, /* TEXICMD_RESULT */ { doinline, "samp", 4 }, /* TEXICMD_SAMP */ { doinline, "sansserif", 9 }, /* TEXICMD_SANSSERIF */ @@ -224,9 +236,11 @@ static const struct texitok __texitoks[TEXICMD__MAX] = { doinline, "strong", 6 }, /* TEXICMD_STRONG */ { dosubsection, "subheading", 10 }, /* TEXICMD_SUBHEADING */ { dosubsection, "subsection", 10 }, /* TEXICMD_SUBSECTION */ + { dosubsubsection, "subsubheading", 13 }, /* TEXICMD_SUBSUBHEADING */ { dosubsubsection, "subsubsection", 13 }, /* TEXICMD_SUBSUBSECTION */ { doignline, "subtitle", 8 }, /* TEXICMD_SUBTITLE */ { doignline, "summarycontents", 15 }, /* TEXICMD_SUMMARYCONTENTS */ + { doignline, "synindex", 8 }, /* TEXICMD_SYNINDEX */ { doignline, "syncodeindex", 12 }, /* TEXICMD_SYNCODEINDEX */ { doinline, "t", 1 }, /* TEXICMD_T */ { dotab, "tab", 3 }, /* TEXICMD_TAB */ @@ -249,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 */ @@ -262,6 +277,37 @@ static const struct texitok __texitoks[TEXICMD__MAX] = const struct texitok *const texitoks = __texitoks; static void +dodefindex(struct texi *p, enum texicmd cmd, + const char *buf, size_t sz, size_t *pos) +{ + size_t start, end; + char *cp; + + while (*pos < sz && isws(buf[*pos])) + advance(p, buf, pos); + + start = end = *pos; + while (end < sz && ! ismspace(buf[end])) + end++; + + if (start == end) { + advanceeoln(p, buf, sz, pos, 1); + return; + } else if (NULL == (cp = malloc(end - start + 1))) + texiabort(p, NULL); + + memcpy(cp, &buf[start], end - start); + cp[end - start] = '\0'; + + p->indexs = realloc(p->indexs, + sizeof(char *) * (p->indexsz + 1)); + + if (NULL == p->indexs) + texiabort(p, NULL); + p->indexs[p->indexsz++] = cp; +} + +static void dodefn(struct texi *p, enum texicmd cmd, const char *buf, size_t sz, size_t *pos) { @@ -385,13 +431,96 @@ dodefn(struct texi *p, enum texicmd cmd, } 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, const char *buf, size_t sz, size_t *pos) { - - p->ign++; - parseto(p, buf, sz, pos, texitoks[cmd].tok); - p->ign--; + char end[32]; + const char *term; + size_t endsz, endpos; + + /* + * We want to completely ignore everything in these blocks, so + * simply jump to the @end block. + */ + endsz = snprintf(end, sizeof(end), + "\n@end %s\n", texitoks[cmd].tok); + assert(endsz < sizeof(end)); + + /* + * Look up where our end token occurs. + * Set our end position based on the relative offset of that + * from our current position, or the EOF if we don't have a + * proper ending point. + */ + term = memmem(&buf[*pos], sz, end, endsz); + endpos = NULL == term ? sz : + *pos + term - &buf[*pos]; + assert(endpos <= sz); + while (*pos < endpos) + advance(p, buf, pos); + + /* Only do this if we're not already at the end. */ + if (endpos < sz) + advanceto(p, buf, pos, endpos + endsz); } static void @@ -461,9 +590,47 @@ 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; size_t endsz, endpos; + advanceeoln(p, buf, sz, pos, 1); + /* We end at exactly this token. */ end = "\n@end verbatim\n"; endsz = strlen(end); @@ -479,8 +646,11 @@ doverb(struct texi *p, enum texicmd cmd, teximacro(p, "Bd -literal -offset indent"); assert(endpos <= sz); - /* Run to the point inclusive the endpoint newline. */ - while (*pos < endpos + 1) { + while (*pos < endpos) { + if (buf[*pos] == '\n') + p->outcol = 0; + else + p->outcol++; if (*pos > 0 && '.' == buf[*pos]) if ('\n' == buf[*pos - 1]) fputs("\\&", stdout); @@ -490,7 +660,7 @@ doverb(struct texi *p, enum texicmd cmd, advance(p, buf, pos); } teximacro(p, "Ed"); - advanceto(p, buf, pos, *pos + endpos + endsz); + advanceto(p, buf, pos, endpos + endsz); } static void @@ -514,7 +684,7 @@ doverbinclude(struct texi *p, enum texicmd cmd, advance(p, buf, pos); continue; } - type = texicmd(p, buf, *pos, sz, &end); + type = texicmd(p, buf, *pos, sz, &end, NULL); advanceto(p, buf, pos, end); if (TEXICMD_VALUE != type) texierr(p, "unknown verbatiminclude command"); @@ -573,7 +743,7 @@ doinclude(struct texi *p, enum texicmd cmd, advance(p, buf, pos); continue; } - type = texicmd(p, buf, *pos, sz, &end); + type = texicmd(p, buf, *pos, sz, &end, NULL); advanceto(p, buf, pos, end); if (TEXICMD_VALUE != type) texierr(p, "unknown include command"); @@ -681,8 +851,11 @@ dotitle(struct texi *p, enum texicmd cmd, start = end = *pos; while (end < sz && '\n' != buf[end]) end++; + advanceeoln(p, buf, sz, pos, 1); free(p->subtitle); p->subtitle = malloc(end - start + 1); + if (NULL == p->subtitle) + texiabort(p, NULL); memcpy(p->subtitle, &buf[start], end - start); p->subtitle[end - start] = '\0'; } @@ -802,6 +975,9 @@ dosymbol(struct texi *p, enum texicmd cmd, case (TEXICMD_DOTS): texiputchars(p, "..."); break; + case (TEXICMD_EQUIV): + texiputchars(p, "\\(=="); + break; case (TEXICMD_ERROR): texiputchars(p, "error\\(->"); break; @@ -836,7 +1012,6 @@ dosymbol(struct texi *p, enum texicmd cmd, case (TEXICMD_HYPHEN): break; default: - texiwarn(p, "sym: %d", cmd); abort(); } @@ -893,8 +1068,7 @@ static void dovalue(struct texi *p, enum texicmd cmd, const char *buf, size_t sz, size_t *pos) { - size_t start, end; - int clr; + size_t start, end, i; char *key, *val; const char *cp; @@ -910,10 +1084,8 @@ dovalue(struct texi *p, enum texicmd cmd, advanceto(p, buf, pos, end); key = malloc(end - start + 1); - if (NULL == key) { - perror(NULL); - exit(EXIT_FAILURE); - } + if (NULL == key) + texiabort(p, NULL); memcpy(key, &buf[start], end - start); key[end - start] = '\0'; @@ -926,10 +1098,8 @@ dovalue(struct texi *p, enum texicmd cmd, advanceeoln(p, buf, sz, pos, 1); val = malloc(end - start + 1); - if (NULL == val) { - perror(NULL); - exit(EXIT_FAILURE); - } + if (NULL == val) + texiabort(p, NULL); memcpy(val, &buf[start], end - start); val[end - start] = '\0'; valueadd(p, key, val); @@ -937,17 +1107,29 @@ dovalue(struct texi *p, enum texicmd cmd, if (p->seenws) texiputchar(p, ' '); p->seenws = 0; - if (NULL == (cp = valueblookup(p, buf, sz, pos))) + if (NULL != (cp = valueblookup(p, buf, sz, pos))) { + for (i = 0; i < p->valstackpos; i++) + if (cp == p->valstack[i]) + break; + if (i < p->valstackpos) + texierr(p, "recursive value"); + if (64 == p->valstackpos) + texierr(p, "too many nested values"); + p->valstack[p->valstackpos++] = cp; + parsemembuf(p, cp, strlen(cp)); + p->valstackpos--; + } else texiputchars(p, "{No value}"); - else - texiputchars(p, cp); } else if (TEXICMD_IFCLEAR == cmd) { - clr = NULL != valuellookup(p, buf, sz, pos); - if (clr) - p->ign++; - parseto(p, buf, sz, pos, texitoks[cmd].tok); - if (clr) - p->ign--; + 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_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) valuelclear(p, buf, sz, pos); } @@ -1121,6 +1303,9 @@ dotop(struct texi *p, enum texicmd cmd, time_t t; char date[32]; + if (--p->ign) + texierr(p, "@top command while ignoring (%d)", p->ign); + /* * Here we print our standard mdoc(7) prologue. * We use the title set with @settitle for the `Nd' description @@ -1131,7 +1316,6 @@ dotop(struct texi *p, enum texicmd cmd, t = time(NULL); strftime(date, sizeof(date), "%F", localtime(&t)); - p->ign--; teximacroopen(p, "Dd"); texiputchars(p, date); teximacroclose(p); @@ -1206,10 +1390,16 @@ domultitable(struct texi *p, enum texicmd cmd, const char *buf, size_t sz, size_t *pos) { enum texilist sv = p->list; + int svliteral = p->literal; enum texicmd type; size_t i, end, columns; 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"); columns = 0; @@ -1226,7 +1416,7 @@ domultitable(struct texi *p, enum texicmd cmd, * arguments to set the number of columns that we'll * have. */ - type = texicmd(p, buf, *pos, sz, &end); + type = texicmd(p, buf, *pos, sz, &end, NULL); advanceto(p, buf, pos, end); if (TEXICMD_COLUMNFRACTIONS != type) texierr(p, "unknown multitable command"); @@ -1262,6 +1452,7 @@ domultitable(struct texi *p, enum texicmd cmd, parseto(p, buf, sz, pos, texitoks[cmd].tok); p->outmacro--; teximacro(p, "TE"); + p->literal = svliteral; p->list = sv; } @@ -1339,7 +1530,7 @@ doignline(struct texi *p, enum texicmd cmd, * This does NOT sanitise the directories! */ static char ** -parsedirs(const char *base, const char *cp, size_t *sz) +parsedirs(struct texi *p, const char *base, const char *cp, size_t *sz) { char *tok, *str, *tofree; const char *cpp; @@ -1351,28 +1542,20 @@ parsedirs(const char *base, const char *cp, size_t *sz for ( ; NULL != (cpp = strchr(cpp, ':')); (*sz)++) cpp++; - dirs = calloc(*sz, sizeof(char *)); - if (NULL == dirs) { - perror(NULL); - exit(EXIT_FAILURE); - } else if (NULL == (dirs[0] = strdup(base))) { - perror(NULL); - exit(EXIT_FAILURE); - } + if (NULL == (dirs = calloc(*sz, sizeof(char *)))) + texiabort(p, NULL); + else if (NULL == (dirs[0] = strdup(base))) + texiabort(p, NULL); if (NULL == cp) return(dirs); - if (NULL == (tofree = tok = str = strdup(cp))) { - perror(NULL); - exit(EXIT_FAILURE); - } + if (NULL == (tofree = tok = str = strdup(cp))) + texiabort(p, NULL); for (i = 1; NULL != (tok = strsep(&str, ":")); i++) - if (NULL == (dirs[i] = strdup(tok))) { - perror(NULL); - exit(EXIT_FAILURE); - } + if (NULL == (dirs[i] = strdup(tok))) + texiabort(p, NULL); free(tofree); return(dirs); @@ -1408,14 +1591,11 @@ main(int argc, char *argv[]) if (0 == (argc -= optind)) goto usage; - if (NULL == (path = strdup(argv[0]))) { - perror(NULL); - exit(EXIT_FAILURE); - } else if (NULL == (dir = dirname(path))) { - perror(argv[0]); - free(path); - exit(EXIT_FAILURE); - } + if (NULL == (path = strdup(argv[0]))) + texiabort(&texi, NULL); + else if (NULL == (dir = dirname(path))) + texiabort(&texi, NULL); + free(path); if (NULL != (cp = strrchr(argv[0], '/'))) @@ -1423,14 +1603,13 @@ main(int argc, char *argv[]) else texi.title = strdup(argv[0]); - if (NULL == texi.title) { - perror(NULL); - exit(EXIT_FAILURE); - } else if (NULL != (path = strchr(texi.title, '.'))) + if (NULL == texi.title) + texiabort(&texi, NULL); + else if (NULL != (path = strchr(texi.title, '.'))) *path = '\0'; texi.ign = 1; - texi.dirs = parsedirs(dir, Idir, &texi.dirsz); + texi.dirs = parsedirs(&texi, dir, Idir, &texi.dirsz); parsefile(&texi, argv[0], 1); /* We shouldn't get here. */ texiexit(&texi);