diff options
Diffstat (limited to 'contrib/less/cvt.c')
-rw-r--r-- | contrib/less/cvt.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/contrib/less/cvt.c b/contrib/less/cvt.c index e850a51452a2..9cf44b894e7d 100644 --- a/contrib/less/cvt.c +++ b/contrib/less/cvt.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 1984-2020 Mark Nudelman + * Copyright (C) 1984-2021 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. @@ -77,6 +77,7 @@ cvt_text(odst, osrc, chpos, lenp, ops) { int src_pos = (int) (src - osrc); int dst_pos = (int) (dst - odst); + struct ansi_state *pansi; ch = step_char(&src, +1, src_end); if ((ops & CVT_BS) && ch == '\b' && dst > odst) { @@ -85,13 +86,16 @@ cvt_text(odst, osrc, chpos, lenp, ops) dst--; } while (dst > odst && utf_mode && !IS_ASCII_OCTET(*dst) && !IS_UTF8_LEAD(*dst)); - } else if ((ops & CVT_ANSI) && IS_CSI_START(ch)) + } else if ((ops & CVT_ANSI) && (pansi = ansi_start(ch)) != NULL) { /* Skip to end of ANSI escape sequence. */ - src++; /* skip the CSI start char */ while (src < src_end) - if (!is_ansi_middle(*src++)) + { + if (ansi_step(pansi, ch) != ANSI_MID) break; + ch = *src++; + } + ansi_done(pansi); } else { /* Just copy the char to the destination buffer. */ |