mirror of
https://sourceware.org/git/glibc.git
synced 2025-01-18 06:30:05 +00:00
Update.
2001-02-06 Ulrich Drepper <drepper@redhat.com> * locale/programs/locale.c (write_locales): Use scandir to read directory so that the entries are sorted.
This commit is contained in:
parent
75387c9a18
commit
fdc6c28a80
@ -1,3 +1,8 @@
|
||||
2001-02-06 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* locale/programs/locale.c (write_locales): Use scandir to read
|
||||
directory so that the entries are sorted.
|
||||
|
||||
2001-02-06 Andreas Jaeger <aj@suse.de>
|
||||
|
||||
* include/pthread.h: New file.
|
||||
|
@ -295,6 +295,37 @@ print_names (const void *nodep, VISIT value, int level)
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
select_dirs (const struct dirent *dirent)
|
||||
{
|
||||
int result = 0;
|
||||
|
||||
if (strcmp (dirent->d_name, ".") != 0 && strcmp (dirent->d_name, "..") != 0)
|
||||
{
|
||||
mode_t mode = 0;
|
||||
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
if (dirent->d_type != DT_UNKNOWN && dirent->d_type != DT_LNK)
|
||||
mode = DTTOIF (dirent->d_type);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
struct stat64 st;
|
||||
char buf[sizeof (LOCALEDIR) + strlen (dirent->d_name) + 1];
|
||||
|
||||
stpcpy (stpcpy (stpcpy (buf, LOCALEDIR), "/"), dirent->d_name);
|
||||
|
||||
if (stat64 (buf, &st) == 0)
|
||||
mode = st.st_mode;
|
||||
}
|
||||
|
||||
result = S_ISDIR (mode);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/* Write the names of all available locales to stdout. We have some
|
||||
sources of the information: the contents of the locale directory
|
||||
and the locale.alias file. To avoid duplicates and print the
|
||||
@ -305,8 +336,9 @@ write_locales (void)
|
||||
{
|
||||
char linebuf[80];
|
||||
void *all_data = NULL;
|
||||
DIR *dir;
|
||||
struct dirent *dirent;
|
||||
struct dirent **dirents;
|
||||
int ndirents;
|
||||
int cnt;
|
||||
char *alias_path;
|
||||
size_t alias_path_len;
|
||||
char *entry;
|
||||
@ -406,51 +438,22 @@ write_locales (void)
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
/* This is the directory with the locale files. */
|
||||
dir = opendir (LOCALEDIR);
|
||||
if (dir == NULL)
|
||||
{
|
||||
error (1, errno, gettext ("cannot read locale directory `%s'"),
|
||||
LOCALEDIR);
|
||||
return;
|
||||
}
|
||||
|
||||
memset (linebuf, '-', sizeof (linebuf) - 1);
|
||||
linebuf[sizeof (linebuf) - 1] = '\0';
|
||||
|
||||
/* Now we can look for all files in the directory. */
|
||||
while ((dirent = readdir (dir)) != NULL)
|
||||
if (strcmp (dirent->d_name, ".") != 0
|
||||
&& strcmp (dirent->d_name, "..") != 0)
|
||||
{
|
||||
mode_t mode;
|
||||
#ifdef _DIRENT_HAVE_D_TYPE
|
||||
if (dirent->d_type != DT_UNKNOWN && dirent->d_type != DT_LNK)
|
||||
mode = DTTOIF (dirent->d_type);
|
||||
else
|
||||
#endif
|
||||
{
|
||||
struct stat64 st;
|
||||
char buf[sizeof (LOCALEDIR) + strlen (dirent->d_name) + 1];
|
||||
|
||||
stpcpy (stpcpy (stpcpy (buf, LOCALEDIR), "/"), dirent->d_name);
|
||||
|
||||
if (stat64 (buf, &st) < 0)
|
||||
continue;
|
||||
mode = st.st_mode;
|
||||
}
|
||||
|
||||
if (S_ISDIR (mode))
|
||||
ndirents = scandir (LOCALEDIR, &dirents, select_dirs, alphasort);
|
||||
for (cnt = 0; cnt < ndirents; ++cnt)
|
||||
{
|
||||
/* Test whether at least the LC_CTYPE data is there. Some
|
||||
directories only contain translations. */
|
||||
char buf[sizeof (LOCALEDIR) + strlen (dirent->d_name)
|
||||
char buf[sizeof (LOCALEDIR) + strlen (dirents[cnt]->d_name)
|
||||
+ sizeof "/LC_IDENTIFICATION"];
|
||||
char *enddir;
|
||||
struct stat64 st;
|
||||
|
||||
stpcpy (enddir = stpcpy (stpcpy (stpcpy (buf, LOCALEDIR), "/"),
|
||||
dirent->d_name),
|
||||
dirents[cnt]->d_name),
|
||||
"/LC_IDENTIFICATION");
|
||||
|
||||
if (stat64 (buf, &st) == 0 && S_ISREG (st.st_mode))
|
||||
@ -466,7 +469,7 @@ write_locales (void)
|
||||
first_locale = 0;
|
||||
|
||||
printf ("locale: %-15.15s directory: %.*s\n%s\n",
|
||||
dirent->d_name, (int) (enddir - buf), buf,
|
||||
dirents[cnt]->d_name, (int) (enddir - buf), buf,
|
||||
linebuf);
|
||||
|
||||
fd = open64 (buf, O_RDONLY);
|
||||
@ -557,12 +560,11 @@ write_locales (void)
|
||||
else
|
||||
/* If the verbose format is not selected we simply
|
||||
collect the names. */
|
||||
PUT (xstrdup (dirent->d_name));
|
||||
PUT (xstrdup (dirents[cnt]->d_name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
closedir (dir);
|
||||
if (ndirents > 0)
|
||||
free (dirents);
|
||||
|
||||
if (! verbose)
|
||||
{
|
||||
|
@ -1,3 +1,8 @@
|
||||
2001-02-06 Ulrich Drepper <drepper@redhat.com>
|
||||
|
||||
* locales/zh_TW: Extend LC_IDENTIFICATION entries a bit.
|
||||
* locales/zh_CN: Likewise.
|
||||
|
||||
2001-02-04 Bruno Haible <haible@clisp.cons.org>
|
||||
|
||||
* locales/translit_cjk_compat: Add missing characters in range
|
||||
|
Loading…
Reference in New Issue
Block a user