diff options
Diffstat (limited to 'locale')
-rw-r--r-- | locale/programs/localedef.c | 12 | ||||
-rw-r--r-- | locale/programs/locfile.c | 28 | ||||
-rw-r--r-- | locale/setlocale.c | 3 |
3 files changed, 34 insertions, 9 deletions
diff --git a/locale/programs/localedef.c b/locale/programs/localedef.c index 96ff12eaff..1830be3da4 100644 --- a/locale/programs/localedef.c +++ b/locale/programs/localedef.c @@ -240,21 +240,23 @@ main (int argc, char *argv[]) if (! avail) { - const char *locale_names[] = { "LC_COLLATE", "LC_CTYPE", - "LC_MONETARY", "LC_NUMERIC", - "LC_TIME", "LC_MESSAGES" }; + static const char *locale_names[] = + { + "LC_COLLATE", "LC_CTYPE", "LC_MONETARY", + "LC_NUMERIC", "LC_TIME", "LC_MESSAGES" + }; char *fname; int fd; struct stat st; - asprintf (&fname, LOCALE_PATH "/%s/%s", act_add_locdef->name, + asprintf (&fname, LOCALEDIR "/%s/%s", act_add_locdef->name, locale_names[cat]); fd = open (fname, O_RDONLY); if (fd == -1) { free (fname); - asprintf (&fname, LOCALE_PATH "/%s/%s/SYS_%s", + asprintf (&fname, LOCALEDIR "/%s/%s/SYS_%s", act_add_locdef->name, locale_names[cat], locale_names[cat]); diff --git a/locale/programs/locfile.c b/locale/programs/locfile.c index 4ab04253b9..aecc8913e2 100644 --- a/locale/programs/locfile.c +++ b/locale/programs/locfile.c @@ -26,6 +26,7 @@ #include <locale.h> #include <malloc.h> #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/stat.h> @@ -76,10 +77,31 @@ locfile_read (const char *filename, struct charset_t *charset) { if (filename[0] != '/') { - char path[strlen (filename) + 1 + sizeof (LOCSRCDIR)]; + char *i18npath = __secure_getenv ("I18NPATH"); + if (i18npath != NULL && *i18npath != '\0') + { + char path[strlen (filename) + 1 + strlen (i18npath) + 1]; + char *next; + i18npath = strdupa (i18npath); + + + while (ldfile == NULL + && (next = strsep (&i18npath, ":")) != NULL) + { + stpcpy (stpcpy (stpcpy (path, next), "/"), filename); + + ldfile = lr_open (path, locfile_hash); + } + } - stpcpy (stpcpy (stpcpy (path, LOCSRCDIR), "/"), filename); - ldfile = lr_open (path, locfile_hash); + /* Test in the default directory. */ + if (ldfile == NULL) + { + char path[strlen (filename) + 1 + sizeof (LOCSRCDIR)]; + + stpcpy (stpcpy (stpcpy (path, LOCSRCDIR), "/"), filename); + ldfile = lr_open (path, locfile_hash); + } } if (ldfile == NULL) diff --git a/locale/setlocale.c b/locale/setlocale.c index 12e6569384..4eceea6446 100644 --- a/locale/setlocale.c +++ b/locale/setlocale.c @@ -368,7 +368,8 @@ setlocale (int category, const char *locale) /* We must not simply free a global locale since we have no control over the usage. So we mark it as un-deletable. */ - newdata->usage_count = MAX_USAGE_COUNT; + if (newdata->usage_count != MAX_USAGE_COUNT) + newdata->usage_count = MAX_USAGE_COUNT; } /* Create new composite name. */ |