]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
util: add helpers for generating colored check mark glyphs from bools
authorLennart Poettering <lennart@poettering.net>
Wed, 30 Dec 2020 20:49:10 +0000 (21:49 +0100)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 2 Mar 2021 18:08:31 +0000 (03:08 +0900)
src/basic/locale-util.h
src/basic/terminal-util.h
src/boot/bootctl.c

index bebdf97aa8bb37b6092e5751694786bc0902dffb..558c5a898bb5c9f7ae659f9d9993639c8d53c5f9 100644 (file)
@@ -90,3 +90,7 @@ void locale_variables_free(char* l[_VARIABLE_LC_MAX]);
 static inline void locale_variables_freep(char*(*l)[_VARIABLE_LC_MAX]) {
         locale_variables_free(*l);
 }
+
+static inline const char *special_glyph_check_mark(bool b) {
+        return b ? special_glyph(SPECIAL_GLYPH_CHECK_MARK) : special_glyph(SPECIAL_GLYPH_CROSS_MARK);
+}
index 27e7f8db22adf469864ea3fc1af5c1d8d3e536d7..d327627b20dd4859b1714ab15eaa26b63746f60b 100644 (file)
@@ -253,5 +253,9 @@ int vt_release(int fd, bool restore_vt);
 
 void get_log_colors(int priority, const char **on, const char **off, const char **highlight);
 
+static inline const char* ansi_highlight_green_red(bool b) {
+        return b ? ansi_highlight_green() : ansi_highlight_red();
+}
+
 /* This assumes there is a 'tty' group */
 #define TTY_MODE 0620
index cccd834cc82fe66ef68a00c4af57cd749768afee..9964dda1fcc61d98698a7a693386b5e0125266c6 100644 (file)
@@ -1153,8 +1153,8 @@ static void read_loader_efi_var(const char *name, char **var) {
 static void print_yes_no_line(bool first, bool good, const char *name) {
         printf("%s%s%s%s %s\n",
                first ? "     Features: " : "               ",
-               good ? ansi_highlight_green() : ansi_highlight_red(),
-               good ? special_glyph(SPECIAL_GLYPH_CHECK_MARK) : special_glyph(SPECIAL_GLYPH_CROSS_MARK),
+               ansi_highlight_green_red(good),
+               special_glyph_check_mark(good),
                ansi_normal(),
                name);
 }