teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0239-delta-do-not-use-unicode-chars-in-C-locale.patch

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