From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from krisdoz.my.domain (kristaps@localhost [127.0.0.1]) by krisdoz.my.domain (8.14.5/8.14.5) with ESMTP id s33GoW6o021499 for ; Thu, 3 Apr 2014 12:50:32 -0400 (EDT) Received: (from kristaps@localhost) by krisdoz.my.domain (8.14.5/8.14.3/Submit) id s33GoWa2010643; Thu, 3 Apr 2014 12:50:32 -0400 (EDT) Date: Thu, 3 Apr 2014 12:50:32 -0400 (EDT) Message-Id: <201404031650.s33GoWa2010643@krisdoz.my.domain> X-Mailinglist: mdocml-source Reply-To: source@mdocml.bsd.lv MIME-Version: 1.0 From: kristaps@mdocml.bsd.lv To: source@mdocml.bsd.lv Subject: pod2mdoc: Translate leading #include statements in verbatim SYNOPSIS X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Log Message: ----------- Translate leading #include statements in verbatim SYNOPSIS text as In. Modified Files: -------------- pod2mdoc: pod2mdoc.1 pod2mdoc.c Revision Data ------------- Index: pod2mdoc.c =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/pod2mdoc/pod2mdoc.c,v retrieving revision 1.21 retrieving revision 1.22 diff -Lpod2mdoc.c -Lpod2mdoc.c -u -p -r1.21 -r1.22 --- pod2mdoc.c +++ pod2mdoc.c @@ -850,10 +850,47 @@ static void verbatim(struct state *st, const char *buf, size_t start, size_t end) { int last; + size_t i; if ( ! st->parsing || st->paused) return; - +again: + /* + * If we're in the SYNOPSIS, see if we're an #include block. + * If we are, then print the "In" macro and re-loop. + * This handles any number of inclusions, but only when they + * come before the remaining parts... + */ + if (SECT_SYNOPSIS == st->sect) { + i = start; + for (i = start; i < end && ' ' == buf[i]; i++) + /* Spin. */ ; + if (i == end) + return; + /* We're an include block! */ + if (end - i > 10 && + 0 == memcmp(&buf[i], "#include <", 10)) { + start = i + 10; + while (start < end && ' ' == buf[start]) + start++; + fputs(".In ", stdout); + /* Stop til the '>' marker or we hit eoln. */ + while (start < end && + '>' != buf[start] && '\n' != buf[start]) + putchar(buf[start++]); + putchar('\n'); + if (start < end && '>' == buf[start]) + start++; + if (start < end && '\n' == buf[start]) + start++; + if (start < end) + goto again; + return; + } + } + + if (start == end) + return; puts(".Bd -literal"); for (last = ' '; start < end; start++) { /* Index: pod2mdoc.1 =================================================================== RCS file: /usr/vhosts/mdocml.bsd.lv/cvs/pod2mdoc/pod2mdoc.1,v retrieving revision 1.11 retrieving revision 1.12 diff -Lpod2mdoc.1 -Lpod2mdoc.1 -u -p -r1.11 -r1.12 --- pod2mdoc.1 +++ pod2mdoc.1 @@ -101,6 +101,12 @@ Specifically, within each paragraph of t following occur: .Bl -bullet .It +If any number of +.Li #include +lines are found at the start of a verbatim paragraph, they're rendered +with +.Sq \&In . +.It An initial .Li B<> format code is rendered as -- To unsubscribe send an email to source+unsubscribe@mdocml.bsd.lv