summaryrefslogtreecommitdiff
path: root/locale
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-03-21 07:58:50 +0000
committerRoland McGrath <roland@gnu.org>1995-03-21 07:58:50 +0000
commit49e522bfb8642bb31afc2a119b2538a6a6465996 (patch)
tree4301902f9aa76f21271ab04697fcc107c58f2a43 /locale
parent6bf028786c61b3b1e98d34557c5c442c2f954526 (diff)
downloadglibc-49e522bfb8642bb31afc2a119b2538a6a6465996.tar.gz
Tue Mar 21 00:14:27 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* locale/loadlocale.c (_nl_load_locale): If LOCALE/LC_* is a directory, open LOCALE/LC_*/SYS_LC_* instead. * stdio/fpioconst.c, stdio/fpioconst.h, stdio/gmp-impl.h, stdio/gmp.h, stdio/longlong.h, stdio/mp_clz_tab.c, stdio/gen-mpn-copy: Files moved to stdlib. * stdio/Makefile: All mpn stuff moved to stdlib/Makefile. * stdio/printf_fp.c: Use ../stdlib to find fpioconst.h and gmp headers. * stdlib/strtod.c: Don't use ../stdio to find fpioconst.h and gmp headers.
Diffstat (limited to 'locale')
-rw-r--r--locale/loadlocale.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index 7ad7a21b53..a8cf7d5448 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -38,7 +38,6 @@ const size_t _nl_category_num_items[] =
struct locale_data *
_nl_load_locale (int category, char **name)
{
- char *file;
int fd;
struct
{
@@ -69,18 +68,31 @@ _nl_load_locale (int category, char **name)
*name = (char *) "local";
}
-/* XXX can't use asprintf here */
- if (asprintf (&file, "%s%s/%s",
- strchr (*name, '/') != NULL ? "" : "/share/locale/", /* XXX */
- *name, _nl_category_names[category]) == -1)
- return NULL;
-
- fd = __open (file, O_RDONLY);
- free (file);
- if (fd < 0)
- return NULL;
- if (__fstat (fd, &st) < 0)
- goto puntfd;
+ {
+ const char localedir[] = "/share/locale/"; /* XXX */
+ const char *catname = _nl_category_names[category];
+ size_t namelen = strlen (*name);
+ size_t catlen = strlen (catname);
+ char file[sizeof localedir + namelen + catlen * 2 + 4];
+ sprintf (file, "%s%s/%s",
+ strchr (*name, '/') != NULL ? "" : localedir, *name, catname);
+ fd = __open (file, O_RDONLY);
+ if (fd < 0)
+ return NULL;
+ if (__fstat (fd, &st) < 0)
+ goto puntfd;
+ if (S_ISDIR (st.st_mode))
+ {
+ /* LOCALE/LC_* is a directory; open LOCALE/LC_*/SYS_LC_* instead. */
+ __close (fd);
+ memcpy (stpcpy (strchr (file, '\0'), "SYS_"), catname, catlen);
+ fd = __open (file, O_RDONLY);
+ if (fd < 0)
+ return NULL;
+ if (__fstat (fd, &st) < 0)
+ goto puntfd;
+ }
+ }
{
/* Map in the file's data. */