* locale/setlocale.c: Change _nl_category_names into a string.

Add new _nl_category_name_idxs.  Change all users.
	* locale/localeinfo.h: Adjust declaration of _nl_category_names.
	Declare _nl_category_name_idxs.
	* locale/findlocale.c: Adjust for _nl_category_names change.
	* locale/loadlocale.c: Likewise.
	* locale/newlocale.c: Likewise.
	* intl/dcigettext.c: Likewise.
This commit is contained in:
Ulrich Drepper 2006-05-15 18:36:28 +00:00
parent 88dbff8cf9
commit 9446614c28
7 changed files with 62 additions and 23 deletions

View File

@ -1,5 +1,14 @@
2006-05-15 Ulrich Drepper <drepper@redhat.com> 2006-05-15 Ulrich Drepper <drepper@redhat.com>
* locale/setlocale.c: Change _nl_category_names into a string.
Add new _nl_category_name_idxs. Change all users.
* locale/localeinfo.h: Adjust declaration of _nl_category_names.
Declare _nl_category_name_idxs.
* locale/findlocale.c: Adjust for _nl_category_names change.
* locale/loadlocale.c: Likewise.
* locale/newlocale.c: Likewise.
* intl/dcigettext.c: Likewise.
* iconv/gconv_conf.c (add_alias): Move actual alias handling to... * iconv/gconv_conf.c (add_alias): Move actual alias handling to...
(add_alias2): ...here. New function. (add_alias2): ...here. New function.
(__gconv_read_conf): Simplify builtin alias handling. (__gconv_read_conf): Simplify builtin alias handling.

View File

