dcavalca / rpms / systemd

Forked from rpms/systemd 4 months ago
Clone
84b277
From 719f080ce2c999febe4c9289fb09e5e2e719d4d2 Mon Sep 17 00:00:00 2001
84b277
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
84b277
Date: Wed, 16 Apr 2014 23:33:41 -0400
84b277
Subject: [PATCH] delta: do not use unicode chars in C locale
84b277
84b277
https://bugzilla.redhat.com/show_bug.cgi?id=1088418
84b277
84b277
(cherry picked from commit 00a5cc3a63c125633e822f39efd9c32223169f62)
84b277
84b277
Resolves: #1088419
84b277
---
84b277
 src/delta/delta.c | 40 +++++++++++++++++++++++++---------------
84b277
 1 file changed, 25 insertions(+), 15 deletions(-)
84b277
84b277
diff --git a/src/delta/delta.c b/src/delta/delta.c
84b277
index a8dd57e..f1aea80 100644
84b277
--- a/src/delta/delta.c
84b277
+++ b/src/delta/delta.c
84b277
@@ -85,6 +85,10 @@ static void pager_open_if_enabled(void) {
84b277
         pager_open(false);
84b277
 }
84b277
 
84b277
+static inline const char* arrow(void) {
84b277
+        return is_locale_utf8() ? "→" : "->";
84b277
+}
84b277
+
84b277
 static int equivalent(const char *a, const char *b) {
84b277
         _cleanup_free_ char *x = NULL, *y = NULL;
84b277
 
84b277
@@ -103,8 +107,9 @@ static int notify_override_masked(const char *top, const char *bottom) {
84b277
         if (!(arg_flags & SHOW_MASKED))
84b277
                 return 0;
84b277
 
84b277
-        printf("%s%s%s     %s → %s\n",
84b277
-               ansi_highlight_red(), "[MASKED]", ansi_highlight_off(), top, bottom);
84b277
+        printf("%s%s%s     %s %s %s\n",
84b277
+               ansi_highlight_red(), "[MASKED]", ansi_highlight_off(),
84b277
+               top, arrow(), bottom);
84b277
         return 1;
84b277
 }
84b277
 
84b277
@@ -112,8 +117,9 @@ static int notify_override_equivalent(const char *top, const char *bottom) {
84b277
         if (!(arg_flags & SHOW_EQUIVALENT))
84b277
                 return 0;
84b277
 
84b277
-        printf("%s%s%s %s → %s\n",
84b277
-               ansi_highlight_green(), "[EQUIVALENT]", ansi_highlight_off(), top, bottom);
84b277
+        printf("%s%s%s %s %s %s\n",
84b277
+               ansi_highlight_green(), "[EQUIVALENT]", ansi_highlight_off(),
84b277
+               top, arrow(), bottom);
84b277
         return 1;
84b277
 }
84b277
 
84b277
@@ -121,8 +127,9 @@ static int notify_override_redirected(const char *top, const char *bottom) {
84b277
         if (!(arg_flags & SHOW_REDIRECTED))
84b277
                 return 0;
84b277
 
84b277
-        printf("%s%s%s   %s → %s\n",
84b277
-               ansi_highlight(), "[REDIRECTED]", ansi_highlight_off(), top, bottom);
84b277
+        printf("%s%s%s   %s %s %s\n",
84b277
+               ansi_highlight(), "[REDIRECTED]", ansi_highlight_off(),
84b277
+               top, arrow(), bottom);
84b277
         return 1;
84b277
 }
84b277
 
84b277
@@ -130,8 +137,9 @@ static int notify_override_overridden(const char *top, const char *bottom) {
84b277
         if (!(arg_flags & SHOW_OVERRIDDEN))
84b277
                 return 0;
84b277
 
84b277
-        printf("%s%s%s %s → %s\n",
84b277
-               ansi_highlight(), "[OVERRIDDEN]", ansi_highlight_off(), top, bottom);
84b277
+        printf("%s%s%s %s %s %s\n",
84b277
+               ansi_highlight(), "[OVERRIDDEN]", ansi_highlight_off(),
84b277
+               top, arrow(), bottom);
84b277
         return 1;
84b277
 }
84b277
 
84b277
@@ -139,8 +147,9 @@ static int notify_override_extended(const char *top, const char *bottom) {
84b277
         if (!(arg_flags & SHOW_EXTENDED))
84b277
                return 0;
84b277
 
84b277
-        printf("%s%s%s   %s → %s\n",
84b277
-               ansi_highlight(), "[EXTENDED]", ansi_highlight_off(), top, bottom);
84b277
+        printf("%s%s%s   %s %s %s\n",
84b277
+               ansi_highlight(), "[EXTENDED]", ansi_highlight_off(),
84b277
+               top, arrow(), bottom);
84b277
         return 1;
84b277
 }
84b277
 
84b277
@@ -241,7 +250,7 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const
84b277
                         return -ENOMEM;
84b277
                 d = p + strlen(toppath) + 1;
84b277
 
84b277
-                log_debug("Adding at top: %s → %s", d, p);
84b277
+                log_debug("Adding at top: %s %s %s", d, arrow(), p);
84b277
                 k = hashmap_put(top, d, p);
84b277
                 if (k >= 0) {
84b277
                         p = strdup(p);
84b277
@@ -253,7 +262,7 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const
84b277
                         return k;
84b277
                 }
84b277
 
84b277
-                log_debug("Adding at bottom: %s → %s", d, p);
84b277
+                log_debug("Adding at bottom: %s %s %s", d, arrow(), p);
84b277
                 free(hashmap_remove(bottom, d));
84b277
                 k = hashmap_put(bottom, d, p);
84b277
                 if (k < 0) {
84b277
@@ -276,7 +285,8 @@ static int enumerate_dir_d(Hashmap *top, Hashmap *bottom, Hashmap *drops, const
84b277
                 if (!p)
84b277
                         return -ENOMEM;
84b277
 
84b277
-                log_debug("Adding to drops: %s → %s → %s", unit, basename(p), p);
84b277
+                log_debug("Adding to drops: %s %s %s %s %s",
84b277
+                          unit, arrow(), basename(p), arrow(), p);
84b277
                 k = hashmap_put(h, basename(p), p);
84b277
                 if (k < 0) {
84b277
                         free(p);
84b277
@@ -328,7 +338,7 @@ static int enumerate_dir(Hashmap *top, Hashmap *bottom, Hashmap *drops, const ch
84b277
                 if (!p)
84b277
                         return -ENOMEM;
84b277
 
84b277
-                log_debug("Adding at top: %s → %s", basename(p), p);
84b277
+                log_debug("Adding at top: %s %s %s", basename(p), arrow(), p);
84b277
                 k = hashmap_put(top, basename(p), p);
84b277
                 if (k >= 0) {
84b277
                         p = strdup(p);
84b277
@@ -339,7 +349,7 @@ static int enumerate_dir(Hashmap *top, Hashmap *bottom, Hashmap *drops, const ch
84b277
                         return k;
84b277
                 }
84b277
 
84b277
-                log_debug("Adding at bottom: %s → %s", basename(p), p);
84b277
+                log_debug("Adding at bottom: %s %s %s", basename(p), arrow(), p);
84b277
                 free(hashmap_remove(bottom, basename(p)));
84b277
                 k = hashmap_put(bottom, basename(p), p);
84b277
                 if (k < 0) {