aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-core/swupd-server/swupd-server-3.2.5/0028-enable-locales-in-all-programs.patch
blob: 0322735db56df8840411b47566b87c585b996105 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From f74807f9aebbb7b8feb1f50107e268bd869f2691 Mon Sep 17 00:00:00 2001
From: Patrick Ohly <patrick.ohly@intel.com>
Date: Wed, 28 Sep 2016 16:55:22 +0200
Subject: [PATCH 1/3] enable locales in all programs

This is a pre-condition for using libarchive directly: libarchive
needs to know what the encoding of filenames is, and it uses the
current locale for that. Without setlocale(), the locale is "C", which
only supports ASCII filenames, leading to warnings about "Can't
encode..." from libarchive when it is forced to fall back to copying
strings verbatim when writing archives that require UTF-8 encoding.

As a side effect, error messages from libc will get translated
according to the user's environment.

Upstream-Status: Submitted [https://github.com/clearlinux/swupd-server/pull/44]

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>

---
 src/create_update.c  | 6 ++++++
 src/make_fullfiles.c | 6 ++++++
 src/make_packs.c     | 6 ++++++
 3 files changed, 18 insertions(+)

diff --git a/src/create_update.c b/src/create_update.c
index 97045e5..766609b 100644
--- a/src/create_update.c
+++ b/src/create_update.c
@@ -29,6 +29,7 @@
 #include <errno.h>
 #include <getopt.h>
 #include <glib.h>
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -240,6 +241,11 @@ int main(int argc, char **argv)
 	/* keep valgrind working well */
 	setenv("G_SLICE", "always-malloc", 0);
 
+	if (!setlocale(LC_ALL, "")) {
+		fprintf(stderr, "%s: setlocale() failed\n", argv[0]);
+		return EXIT_FAILURE;
+	}
+
 	if (!parse_options(argc, argv)) {
 		free_globals();
 		return EXIT_FAILURE;
diff --git a/src/make_fullfiles.c b/src/make_fullfiles.c
index 4ea2f01..2a1e2e9 100644
--- a/src/make_fullfiles.c
+++ b/src/make_fullfiles.c
@@ -23,6 +23,7 @@
 #define _GNU_SOURCE
 #include <assert.h>
 #include <getopt.h>
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -88,6 +89,11 @@ int main(int argc, char **argv)
 	/* keep valgrind working well */
 	setenv("G_SLICE", "always-malloc", 0);
 
+	if (!setlocale(LC_ALL, "")) {
+		fprintf(stderr, "%s: setlocale() failed\n", argv[0]);
+		return EXIT_FAILURE;
+	}
+
 	if (!parse_options(argc, argv)) {
 		free_state_globals();
 		return EXIT_FAILURE;
diff --git a/src/make_packs.c b/src/make_packs.c
index 4002cd9..8560b3f 100644
--- a/src/make_packs.c
+++ b/src/make_packs.c
@@ -27,6 +27,7 @@
 #include <getopt.h>
 #include <getopt.h>
 #include <glib.h>
+#include <locale.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -101,6 +102,11 @@ int main(int argc, char **argv)
 	int exit_status = EXIT_FAILURE;
 	char *file_path = NULL;
 
+	if (!setlocale(LC_ALL, "")) {
+		fprintf(stderr, "%s: setlocale() failed\n", argv[0]);
+		return EXIT_FAILURE;
+	}
+
 	if (!parse_options(argc, argv)) {
 		free_state_globals();
 		return EXIT_FAILURE;
-- 
2.1.4