@ -1,5 +1,5 @@
/* Implementation of the internal dcigettext function. /* Implementation of the internal dcigettext function.
Copyright (C) 1995-2002,2003,2004,2005 Free Software Foundation, Inc. Copyright (C) 1995-2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -286,7 +286,8 @@ static const char *guess_category_value PARAMS ((int category,
internal_function; internal_function;
#ifdef _LIBC #ifdef _LIBC
# include "../locale/localeinfo.h" # include "../locale/localeinfo.h"
# define category_to_name(category) _nl_category_names[category] # define category_to_name(category) \
_nl_category_names.str + _nl_category_name_idxs[category]
#else #else
static const char *category_to_name PARAMS ((int category)) internal_function; static const char *category_to_name PARAMS ((int category)) internal_function;
#endif #endif

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1996-2001, 2002, 2003 Free Software Foundation, Inc. /* Copyright (C) 1996-2001, 2002, 2003, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@ -80,7 +80,8 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
variables. */ variables. */
*name = getenv ("LC_ALL"); *name = getenv ("LC_ALL");
if (*name == NULL || (*name)[0] == '\0') if (*name == NULL || (*name)[0] == '\0')
*name = getenv (_nl_category_names[category]); *name = getenv (_nl_category_names.str
+ _nl_category_name_idxs[category]);
if (*name == NULL || (*name)[0] == '\0') if (*name == NULL || (*name)[0] == '\0')
*name = getenv ("LANG"); *name = getenv ("LANG");
} }
@ -145,7 +146,8 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
locale_path, locale_path_len, mask, locale_path, locale_path_len, mask,
language, territory, codeset, language, territory, codeset,
normalized_codeset, modifier, normalized_codeset, modifier,
_nl_category_names[category], 0); _nl_category_names.str
+ _nl_category_name_idxs[category], 0);
if (locale_file == NULL) if (locale_file == NULL)
{ {
@ -155,7 +157,8 @@ _nl_find_locale (const char *locale_path, size_t locale_path_len,
locale_path, locale_path_len, mask, locale_path, locale_path_len, mask,
language, territory, codeset, language, territory, codeset,
normalized_codeset, modifier, normalized_codeset, modifier,
_nl_category_names[category], 1); _nl_category_names.str
+ _nl_category_name_idxs[category], 1);
if (locale_file == NULL) if (locale_file == NULL)
/* This means we are out of core. */ /* This means we are out of core. */
return NULL; return NULL;

View File

@ -1,5 +1,5 @@
/* Functions to read locale data files. /* Functions to read locale data files.
Copyright (C) 1996-2004, 2005 Free Software Foundation, Inc. Copyright (C) 1996-2004, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@ -198,7 +198,7 @@ _nl_load_locale (struct loaded_l10nfile *file, int category)
+ 5 + _nl_category_name_sizes[category] + 1); + 5 + _nl_category_name_sizes[category] + 1);
__mempcpy (__mempcpy (__mempcpy (newp, file->filename, filenamelen), __mempcpy (__mempcpy (__mempcpy (newp, file->filename, filenamelen),
"/SYS_", 5), "/SYS_", 5),
_nl_category_names[category], _nl_category_names.str + _nl_category_name_idxs[category],
_nl_category_name_sizes[category] + 1); _nl_category_name_sizes[category] + 1);
fd = open_not_cancel_2 (newp, O_RDONLY); fd = open_not_cancel_2 (newp, O_RDONLY);

View File

@ -1,5 +1,5 @@
/* Declarations for internal libc locale interfaces /* Declarations for internal libc locale interfaces
Copyright (C) 1995-2001, 2002, 2003, 2005 Free Software Foundation, Inc. Copyright (C) 1995-2003, 2005, 2006 Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or The GNU C Library is free software; you can redistribute it and/or
@ -172,8 +172,22 @@ enum
#define _ISCTYPE(c, desc) \ #define _ISCTYPE(c, desc) \
(((((const uint32_t *) (desc)) - 8)[(c) >> 5] >> ((c) & 0x1f)) & 1) (((((const uint32_t *) (desc)) - 8)[(c) >> 5] >> ((c) & 0x1f)) & 1)
extern const char *const _nl_category_names[__LC_LAST] attribute_hidden; /* Category name handling variables. */
extern const size_t _nl_category_name_sizes[__LC_LAST] attribute_hidden; #define CATNAMEMF(line) CATNAMEMF1 (line)
#define CATNAMEMF1(line) str##line
extern const union catnamestr_t
{
struct
{
#define DEFINE_CATEGORY(category, category_name, items, a) \
char CATNAMEMF (__LINE__)[sizeof (category_name)];
#include "categories.def"
#undef DEFINE_CATEGORY
};
char str[0];
} _nl_category_names attribute_hidden;
const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden;
extern const uint8_t _nl_category_name_sizes[__LC_LAST] attribute_hidden;
/* Name of the standard locales. */ /* Name of the standard locales. */
extern const char _nl_C_name[] attribute_hidden; extern const char _nl_C_name[] attribute_hidden;

View File

@ -1,5 +1,5 @@
/* Return a reference to locale information record. /* Return a reference to locale information record.
Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002, 2004, 2005 Copyright (C) 1996, 1997, 1999, 2000-2002, 2004, 2005, 2006
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
@ -133,7 +133,8 @@ __newlocale (int category_mask, const char *locale, __locale_t base)
for (cnt = 0; cnt < __LC_LAST; ++cnt) for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL if (cnt != LC_ALL
&& (size_t) (cp - np) == _nl_category_name_sizes[cnt] && (size_t) (cp - np) == _nl_category_name_sizes[cnt]
&& memcmp (np, _nl_category_names[cnt], cp - np) == 0) && memcmp (np, (_nl_category_names.str
+ _nl_category_name_idxs[cnt]), cp - np) == 0)
break; break;
if (cnt == __LC_LAST) if (cnt == __LC_LAST)

View File

@ -1,4 +1,4 @@
/* Copyright (C) 1991, 1992, 1995-2000, 2002, 2003, 2004 /* Copyright (C) 1991, 1992, 1995-2000, 2002, 2003, 2004, 2006
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of the GNU C Library. This file is part of the GNU C Library.
@ -66,18 +66,27 @@ static char *const _nl_current_used[] =
#endif #endif
/* Define an array of category names (also the environment variable names), /* Define an array of category names (also the environment variable names). */
indexed by integral category. */ const union catnamestr_t _nl_category_names attribute_hidden =
const char *const _nl_category_names[] = {
{ {
#define DEFINE_CATEGORY(category, category_name, items, a) \ #define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = category_name, category_name,
#include "categories.def" #include "categories.def"
#undef DEFINE_CATEGORY #undef DEFINE_CATEGORY
[LC_ALL] = "LC_ALL" }
}; };
const uint8_t _nl_category_name_idxs[__LC_LAST] attribute_hidden =
{
#define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = offsetof (union catnamestr_t, CATNAMEMF (__LINE__)),
#include "categories.def"
#undef DEFINE_CATEGORY
};
/* An array of their lengths, for convenience. */ /* An array of their lengths, for convenience. */
const size_t _nl_category_name_sizes[] = const uint8_t _nl_category_name_sizes[] attribute_hidden =
{ {
#define DEFINE_CATEGORY(category, category_name, items, a) \ #define DEFINE_CATEGORY(category, category_name, items, a) \
[category] = sizeof (category_name) - 1, [category] = sizeof (category_name) - 1,
@ -173,7 +182,7 @@ new_composite_name (int category, const char *newnames[__LC_LAST])
const char *name = (category == LC_ALL ? newnames[i] : const char *name = (category == LC_ALL ? newnames[i] :
category == i ? newnames[0] : category == i ? newnames[0] :
_nl_global_locale.__names[i]); _nl_global_locale.__names[i]);
p = __stpcpy (p, _nl_category_names[i]); p = __stpcpy (p, _nl_category_names.str + _nl_category_name_idxs[i]);
*p++ = '='; *p++ = '=';
p = __stpcpy (p, name); p = __stpcpy (p, name);
*p++ = ';'; *p++ = ';';
@ -275,7 +284,9 @@ setlocale (int category, const char *locale)
for (cnt = 0; cnt < __LC_LAST; ++cnt) for (cnt = 0; cnt < __LC_LAST; ++cnt)
if (cnt != LC_ALL if (cnt != LC_ALL
&& (size_t) (cp - np) == _nl_category_name_sizes[cnt] && (size_t) (cp - np) == _nl_category_name_sizes[cnt]
&& memcmp (np, _nl_category_names[cnt], cp - np) == 0) && (memcmp (np, (_nl_category_names.str
+ _nl_category_name_idxs[cnt]), cp - np)
== 0))
break; break;
if (cnt == __LC_LAST) if (cnt == __LC_LAST)