teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

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

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