summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2010-06-04 22:16:27 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2010-06-04 22:16:27 +0000
commit60594285aadf7b17048d8d3b552c3b12563f3622 (patch)
tree3cac3cd457e34ddd0ba29522fd90c9818cb0538d
parent14deda6326abdec269681291139d0ae022db56f9 (diff)
downloadmandoc-60594285aadf7b17048d8d3b552c3b12563f3622.tar.gz
Fixed `Fn' newline behaviour and added some regression tests to this
extent. Documented `Fn'. Please note the COMPATIBILITY note regarding historic groff.
-rw-r--r--mdoc.733
-rw-r--r--mdoc_html.c3
-rw-r--r--mdoc_term.c11
-rw-r--r--regress/mdoc/Fn/fn1.in21
-rw-r--r--regress/mdoc/Fn/fn2.in16
5 files changed, 81 insertions, 3 deletions
diff --git a/mdoc.7 b/mdoc.7
index 73f0ecf6..441e871a 100644
--- a/mdoc.7
+++ b/mdoc.7
@@ -1656,6 +1656,33 @@ Examples:
See also
.Sx \&Cm .
.Ss \&Fn
+A function name.
+Its calling syntax is as follows:
+.Bd -ragged -offset indent
+.Pf \. Ns Sx \&Fn
+.Op Cm functype
+.Cm funcname
+.Op Oo Cm argtype Oc Cm argname
+.Ed
+If invoked in the
+.Em SYNOPSIS
+section, vertical space is asserted before and after the macro.
+In all cases, the function arguments are surrounded in parenthesis and
+are delimited by commas.
+If no arguments are specified, blank parenthesis are output.
+.Pp
+Examples:
+.D1 \&.Fn "int funcname" "int arg0" "int arg1"
+.D1 \&.Fn funcname
+.D1 \&.Fn funcname "int arg0"
+.D1 \&.Fn funcname arg0
+.Pp
+See also
+.Sx \&Fa ,
+.Sx \&Fo ,
+.Sx \&Fc ,
+and
+.Sx \&Ft .
.Ss \&Fo
.Ss \&Fr
.Ss \&Ft
@@ -2048,6 +2075,12 @@ Heirloom troff, the other significant troff implementation accepting
.Pp
.Bl -dash -compact
.It
+Historic groff does not break before an
+.Sx \&Fn
+when not invoked as the line macro in the
+.Em SYNOPSIS
+section.
+.It
Historic groff formats the
.Sx \&In
badly: trailing arguments are trashed and
diff --git a/mdoc_html.c b/mdoc_html.c
index 0f96cf63..f14b8fc5 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1584,7 +1584,8 @@ mdoc_fn_pre(MDOC_ARGS)
int sz, i;
struct roffsu su;
- if (SEC_SYNOPSIS == n->sec && MDOC_LINE & n->flags) {
+ /* NB: MDOC_LINE has no effect on this macro! */
+ if (SEC_SYNOPSIS == n->sec) {
SCALE_HS_INIT(&su, INDENT);
bufcat_su(h, "margin-left", &su);
su.scale = -su.scale;
diff --git a/mdoc_term.c b/mdoc_term.c
index 6f67f621..63f63186 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1536,6 +1536,12 @@ termp_fn_pre(DECL_ARGS)
{
const struct mdoc_node *nn;
+ /* NB: MDOC_LINE has no effect on this macro! */
+ if (SEC_SYNOPSIS == n->sec) {
+ if (n->prev)
+ term_vspace(p);
+ }
+
term_fontpush(p, TERMFONT_BOLD);
term_word(p, n->child->string);
term_fontpop(p);
@@ -1566,8 +1572,9 @@ static void
termp_fn_post(DECL_ARGS)
{
- if (n->sec == SEC_SYNOPSIS && n->next && MDOC_LINE & n->flags)
- term_vspace(p);
+ /* NB: MDOC_LINE has no effect on this macro! */
+ if (SEC_SYNOPSIS == n->sec)
+ term_newln(p);
}
diff --git a/regress/mdoc/Fn/fn1.in b/regress/mdoc/Fn/fn1.in
new file mode 100644
index 00000000..02a17aca
--- /dev/null
+++ b/regress/mdoc/Fn/fn1.in
@@ -0,0 +1,21 @@
+.Dd $Mdocdate$
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh SYNOPSIS
+1
+.In 2
+a
+.Fn 3
+.Fn 4 5 6
+.Ar a Fn 4
+5
+.Sh DESCRIPTION
+1
+.In 2
+.Fn 3
+.Fn 3 4 5
+.Ar a Fn 6
+4
diff --git a/regress/mdoc/Fn/fn2.in b/regress/mdoc/Fn/fn2.in
new file mode 100644
index 00000000..94405bba
--- /dev/null
+++ b/regress/mdoc/Fn/fn2.in
@@ -0,0 +1,16 @@
+.Dd $Mdocdate$
+.Dt FOO 1
+.Os
+.Sh NAME
+.Nm foo
+.Nd bar
+.Sh SYNOPSIS
+.Fn 1
+.Fn "1 2"
+.Fn "1 2" "3 4"
+.Fn "1 2" "4"
+.Sh DESCRIPTION
+.Fn 1
+.Fn "1 2"
+.Fn "1 2" "3 4"
+.Fn "1 2" "4"