Group :: System/Base
RPM: util-linux
Main Changelog Spec Patches Sources Download Gear Bugs and FR Repocop
Patch: 0003-ALT-Replace-vidattr-by-own-function-that-works-like-.patch
Download
Download
From 4112a6565724793bbbb824cb71590e032c3f74df Mon Sep 17 00:00:00 2001
From: Alexey Gladkov <legion@altlinux.org>
Date: Thu, 14 May 2020 15:33:42 +0300
Subject: ALT: Replace vidattr by own function that works like
vidattr((~7)&attr)
Signed-off-by: Alexey Gladkov <legion@altlinux.org>
---
text-utils/pg.c | 45 +++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 43 insertions(+), 2 deletions(-)
diff --git a/text-utils/pg.c b/text-utils/pg.c
index adb3840be..5e430aed3 100644
--- a/text-utils/pg.c
+++ b/text-utils/pg.c
@@ -297,16 +297,57 @@ static int outcap(int i)
return write_all(STDOUT_FILENO, &c, 1) == 0 ? 1 : -1;
}
+/* works like vidattr((~7)&attr) */
+static void my_vidputs(chtype attr, int (*putc)(int))
+{
+ if (set_attributes)
+ tputs(tparm(set_attributes,
+ (attr & A_STANDOUT) != 0,
+ (attr & A_UNDERLINE) != 0,
+ (attr & A_REVERSE) != 0,
+ (attr & A_BLINK) != 0,
+ (attr & A_DIM) != 0,
+ (attr & A_BOLD) != 0,
+ (attr & A_INVIS) != 0,
+ (attr & A_PROTECT) != 0,
+ (attr & A_ALTCHARSET) != 0), 1, putc);
+ else {
+ /* try to use enter_*_mode capabilities */
+ /* turn all atributes first, it's similar to normal */
+ if (exit_attribute_mode)
+ tputs(tparm(exit_attribute_mode), 1, putc);
+
+ if (enter_standout_mode && (attr&A_STANDOUT))
+ tputs(tparm(enter_standout_mode), 1, putc);
+ if (enter_underline_mode && (attr&A_UNDERLINE))
+ tputs(tparm(enter_underline_mode), 1, putc);
+ if (enter_reverse_mode && (attr&A_REVERSE))
+ tputs(tparm(enter_reverse_mode), 1, putc);
+ if (enter_blink_mode && (attr&A_BLINK))
+ tputs(tparm(enter_blink_mode), 1, putc);
+ if (enter_dim_mode && (attr&A_DIM))
+ tputs(tparm(enter_dim_mode), 1, putc);
+ if (enter_bold_mode && (attr&A_BOLD))
+ tputs(tparm(enter_bold_mode), 1, putc);
+ if (enter_secure_mode && (attr&A_INVIS))
+ tputs(tparm(enter_secure_mode), 1, putc);
+ if (enter_protected_mode && (attr&A_PROTECT))
+ tputs(tparm(enter_protected_mode), 1, putc);
+ if (enter_alt_charset_mode && (attr&A_ALTCHARSET))
+ tputs(tparm(enter_alt_charset_mode), 1, putc);
+ }
+}
+
/* Write messages to terminal. */
static void mesg(const char *message)
{
if (ontty == 0)
return;
if (*message != '\n' && sflag)
- vidputs(A_STANDOUT, outcap);
+ my_vidputs(A_STANDOUT, outcap);
write_all(STDOUT_FILENO, message, strlen(message));
if (*message != '\n' && sflag)
- vidputs(A_NORMAL, outcap);
+ my_vidputs(A_NORMAL, outcap);
}
/* Get the window size. */
--
2.25.4