fontconfig-locale.patch 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. From 923b5be626a6e03fbaeee0b5cd6d0246c2f8f36f Mon Sep 17 00:00:00 2001
  2. From: Akira TAGOH <akira@tagoh.org>
  3. Date: Wed, 14 Mar 2018 12:35:05 +0900
  4. Subject: [PATCH 1/5] Do not override locale if already set by app
  5. https://bugs.freedesktop.org/show_bug.cgi?id=105492
  6. ---
  7. src/fccfg.c | 7 ++++++-
  8. 1 file changed, 6 insertions(+), 1 deletion(-)
  9. diff --git a/src/fccfg.c b/src/fccfg.c
  10. index eb0b76d..e311f17 100644
  11. --- a/src/fccfg.c
  12. +++ b/src/fccfg.c
  13. @@ -45,11 +45,16 @@ retry_locale:
  14. is_locale_initialized = (intptr_t) fc_atomic_ptr_get (&static_is_locale_initialized);
  15. if (!is_locale_initialized)
  16. {
  17. + char *loc;
  18. +
  19. is_locale_initialized = FcTrue;
  20. if (!fc_atomic_ptr_cmpexch (&static_is_locale_initialized, NULL,
  21. (void *)(intptr_t) is_locale_initialized))
  22. goto retry_locale;
  23. - setlocale (LC_ALL, "");
  24. +
  25. + loc = setlocale (LC_ALL, NULL);
  26. + if (!loc || strcmp (loc, "C") == 0)
  27. + setlocale (LC_ALL, "");
  28. }
  29. retry_config:
  30. config = fc_atomic_ptr_get (&_fcConfig);
  31. --
  32. 2.14.3
  33. From 98eaef69af1350e459bf9c175476d3b772968874 Mon Sep 17 00:00:00 2001
  34. From: Akira TAGOH <akira@tagoh.org>
  35. Date: Thu, 15 Mar 2018 12:17:52 +0900
  36. Subject: [PATCH 4/5] Leave the locale setting to applications
  37. https://bugs.freedesktop.org/show_bug.cgi?id=105492
  38. ---
  39. fc-conflist/fc-conflist.c | 2 ++
  40. src/fccfg.c | 22 ++--------------------
  41. 2 files changed, 4 insertions(+), 20 deletions(-)
  42. diff --git a/fc-conflist/fc-conflist.c b/fc-conflist/fc-conflist.c
  43. index d02273b..5c40a0f 100644
  44. --- a/fc-conflist/fc-conflist.c
  45. +++ b/fc-conflist/fc-conflist.c
  46. @@ -38,6 +38,7 @@
  47. #include <unistd.h>
  48. #include <stdlib.h>
  49. #include <string.h>
  50. +#include <locale.h>
  51. #ifdef ENABLE_NLS
  52. #include <libintl.h>
  53. @@ -102,6 +103,7 @@ main (int argc, char **argv)
  54. #if HAVE_GETOPT_LONG || HAVE_GETOPT
  55. int c;
  56. + setlocale (LC_ALL, "");
  57. #if HAVE_GETOPT_LONG
  58. while ((c = getopt_long (argc, argv, "Vh", longopts, NULL)) != -1)
  59. #else
  60. diff --git a/src/fccfg.c b/src/fccfg.c
  61. index e311f17..e35c451 100644
  62. --- a/src/fccfg.c
  63. +++ b/src/fccfg.c
  64. @@ -26,7 +26,6 @@
  65. #include "fcint.h"
  66. #include <dirent.h>
  67. -#include <locale.h>
  68. #include <sys/types.h>
  69. #if defined (_WIN32) && !defined (R_OK)
  70. @@ -39,24 +38,7 @@ static FcConfig *
  71. FcConfigEnsure (void)
  72. {
  73. FcConfig *config;
  74. - FcBool is_locale_initialized;
  75. - static void *static_is_locale_initialized;
  76. -retry_locale:
  77. - is_locale_initialized = (intptr_t) fc_atomic_ptr_get (&static_is_locale_initialized);
  78. - if (!is_locale_initialized)
  79. - {
  80. - char *loc;
  81. -
  82. - is_locale_initialized = FcTrue;
  83. - if (!fc_atomic_ptr_cmpexch (&static_is_locale_initialized, NULL,
  84. - (void *)(intptr_t) is_locale_initialized))
  85. - goto retry_locale;
  86. -
  87. - loc = setlocale (LC_ALL, NULL);
  88. - if (!loc || strcmp (loc, "C") == 0)
  89. - setlocale (LC_ALL, "");
  90. - }
  91. -retry_config:
  92. +retry:
  93. config = fc_atomic_ptr_get (&_fcConfig);
  94. if (!config)
  95. {
  96. @@ -64,7 +46,7 @@ retry_config:
  97. if (!fc_atomic_ptr_cmpexch (&_fcConfig, NULL, config)) {
  98. FcConfigDestroy (config);
  99. - goto retry_config;
  100. + goto retry;
  101. }
  102. }
  103. return config;
  104. --
  105. 2.14.3
  106. From 2938e4d72da40f6bb0d22086c519a9852a820f40 Mon Sep 17 00:00:00 2001
  107. From: Akira TAGOH <akira@tagoh.org>
  108. Date: Thu, 15 Mar 2018 12:54:02 +0900
  109. Subject: [PATCH 5/5] call setlocale
  110. ---
  111. fc-cache/fc-cache.c | 2 ++
  112. fc-cat/fc-cat.c | 2 ++
  113. fc-list/fc-list.c | 2 ++
  114. fc-match/fc-match.c | 2 ++
  115. fc-pattern/fc-pattern.c | 2 ++
  116. fc-query/fc-query.c | 2 ++
  117. fc-scan/fc-scan.c | 2 ++
  118. 7 files changed, 14 insertions(+)
  119. diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c
  120. index dc93c19..87e3020 100644
  121. --- a/fc-cache/fc-cache.c
  122. +++ b/fc-cache/fc-cache.c
  123. @@ -41,6 +41,7 @@
  124. #include <fcntl.h>
  125. #include <dirent.h>
  126. #include <string.h>
  127. +#include <locale.h>
  128. #if defined (_WIN32)
  129. #define STRICT
  130. @@ -302,6 +303,7 @@ main (int argc, char **argv)
  131. #if HAVE_GETOPT_LONG || HAVE_GETOPT
  132. int c;
  133. + setlocale (LC_ALL, "");
  134. #if HAVE_GETOPT_LONG
  135. while ((c = getopt_long (argc, argv, "Efrsy:Vvh", longopts, NULL)) != -1)
  136. #else
  137. diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c
  138. index dfe30d7..69611bc 100644
  139. --- a/fc-cat/fc-cat.c
  140. +++ b/fc-cat/fc-cat.c
  141. @@ -40,6 +40,7 @@
  142. #include <sys/types.h>
  143. #include <sys/stat.h>
  144. #include <errno.h>
  145. +#include <locale.h>
  146. #ifdef ENABLE_NLS
  147. #include <libintl.h>
  148. @@ -271,6 +272,7 @@ main (int argc, char **argv)
  149. #if HAVE_GETOPT_LONG || HAVE_GETOPT
  150. int c;
  151. + setlocale (LC_ALL, "");
  152. #if HAVE_GETOPT_LONG
  153. while ((c = getopt_long (argc, argv, "Vvrh", longopts, NULL)) != -1)
  154. #else
  155. diff --git a/fc-list/fc-list.c b/fc-list/fc-list.c
  156. index 5cded50..2039acd 100644
  157. --- a/fc-list/fc-list.c
  158. +++ b/fc-list/fc-list.c
  159. @@ -27,6 +27,7 @@
  160. #include <unistd.h>
  161. #include <stdlib.h>
  162. #include <string.h>
  163. +#include <locale.h>
  164. #ifdef HAVE_CONFIG_H
  165. #include <config.h>
  166. #else
  167. @@ -117,6 +118,7 @@ main (int argc, char **argv)
  168. #if HAVE_GETOPT_LONG || HAVE_GETOPT
  169. int c;
  170. + setlocale (LC_ALL, "");
  171. #if HAVE_GETOPT_LONG
  172. while ((c = getopt_long (argc, argv, "vbf:qVh", longopts, NULL)) != -1)
  173. #else
  174. diff --git a/fc-match/fc-match.c b/fc-match/fc-match.c
  175. index 7902707..dee6147 100644
  176. --- a/fc-match/fc-match.c
  177. +++ b/fc-match/fc-match.c
  178. @@ -36,6 +36,7 @@
  179. #include <unistd.h>
  180. #include <stdlib.h>
  181. #include <string.h>
  182. +#include <locale.h>
  183. #ifdef ENABLE_NLS
  184. #include <libintl.h>
  185. @@ -121,6 +122,7 @@ main (int argc, char **argv)
  186. #if HAVE_GETOPT_LONG || HAVE_GETOPT
  187. int c;
  188. + setlocale (LC_ALL, "");
  189. #if HAVE_GETOPT_LONG
  190. while ((c = getopt_long (argc, argv, "asvbf:Vh", longopts, NULL)) != -1)
  191. #else
  192. diff --git a/fc-pattern/fc-pattern.c b/fc-pattern/fc-pattern.c
  193. index f63761c..7989b81 100644
  194. --- a/fc-pattern/fc-pattern.c
  195. +++ b/fc-pattern/fc-pattern.c
  196. @@ -36,6 +36,7 @@
  197. #include <unistd.h>
  198. #include <stdlib.h>
  199. #include <string.h>
  200. +#include <locale.h>
  201. #ifdef ENABLE_NLS
  202. #include <libintl.h>
  203. @@ -111,6 +112,7 @@ main (int argc, char **argv)
  204. #if HAVE_GETOPT_LONG || HAVE_GETOPT
  205. int c;
  206. + setlocale (LC_ALL, "");
  207. #if HAVE_GETOPT_LONG
  208. while ((c = getopt_long (argc, argv, "cdf:Vh", longopts, NULL)) != -1)
  209. #else
  210. diff --git a/fc-query/fc-query.c b/fc-query/fc-query.c
  211. index 9da090d..fbffb84 100644
  212. --- a/fc-query/fc-query.c
  213. +++ b/fc-query/fc-query.c
  214. @@ -39,6 +39,7 @@
  215. #include <unistd.h>
  216. #include <stdlib.h>
  217. #include <string.h>
  218. +#include <locale.h>
  219. #ifdef ENABLE_NLS
  220. #include <libintl.h>
  221. @@ -115,6 +116,7 @@ main (int argc, char **argv)
  222. #if HAVE_GETOPT_LONG || HAVE_GETOPT
  223. int c;
  224. + setlocale (LC_ALL, "");
  225. #if HAVE_GETOPT_LONG
  226. while ((c = getopt_long (argc, argv, "i:bf:Vh", longopts, NULL)) != -1)
  227. #else
  228. diff --git a/fc-scan/fc-scan.c b/fc-scan/fc-scan.c
  229. index edb967c..9302ac5 100644
  230. --- a/fc-scan/fc-scan.c
  231. +++ b/fc-scan/fc-scan.c
  232. @@ -39,6 +39,7 @@
  233. #include <unistd.h>
  234. #include <stdlib.h>
  235. #include <string.h>
  236. +#include <locale.h>
  237. #ifdef ENABLE_NLS
  238. #include <libintl.h>
  239. @@ -110,6 +111,7 @@ main (int argc, char **argv)
  240. #if HAVE_GETOPT_LONG || HAVE_GETOPT
  241. int c;
  242. + setlocale (LC_ALL, "");
  243. #if HAVE_GETOPT_LONG
  244. while ((c = getopt_long (argc, argv, "bf:Vh", longopts, NULL)) != -1)
  245. #else
  246. --
  247. 2.14.3