ref: 3a15190ed4a17671ea5d97d00c9a168df7a3d65c
parent: 16a3d86bab480417e25b29efe903e8a8f7a12585
author: Ali Gholami Rudi <[email protected]>
date: Fri May 16 09:30:55 EDT 2014
cp: \E is an escape character when not in copy-mode
--- a/cp.c
+++ b/cp.c
@@ -5,7 +5,7 @@
static int cp_nblk; /* input block depth (text in \{ and \}) */
static int cp_sblk[NIES]; /* skip \} escape at this depth, if set */
-static int cp_widreq = 1; /* inline \w requests */
+static int cp_cpmode; /* disable the interpretation \w and \E */
static void cparg(char *d)
{
@@ -125,10 +125,12 @@
c = cp_raw();
if (c == c_ec) {
c = cp_raw();
+ if (c == 'E' && !cp_cpmode)
+ c = cp_next();
if (c == '"') {
while (c >= 0 && c != '\n')
c = cp_raw();
- } else if (c == 'w' && cp_widreq) {
+ } else if (c == 'w' && !cp_cpmode) {
cp_width();
c = cp_next();
} else if (c == 'n') {
@@ -171,7 +173,7 @@
}
}
-void cp_wid(int enable)
+void cp_copymode(int mode)
{
- cp_widreq = enable;
+ cp_cpmode = mode;
}
--- a/roff.h
+++ b/roff.h
@@ -208,7 +208,7 @@
int in_lnum(void); /* current line number */
void cp_blk(int skip); /* skip or read the next line or block */
-void cp_wid(int enable); /* control inlining \w requests */
+void cp_copymode(int mode); /* do not interpret \w and \E */
#define cp_back in_back /* cp.c is stateless */
int tr_nextreq(void); /* read the next troff request */
--- a/tr.c
+++ b/tr.c
@@ -116,7 +116,7 @@
int i, c;
int first = 1;
cp_back('\n');
- cp_wid(0); /* copy-mode; disable \w handling */
+ cp_copymode(1);
while ((c = cp_next()) >= 0) {
if (sbuf && !first)
sbuf_add(sbuf, c);
@@ -141,7 +141,7 @@
sbuf_add(sbuf, c);
}
}
- cp_wid(1);
+ cp_copymode(0);
}
static void tr_de(char **args)
@@ -781,9 +781,9 @@
args[0] = s;
s = arg_regname(s, e - s);
args[1] = s;
- cp_wid(0);
+ cp_copymode(1);
s = arg_string(s, e - s);
- cp_wid(1);
+ cp_copymode(0);
c = cp_next();
if (c >= 0 && c != '\n')
jmp_eol();
@@ -950,9 +950,9 @@
mkargs_req(args + 1, buf, sizeof(buf));
req->f(args);
} else {
- cp_wid(0);
+ cp_copymode(1);
mkargs(args + 1, buf, sizeof(buf));
- cp_wid(1);
+ cp_copymode(0);
if (str_get(map(cmd + 1)))
in_push(str_get(map(cmd + 1)), args + 1);
}