cvt.c (367516) | cvt.c (369759) |
---|---|
1/* | 1/* |
2 * Copyright (C) 1984-2020 Mark Nudelman | 2 * Copyright (C) 1984-2021 Mark Nudelman |
3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10/* --- 61 unchanged lines hidden (view full) --- 72 src_end = osrc + *lenp; 73 else 74 src_end = osrc + strlen(osrc); 75 76 for (src = osrc, dst = odst; src < src_end; ) 77 { 78 int src_pos = (int) (src - osrc); 79 int dst_pos = (int) (dst - odst); | 3 * 4 * You may distribute under the terms of either the GNU General Public 5 * License or the Less License, as specified in the README file. 6 * 7 * For more information, see the README file. 8 */ 9 10/* --- 61 unchanged lines hidden (view full) --- 72 src_end = osrc + *lenp; 73 else 74 src_end = osrc + strlen(osrc); 75 76 for (src = osrc, dst = odst; src < src_end; ) 77 { 78 int src_pos = (int) (src - osrc); 79 int dst_pos = (int) (dst - odst); |
80 struct ansi_state *pansi; |
|
80 ch = step_char(&src, +1, src_end); 81 if ((ops & CVT_BS) && ch == '\b' && dst > odst) 82 { 83 /* Delete backspace and preceding char. */ 84 do { 85 dst--; 86 } while (dst > odst && utf_mode && 87 !IS_ASCII_OCTET(*dst) && !IS_UTF8_LEAD(*dst)); | 81 ch = step_char(&src, +1, src_end); 82 if ((ops & CVT_BS) && ch == '\b' && dst > odst) 83 { 84 /* Delete backspace and preceding char. */ 85 do { 86 dst--; 87 } while (dst > odst && utf_mode && 88 !IS_ASCII_OCTET(*dst) && !IS_UTF8_LEAD(*dst)); |
88 } else if ((ops & CVT_ANSI) && IS_CSI_START(ch)) | 89 } else if ((ops & CVT_ANSI) && (pansi = ansi_start(ch)) != NULL) |
89 { 90 /* Skip to end of ANSI escape sequence. */ | 90 { 91 /* Skip to end of ANSI escape sequence. */ |
91 src++; /* skip the CSI start char */ | |
92 while (src < src_end) | 92 while (src < src_end) |
93 if (!is_ansi_middle(*src++)) | 93 { 94 if (ansi_step(pansi, ch) != ANSI_MID) |
94 break; | 95 break; |
96 ch = *src++; 97 } 98 ansi_done(pansi); |
|
95 } else 96 { 97 /* Just copy the char to the destination buffer. */ 98 if ((ops & CVT_TO_LC) && IS_UPPER(ch)) 99 ch = TO_LOWER(ch); 100 put_wchar(&dst, ch); 101 /* Record the original position of the char. */ 102 if (chpos != NULL) --- 12 unchanged lines hidden --- | 99 } else 100 { 101 /* Just copy the char to the destination buffer. */ 102 if ((ops & CVT_TO_LC) && IS_UPPER(ch)) 103 ch = TO_LOWER(ch); 104 put_wchar(&dst, ch); 105 /* Record the original position of the char. */ 106 if (chpos != NULL) --- 12 unchanged lines hidden --- |