1 |
From 43f76569a2418d65a9a57e2857d173e137a836da Mon Sep 17 00:00:00 2001 |
2 |
From: Colin Guthrie <colin@mageia.org> |
3 |
Date: Sun, 8 Feb 2015 12:47:12 +0000 |
4 |
Subject: [PATCH 508/509] Add path to locale search. |
5 |
|
6 |
Mageia seems to store it's locales in /usr/share/locale (and also seems |
7 |
to copy it to /etc/locale??) so add in /usr/share/locale in addition to |
8 |
/usr/lib/locale. We should investigate if we 'force' the share path and |
9 |
make steps to move it if it's a pointless deviation. |
10 |
|
11 |
We should also find out why we have /etc/locale/ directory tree populated. |
12 |
--- |
13 |
src/basic/locale-util.c | 31 +++++++++++++++++++++++++++++++ |
14 |
1 file changed, 31 insertions(+) |
15 |
|
16 |
diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c |
17 |
index 266cb2993..dfced88bc 100644 |
18 |
--- a/src/basic/locale-util.c |
19 |
+++ b/src/basic/locale-util.c |
20 |
@@ -173,6 +173,33 @@ static int add_locales_from_libdir (Set *locales) { |
21 |
return 0; |
22 |
} |
23 |
|
24 |
+static int add_locales_from_sharedir (Set *locales) { |
25 |
+ _cleanup_closedir_ DIR *dir = NULL; |
26 |
+ struct dirent *entry; |
27 |
+ int r; |
28 |
+ |
29 |
+ dir = opendir("/usr/share/locale"); |
30 |
+ if (!dir) |
31 |
+ return errno == ENOENT ? 0 : -errno; |
32 |
+ |
33 |
+ FOREACH_DIRENT(entry, dir, return -errno) { |
34 |
+ char *z; |
35 |
+ |
36 |
+ if (entry->d_type != DT_DIR) |
37 |
+ continue; |
38 |
+ |
39 |
+ z = strdup(entry->d_name); |
40 |
+ if (!z) |
41 |
+ return -ENOMEM; |
42 |
+ |
43 |
+ r = set_consume(locales, z); |
44 |
+ if (r < 0 && r != -EEXIST) |
45 |
+ return r; |
46 |
+ } |
47 |
+ |
48 |
+ return 0; |
49 |
+} |
50 |
+ |
51 |
int get_locales(char ***ret) { |
52 |
_cleanup_set_free_ Set *locales = NULL; |
53 |
_cleanup_strv_free_ char **l = NULL; |
54 |
@@ -190,6 +217,10 @@ int get_locales(char ***ret) { |
55 |
if (r < 0) |
56 |
return r; |
57 |
|
58 |
+ r = add_locales_from_sharedir(locales); |
59 |
+ if (r < 0) |
60 |
+ return r; |
61 |
+ |
62 |
l = set_get_strv(locales); |
63 |
if (!l) |
64 |
return -ENOMEM; |
65 |
-- |
66 |
2.13.5 |
67 |
|