source@mandoc.bsd.lv
 help / color / mirror / Atom feed
* mandoc: Trivial patch to put the roff(7) \g (interpolate format of
@ 2022-05-31 18:10 schwarze
  0 siblings, 0 replies; only message in thread
From: schwarze @ 2022-05-31 18:10 UTC (permalink / raw)
  To: source

Log Message:
-----------
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".

Modified Files:
--------------
    mandoc:
        roff.c
        roff_escape.c
        roff.7

Revision Data
-------------
Index: roff.7
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.7,v
retrieving revision 1.118
retrieving revision 1.119
diff -Lroff.7 -Lroff.7 -u -p -r1.118 -r1.119
--- roff.7
+++ roff.7
@@ -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
Index: roff_escape.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff_escape.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -Lroff_escape.c -Lroff_escape.c -u -p -r1.3 -r1.4
--- roff_escape.c
+++ roff_escape.c
@@ -158,6 +158,7 @@ roff_escape(const char *buf, const int l
 	case '$':
 	case '*':
 	case 'V':
+	case 'g':
 	case 'n':
 		rval = ESCAPE_EXPAND;
 		break;
@@ -165,7 +166,6 @@ roff_escape(const char *buf, const int l
 	case 'M':
 	case 'O':
 	case 'Y':
-	case 'g':
 	case 'k':
 	case 'm':
 		rval = ESCAPE_IGNORE;
Index: roff.c
===================================================================
RCS file: /home/cvs/mandoc/mandoc/roff.c,v
retrieving revision 1.389
retrieving revision 1.390
diff -Lroff.c -Lroff.c -u -p -r1.389 -r1.390
--- roff.c
+++ roff.c
@@ -1535,6 +1535,8 @@ roff_expand(struct roff *r, struct buf *
 			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",
--
 To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-05-31 18:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-31 18:10 mandoc: Trivial patch to put the roff(7) \g (interpolate format of schwarze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).