[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Groff] Macro "itc" is needed to make escape "\c" useful
From: |
Ingo Schwarze |
Subject: |
Re: [Groff] Macro "itc" is needed to make escape "\c" useful |
Date: |
Tue, 2 May 2017 01:57:54 +0200 |
User-agent: |
Mutt/1.6.2 (2016-07-01) |
Purely FYI:
Given that the man(7) .TP .itc hack got committed to groff,
as promised, i adjusted mandoc(1), both in OpenBSD and in the
portable version, to handle .TP heads with \c the same way.
Of course, i still don't recommend actually using it, because
that would make your manual page misrender on groff <= 1.22.3,
on mandoc <= 1.14.1, and on any version of anything else.
CVSROOT: /cvs
Module name: src
Changes by: address@hidden 2017/05/01 17:27:23
Modified files:
usr.bin/mandoc : man.c
Log message:
A few days ago, a patch from <G dot Branden dot Robinson at gmail dot com>
got committed to groff which changed .TP from using .it to using .itc,
such that groff now supports more than one man(7) macro line in the .TP
head if all but the last line in the head end with \c.
Of course, relying on that behaviour is utterly non-portable, but if
authors are reckless enough to use that idiom, let's do what they want.
Index: man.c
===================================================================
RCS file: /cvs/src/usr.bin/mandoc/man.c,v
retrieving revision 1.118
diff -U8 -p -r1.118 man.c
--- man.c 29 Apr 2017 12:43:55 -0000 1.118
+++ man.c 1 May 2017 22:55:22 -0000
@@ -194,12 +194,26 @@ man_pmacro(struct roff_man *man, int ln,
/*
* Some macros break next-line scopes; otherwise, remember
* whether we are in next-line scope for a block head.
*/
man_breakscope(man, tok);
bline = man->flags & MAN_BLINE;
+ /*
+ * If the line in next-line scope ends with \c, keep the
+ * next-line scope open for the subsequent input line.
+ * That is not at all portable, only groff >= 1.22.4
+ * does it, but *if* this weird idiom occurs in a manual
+ * page, that's very likely what the author intended.
+ */
+
+ if (bline) {
+ cp = strchr(buf + offs, '\0') - 2;
+ if (cp >= buf && cp[0] == '\\' && cp[1] == 'c')
+ bline = 0;
+ }
+
/* Call to handler... */
assert(man_macros[tok].fp);
(*man_macros[tok].fp)(man, tok, ln, ppos, &offs, buf);
address@hidden $ mandoc
.TH TEST 1 2017-05-01
.SH NAME
name \- descr
.SH DESCRIPTION
initial text
.TP
.B -S \c
.IR var [= val ]
indented
.br
text
^D
TEST(1) General Commands Manual TEST(1)
NAME
name - descr
DESCRIPTION
initial text
-S var[=val]
indented
text
2017-05-01 TEST(1)
- Re: [Groff] Macro "itc" is needed to make escape "\c" useful,
Ingo Schwarze <=