=================================================================== RCS file: /cvs/texi2mdoc/util.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -p -r1.20 -r1.21 --- texi2mdoc/util.c 2015/03/01 00:25:08 1.20 +++ texi2mdoc/util.c 2015/03/01 13:39:51 1.21 @@ -1,4 +1,4 @@ -/* $Id: util.c,v 1.20 2015/03/01 00:25:08 kristaps Exp $ */ +/* $Id: util.c,v 1.21 2015/03/01 13:39:51 kristaps Exp $ */ /* * Copyright (c) 2015 Kristaps Dzonsons * @@ -472,7 +472,7 @@ texiexecmacro(struct texi *p, struct teximacro *m, siz aasz = asz < m->argsz ? asz : m->argsz; if (0 == aasz) { - texisplice(p, m->value, valsz, pos); + texisplice(p, m->value, valsz, *pos); return; } @@ -535,7 +535,7 @@ texiexecmacro(struct texi *p, struct teximacro *m, siz i = end; } - texisplice(p, val, strlen(val), pos); + texisplice(p, val, strlen(val), *pos); for (i = 0; i < asz; i++) free(args[i]); @@ -927,7 +927,7 @@ parseeof(struct texi *p) } void -texisplice(struct texi *p, const char *buf, size_t sz, size_t *pos) +texisplice(struct texi *p, const char *buf, size_t sz, size_t pos) { char *cp; struct texifile *f; @@ -944,8 +944,8 @@ texisplice(struct texi *p, const char *buf, size_t sz, } f->insplice += sz; - memmove(f->map + *pos + sz, f->map + *pos, f->mapsz - *pos); - memcpy(f->map + *pos, buf, sz); + memmove(f->map + pos + sz, f->map + pos, f->mapsz - pos); + memcpy(f->map + pos, buf, sz); f->mapsz += sz; } @@ -1405,7 +1405,7 @@ teximdocclose(struct texi *p, int last) * Otherwise just print the mdoc(7) prologue. */ void -teximdocopen(struct texi *p) +teximdocopen(struct texi *p, size_t *pos) { const char *cp; time_t t; @@ -1445,10 +1445,14 @@ teximdocopen(struct texi *p) texiputchar(p, *cp); teximacroclose(p); teximacroopen(p, "Nd"); - if (NULL != p->subtitle) - for (cp = p->subtitle; '\0' != *cp; cp++) - texiputchar(p, *cp); - else + /* + * The subtitle `Nd' can consist of arbitrary macros, so paste + * it and parse to the end of the line. + */ + if (NULL != p->subtitle) { + texisplice(p, p->subtitle, strlen(p->subtitle), *pos); + parseeoln(p, pos); + } else texiputchars(p, "Unknown description"); teximacroclose(p); p->seenvs = 1;