overhaul locale internals to treat categories roughly uniformly

previously, LC_MESSAGES was treated specially as the only category
which could be set to a locale name without a definition file, in
order to facilitate gettext message translations when no libc locale
was available. LC_NUMERIC was completely un-settable, and LC_CTYPE
stored a flag intended to be used for a possible future byte-based C
locale, instead of storing a __locale_map pointer like the other
categories use.

this patch changes all categories to be represented by pointers to
__locale_map structures, and allows locale names without definition
files to be treated as valid locales with trivial definition when used
in any category. outwardly visible functional changes should be minor,
limited mainly to the strings read back from setlocale and the way
gettext handles translations in categories other than LC_MESSAGES.

various internal refactoring has also been performed, and improvements
in const correctness have been made.
This commit is contained in:
Rich Felker
2015-05-27 03:22:52 -04:00
parent 63c188ec42
commit 61a3364d24
8 changed files with 114 additions and 138 deletions

View File

@ -8,9 +8,7 @@
struct __locale_map;
struct __locale_struct {
volatile int ctype_utf8;
char *messages_name;
struct __locale_map *volatile cat[4];
const struct __locale_map *volatile cat[6];
};
struct __libc {