Bump to 608
[platform/upstream/less.git] / cvt.c
diff --git a/cvt.c b/cvt.c
index 3a77949..bb46492 100644 (file)
--- a/cvt.c
+++ b/cvt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1984-2017  Mark Nudelman
+ * Copyright (C) 1984-2022  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. */