From a90a19d8ea1fd9c75174c833a56f4c68dae450c4 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 21 Dec 2018 17:15:18 +0000 Subject: Rename mandoc_getarg() to roff_getarg() and pass it the roff parser struct as an argument such that after copy-in, it can call roff_expand() once again, which used to be called roff_res() before this. This fixes a subtle low-level roff(7) parsing bug reported by Fabio Scotoni in the 4.4BSD-Lite2 mdoc.samples(7) manual page, because that page used an escaped escape sequence in a macro argument. To expand escaped escape sequences in quoted mdoc(7) arguments, too, stop bypassing the call to roff_getarg() in mdoc_argv.c, function args() for this case. This does not solve the case of escaped escape sequences in quoted .Bl -column phrases yet. Because roff_expand() can make the string longer, roff_getarg() can no longer operate in-place but needs to malloc(3) the returned string. In the high-level parsers, free(3) that string after processing it. --- regress/mdoc/Op/Makefile | 4 ++-- regress/mdoc/Op/arg.in | 20 ++++++++++++++++++++ regress/mdoc/Op/arg.out_ascii | 15 +++++++++++++++ regress/mdoc/Op/arg.out_markdown | 21 +++++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 regress/mdoc/Op/arg.in create mode 100644 regress/mdoc/Op/arg.out_ascii create mode 100644 regress/mdoc/Op/arg.out_markdown (limited to 'regress/mdoc/Op') diff --git a/regress/mdoc/Op/Makefile b/regress/mdoc/Op/Makefile index 4a2d6fda..b2a79566 100644 --- a/regress/mdoc/Op/Makefile +++ b/regress/mdoc/Op/Makefile @@ -1,6 +1,6 @@ -# $OpenBSD: Makefile,v 1.3 2014/07/02 11:42:56 schwarze Exp $ +# $OpenBSD: Makefile,v 1.7 2018/12/21 16:58:49 schwarze Exp $ -REGRESS_TARGETS = break broken punct +REGRESS_TARGETS = arg break broken punct LINT_TARGETS = break broken punct SKIP_GROFF = break diff --git a/regress/mdoc/Op/arg.in b/regress/mdoc/Op/arg.in new file mode 100644 index 00000000..2043b01e --- /dev/null +++ b/regress/mdoc/Op/arg.in @@ -0,0 +1,20 @@ +.\" $OpenBSD: arg.in,v 1.1 2018/12/21 16:58:49 schwarze Exp $ +.Dd $Mdocdate: December 21 2018 $ +.Dt OP-ARG 1 +.Os +.Sh NAME +.Nm Op-arg +.Nd escape sequences in the arguments of partial implicit macros +.Sh DESCRIPTION +.ds a \(at +unquoted unescaped: +.Op \*a +.Pp +quoted unescaped: +.Op "\*a" +.Pp +unquoted escaped: +.Op \\*a +.Pp +quoted escaped: +.Op "\\*a" diff --git a/regress/mdoc/Op/arg.out_ascii b/regress/mdoc/Op/arg.out_ascii new file mode 100644 index 00000000..534917cb --- /dev/null +++ b/regress/mdoc/Op/arg.out_ascii @@ -0,0 +1,15 @@ +OP-ARG(1) General Commands Manual OP-ARG(1) + +NNAAMMEE + OOpp--aarrgg - escape sequences in the arguments of partial implicit macros + +DDEESSCCRRIIPPTTIIOONN + unquoted unescaped: [@] + + quoted unescaped: [@] + + unquoted escaped: [@] + + quoted escaped: [@] + +OpenBSD December 21, 2018 OpenBSD diff --git a/regress/mdoc/Op/arg.out_markdown b/regress/mdoc/Op/arg.out_markdown new file mode 100644 index 00000000..5ad86f7d --- /dev/null +++ b/regress/mdoc/Op/arg.out_markdown @@ -0,0 +1,21 @@ +OP-ARG(1) - General Commands Manual + +# NAME + +**Op-arg** - escape sequences in the arguments of partial implicit macros + +# DESCRIPTION + +unquoted unescaped: +\[@] + +quoted unescaped: +\[@] + +unquoted escaped: +\[@] + +quoted escaped: +\[@] + +OpenBSD - December 21, 2018 -- cgit v1.2.3-56-ge451