Date: Mon, 03 Aug 2026 14:30:48 +0000 From: Lexi Winter <ivy@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org Subject: git: 9f18614d5353 - main - mandoc: Const correctness for C23 Message-ID: <6a70a618.36a77.35390257@gitrepo.freebsd.org>
index | next in thread | raw e-mail
The branch main has been updated by ivy: URL: https://cgit.FreeBSD.org/src/commit/?id=9f18614d5353ce513511ccbf59d09e76c93f7bc9 commit 9f18614d5353ce513511ccbf59d09e76c93f7bc9 Author: Lexi Winter <ivy@FreeBSD.org> AuthorDate: 2026-08-03 14:09:39 +0000 Commit: Lexi Winter <ivy@FreeBSD.org> CommitDate: 2026-08-03 14:09:39 +0000 mandoc: Const correctness for C23 On some platforms, e.g. Linux Clang 22.1.8 / glibc 2.43, strchr() now implements the C23 behaviour where passing a const pointer to strchr() also returns a const pointer. This breaks mandoc during the bootstrap build, since it assumes the return value is always a mutable pointer. In read.c, make the existing temporary pointer const, and for the mandoc_asprintf() call, add a new mutable local. In mdoc.c and out.c, since the data is mutable and is mutated here, remove const from the temporary pointers. MFC after: 1 week Reviewed by: fuz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D58495 --- contrib/mandoc/mdoc.c | 3 +-- contrib/mandoc/out.c | 4 ++-- contrib/mandoc/read.c | 10 ++++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/contrib/mandoc/mdoc.c b/contrib/mandoc/mdoc.c index 475a6aa0ddb3..90a079870f64 100644 --- a/contrib/mandoc/mdoc.c +++ b/contrib/mandoc/mdoc.c @@ -165,8 +165,7 @@ static int mdoc_ptext(struct roff_man *mdoc, int line, char *buf, int offs) { struct roff_node *n; - const char *cp, *sp; - char *c, *ws, *end; + char *c, *ws, *end, *cp, *sp; n = mdoc->last; diff --git a/contrib/mandoc/out.c b/contrib/mandoc/out.c index 21c282b2141b..082e7e61e8af 100644 --- a/contrib/mandoc/out.c +++ b/contrib/mandoc/out.c @@ -457,8 +457,8 @@ static size_t tblcalc_literal(struct rofftbl *tbl, struct roffcol *col, const struct tbl_dat *dp, size_t mw) { - const char *str; /* Beginning of the first line. */ - const char *beg; /* Beginning of the current line. */ + char *str; /* Beginning of the first line. */ + char *beg; /* Beginning of the current line. */ char *end; /* End of the current line. */ /* Widths in basic units. */ diff --git a/contrib/mandoc/read.c b/contrib/mandoc/read.c index 0e8d32df5a5e..d958a25832b3 100644 --- a/contrib/mandoc/read.c +++ b/contrib/mandoc/read.c @@ -628,7 +628,7 @@ mparse_readfd(struct mparse *curp, int fd, const char *filename) int mparse_open(struct mparse *curp, const char *file) { - char *cp; + const char *cp; int fd, save_errno; cp = strrchr(file, '.'); @@ -645,10 +645,12 @@ mparse_open(struct mparse *curp, const char *file) */ if ( ! curp->gzip) { + char *fn; + save_errno = errno; - mandoc_asprintf(&cp, "%s.gz", file); - fd = open(cp, O_RDONLY); - free(cp); + mandoc_asprintf(&fn, "%s.gz", file); + fd = open(fn, O_RDONLY); + free(fn); errno = save_errno; if (fd != -1) { curp->gzip = 1;home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6a70a618.36a77.35390257>
