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