mandoc: Vendor import of upstream at 2025-06-13

Interesting changes:
+ Lb is now part of SNYOPSIS, the LIBRARY section is deprecated
+ Ft now takes multiple args, and no longer should be quoted
+ Fix a segfaut on malformed Tg markup
This commit is contained in:
Alexander Ziaee
2025-06-25 13:50:25 -04:00
4 changed files with 117 additions and 63 deletions
+24 -3
View File
@@ -1,6 +1,6 @@
/* $Id: mandocdb.c,v 1.274 2024/05/14 21:19:12 schwarze Exp $ */ /* $Id: mandocdb.c,v 1.275 2025/06/05 12:33:41 schwarze Exp $ */
/* /*
* Copyright (c) 2011-2021, 2024 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2011-2021, 2024, 2025 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2016 Ed Maste <emaste@freebsd.org> * Copyright (c) 2016 Ed Maste <emaste@freebsd.org>
* *
@@ -151,6 +151,8 @@ static int parse_mdoc_Fn(struct mpage *, const struct roff_meta *,
const struct roff_node *); const struct roff_node *);
static int parse_mdoc_Fo(struct mpage *, const struct roff_meta *, static int parse_mdoc_Fo(struct mpage *, const struct roff_meta *,
const struct roff_node *); const struct roff_node *);
static int parse_mdoc_Lb(struct mpage *, const struct roff_meta *,
const struct roff_node *);
static int parse_mdoc_Nd(struct mpage *, const struct roff_meta *, static int parse_mdoc_Nd(struct mpage *, const struct roff_meta *,
const struct roff_node *); const struct roff_node *);
static int parse_mdoc_Nm(struct mpage *, const struct roff_meta *, static int parse_mdoc_Nm(struct mpage *, const struct roff_meta *,
@@ -299,7 +301,7 @@ static const struct mdoc_handler mdoc_handlers[MDOC_MAX - MDOC_Dd] = {
{ NULL, 0, 0 }, /* Hf */ { NULL, 0, 0 }, /* Hf */
{ NULL, 0, 0 }, /* Fr */ { NULL, 0, 0 }, /* Fr */
{ NULL, 0, 0 }, /* Ud */ { NULL, 0, 0 }, /* Ud */
{ NULL, TYPE_Lb, NODE_NOSRC }, /* Lb */ { parse_mdoc_Lb, 0, 0 }, /* Lb */
{ NULL, 0, 0 }, /* Lp */ { NULL, 0, 0 }, /* Lp */
{ NULL, TYPE_Lk, 0 }, /* Lk */ { NULL, TYPE_Lk, 0 }, /* Lk */
{ NULL, TYPE_Mt, NODE_NOSRC }, /* Mt */ { NULL, TYPE_Mt, NODE_NOSRC }, /* Mt */
@@ -1753,6 +1755,25 @@ parse_mdoc_Fo(struct mpage *mpage, const struct roff_meta *meta,
return 0; return 0;
} }
static int
parse_mdoc_Lb(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n)
{
char *cp;
for (n = n->child; n != NULL; n = n->next) {
if (n->flags & NODE_NOSRC)
continue;
cp = n->string;
if (n->sec == SEC_SYNOPSIS)
mandoc_asprintf(&cp, "lib%s", cp);
putkey(mpage, cp, TYPE_Lb);
if (n->sec == SEC_SYNOPSIS)
free(cp);
}
return 0;
}
static int static int
parse_mdoc_Va(struct mpage *mpage, const struct roff_meta *meta, parse_mdoc_Va(struct mpage *mpage, const struct roff_meta *meta,
const struct roff_node *n) const struct roff_node *n)
+61 -48
View File
@@ -1,7 +1,7 @@
.\" $Id: mdoc.7,v 1.296 2025/01/27 03:17:33 schwarze Exp $ .\" $Id: mdoc.7,v 1.299 2025/06/13 16:18:28 schwarze Exp $
.\" .\"
.\" Copyright (c) 2010-2021, 2024, 2025 Ingo Schwarze <schwarze@openbsd.org>
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv> .\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010, 2011, 2013-2020 Ingo Schwarze <schwarze@openbsd.org>
.\" .\"
.\" Permission to use, copy, modify, and distribute this software for any .\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above .\" purpose with or without fee is hereby granted, provided that the above
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\" .\"
.Dd $Mdocdate: January 27 2025 $ .Dd $Mdocdate: June 13 2025 $
.Dt MDOC 7 .Dt MDOC 7
.Os .Os
.Sh NAME .Sh NAME
@@ -195,15 +195,13 @@ See
and and
.Ic \&Nd . .Ic \&Nd .
.It Em LIBRARY .It Em LIBRARY
The name of the library containing the documented material, which is The name of the library containing the documented functions.
assumed to be a function in a section 2, 3, or 9 manual. Using this section is no longer recommended.
The syntax for this is as follows: If any
.Bd -literal -offset indent .Ic \&Lb
\&.Lb libarm macro is needed, put it at the beginning of the
.Ed .Em SYNOPSIS
.Pp section instead.
See
.Ic \&Lb .
.It Em SYNOPSIS .It Em SYNOPSIS
Documents the utility invocation syntax, function call syntax, or device Documents the utility invocation syntax, function call syntax, or device
configuration. configuration.
@@ -225,11 +223,12 @@ Commands should be ordered alphabetically.
.Pp .Pp
For the second, function calls (sections 2, 3, 9): For the second, function calls (sections 2, 3, 9):
.Bd -literal -offset indent .Bd -literal -offset indent
\&.Lb libname \e" unless the functions are in libc
\&.In header.h \&.In header.h
\&.Vt extern const char *global; \&.Vt extern const char *global;
\&.Ft "char *" \&.Ft char *
\&.Fn foo "const char *src" \&.Fn foo "const char *src"
\&.Ft "char *" \&.Ft char *
\&.Fn bar "const char *src" \&.Fn bar "const char *src"
.Ed .Ed
.Pp .Pp
@@ -467,7 +466,8 @@ in the alphabetical
.Op Fl compact .Op Fl compact
.It Ic \&D1 Ta indented display (one line) .It Ic \&D1 Ta indented display (one line)
.It Ic \&Dl Ta indented literal display (one line) .It Ic \&Dl Ta indented literal display (one line)
.It Ic \&Ql Ta in-line literal display: Ql text .It Ic \&Ql Ta normal in-line literal display: Ql text
.It Ic \&Li Ta unquoted in-line literal display: Li text
.It Ic \&Bl , \&El Ta list block: .It Ic \&Bl , \&El Ta list block:
.Fl Ar type .Fl Ar type
.Op Fl width Ar val .Op Fl width Ar val
@@ -498,7 +498,7 @@ in the alphabetical
.El .El
.Ss Semantic markup for function libraries .Ss Semantic markup for function libraries
.Bl -column "Brq, Bro, Brc" description .Bl -column "Brq, Bro, Brc" description
.It Ic \&Lb Ta function library (one argument) .It Ic \&Lb Ta function library (>0 arguments)
.It Ic \&In Ta include file (one argument) .It Ic \&In Ta include file (one argument)
.It Ic \&Fd Ta other preprocessor directive (>0 arguments) .It Ic \&Fd Ta other preprocessor directive (>0 arguments)
.It Ic \&Ft Ta function type (>0 arguments) .It Ic \&Ft Ta function type (>0 arguments)
@@ -1277,9 +1277,9 @@ and
.Ic \&Os . .Ic \&Os .
.Tg Dl .Tg Dl
.It Ic \&Dl Ar line .It Ic \&Dl Ar line
One-line indented display. One-line indented literal display.
This is formatted as literal text and is useful for commands and This is formatted using a constant-width font
invocations. and is useful for commands and invocations.
It is followed by a newline. It is followed by a newline.
.Pp .Pp
Examples: Examples:
@@ -1867,34 +1867,45 @@ but not the whitespace before the semicolon.
See also See also
.Ic \&Bl . .Ic \&Bl .
.Tg Lb .Tg Lb
.It Ic \&Lb Cm lib Ns Ar name .It Ic \&Lb Cm lib Ns Ar name Op Cm lib Ns Ar name ...
Specify a library. Specify one or more libraries to link against.
.Pp Putting this macro at the beginning of the
The
.Ar name
parameter may be a system library, such as
.Cm z
or
.Cm pam ,
in which case a small library description is printed next to the linker
invocation; or a custom library, in which case the library name is
printed in quotes.
This is most commonly used in the
.Em SYNOPSIS .Em SYNOPSIS
section as described in section is recommended, in which case it prints this comment:
.Sx MANUAL STRUCTURE . .D1 /* Fl l Ns Ar name Oo Fl l Ns Ar name ... Oc */
.Pp .Pp
Examples: If used outside the
.Dl \&.Lb libz .Em SYNOPSIS ,
.Dl \&.Lb libmandoc this macro prints
.D1 library Dq Cm lib Ns Ar name
instead.
For system libraries, some operating systems
print a short library description.
.Pp
Example:
.Bd -literal -offset indent -compact
\&.Sh SYNOPSIS
\&.Lb libtls libssl libcrypto
\&.In tls.h
\&.Ft int
\&.Fn tls_init void
.Ed
.Tg Li .Tg Li
.It Ic \&Li Ar word ... .It Ic \&Li Ar word ...
Request a typewriter (literal) font. Unquoted in-line literal display, always set in a constant-width font.
Deprecated because on terminal output devices, this is usually In most cases, use
indistinguishable from normal text. .Ic \&Ql
For literal displays, use instead because on terminal output devices,
.Ic \&Ql Pq in-line , .Ic \&Li
.Ic \&Dl Pq single line , is usually indistinguishable from normal text.
This macro is only useful when enclosing the argument in quotes
is explicitly not desired, for example because it already stands out
due to being wrapped in another macro, e.g. in an
.Ic \&It
head.
.Pp
For longer literal displays, use
.Ic \&Dl Pq single line
or or
.Ic \&Bd Fl literal Pq multi-line .Ic \&Bd Fl literal Pq multi-line
instead. instead.
@@ -2207,15 +2218,17 @@ Close quoted context opened by
.Ic \&Qo . .Ic \&Qo .
.Tg Ql .Tg Ql
.It Ic \&Ql Ar line .It Ic \&Ql Ar line
In-line literal display. Normal in-line literal display, always set in constant-width font and
additionally enclosed in quotes by many formatters in many cases.
This can be used for complete command invocations and for multi-word This can be used for complete command invocations and for multi-word
code examples when an indented display is not desired. code examples when an indented display is not desired.
.Pp .Pp
See also See also
.Ic \&Dl .Ic \&Dl ,
and
.Ic \&Bd .Ic \&Bd
.Fl literal . .Fl literal ,
and
.Ic \&Li .
.It Ic \&Qo Ar block .It Ic \&Qo Ar block
Multi-line version of Multi-line version of
.Ic \&Qq . .Ic \&Qq .
@@ -3031,7 +3044,7 @@ then the macro accepts an arbitrary number of arguments.
.It Ic \&Hf Ta \&No Ta \&No Ta n .It Ic \&Hf Ta \&No Ta \&No Ta n
.It Ic \&Ic Ta Yes Ta Yes Ta >0 .It Ic \&Ic Ta Yes Ta Yes Ta >0
.It Ic \&In Ta Yes Ta Yes Ta 1 .It Ic \&In Ta Yes Ta Yes Ta 1
.It Ic \&Lb Ta \&No Ta \&No Ta 1 .It Ic \&Lb Ta \&No Ta \&No Ta >0
.It Ic \&Li Ta Yes Ta Yes Ta >0 .It Ic \&Li Ta Yes Ta Yes Ta >0
.It Ic \&Lk Ta Yes Ta Yes Ta >0 .It Ic \&Lk Ta Yes Ta Yes Ta >0
.It Ic \&Lp Ta \&No Ta \&No Ta 0 .It Ic \&Lp Ta \&No Ta \&No Ta 0
+3 -4
View File
@@ -1,4 +1,4 @@
/* $Id: mdoc_macro.c,v 1.235 2022/04/14 16:43:44 schwarze Exp $ */ /* $Id: mdoc_macro.c,v 1.237 2025/06/13 14:24:56 schwarze Exp $ */
/* /*
* Copyright (c) 2010, 2012-2021 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2010, 2012-2021 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -92,7 +92,7 @@ static const struct mdoc_macro mdoc_macros[MDOC_MAX - MDOC_Dd] = {
{ in_line_eoln, 0 }, /* Fd */ { in_line_eoln, 0 }, /* Fd */
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fl */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fl */
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fn */ { in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Fn */
{ in_line, MDOC_CALLABLE | MDOC_PARSED }, /* Ft */ { in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ft */
{ in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ic */ { in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Ic */
{ in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* In */ { in_line_argn, MDOC_CALLABLE | MDOC_PARSED }, /* In */
{ in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Li */ { in_line, MDOC_CALLABLE | MDOC_PARSED | MDOC_JOIN }, /* Li */
@@ -448,8 +448,7 @@ dword(struct roff_man *mdoc, int line, int col, const char *p,
if (d == DELIM_MAX) if (d == DELIM_MAX)
d = mdoc_isdelim(p); d = mdoc_isdelim(p);
if (may_append && if (may_append && ! (mdoc->flags & (MDOC_KEEP | MDOC_SMOFF)) &&
! (mdoc->flags & (MDOC_SYNOPSIS | MDOC_KEEP | MDOC_SMOFF)) &&
d == DELIM_NONE && mdoc->last->type == ROFFT_TEXT && d == DELIM_NONE && mdoc->last->type == ROFFT_TEXT &&
mdoc_isdelim(mdoc->last->string) == DELIM_NONE) { mdoc_isdelim(mdoc->last->string) == DELIM_NONE) {
roff_word_append(mdoc, p); roff_word_append(mdoc, p);
+29 -8
View File
@@ -1,6 +1,6 @@
/* $Id: mdoc_validate.c,v 1.391 2022/06/08 16:31:46 schwarze Exp $ */ /* $Id: mdoc_validate.c,v 1.393 2025/06/05 12:38:26 schwarze Exp $ */
/* /*
* Copyright (c) 2010-2021 Ingo Schwarze <schwarze@openbsd.org> * Copyright (c) 2010-2022, 2025 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org> * Copyright (c) 2010 Joerg Sonnenberger <joerg@netbsd.org>
* *
@@ -991,18 +991,39 @@ post_ex(POST_ARGS)
static void static void
post_lb(POST_ARGS) post_lb(POST_ARGS)
{ {
struct roff_node *n; struct roff_node *n, *nch;
const char *p; const char *ccp;
char *cp;
post_delim_nb(mdoc); post_delim_nb(mdoc);
n = mdoc->last; n = mdoc->last;
assert(n->child->type == ROFFT_TEXT); nch = n->child;
assert(nch->type == ROFFT_TEXT);
mdoc->next = ROFF_NEXT_CHILD; mdoc->next = ROFF_NEXT_CHILD;
if ((p = mdoc_a2lib(n->child->string)) != NULL) { if (n->sec == SEC_SYNOPSIS) {
roff_word_alloc(mdoc, n->line, n->pos, "/*");
mdoc->last->flags = NODE_NOSRC;
while (nch != NULL) {
roff_word_alloc(mdoc, n->line, n->pos, "-l");
mdoc->last->flags = NODE_DELIMO | NODE_NOSRC;
mdoc->last = nch;
assert(nch->type == ROFFT_TEXT);
cp = nch->string;
if (strncmp(cp, "lib", 3) == 0)
memmove(cp, cp + 3, strlen(cp) - 3 + 1);
nch = nch->next;
}
roff_word_alloc(mdoc, n->line, n->pos, "*/");
mdoc->last->flags = NODE_NOSRC;
mdoc->last = n;
return;
}
if ((ccp = mdoc_a2lib(n->child->string)) != NULL) {
n->child->flags |= NODE_NOPRT; n->child->flags |= NODE_NOPRT;
roff_word_alloc(mdoc, n->line, n->pos, p); roff_word_alloc(mdoc, n->line, n->pos, ccp);
mdoc->last->flags = NODE_NOSRC; mdoc->last->flags = NODE_NOSRC;
mdoc->last = n; mdoc->last = n;
return; return;
@@ -3101,6 +3122,6 @@ macro2len(enum roff_tok macro)
return 10; return 10;
default: default:
break; break;
}; }
return 0; return 0;
} }