[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240122110401.7289-11-jirislaby@kernel.org>
Date: Mon, 22 Jan 2024 12:03:24 +0100
From: "Jiri Slaby (SUSE)" <jirislaby@...nel.org>
To: gregkh@...uxfoundation.org
Cc: linux-serial@...r.kernel.org,
linux-kernel@...r.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@...nel.org>
Subject: [PATCH v2 10/47] tty: vt: use case ranges for CSI+m fg/bg colors
Replacing the default case with the iffery by case ranges makes the code
more understandable at last.
Signed-off-by: Jiri Slaby (SUSE) <jirislaby@...nel.org>
---
drivers/tty/vt/vt.c | 35 ++++++++++++++++-------------------
1 file changed, 16 insertions(+), 19 deletions(-)
diff --git a/drivers/tty/vt/vt.c b/drivers/tty/vt/vt.c
index b2ba1b943eb6..66ebc90a9fe9 100644
--- a/drivers/tty/vt/vt.c
+++ b/drivers/tty/vt/vt.c
@@ -1795,25 +1795,22 @@ static void csi_m(struct vc_data *vc)
vc->state.color = (vc->vc_def_color & 0xf0) |
(vc->state.color & 0x0f);
break;
- default:
- if (vc->vc_par[i] >= CSI_m_BRIGHT_FG_COLOR_BEG &&
- vc->vc_par[i] <= CSI_m_BRIGHT_BG_COLOR_END) {
- if (vc->vc_par[i] < CSI_m_BRIGHT_BG_COLOR_BEG)
- vc->state.intensity = VCI_BOLD;
- vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF;
- }
- if (vc->vc_par[i] >= CSI_m_FG_COLOR_BEG &&
- vc->vc_par[i] <= CSI_m_FG_COLOR_END) {
- vc->vc_par[i] -= CSI_m_FG_COLOR_BEG;
- vc->state.color = color_table[vc->vc_par[i]] |
- (vc->state.color & 0xf0);
- } else if (vc->vc_par[i] >= CSI_m_BG_COLOR_BEG &&
- vc->vc_par[i] <= CSI_m_BG_COLOR_END) {
- vc->vc_par[i] -= CSI_m_BG_COLOR_BEG;
- vc->state.color = (color_table[vc->vc_par[i]] << 4) |
- (vc->state.color & 0x0f);
- }
-
+ case CSI_m_BRIGHT_FG_COLOR_BEG ... CSI_m_BRIGHT_FG_COLOR_END:
+ vc->state.intensity = VCI_BOLD;
+ vc->vc_par[i] -= CSI_m_BRIGHT_FG_COLOR_OFF;
+ fallthrough;
+ case CSI_m_FG_COLOR_BEG ... CSI_m_FG_COLOR_END:
+ vc->vc_par[i] -= CSI_m_FG_COLOR_BEG;
+ vc->state.color = color_table[vc->vc_par[i]] |
+ (vc->state.color & 0xf0);
+ break;
+ case CSI_m_BRIGHT_BG_COLOR_BEG ... CSI_m_BRIGHT_BG_COLOR_END:
+ vc->vc_par[i] -= CSI_m_BRIGHT_BG_COLOR_OFF;
+ fallthrough;
+ case CSI_m_BG_COLOR_BEG ... CSI_m_BG_COLOR_END:
+ vc->vc_par[i] -= CSI_m_BG_COLOR_BEG;
+ vc->state.color = (color_table[vc->vc_par[i]] << 4) |
+ (vc->state.color & 0x0f);
break;
}
update_attr(vc);
--
2.43.0
Powered by blists - more mailing lists