summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/less/cvt.c2
-rw-r--r--usr.bin/less/filename.c2
-rw-r--r--usr.bin/less/less.h4
-rw-r--r--usr.bin/less/line.c22
4 files changed, 11 insertions, 19 deletions
diff --git a/usr.bin/less/cvt.c b/usr.bin/less/cvt.c
index d47ef133ede..ed7c72d69a1 100644
--- a/usr.bin/less/cvt.c
+++ b/usr.bin/less/cvt.c
@@ -77,7 +77,7 @@ cvt_text(char *odst, char *osrc, int *chpos, int *lenp, int ops)
dst--;
} while (dst > odst &&
!IS_ASCII_OCTET(*dst) && !IS_UTF8_LEAD(*dst));
- } else if ((ops & CVT_ANSI) && IS_CSI_START(ch)) {
+ } else if ((ops & CVT_ANSI) && ch == ESC) {
/* Skip to end of ANSI escape sequence. */
src++; /* skip the CSI start char */
while (src < src_end)
diff --git a/usr.bin/less/filename.c b/usr.bin/less/filename.c
index 00bf8573ce5..2e480e6445d 100644
--- a/usr.bin/less/filename.c
+++ b/usr.bin/less/filename.c
@@ -348,7 +348,7 @@ bin_file(int f)
pend = &data[n];
for (p = data; p < pend; ) {
LWCHAR c = step_char(&p, +1, pend);
- if (ctldisp == OPT_ONPLUS && IS_CSI_START(c)) {
+ if (ctldisp == OPT_ONPLUS && c == ESC) {
do {
c = step_char(&p, +1, pend);
} while (p < pend && is_ansi_middle(c));
diff --git a/usr.bin/less/less.h b/usr.bin/less/less.h
index a3a389b52af..3bd9e307201 100644
--- a/usr.bin/less/less.h
+++ b/usr.bin/less/less.h
@@ -38,8 +38,6 @@
#define IS_SPACE(c) isspace((unsigned char)(c))
#define IS_DIGIT(c) isdigit((unsigned char)(c))
-#define IS_CSI_START(c) (((LWCHAR)(c)) == ESC || (((LWCHAR)(c)) == CSI))
-
#ifndef TRUE
#define TRUE 1
#endif
@@ -151,9 +149,7 @@ struct textlist {
#define AT_INDET (1 << 7) /* Indeterminate: either bold or underline */
#define CONTROL(c) ((c)&037)
-
#define ESC CONTROL('[')
-#define CSI ((unsigned char)'\233')
#define S_INTERRUPT 01
#define S_STOP 02
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.
*/