From dabd2921e7de529e5644eb6583e5ce84ee3389bc Mon Sep 17 00:00:00 2001 From: Ali Gholami Rudi Date: Fri, 16 May 2014 17:28:58 +0430 Subject: [PATCH] cp: \R'x n' is equivalent to .nr x n --- cp.c | 17 +++++++++++++++++ roff.h | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/cp.c b/cp.c index b19bd7b..8e5ddc8 100644 --- a/cp.c +++ b/cp.c @@ -78,6 +78,20 @@ static void cp_width(void) 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; @@ -145,6 +159,9 @@ int cp_next(void) } else if (c == '$') { cp_arg(); c = cp_next(); + } else if (c == 'R' && !cp_cpmode) { + cp_numdef(); + c = cp_next(); } else { cp_back(c); c = c_ec; diff --git a/roff.h b/roff.h index 6b9a02e..2480f18 100644 --- 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)) -- 2.11.4.GIT