shithub: neatroff

Download patch

ref: 05da336cb5969ce266a6188fc4ec48c1f8dfdfd7
parent: 883272e1c24f8410b7c78e3671cc5b2603635fbe
author: Ali Gholami Rudi <ali@rudi.ir>
date: Wed May 2 21:40:22 EDT 2018

tr: .dv request

This is almost equivalent to \X escape sequence, except that it is not
added to the current line buffer.  The argument of .dv is parsed as
the argument of .ds request.

--- a/out.c
+++ b/out.c
@@ -159,6 +159,11 @@
 	outnn("h%d", cwid);
 }
 
+void out_x(char *s)
+{
+	out("x X %s\n", s);
+}
+
 void out_line(char *s)
 {
 	char *c;
@@ -195,7 +200,7 @@
 			outnn("v%d", eval(c, 'v'));
 			break;
 		case 'X':
-			out("x X %s\n", c);
+			out_x(c);
 			break;
 		}
 	}
--- a/roff.h
+++ b/roff.h
@@ -346,6 +346,7 @@
 
 /* out.c */
 void out_line(char *s);				/* output rendered line */
+void out_x(char *s);				/* output \X requests */
 void out(char *s, ...);				/* output troff cmd */
 
 /* troff commands */
--- a/tr.c
+++ b/tr.c
@@ -931,6 +931,12 @@
 	}
 }
 
+static void tr_dv(char **args)
+{
+	if (args[1])
+		out_x(args[1]);
+}
+
 /* read a single macro argument */
 static int macroarg(struct sbuf *sbuf, int brk, int (*next)(void), void (*back)(int))
 {
@@ -1125,6 +1131,7 @@
 	{"di", tr_di},
 	{"ds", tr_ds, mkargs_ds},
 	{"dt", tr_dt},
+	{"dv", tr_dv, mkargs_eol},
 	{"ec", tr_ec},
 	{"el", tr_el, mkargs_null},
 	{"em", tr_em},