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