=================================================================== RCS file: /cvs/pod2mdoc/pod2mdoc.c,v retrieving revision 1.15 retrieving revision 1.17 diff -u -p -r1.15 -r1.17 --- pod2mdoc/pod2mdoc.c 2014/04/02 14:50:09 1.15 +++ pod2mdoc/pod2mdoc.c 2014/04/02 20:32:41 1.17 @@ -1,4 +1,4 @@ -/* $Id: pod2mdoc.c,v 1.15 2014/04/02 14:50:09 kristaps Exp $ */ +/* $Id: pod2mdoc.c,v 1.17 2014/04/02 20:32:41 kristaps Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * @@ -866,6 +866,40 @@ dosynopsisop(const char *buf, int *last, } /* + * Format multiple "Nm" manpage names in the NAME section. + */ +static void +donamenm(struct state *st, const char *buf, size_t *start, size_t end) +{ + size_t word; + + while (*start < end && ' ' == buf[*start]) + (*start)++; + + if (end == *start) { + puts(".Nm unknown"); + return; + } + + while (*start < end) { + fputs(".Nm ", stdout); + for (word = *start; word < end; word++) + if (',' == buf[word]) + break; + formatcodeln(st, buf, start, word, 1); + if (*start == end) { + putchar('\n'); + continue; + } + assert(',' == buf[*start]); + puts(" ,"); + (*start)++; + while (*start < end && ' ' == buf[*start]) + (*start)++; + } +} + +/* * Ordinary paragraph. * Well, this is really the hardest--POD seems to assume that, for * example, a leading space implies a newline, and so on. @@ -898,10 +932,10 @@ ordinary(struct state *st, const char *buf, size_t sta for ( ; i > start; i--) if ('-' != buf[i]) break; - fputs(".Nm ", stdout); - formatcodeln(st, buf, &start, i + 1, 1); - putchar('\n'); + donamenm(st, buf, &start, i + 1); start = j + 1; + while (start < end && ' ' == buf[start]) + start++; fputs(".Nd ", stdout); formatcodeln(st, buf, &start, end, 1); putchar('\n'); @@ -955,8 +989,19 @@ ordinary(struct state *st, const char *buf, size_t sta * following that, a newline. * Consume all whitespace so we don't * accidentally start an implicit literal line. + * If the macro ends with a flush comma or + * period, let mdoc(7) handle it for us. */ if (formatcode(st, buf, &start, end, 0, 0, seq)) { + if ((start == end - 1 || + (start < end - 1 && + (' ' == buf[start + 1] || + '\n' == buf[start + 1]))) && + ('.' == buf[start] || + ',' == buf[start])) { + putchar(' '); + putchar(buf[start++]); + } putchar(last = '\n'); while (start < end && ' ' == buf[start]) start++;