aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2022-05-31 18:09:57 +0000
committerIngo Schwarze <schwarze@openbsd.org>2022-05-31 18:09:57 +0000
commitea452a23a02a06e590a1b863b12b3fa42b728535 (patch)
treedaad6e3ff564c8c5940bccb04cc02fd1c8ae9cc0
parentda6633e8c5db9f71ef2499ad46bc43e3854c2ac9 (diff)
downloadmandoc-ea452a23a02a06e590a1b863b12b3fa42b728535.tar.gz
mandoc-ea452a23a02a06e590a1b863b12b3fa42b728535.tar.zst
mandoc-ea452a23a02a06e590a1b863b12b3fa42b728535.zip
Trivial patch to put the roff(7) \g (interpolate format of register)
escape sequence into the correct parsing class, ESCAPE_EXPAND. Expansion of \g is supposed to work exactly like the expansion of the related escape sequence \n (interpolate register value), but since we ignore the .af (assign output format) request, we just interpolate an empty string to replace the \g sequence. Surprising as it may seem, this actually makes a formatting difference for deviate input like ".O\gNx" which used to raise bogus "escaped character not allowed in a name" and "skipping unknown macro" errors and printed nothing, whereas now it correctly prints "OpenBSD".
-rw-r--r--roff.77
-rw-r--r--roff.c4
-rw-r--r--roff_escape.c2
3 files changed, 8 insertions, 5 deletions
diff --git a/roff.7 b/roff.7
index 6ebde4ff..cafa5287 100644
--- a/roff.7
+++ b/roff.7
@@ -1,4 +1,4 @@
-.\" $Id: roff.7,v 1.118 2022/05/30 23:03:47 schwarze Exp $
+.\" $Id: roff.7,v 1.119 2022/05/31 18:09:57 schwarze Exp $
.\"
.\" Copyright (c) 2010-2019, 2022 Ingo Schwarze <schwarze@openbsd.org>
.\" Copyright (c) 2010, 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 30 2022 $
+.Dd $Mdocdate: May 31 2022 $
.Dt ROFF 7
.Os
.Sh NAME
@@ -2085,7 +2085,8 @@ defaults to
.Ic \efP .
.It Ic \eg[ Ns Ar name Ns Ic \&]
Interpolate the format of a number register; ignored by
-.Xr mandoc 1 .
+.Xr mandoc 1 ,
+which interpolates an empty string instead.
For short names, there are variants
.Ic \eg Ns Ar c
and
diff --git a/roff.c b/roff.c
index 59e2644f..0c36e08e 100644
--- a/roff.c
+++ b/roff.c
@@ -1,4 +1,4 @@
-/* $Id: roff.c,v 1.389 2022/05/30 23:03:47 schwarze Exp $ */
+/* $Id: roff.c,v 1.390 2022/05/31 18:09:57 schwarze Exp $ */
/*
* Copyright (c) 2010-2015, 2017-2022 Ingo Schwarze <schwarze@openbsd.org>
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
@@ -1535,6 +1535,8 @@ roff_expand(struct roff *r, struct buf *buf, int ln, int pos, char ec)
roff_expand_patch(buf, iendarg, "}", iend);
roff_expand_patch(buf, iesc, "${", iarg);
continue;
+ case 'g':
+ break;
case 'n':
if (iendarg > iarg)
(void)snprintf(ubuf, sizeof(ubuf), "%d",
diff --git a/roff_escape.c b/roff_escape.c
index 51e3d897..3c38ced7 100644
--- a/roff_escape.c
+++ b/roff_escape.c
@@ -158,6 +158,7 @@ roff_escape(const char *buf, const int ln, const int aesc,
case '$':
case '*':
case 'V':
+ case 'g':
case 'n':
rval = ESCAPE_EXPAND;
break;
@@ -165,7 +166,6 @@ roff_escape(const char *buf, const int ln, const int aesc,
case 'M':
case 'O':
case 'Y':
- case 'g':
case 'k':
case 'm':
rval = ESCAPE_IGNORE;