shithub: neatroff

Download patch

ref: dabd2921e7de529e5644eb6583e5ce84ee3389bc
parent: e437437f48e52cd408c69d3f95b33c8afcea76f4
author: Ali Gholami Rudi <[email protected]>
date: Fri May 16 13:28:58 EDT 2014

cp: \R'x n' is equivalent to .nr x n

--- a/cp.c
+++ b/cp.c
@@ -78,6 +78,20 @@
 	in_push(wid, NULL);
 }
 
+static void cp_numdef(void)
+{
+	char arg[ILNLEN];
+	char *s;
+	argnext(arg, 'R', cp_next, cp_back);
+	s = arg;
+	while (*s && *s != ' ')
+		s++;
+	if (!*s)
+		return;
+	*s++ = '\0';
+	num_set(map(arg), eval_re(s, num_get(map(arg), 0), 'u'));
+}
+
 static int cp_raw(void)
 {
 	int c;
@@ -144,6 +158,9 @@
 			c = cp_next();
 		} else if (c == '$') {
 			cp_arg();
+			c = cp_next();
+		} else if (c == 'R' && !cp_cpmode) {
+			cp_numdef();
 			c = cp_next();
 		} else {
 			cp_back(c);
--- a/roff.h
+++ b/roff.h
@@ -56,7 +56,7 @@
 #define SC_EM		(n_s * SC_IN / 72)
 
 /* escape sequences */
-#define ESC_Q	"bCDhHlLNoSvwxX"	/* \X'ccc' quoted escape sequences */
+#define ESC_Q	"bCDhHlLNoRSvwxX"	/* \X'ccc' quoted escape sequences */
 #define ESC_P	"*fgkmns"		/* \Xc \X(cc \X[ccc] escape sequences */
 
 #define MIN(a, b)	((a) < (b) ? (a) : (b))