From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (fantadrom.bsd.lv [local]); by fantadrom.bsd.lv (OpenSMTPD) with ESMTPA id ce1d91ad; for ; Mon, 23 Feb 2015 09:30:59 -0500 (EST) Date: Mon, 23 Feb 2015 09:30:59 -0500 (EST) Message-Id: <1846040109360101333.enqueue@fantadrom.bsd.lv> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: schwarze@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: pod2mdoc: Re-wrap text lines. X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Re-wrap text lines. Preserving the original man(7) input line breaks has no syntactic or semantic relevance and merely results in awkwardly wrapped mdoc(7) code. Modified Files: -------------- pod2mdoc: pod2mdoc.c Revision Data ------------- Index: pod2mdoc.c =================================================================== RCS file: /home/cvs/mdocml/pod2mdoc/pod2mdoc.c,v retrieving revision 1.57 retrieving revision 1.58 diff -Lpod2mdoc.c -Lpod2mdoc.c -u -p -r1.57 -r1.58 --- pod2mdoc.c +++ pod2mdoc.c @@ -75,6 +75,7 @@ struct state { char *outbuf; /* text buffered for output */ size_t outbufsz; /* allocated size of outbuf */ size_t outbuflen; /* current length of outbuf */ + size_t outlnlen; /* chars so far on this output line */ }; enum fmt { @@ -208,6 +209,14 @@ outbuf_flush(struct state *st) if (0 == st->outbuflen) return; + st->outlnlen += st->outbuflen; + if (OUST_TXT == st->oust && st->wantws) { + if (++st->outlnlen > 72) { + putchar('\n'); + st->oust = OUST_NL; + st->outlnlen = st->outbuflen; + } + } if (OUST_NL != st->oust && st->wantws) putchar(' '); @@ -233,6 +242,7 @@ mdoc_newln(struct state *st) putchar('\n'); last = '\n'; st->oust = OUST_NL; + st->outlnlen = 0; st->wantws = 1; } @@ -1632,7 +1642,7 @@ ordinary(struct state *st, const char *b } } else if (start < end && '\n' == buf[start]) { outbuf_flush(st); - mdoc_newln(st); + st->wantws = 1; if (++start >= end) continue; /* @@ -1643,8 +1653,10 @@ ordinary(struct state *st, const char *b * have a macro subsequent it, which may be * possible if we have an escape next. */ - if (' ' == buf[start] || '\t' == buf[start]) + if (' ' == buf[start] || '\t' == buf[start]) { + mdoc_newln(st); puts(".br"); + } for ( ; start < end; start++) if (' ' != buf[start] && '\t' != buf[start]) break; -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv