summaryrefslogtreecommitdiff
path: root/usr.bin/less/line.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@cvs.openbsd.org>2019-02-26 11:01:55 +0000
committerIngo Schwarze <schwarze@cvs.openbsd.org>2019-02-26 11:01:55 +0000
commit555ee9dc210c327d69b5493bee594636e70c6209 (patch)
tree4ecfebcc7893d3b36540928b2c18c14daab118e6 /usr.bin/less/line.c
parent53e9bec00e25346b3912553bc6d4181a422fa229 (diff)
To simplify the upcoming UTF-8 cleanup in less(1), delete support
for ANSI escape sequences introduced by an 8-bit CSI (e.g. "\23343m") because these are neither compatible with UTF-8 nor strictly compatible with pure ASCII and for those introduced by an UTF-8 CSI (e.g. "\302\23343m") because not even xterm(1) supports them at all, not even with a non-default configuration, because both forms are very rarely used, if at all, and because the current code trying to support them doesn't even appear to work according to my tests. Full support for the ESC-[ CSI (e.g. "\033[43m") remains. Tweaks and OK millert@, OK nicm@, and sthen@ agrees with the general direction.
Diffstat (limited to 'usr.bin/less/line.c')
-rw-r--r--usr.bin/less/line.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/usr.bin/less/line.c b/usr.bin/less/line.c
index c39a639fef4..e8ce55ade3e 100644
--- a/usr.bin/less/line.c
+++ b/usr.bin/less/line.c
@@ -230,7 +230,7 @@ pshift(int shift)
*/
while (shifted <= shift && from < curr) {
c = linebuf[from];
- if (ctldisp == OPT_ONPLUS && IS_CSI_START(c)) {
+ if (ctldisp == OPT_ONPLUS && c == ESC) {
/* Keep cumulative effect. */
linebuf[to] = c;
attr[to++] = attr[from++];
@@ -463,17 +463,16 @@ backc(void)
static int
in_ansi_esc_seq(void)
{
- char *p;
+ int i;
/*
* Search backwards for either an ESC (which means we ARE in a seq);
* or an end char (which means we're NOT in a seq).
*/
- for (p = &linebuf[curr]; p > linebuf; ) {
- LWCHAR ch = step_char(&p, -1, linebuf);
- if (IS_CSI_START(ch))
+ for (i = curr - 1; i >= 0; i--) {
+ if (linebuf[i] == ESC)
return (1);
- if (!is_ansi_middle(ch))
+ if (!is_ansi_middle(linebuf[i]))
return (0);
}
return (0);
@@ -533,17 +532,14 @@ store_char(LWCHAR ch, char a, char *rep, off_t pos)
if (ctldisp == OPT_ONPLUS && in_ansi_esc_seq()) {
if (!is_ansi_end(ch) && !is_ansi_middle(ch)) {
/* Remove whole unrecognized sequence. */
- char *p = &linebuf[curr];
- LWCHAR bch;
do {
- bch = step_char(&p, -1, linebuf);
- } while (p > linebuf && !IS_CSI_START(bch));
- curr = p - linebuf;
+ curr--;
+ } while (curr > 0 && linebuf[curr] != ESC);
return (0);
}
a = AT_ANSI; /* Will force re-AT_'ing around it. */
w = 0;
- } else if (ctldisp == OPT_ONPLUS && IS_CSI_START(ch)) {
+ } else if (ctldisp == OPT_ONPLUS && ch == ESC) {
a = AT_ANSI; /* Will force re-AT_'ing around it. */
w = 0;
} else {
@@ -851,7 +847,7 @@ do_append(LWCHAR ch, char *rep, off_t pos)
} else if ((!utf_mode || is_ascii_char(ch)) && control_char((char)ch)) {
do_control_char:
if (ctldisp == OPT_ON ||
- (ctldisp == OPT_ONPLUS && IS_CSI_START(ch))) {
+ (ctldisp == OPT_ONPLUS && ch == ESC)) {
/*
* Output as a normal character.
*/