dryang / rpms / systemd

Forked from rpms/systemd a year ago
Clone
8d419f
From 65038051854a48ed8c86bfcfdddfee9122fc2cab Mon Sep 17 00:00:00 2001
8d419f
From: Lennart Poettering <lennart@poettering.net>
8d419f
Date: Wed, 16 Feb 2022 14:53:34 +0100
8d419f
Subject: [PATCH] glyph-util: add new glyphs for up/down arrows
8d419f
8d419f
(cherry picked from commit fc03e80c6b19521ecf4f3af06865b2054e685f9a)
8d419f
8d419f
Related: #2118297
8d419f
---
8d419f
 src/analyze/analyze-security.c |  2 +-
8d419f
 src/basic/chase-symlinks.c     |  2 +-
8d419f
 src/basic/glyph-util.c         | 10 ++++++++--
8d419f
 src/basic/glyph-util.h         |  5 ++++-
8d419f
 src/delta/delta.c              | 20 ++++++++++----------
8d419f
 src/partition/repart.c         |  4 ++--
8d419f
 src/portable/portable.c        |  6 +++---
8d419f
 src/portable/portablectl.c     |  4 ++--
8d419f
 src/shared/cgroup-show.c       |  2 +-
8d419f
 src/shared/install.c           |  2 +-
8d419f
 src/test/test-locale-util.c    |  5 ++++-
8d419f
 11 files changed, 37 insertions(+), 25 deletions(-)
8d419f
8d419f
diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c
8d419f
index e112922cbf..522d443f8a 100644
8d419f
--- a/src/analyze/analyze-security.c
8d419f
+++ b/src/analyze/analyze-security.c
8d419f
@@ -1902,7 +1902,7 @@ static int assess(const SecurityInfo *info,
8d419f
                         name = info->id;
8d419f
 
8d419f
                 printf("\n%s %sOverall exposure level for %s%s: %s%" PRIu64 ".%" PRIu64 " %s%s %s\n",
8d419f
-                       special_glyph(SPECIAL_GLYPH_ARROW),
8d419f
+                       special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
8d419f
                        ansi_highlight(),
8d419f
                        name,
8d419f
                        ansi_normal(),
8d419f
diff --git a/src/basic/chase-symlinks.c b/src/basic/chase-symlinks.c
8d419f
index 344e7e1bb7..61f8b3351b 100644
8d419f
--- a/src/basic/chase-symlinks.c
8d419f
+++ b/src/basic/chase-symlinks.c
8d419f
@@ -41,7 +41,7 @@ static int log_unsafe_transition(int a, int b, const char *path, unsigned flags)
8d419f
 
8d419f
         return log_warning_errno(SYNTHETIC_ERRNO(ENOLINK),
8d419f
                                  "Detected unsafe path transition %s (owned by %s) %s %s (owned by %s) during canonicalization of %s.",
8d419f
-                                 strna(n1), strna(user_a), special_glyph(SPECIAL_GLYPH_ARROW), strna(n2), strna(user_b), path);
8d419f
+                                 strna(n1), strna(user_a), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), strna(n2), strna(user_b), path);
8d419f
 }
8d419f
 
