=================================================================== RCS file: /cvs/pod2mdoc/pod2mdoc.c,v retrieving revision 1.53 retrieving revision 1.54 diff -u -p -r1.53 -r1.54 --- pod2mdoc/pod2mdoc.c 2015/02/19 13:50:45 1.53 +++ pod2mdoc/pod2mdoc.c 2015/02/19 15:26:45 1.54 @@ -1,4 +1,4 @@ -/* $Id: pod2mdoc.c,v 1.53 2015/02/19 13:50:45 schwarze Exp $ */ +/* $Id: pod2mdoc.c,v 1.54 2015/02/19 15:26:45 schwarze Exp $ */ /* * Copyright (c) 2014 Kristaps Dzonsons * Copyright (c) 2014, 2015 Ingo Schwarze @@ -185,7 +185,11 @@ outbuf_flush(struct state *st) if (OUST_TXT == st->oust && st->wantws) putchar(' '); - fputs(st->outbuf, stdout); + if (OUST_MAC == st->oust && '"' == *st->outbuf) + printf("\\(dq%s", st->outbuf + 1); + else + fputs(st->outbuf, stdout); + *st->outbuf = '\0'; st->outbuflen = 0; @@ -480,7 +484,6 @@ formatcode(struct state *st, const char *buf, size_t * { size_t i, j, dsz; enum fmt fmt; - int wantws; unsigned char uc; assert(*start + 1 < end); @@ -559,45 +562,43 @@ formatcode(struct state *st, const char *buf, size_t * if (FMT__MAX != fmt && !nomacro) { /* - * We may already have wantws if there was whitespace - * before the code ("text Boust ? st->wantws : ! st->outbuflen); - - /* * If we are on a text line and there is no * whitespace before our content, we have to make * the previous word a prefix to the macro line. - * In the following, mdoc_newln() must not be used - * lest we clobber out output state. */ - if (OUST_MAC != st->oust && ! wantws) { + if (OUST_MAC != st->oust && ' ' != buf[*start] && + st->outbuflen) { if (OUST_NL != st->oust) - putchar('\n'); + mdoc_newln(st); printf(".Pf "); - st->wantws = 0; + st->oust = OUST_MAC; + st->wantws = 1; } outbuf_flush(st); - /* Whitespace is easier to suppress on macro lines. */ + /* + * Whitespace is easier to suppress on macro lines. + * We may already have wantws if there was whitespace + * before the code ("text Boust && ! wantws) - printf(" Ns "); + if (OUST_MAC == st->oust && ' ' != buf[*start] && + ! st->wantws) + printf(" Ns"); /* Unless we are on a macro line, start one. */ - if (OUST_MAC != st->oust && wantws) { + if (OUST_MAC != st->oust) { if (OUST_NL != st->oust) - putchar('\n'); + mdoc_newln(st); putchar('.'); + st->oust = OUST_MAC; } else putchar(' '); + st->wantws = 1; /* * Print the macro corresponding to this format code, @@ -657,8 +658,6 @@ formatcode(struct state *st, const char *buf, size_t * default: abort(); } - st->oust = OUST_MAC; - st->wantws = 1; } else outbuf_flush(st);