ref: e60c6c79b126a0719d730de7d76d2d6af6fa834b
parent: 3dd4fdbf2e959b9916dfeba63453bdf1c1fa3afb
author: Ali Gholami Rudi <ali@rudi.ir>
date: Thu May 2 10:18:16 EDT 2013
cp: ignore tabs and leaders for now
--- a/cp.c
+++ b/cp.c
@@ -63,19 +63,35 @@
int c;
if (in_top() >= 0)
return in_next();
- c = in_next();
- if (c == c_ec) {
+ do {
c = in_next();
+ } while (c == c_ni);
+ if (c == c_ec) {
+ do {
+ c = in_next();
+ } while (c == c_ni);
if (c == '\n')
- return in_next();
+ return cp_raw();
if (c == '.')
return '.';
+ if (c == '\\') {
+ in_back('\\');
+ return c_ni;
+ }
+ if (c == 't') {
+ in_back('\t');
+ return c_ni;
+ }
+ if (c == 'a') {
+ in_back('');
+ return c_ni;
+ }
if (c == '{' && cp_nblk < LEN(cp_sblk))
cp_sblk[cp_nblk++] = 0;
if (c == '}' && cp_nblk > 0)
if (cp_sblk[--cp_nblk])
return cp_raw();
- cp_back(c);
+ in_back(c);
return c_ec;
}
return c;
--- a/dev.c
+++ b/dev.c
@@ -125,7 +125,7 @@
{
struct glyph *g;
int i;
- if (c[0] == c_ec && c[1] == c_ec)
+ if ((c[0] == c_ec || c[0] == c_ni) && c[1] == c_ec)
c++;
if (c[0] == c_ec && c[1] == '(')
c += 2;
--- a/in.c
+++ b/in.c
@@ -114,12 +114,7 @@
return c;
in_pop();
}
- if (!buf)
- return -1;
- /* replacing \\ with \ only for buffers inserted via in_push() */
- if (buf->buf[buf->pos] == c_ec && buf->buf[buf->pos + 1] == c_ec)
- buf->pos++;
- return (unsigned char) buf->buf[buf->pos++];
+ return buf ? (unsigned char) buf->buf[buf->pos++] : -1;
}
int in_next(void)
--- a/out.c
+++ b/out.c
@@ -199,6 +199,10 @@
}
}
}
+ if (c[0] == c_ni)
+ s = utf8get(c, s);
+ if (c[0] == '\t' || c[0] == '')
+ continue;
g = dev_glyph(c, o_f);
if (utf8len(c[0]) == strlen(c))
outnn("c%s%s", c, c[1] ? "\n" : "");
--- a/ren.c
+++ b/ren.c
@@ -573,6 +573,8 @@
return;
}
}
+ if (c[0] == c_ni)
+ nextchar(c + 1, next);
wb_put(wb, c);
}
--- a/tr.c
+++ b/tr.c
@@ -161,6 +161,10 @@
{
d[0] = next();
d[1] = '\0';
+ if (d[0] == c_ni) {
+ d[1] = next();
+ d[2] = '\0';
+ }
if (d[0] == c_ec) {
d[1] = next();
d[2] = '\0';
--- a/wb.c
+++ b/wb.c
@@ -74,6 +74,11 @@
wb_hmov(wb, charwid(dev_spacewid(), n_s));
return;
}
+ if (c[0] == '\t' || c[0] == '' ||
+ (c[0] == c_ni && (c[1] == '\t' || c[1] == ''))) {
+ sbuf_append(&wb->sbuf, c);
+ return;
+ }
g = dev_glyph(c, n_f);
wb_font(wb);
sbuf_append(&wb->sbuf, c);
--- a/xroff.h
+++ b/xroff.h
@@ -33,6 +33,7 @@
extern int c_ec; /* escape character (\) */
extern int c_cc; /* basic control character (.) */
extern int c_c2; /* no-break control character (') */
+#define c_ni 3 /* non-interpreted copy mode escape */
/* number registers */
int num_get(int id, int inc);