Blame SOURCES/fontconfig-locale.patch

66498b
From 923b5be626a6e03fbaeee0b5cd6d0246c2f8f36f Mon Sep 17 00:00:00 2001
66498b
From: Akira TAGOH <akira@tagoh.org>
66498b
Date: Wed, 14 Mar 2018 12:35:05 +0900
66498b
Subject: [PATCH 1/5] Do not override locale if already set by app
66498b
66498b
https://bugs.freedesktop.org/show_bug.cgi?id=105492
66498b
---
66498b
 src/fccfg.c | 7 ++++++-
66498b
 1 file changed, 6 insertions(+), 1 deletion(-)
66498b
66498b
diff --git a/src/fccfg.c b/src/fccfg.c
66498b
index eb0b76d..e311f17 100644
66498b
--- a/src/fccfg.c
66498b
+++ b/src/fccfg.c
66498b
@@ -45,11 +45,16 @@ retry_locale:
66498b
     is_locale_initialized = (intptr_t) fc_atomic_ptr_get (&static_is_locale_initialized);
66498b
     if (!is_locale_initialized)
66498b
     {
66498b
+	char *loc;
66498b
+
66498b
 	is_locale_initialized = FcTrue;
66498b
 	if (!fc_atomic_ptr_cmpexch (&static_is_locale_initialized, NULL,
66498b
 				    (void *)(intptr_t) is_locale_initialized))
66498b
 	    goto retry_locale;
66498b
-	setlocale (LC_ALL, "");
66498b
+
66498b
+	loc = setlocale (LC_ALL, NULL);
66498b
+	if (!loc || strcmp (loc, "C") == 0)
66498b
+	    setlocale (LC_ALL, "");
66498b
     }
66498b
 retry_config:
66498b
     config = fc_atomic_ptr_get (&_fcConfig);
66498b
-- 
66498b
2.14.3
66498b
66498b
From 98eaef69af1350e459bf9c175476d3b772968874 Mon Sep 17 00:00:00 2001
66498b
From: Akira TAGOH <akira@tagoh.org>
66498b
Date: Thu, 15 Mar 2018 12:17:52 +0900
66498b
Subject: [PATCH 4/5] Leave the locale setting to applications
66498b
66498b
https://bugs.freedesktop.org/show_bug.cgi?id=105492
66498b
---
66498b
 fc-conflist/fc-conflist.c |  2 ++
66498b
 src/fccfg.c               | 22 ++--------------------
66498b
 2 files changed, 4 insertions(+), 20 deletions(-)
66498b
66498b
diff --git a/fc-conflist/fc-conflist.c b/fc-conflist/fc-conflist.c
66498b
index d02273b..5c40a0f 100644
66498b
--- a/fc-conflist/fc-conflist.c
66498b
+++ b/fc-conflist/fc-conflist.c
66498b
@@ -38,6 +38,7 @@
66498b
 #include <unistd.h>
66498b
 #include <stdlib.h>
66498b
 #include <string.h>
66498b
+#include <locale.h>
66498b
 
66498b
 #ifdef ENABLE_NLS
66498b
 #include <libintl.h>
66498b
@@ -102,6 +103,7 @@ main (int argc, char **argv)
66498b
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
66498b
     int		c;
66498b
 
66498b
+    setlocale (LC_ALL, "");
66498b
 #if HAVE_GETOPT_LONG
66498b
     while ((c = getopt_long (argc, argv, "Vh", longopts, NULL)) != -1)
66498b
 #else
66498b
diff --git a/src/fccfg.c b/src/fccfg.c
66498b
index e311f17..e35c451 100644
66498b
--- a/src/fccfg.c
66498b
+++ b/src/fccfg.c
66498b
@@ -26,7 +26,6 @@
66498b
 
66498b
 #include "fcint.h"
66498b
 #include <dirent.h>
66498b
-#include <locale.h>
66498b
 #include <sys/types.h>
66498b
 
66498b
 #if defined (_WIN32) && !defined (R_OK)
66498b
@@ -39,24 +38,7 @@ static FcConfig *
66498b
 FcConfigEnsure (void)