8d419f
 static int log_autofs_mount_point(int fd, const char *path, unsigned flags) {
8d419f
diff --git a/src/basic/glyph-util.c b/src/basic/glyph-util.c
8d419f
index 8810738fc3..4583b7412c 100644
8d419f
--- a/src/basic/glyph-util.c
8d419f
+++ b/src/basic/glyph-util.c
8d419f
@@ -39,6 +39,7 @@ const char *special_glyph(SpecialGlyph code) {
8d419f
                         [SPECIAL_GLYPH_TREE_BRANCH]             = "|-",
8d419f
                         [SPECIAL_GLYPH_TREE_RIGHT]              = "`-",
8d419f
                         [SPECIAL_GLYPH_TREE_SPACE]              = "  ",
8d419f
+                        [SPECIAL_GLYPH_TREE_TOP]                = ",-",
8d419f
                         [SPECIAL_GLYPH_TRIANGULAR_BULLET]       = ">",
8d419f
                         [SPECIAL_GLYPH_BLACK_CIRCLE]            = "*",
8d419f
                         [SPECIAL_GLYPH_WHITE_CIRCLE]            = "*",
8d419f
@@ -51,7 +52,9 @@ const char *special_glyph(SpecialGlyph code) {
8d419f
                         [SPECIAL_GLYPH_LIGHT_SHADE]             = "-",
8d419f
                         [SPECIAL_GLYPH_DARK_SHADE]              = "X",
8d419f
                         [SPECIAL_GLYPH_SIGMA]                   = "S",
8d419f
-                        [SPECIAL_GLYPH_ARROW]                   = "->",
8d419f
+                        [SPECIAL_GLYPH_ARROW_RIGHT]             = "->",
8d419f
+                        [SPECIAL_GLYPH_ARROW_UP]                = "^",
8d419f
+                        [SPECIAL_GLYPH_ARROW_DOWN]              = "v",
8d419f
                         [SPECIAL_GLYPH_ELLIPSIS]                = "...",
8d419f
                         [SPECIAL_GLYPH_EXTERNAL_LINK]           = "[LNK]",
8d419f
                         [SPECIAL_GLYPH_ECSTATIC_SMILEY]         = ":-]",
8d419f
@@ -75,6 +78,7 @@ const char *special_glyph(SpecialGlyph code) {
8d419f
                         [SPECIAL_GLYPH_TREE_BRANCH]             = "\342\224\234\342\224\200", /* ├─ */
8d419f
                         [SPECIAL_GLYPH_TREE_RIGHT]              = "\342\224\224\342\224\200", /* └─ */
8d419f
                         [SPECIAL_GLYPH_TREE_SPACE]              = "  ",                       /*    */
8d419f
+                        [SPECIAL_GLYPH_TREE_TOP]                = "\u250C\342\224\200",       /* ┌─ */
8d419f
 
8d419f
                         /* Single glyphs in both cases */
8d419f
                         [SPECIAL_GLYPH_TRIANGULAR_BULLET]       = "\342\200\243",             /* ‣ */
8d419f
@@ -89,9 +93,11 @@ const char *special_glyph(SpecialGlyph code) {
8d419f
                         [SPECIAL_GLYPH_LIGHT_SHADE]             = "\342\226\221",             /* ░ */
8d419f
                         [SPECIAL_GLYPH_DARK_SHADE]              = "\342\226\223",             /* ▒ */
8d419f
                         [SPECIAL_GLYPH_SIGMA]                   = "\316\243",                 /* Σ */
8d419f
+                        [SPECIAL_GLYPH_ARROW_UP]                = "\u2191",                   /* ↑ (actually called: UPWARDS ARROW) */
8d419f
+                        [SPECIAL_GLYPH_ARROW_DOWN]              = "\u2193",                   /* ↓ (actually called: DOWNWARDS ARROW) */
8d419f
 
8d419f
                         /* Single glyph in Unicode, two in ASCII */
8d419f
-                        [SPECIAL_GLYPH_ARROW]                   = "\342\206\222",             /* → (actually called: RIGHTWARDS ARROW) */
8d419f
+                        [SPECIAL_GLYPH_ARROW_RIGHT]             = "\342\206\222",             /* → (actually called: RIGHTWARDS ARROW) */
8d419f
 
8d419f
                         /* Single glyph in Unicode, three in ASCII */
8d419f
                         [SPECIAL_GLYPH_ELLIPSIS]                = "\342\200\246",             /* … (actually called: HORIZONTAL ELLIPSIS) */
8d419f
diff --git a/src/basic/glyph-util.h b/src/basic/glyph-util.h
8d419f
index ddee210041..7e0a73842a 100644
8d419f
--- a/src/basic/glyph-util.h
8d419f
+++ b/src/basic/glyph-util.h
8d419f
@@ -11,6 +11,7 @@ typedef enum SpecialGlyph {
8d419f
         SPECIAL_GLYPH_TREE_BRANCH,
8d419f
         SPECIAL_GLYPH_TREE_RIGHT,
8d419f
         SPECIAL_GLYPH_TREE_SPACE,
8d419f
+        SPECIAL_GLYPH_TREE_TOP,
8d419f
         SPECIAL_GLYPH_TRIANGULAR_BULLET,
8d419f
         SPECIAL_GLYPH_BLACK_CIRCLE,
8d419f
         SPECIAL_GLYPH_WHITE_CIRCLE,
8d419f
@@ -20,7 +21,9 @@ typedef enum SpecialGlyph {
8d419f
         SPECIAL_GLYPH_MU,
8d419f
         SPECIAL_GLYPH_CHECK_MARK,
8d419f
         SPECIAL_GLYPH_CROSS_MARK,
8d419f
-        SPECIAL_GLYPH_ARROW,
8d419f
+        SPECIAL_GLYPH_ARROW_RIGHT,
8d419f
+        SPECIAL_GLYPH_ARROW_UP,
8d419f
+        SPECIAL_GLYPH_ARROW_DOWN,
8d419f
         SPECIAL_GLYPH_ELLIPSIS,
8d419f
         SPECIAL_GLYPH_LIGHT_SHADE,
8d419f
         SPECIAL_GLYPH_DARK_SHADE,
8d419f
diff --git a/src/delta/delta.c b/src/delta/delta.c
8d419f
index eafe1c05c4..aa5a546bce 100644
8d419f
--- a/src/delta/delta.c
8d419f
+++ b/src/delta/delta.c
8d419f
@@ -91,7 +91,7 @@ static int notify_override_masked(const char *top, const char *bottom) {
8d419f
 
8d419f
         printf("%s%s%s     %s %s %s\n",
8d419f
                ansi_highlight_red(), "[MASKED]", ansi_normal(),
8d419f
-               top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
8d419f
+               top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
8d419f
         return 1;
8d419f
 }
8d419f
 
8d419f
@@ -101,7 +101,7 @@ static int notify_override_equivalent(const char *top, const char *bottom) {
8d419f
 
8d419f
         printf("%s%s%s %s %s %s\n",
8d419f
                ansi_highlight_green(), "[EQUIVALENT]", ansi_normal(),
8d419f
-               top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
8d419f
+               top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
8d419f
         return 1;
8d419f
 }
8d419f
 
8d419f
@@ -111,7 +111,7 @@ static int notify_override_redirected(const char *top, const char *bottom) {
8d419f
 
8d419f
         printf("%s%s%s %s %s %s\n",
8d419f
                ansi_highlight(), "[REDIRECTED]", ansi_normal(),
8d419f
-               top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
8d419f
+               top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
8d419f
         return 1;
8d419f
 }
8d419f
 
8d419f
@@ -121,7 +121,7 @@ static int notify_override_overridden(const char *top, const char *bottom) {
8d419f
 
8d419f
         printf("%s%s%s %s %s %s\n",
8d419f
                ansi_highlight(), "[OVERRIDDEN]", ansi_normal(),
8d419f
-               top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
8d419f
+               top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
8d419f
         return 1;
8d419f
 }
8d419f
 
8d419f
@@ -131,7 +131,7 @@ static int notify_override_extended(const char *top, const char *bottom) {
8d419f
 
8d419f
         printf("%s%s%s   %s %s %s\n",
8d419f
                ansi_highlight(), "[EXTENDED]", ansi_normal(),
8d419f
-               top, special_glyph(SPECIAL_GLYPH_ARROW), bottom);
8d419f
+               top, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), bottom);
8d419f
         return 1;
8d419f
 }
8d419f
 
8d419f
@@ -235,7 +235,7 @@ static int enumerate_dir_d(
8d419f
                         return -ENOMEM;
8d419f
                 d = p + strlen(toppath) + 1;
8d419f
 
8d419f
-                log_debug("Adding at top: %s %s %s", d, special_glyph(SPECIAL_GLYPH_ARROW), p);
8d419f
+                log_debug("Adding at top: %s %s %s", d, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
8d419f
                 k = ordered_hashmap_put(top, d, p);
8d419f
                 if (k >= 0) {
8d419f
                         p = strdup(p);
8d419f
@@ -247,7 +247,7 @@ static int enumerate_dir_d(
8d419f
                         return k;
8d419f
                 }
8d419f
 
8d419f
-                log_debug("Adding at bottom: %s %s %s", d, special_glyph(SPECIAL_GLYPH_ARROW), p);
8d419f
+                log_debug("Adding at bottom: %s %s %s", d, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
8d419f
                 free(ordered_hashmap_remove(bottom, d));
8d419f
                 k = ordered_hashmap_put(bottom, d, p);
8d419f
                 if (k < 0) {
8d419f
@@ -271,7 +271,7 @@ static int enumerate_dir_d(
8d419f
                         return -ENOMEM;
8d419f
 
8d419f
                 log_debug("Adding to drops: %s %s %s %s %s",
8d419f
-                          unit, special_glyph(SPECIAL_GLYPH_ARROW), basename(p), special_glyph(SPECIAL_GLYPH_ARROW), p);
8d419f
+                          unit, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), basename(p), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
8d419f
                 k = ordered_hashmap_put(h, basename(p), p);
8d419f
                 if (k < 0) {
8d419f
                         free(p);
8d419f
@@ -347,7 +347,7 @@ static int enumerate_dir(
8d419f
                 if (!p)
8d419f
                         return -ENOMEM;
8d419f
 
8d419f
-                log_debug("Adding at top: %s %s %s", basename(p), special_glyph(SPECIAL_GLYPH_ARROW), p);
8d419f
+                log_debug("Adding at top: %s %s %s", basename(p), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
8d419f
                 r = ordered_hashmap_put(top, basename(p), p);
8d419f
                 if (r >= 0) {
8d419f
                         p = strdup(p);
8d419f
@@ -356,7 +356,7 @@ static int enumerate_dir(
8d419f
                 } else if (r != -EEXIST)
8d419f
                         return r;
8d419f
 
8d419f
-                log_debug("Adding at bottom: %s %s %s", basename(p), special_glyph(SPECIAL_GLYPH_ARROW), p);
8d419f
+                log_debug("Adding at bottom: %s %s %s", basename(p), special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), p);
8d419f
                 free(ordered_hashmap_remove(bottom, basename(p)));
8d419f
                 r = ordered_hashmap_put(bottom, basename(p), p);
8d419f
                 if (r < 0)
8d419f
diff --git a/src/partition/repart.c b/src/partition/repart.c
8d419f
index 67e379be55..9f95713130 100644
8d419f
--- a/src/partition/repart.c
8d419f
+++ b/src/partition/repart.c
8d419f
@@ -1968,9 +1968,9 @@ static int format_size_change(uint64_t from, uint64_t to, char **ret) {
8d419f
                 if (from == to || to == UINT64_MAX)
8d419f
                         t = strdup(FORMAT_BYTES(from));
8d419f
                 else
8d419f
-                        t = strjoin(FORMAT_BYTES(from), " ", special_glyph(SPECIAL_GLYPH_ARROW), " ", FORMAT_BYTES(to));
8d419f
+                        t = strjoin(FORMAT_BYTES(from), " ", special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), " ", FORMAT_BYTES(to));
8d419f
         } else if (to != UINT64_MAX)
8d419f
-                t = strjoin(special_glyph(SPECIAL_GLYPH_ARROW), " ", FORMAT_BYTES(to));
8d419f
+                t = strjoin(special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), " ", FORMAT_BYTES(to));
8d419f
         else {
8d419f
                 *ret = NULL;
8d419f
                 return 0;
8d419f
diff --git a/src/portable/portable.c b/src/portable/portable.c
8d419f
index 4c75dc0e0c..c1e253061f 100644
8d419f
--- a/src/portable/portable.c
8d419f
+++ b/src/portable/portable.c
8d419f
@@ -1011,14 +1011,14 @@ static int install_profile_dropin(
8d419f
 
8d419f
                 r = copy_file_atomic(from, dropin, 0644, 0, 0, COPY_REFLINK);
8d419f
                 if (r < 0)
8d419f
-                        return log_debug_errno(r, "Failed to copy %s %s %s: %m", from, special_glyph(SPECIAL_GLYPH_ARROW), dropin);
8d419f
+                        return log_debug_errno(r, "Failed to copy %s %s %s: %m", from, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), dropin);
8d419f
 
8d419f
                 (void) portable_changes_add(changes, n_changes, PORTABLE_COPY, dropin, from);
8d419f
 
8d419f
         } else {
8d419f
 
8d419f
                 if (symlink(from, dropin) < 0)
8d419f
-                        return log_debug_errno(errno, "Failed to link %s %s %s: %m", from, special_glyph(SPECIAL_GLYPH_ARROW), dropin);
8d419f
+                        return log_debug_errno(errno, "Failed to link %s %s %s: %m", from, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), dropin);
8d419f
 
8d419f
                 (void) portable_changes_add(changes, n_changes, PORTABLE_SYMLINK, dropin, from);
8d419f
         }
8d419f
@@ -1188,7 +1188,7 @@ static int install_image_symlink(
8d419f
         (void) mkdir_parents(sl, 0755);
8d419f
 
8d419f
         if (symlink(image_path, sl) < 0)
8d419f
-                return log_debug_errno(errno, "Failed to link %s %s %s: %m", image_path, special_glyph(SPECIAL_GLYPH_ARROW), sl);
8d419f
+                return log_debug_errno(errno, "Failed to link %s %s %s: %m", image_path, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), sl);
8d419f
 
8d419f
         (void) portable_changes_add(changes, n_changes, PORTABLE_SYMLINK, sl, image_path);
8d419f
         return 0;
8d419f
diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c
8d419f
index f4c57e14ae..585568acc1 100644
8d419f
--- a/src/portable/portablectl.c
8d419f
+++ b/src/portable/portablectl.c
8d419f
@@ -433,12 +433,12 @@ static int print_changes(sd_bus_message *m) {
8d419f
                         break;
8d419f
 
8d419f
                 if (streq(type, "symlink"))
8d419f
-                        log_info("Created symlink %s %s %s.", path, special_glyph(SPECIAL_GLYPH_ARROW), source);
8d419f
+                        log_info("Created symlink %s %s %s.", path, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), source);
8d419f
                 else if (streq(type, "copy")) {
8d419f
                         if (isempty(source))
8d419f
                                 log_info("Copied %s.", path);
8d419f
                         else
8d419f
-                                log_info("Copied %s %s %s.", source, special_glyph(SPECIAL_GLYPH_ARROW), path);
8d419f
+                                log_info("Copied %s %s %s.", source, special_glyph(SPECIAL_GLYPH_ARROW_RIGHT), path);
8d419f
                 } else if (streq(type, "unlink"))
8d419f
                         log_info("Removed %s.", path);
8d419f
                 else if (streq(type, "write"))
8d419f
diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c
8d419f
index 48dd4d8001..f18420c1b6 100644
8d419f
--- a/src/shared/cgroup-show.c
8d419f
+++ b/src/shared/cgroup-show.c
8d419f
@@ -228,7 +228,7 @@ static int show_cgroup_name(
8d419f
                         printf("%s%s%s %s%s%s: %s\n",
8d419f
                                prefix,
8d419f
                                glyph == SPECIAL_GLYPH_TREE_BRANCH ? special_glyph(SPECIAL_GLYPH_TREE_VERTICAL) : "  ",
8d419f
-                               special_glyph(SPECIAL_GLYPH_ARROW),
8d419f
+                               special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
8d419f
                                ansi_blue(), x, ansi_normal(),
8d419f
                                y);
8d419f
                 }
8d419f
diff --git a/src/shared/install.c b/src/shared/install.c
8d419f
index eb5c3d5f91..4c7d0d6cad 100644
8d419f
--- a/src/shared/install.c
8d419f
+++ b/src/shared/install.c
8d419f
@@ -335,7 +335,7 @@ void unit_file_dump_changes(int r, const char *verb, const UnitFileChange *chang
8d419f
                         if (!quiet)
8d419f
                                 log_info("Created symlink %s %s %s.",
8d419f
                                          changes[i].path,
8d419f
-                                         special_glyph(SPECIAL_GLYPH_ARROW),
8d419f
+                                         special_glyph(SPECIAL_GLYPH_ARROW_RIGHT),
8d419f
                                          changes[i].source);
8d419f
                         break;
8d419f
                 case UNIT_FILE_UNLINK:
8d419f
diff --git a/src/test/test-locale-util.c b/src/test/test-locale-util.c
8d419f
index 3243e3c567..6ec3f7f00b 100644
8d419f
--- a/src/test/test-locale-util.c
8d419f
+++ b/src/test/test-locale-util.c
8d419f
@@ -91,13 +91,16 @@ TEST(dump_special_glyphs) {
8d419f
         dump_glyph(SPECIAL_GLYPH_TREE_BRANCH);
8d419f
         dump_glyph(SPECIAL_GLYPH_TREE_RIGHT);
8d419f
         dump_glyph(SPECIAL_GLYPH_TREE_SPACE);
8d419f
+        dump_glyph(SPECIAL_GLYPH_TREE_TOP);
8d419f
         dump_glyph(SPECIAL_GLYPH_TRIANGULAR_BULLET);
8d419f
         dump_glyph(SPECIAL_GLYPH_BLACK_CIRCLE);
8d419f
         dump_glyph(SPECIAL_GLYPH_WHITE_CIRCLE);
8d419f
         dump_glyph(SPECIAL_GLYPH_MULTIPLICATION_SIGN);
8d419f
         dump_glyph(SPECIAL_GLYPH_CIRCLE_ARROW);
8d419f
         dump_glyph(SPECIAL_GLYPH_BULLET);
8d419f
-        dump_glyph(SPECIAL_GLYPH_ARROW);
8d419f
+        dump_glyph(SPECIAL_GLYPH_ARROW_RIGHT);
8d419f
+        dump_glyph(SPECIAL_GLYPH_ARROW_UP);
8d419f
+        dump_glyph(SPECIAL_GLYPH_ARROW_DOWN);
8d419f
         dump_glyph(SPECIAL_GLYPH_ELLIPSIS);
8d419f
         dump_glyph(SPECIAL_GLYPH_MU);
8d419f
         dump_glyph(SPECIAL_GLYPH_CHECK_MARK);