about summary refs log tree commit diff
path: root/src/locale/newlocale.c
Commit message (Collapse)AuthorAgeFilesLines
* make the default locale (& a variant) failure-free cases for newlocaleRich Felker2018-10-221-1/+20
| | | | | | | | | | | | | | | commit aeeac9ca5490d7d90fe061ab72da446c01ddf746 introduced fail-safe invariants that creating a locale_t object for the C locale or C.UTF-8 locale will always succeed. extend the guarantee to also cover the following: - newlocale(LC_ALL_MASK, "", 0) - newlocale(LC_ALL_MASK-LC_CTYPE_MASK, "C", 0) provided that the LANG/LC_* environment variables have not been changed by the program. these usages are idiomatic for getting the default locale, and for getting a locale that behaves as the C locale except for honoring the default locale's character encoding.
* simplify newlocale and allow failure for explicit locale namesRich Felker2018-10-221-23/+14
| | | | | | | | | | | | unify the code paths for allocated and non-allocated locale objects, always using a tmp object. this is necessary to avoid clobbering the base locale object too soon if we allow for the possibility that looking up an explicitly requested locale name may fail, and makes the code simpler and cleaner anyway. eliminate the complex and fragile logic for checking whether one of the non-allocated locale objects can be used for the result, and instead just memcmp against each of them.
* reduce spurious inclusion of libc.hRich Felker2018-09-121-1/+0
| | | | | | | | | | | | | | | | | | | | | libc.h was intended to be a header for access to global libc state and related interfaces, but ended up included all over the place because it was the way to get the weak_alias macro. most of the inclusions removed here are places where weak_alias was needed. a few were recently introduced for hidden. some go all the way back to when libc.h defined CANCELPT_BEGIN and _END, and all (wrongly implemented) cancellation points had to include it. remaining spurious users are mostly callers of the LOCK/UNLOCK macros and files that use the LFS64 macro to define the awful *64 aliases. in a few places, new inclusion of libc.h is added because several internal headers no longer implicitly include libc.h. declarations for __lockfile and __unlockfile are moved from libc.h to stdio_impl.h so that the latter does not need libc.h. putting them in libc.h made no sense at all, since the macros in stdio_impl.h are needed to use them correctly anyway.
* make static C and C.UTF-8 locales available outside of newlocaleRich Felker2015-06-061-11/+4
|
* implement fail-safe static locales for newlocaleRich Felker2015-05-271-9/+40
| | | | | | | | this frees applications which need to make temporary use of the C locale (via uselocale) from the possibility that newlocale might fail. the C.UTF-8 locale is also provided as a static locale. presently they behave the same, but this may change in the future.
* overhaul locale internals to treat categories roughly uniformlyRich Felker2015-05-271-4/+3
| | | | | | | | | | | | | | | | | | | | 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.
* add locale frameworkRich Felker2014-07-021-6/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | this commit adds non-stub implementations of setlocale, duplocale, newlocale, and uselocale, along with the data structures and minimal code needed for representing the active locale on a per-thread basis and optimizing the common case where thread-local locale settings are not in use. at this point, the data structures only contain what is necessary to represent LC_CTYPE (a single flag) and LC_MESSAGES (a name for use in finding message translation files). representation for the other categories will be added later; the expectation is that a single pointer will suffice for each. for LC_CTYPE, the strings "C" and "POSIX" are treated as special; any other string is accepted and treated as "C.UTF-8". for other categories, any string is accepted after being truncated to a maximum supported length (currently 15 bytes). for LC_MESSAGES, the name is kept regardless of whether libc itself can use such a message translation locale, since applications using catgets or gettext should be able to use message locales libc is not aware of. for other categories, names which are not successfully loaded as locales (which, at present, means all names) are treated as aliases for "C". setlocale never fails. locale settings are not yet used anywhere, so this commit should have no visible effects except for the contents of the string returned by setlocale.
* add ABI compat aliases for a number of locale_t functionsRich Felker2013-07-241-0/+3
|
* initial check-in, version 0.5.0 v0.5.0Rich Felker2011-02-121-0/+11