Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

vt: support ITU-T T.416 color subparameters

The colon ("bit combination 03/10") is a valid character in parameter
substrings. ECMA-48 says:

Each parameter sub-string consists of one or more bit combinations
from 03/00 to 03/10; the bit combinations from 03/00 to 03/09
represent the digits ZERO to NINE; bit combination 03/10 may be used
as a separator in a parameter sub-string, for example, to separate
the fractional part of a decimal number from the integer part of
that number.

To my knowledge, the only codes where 03/10 is actually used as a
separator are the CSI-m SGR sequences. The colon separated format is
superior as an embedded string for software that doesn't wish to link
ncurses terminal database, because terminals that do not support the
requested SGR sequence can safely skip the sub-parameters rather than
misinterpret them as another sequence. Hence, some software have started
using this "modern" format [1]. We should support the colon separated
format as well.

[1] https://github.com/systemd/systemd/commit/6eabe9f2ff48c1b6924724d5afe64e7b661ccdbf

Signed-off-by: Ronan Pigott <ronan@rjp.ie>
Link: https://patch.msgid.link/20260303010701.631022-1-ronan@rjp.ie
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Ronan Pigott and committed by
Greg Kroah-Hartman
fa4268cf 0b1837c0

+45 -3
+45 -3
drivers/tty/vt/vt.c
··· 1644 1644 1645 1645 /* 1646 1646 * ITU T.416 Higher colour modes. They break the usual properties of SGR codes 1647 - * and thus need to be detected and ignored by hand. That standard also 1648 - * wants : rather than ; as separators but sequences containing : are currently 1649 - * completely ignored by the parser. 1647 + * and thus need to be detected and ignored by hand. 1650 1648 * 1651 1649 * Subcommands 3 (CMY) and 4 (CMYK) are so insane there's no point in 1652 1650 * supporting them. ··· 1701 1703 CSI_m_BG_COLOR_END = 47, 1702 1704 CSI_m_BG_COLOR = 48, 1703 1705 CSI_m_DEFAULT_BG_COLOR = 49, 1706 + CSI_m_UNDERLINE_COLOR = 58, 1704 1707 CSI_m_BRIGHT_FG_COLOR_BEG = 90, 1705 1708 CSI_m_BRIGHT_FG_COLOR_END = 97, 1706 1709 CSI_m_BRIGHT_FG_COLOR_OFF = CSI_m_BRIGHT_FG_COLOR_BEG - CSI_m_FG_COLOR_BEG, ··· 2159 2160 * @ESesc: ESC parsed 2160 2161 * @ESsquare: CSI parsed -- modifiers/parameters/ctrl chars expected 2161 2162 * @ESgetpars: CSI parsed -- parameters/ctrl chars expected 2163 + * @ESgetsubpars: CSI m parsed -- subparameters expected 2162 2164 * @ESfunckey: CSI [ parsed 2163 2165 * @EShash: ESC # parsed 2164 2166 * @ESsetG0: ESC ( parsed ··· 2180 2180 ESesc, 2181 2181 ESsquare, 2182 2182 ESgetpars, 2183 + ESgetsubpars, 2183 2184 ESfunckey, 2184 2185 EShash, 2185 2186 ESsetG0, ··· 2700 2699 fallthrough; 2701 2700 case ESgetpars: /* ESC [ aka CSI, parameters expected */ 2702 2701 switch (c) { 2702 + case ':': /* ITU-T T.416 color subparameters */ 2703 + if (vc->vc_par[vc->vc_npar] == CSI_m_FG_COLOR || 2704 + vc->vc_par[vc->vc_npar] == CSI_m_BG_COLOR || 2705 + vc->vc_par[vc->vc_npar] == CSI_m_UNDERLINE_COLOR) 2706 + vc->vc_state = ESgetsubpars; 2707 + else 2708 + break; 2709 + fallthrough; 2710 + case ';': 2711 + if (vc->vc_npar < NPAR - 1) { 2712 + vc->vc_npar++; 2713 + return; 2714 + } 2715 + break; 2716 + case '0' ... '9': 2717 + vc->vc_par[vc->vc_npar] *= 10; 2718 + vc->vc_par[vc->vc_npar] += c - '0'; 2719 + return; 2720 + } 2721 + if (c >= ASCII_CSI_IGNORE_FIRST && c <= ASCII_CSI_IGNORE_LAST) { 2722 + vc->vc_state = EScsiignore; 2723 + return; 2724 + } 2725 + 2726 + /* parameters done, handle the control char @c */ 2727 + 2728 + vc->vc_state = ESnormal; 2729 + 2730 + switch (vc->vc_priv) { 2731 + case EPdec: 2732 + csi_DEC(tty, vc, c); 2733 + return; 2734 + case EPecma: 2735 + csi_ECMA(tty, vc, c); 2736 + return; 2737 + default: 2738 + return; 2739 + } 2740 + case ESgetsubpars: /* ESC [ 38/48/58, subparameters expected */ 2741 + switch (c) { 2742 + case ':': 2703 2743 case ';': 2704 2744 if (vc->vc_npar < NPAR - 1) { 2705 2745 vc->vc_npar++;