blob: 50c2e1473573b3ef7136f1a077e6d1efd69d8ef0 [file] [log] [blame]
Patrick Williams0ca19cc2021-08-16 14:03:13 -05001From 13bc0e53cc91e102472d532f28b3d44c30d291fc Mon Sep 17 00:00:00 2001
Andrew Geissler82c905d2020-04-13 13:39:40 -05002From: Khem Raj <raj.khem@gmail.com>
3Date: Fri, 3 Aug 2018 09:42:06 -0700
Andrew Geisslerd1e89492021-02-12 15:35:20 -06004Subject: [PATCH] localedef --add-to-archive uses a hard-coded locale path
Andrew Geissler82c905d2020-04-13 13:39:40 -05005
6it doesn't exist in normal use, and there's no way to pass an
7alternative filename.
8
9Add a fallback of $LOCALEARCHIVE from the environment, and allow
10creation of new locale archives that are not the system archive.
11
12Upstream-Status: Inappropriate (OE-specific)
13
14Signed-off-by: Ross Burton <ross.burton@intel.com>
15Signed-off-by: Khem Raj <raj.khem@gmail.com>
16---
17 locale/programs/locarchive.c | 35 +++++++++++++++++++++++++----------
18 1 file changed, 25 insertions(+), 10 deletions(-)
19
20diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c
Patrick Williams0ca19cc2021-08-16 14:03:13 -050021index f38e835c52..8d8f8699b2 100644
Andrew Geissler82c905d2020-04-13 13:39:40 -050022--- a/locale/programs/locarchive.c
23+++ b/locale/programs/locarchive.c
24@@ -340,12 +340,24 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head)
25 struct namehashent *oldnamehashtab;
26 struct locarhandle new_ah;
27 size_t prefix_len = output_prefix ? strlen (output_prefix) : 0;
28- char archivefname[prefix_len + sizeof (ARCHIVE_NAME)];
29- char fname[prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1];
30+ char *archivefname;
31+ char *fname;
32+ char *envarchive = getenv("LOCALEARCHIVE");
33
34- if (output_prefix)
35- memcpy (archivefname, output_prefix, prefix_len);
36- strcpy (archivefname + prefix_len, ARCHIVE_NAME);
37+ if (envarchive != NULL)
38+ {
39+ archivefname = xmalloc(strlen(envarchive) + 1);
40+ fname = xmalloc(strlen(envarchive) + sizeof (".XXXXXX"));
41+ strcpy (archivefname, envarchive);
42+ }
43+ else
44+ {
45+ archivefname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME));
46+ fname = xmalloc(prefix_len + sizeof (ARCHIVE_NAME) + sizeof (".XXXXXX") - 1);
47+ if (output_prefix)
48+ memcpy (archivefname, output_prefix, prefix_len);
49+ strcpy (archivefname + prefix_len, ARCHIVE_NAME);
50+ }
51 strcpy (stpcpy (fname, archivefname), ".XXXXXX");
52
53 /* Not all of the old file has to be mapped. Change this now this
54@@ -569,10 +581,13 @@ open_archive (struct locarhandle *ah, bool readonly)
55 /* If ah has a non-NULL fname open that otherwise open the default. */
56 if (archivefname == NULL)
57 {
58- archivefname = default_fname;
59- if (output_prefix)
60- memcpy (default_fname, output_prefix, prefix_len);
61- strcpy (default_fname + prefix_len, ARCHIVE_NAME);
62+ archivefname = getenv("LOCALEARCHIVE");
63+ if (archivefname == NULL) {
64+ archivefname = default_fname;
65+ if (output_prefix)
66+ memcpy (default_fname, output_prefix, prefix_len);
67+ strcpy (default_fname + prefix_len, ARCHIVE_NAME);
68+ }
69 }
70
71 while (1)
72@@ -585,7 +600,7 @@ open_archive (struct locarhandle *ah, bool readonly)
73 the default locale archive we ignore the failure and
74 list an empty archive, otherwise we print an error
75 and exit. */
76- if (errno == ENOENT && archivefname == default_fname)
77+ if (errno == ENOENT)
78 {
79 if (readonly)
80 {