66498b
 {
66498b
     FcConfig	*config;
66498b
-    FcBool	is_locale_initialized;
66498b
-    static void *static_is_locale_initialized;
66498b
-retry_locale:
66498b
-    is_locale_initialized = (intptr_t) fc_atomic_ptr_get (&static_is_locale_initialized);
66498b
-    if (!is_locale_initialized)
66498b
-    {
66498b
-	char *loc;
66498b
-
66498b
-	is_locale_initialized = FcTrue;
66498b
-	if (!fc_atomic_ptr_cmpexch (&static_is_locale_initialized, NULL,
66498b
-				    (void *)(intptr_t) is_locale_initialized))
66498b
-	    goto retry_locale;
66498b
-
66498b
-	loc = setlocale (LC_ALL, NULL);
66498b
-	if (!loc || strcmp (loc, "C") == 0)
66498b
-	    setlocale (LC_ALL, "");
66498b
-    }
66498b
-retry_config:
66498b
+retry:
66498b
     config = fc_atomic_ptr_get (&_fcConfig);
66498b
     if (!config)
66498b
     {
66498b
@@ -64,7 +46,7 @@ retry_config:
66498b
 
66498b
 	if (!fc_atomic_ptr_cmpexch (&_fcConfig, NULL, config)) {
66498b
 	    FcConfigDestroy (config);
66498b
-	    goto retry_config;
66498b
+	    goto retry;
66498b
 	}
66498b
     }
66498b
     return config;
66498b
-- 
66498b
2.14.3
66498b
66498b
From 2938e4d72da40f6bb0d22086c519a9852a820f40 Mon Sep 17 00:00:00 2001
66498b
From: Akira TAGOH <akira@tagoh.org>
66498b
Date: Thu, 15 Mar 2018 12:54:02 +0900
66498b
Subject: [PATCH 5/5] call setlocale
66498b
66498b
---
66498b
 fc-cache/fc-cache.c     | 2 ++
66498b
 fc-cat/fc-cat.c         | 2 ++
66498b
 fc-list/fc-list.c       | 2 ++
66498b
 fc-match/fc-match.c     | 2 ++
66498b
 fc-pattern/fc-pattern.c | 2 ++
66498b
 fc-query/fc-query.c     | 2 ++
66498b
 fc-scan/fc-scan.c       | 2 ++
66498b
 7 files changed, 14 insertions(+)
66498b
66498b
diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
66498b
index dc93c19..87e3020 100644
66498b
--- a/fc-cache/fc-cache.c
66498b
+++ b/fc-cache/fc-cache.c
66498b
@@ -41,6 +41,7 @@
66498b
 #include <fcntl.h>
66498b
 #include <dirent.h>
66498b
 #include <string.h>
66498b
+#include <locale.h>
66498b
 
66498b
 #if defined (_WIN32)
66498b
 #define STRICT
66498b
@@ -302,6 +303,7 @@ main (int argc, char **argv)
66498b
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
66498b
     int		c;
66498b
 
66498b
+    setlocale (LC_ALL, "");
66498b
 #if HAVE_GETOPT_LONG
66498b
     while ((c = getopt_long (argc, argv, "Efrsy:Vvh", longopts, NULL)) != -1)
66498b
 #else
66498b
diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c
66498b
index dfe30d7..69611bc 100644
66498b
--- a/fc-cat/fc-cat.c
66498b
+++ b/fc-cat/fc-cat.c
66498b
@@ -40,6 +40,7 @@
66498b
 #include <sys/types.h>
66498b
 #include <sys/stat.h>
66498b
 #include <errno.h>
66498b
+#include <locale.h>
66498b
 
66498b
 #ifdef ENABLE_NLS
66498b
 #include <libintl.h>
66498b
@@ -271,6 +272,7 @@ main (int argc, char **argv)
66498b
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
66498b
     int		c;
66498b
 
66498b
+    setlocale (LC_ALL, "");
66498b
 #if HAVE_GETOPT_LONG
66498b
     while ((c = getopt_long (argc, argv, "Vvrh", longopts, NULL)) != -1)
66498b
 #else
66498b
diff --git a/fc-list/fc-list.c b/fc-list/fc-list.c
66498b
index 5cded50..2039acd 100644
66498b
--- a/fc-list/fc-list.c
66498b
+++ b/fc-list/fc-list.c
66498b
@@ -27,6 +27,7 @@
66498b
 #include <unistd.h>
66498b
 #include <stdlib.h>
66498b
 #include <string.h>
66498b
+#include <locale.h>
66498b
 #ifdef HAVE_CONFIG_H
66498b
 #include <config.h>
66498b
 #else
66498b
@@ -117,6 +118,7 @@ main (int argc, char **argv)
66498b
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
66498b
     int			c;
66498b
 
66498b
+    setlocale (LC_ALL, "");
66498b
 #if HAVE_GETOPT_LONG
66498b
     while ((c = getopt_long (argc, argv, "vbf:qVh", longopts, NULL)) != -1)
66498b
 #else
66498b
diff --git a/fc-match/fc-match.c b/fc-match/fc-match.c
66498b
index 7902707..dee6147 100644
66498b
--- a/fc-match/fc-match.c
66498b
+++ b/fc-match/fc-match.c
66498b
@@ -36,6 +36,7 @@
66498b
 #include <unistd.h>
66498b
 #include <stdlib.h>
66498b
 #include <string.h>
66498b
+#include <locale.h>
66498b
 
66498b
 #ifdef ENABLE_NLS
66498b
 #include <libintl.h>
66498b
@@ -121,6 +122,7 @@ main (int argc, char **argv)
66498b
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
66498b
     int			c;
66498b
 
66498b
+    setlocale (LC_ALL, "");
66498b
 #if HAVE_GETOPT_LONG
66498b
     while ((c = getopt_long (argc, argv, "asvbf:Vh", longopts, NULL)) != -1)
66498b
 #else
66498b
diff --git a/fc-pattern/fc-pattern.c b/fc-pattern/fc-pattern.c
66498b
index f63761c..7989b81 100644
66498b
--- a/fc-pattern/fc-pattern.c
66498b
+++ b/fc-pattern/fc-pattern.c
66498b
@@ -36,6 +36,7 @@
66498b
 #include <unistd.h>
66498b
 #include <stdlib.h>
66498b
 #include <string.h>
66498b
+#include <locale.h>
66498b
 
66498b
 #ifdef ENABLE_NLS
66498b
 #include <libintl.h>
66498b
@@ -111,6 +112,7 @@ main (int argc, char **argv)
66498b
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
66498b
     int		c;
66498b
 
66498b
+    setlocale (LC_ALL, "");
66498b
 #if HAVE_GETOPT_LONG
66498b
     while ((c = getopt_long (argc, argv, "cdf:Vh", longopts, NULL)) != -1)
66498b
 #else
66498b
diff --git a/fc-query/fc-query.c b/fc-query/fc-query.c
66498b
index 9da090d..fbffb84 100644
66498b
--- a/fc-query/fc-query.c
66498b
+++ b/fc-query/fc-query.c
66498b
@@ -39,6 +39,7 @@
66498b
 #include <unistd.h>
66498b
 #include <stdlib.h>
66498b
 #include <string.h>
66498b
+#include <locale.h>
66498b
 
66498b
 #ifdef ENABLE_NLS
66498b
 #include <libintl.h>
66498b
@@ -115,6 +116,7 @@ main (int argc, char **argv)
66498b
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
66498b
     int		c;
66498b
 
66498b
+    setlocale (LC_ALL, "");
66498b
 #if HAVE_GETOPT_LONG
66498b
     while ((c = getopt_long (argc, argv, "i:bf:Vh", longopts, NULL)) != -1)
66498b
 #else
66498b
diff --git a/fc-scan/fc-scan.c b/fc-scan/fc-scan.c
66498b
index edb967c..9302ac5 100644
66498b
--- a/fc-scan/fc-scan.c
66498b
+++ b/fc-scan/fc-scan.c
66498b
@@ -39,6 +39,7 @@
66498b
 #include <unistd.h>
66498b
 #include <stdlib.h>
66498b
 #include <string.h>
66498b
+#include <locale.h>
66498b
 
66498b
 #ifdef ENABLE_NLS
66498b
 #include <libintl.h>
66498b
@@ -110,6 +111,7 @@ main (int argc, char **argv)
66498b
 #if HAVE_GETOPT_LONG || HAVE_GETOPT
66498b
     int		c;
66498b
 
66498b
+    setlocale (LC_ALL, "");
66498b
 #if HAVE_GETOPT_LONG
66498b
     while ((c = getopt_long (argc, argv, "bf:Vh", longopts, NULL)) != -1)
66498b
 #else
66498b
-- 
66498b
2.14.3
66498b