From: schwarze@mdocml.bsd.lv
To: source@mdocml.bsd.lv
Subject: pod2mdoc: Re-wrap text lines.
Date: Mon, 23 Feb 2015 09:30:59 -0500 (EST) [thread overview]
Message-ID: <1846040109360101333.enqueue@fantadrom.bsd.lv> (raw)
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
reply other threads:[~2015-02-23 14:30 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1846040109360101333.enqueue@fantadrom.bsd.lv \
--to=schwarze@mdocml.bsd.lv \
--cc=source@mdocml.bsd.lv \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).