History log of /haiku/src/system/libroot/posix/locale/locale_t.cpp
Revision Date Author Comments
# b09c8237 30-Aug-2023 Augustin Cavalier <waddlesplash@gmail.com>

libroot/locale: Minor fixes and expose internal POSIX locale.

* We can return early from duplocale() so set the "magic" flag early.
* Initialize all fields up front.
* Add an internal method __posix_locale_t() which returns a locale_t
usable as a global C/POSIX locale type, and add the appropriate
definition to the musl internal header.


# 2705bc6b 30-Aug-2023 Augustin Cavalier <waddlesplash@gmail.com>

libroot/locale: Fix indentation of locale_t.cpp.

Also adjust some braces. No functional change intended.


# 4d8698c3 19-Apr-2023 Jessica Hamilton <jessica.l.hamilton@gmail.com>

duplocale: fix missing locale magic when creating a new locale.

Fixes #18345.

Change-Id: Ibedfa973b371b65a502dc655eae65f4ed0833144


# 7b233926 22-Aug-2022 Augustin Cavalier <waddlesplash@gmail.com>

libroot: Do not return LC_GLOBAL_LOCALE from __current_locale_t().

Not all things that accept locale_t can accept LC_GLOBAL_LOCALE,
specifically nl_langinfo_l does not (the specification indicates
that passing it is undefined behavior; indeed, no C library I glanced
at seems to support that.)

So, return a static locale_t pointing to the global values instead.

Fixes #17875 and #17876.


# a028a54e 18-Aug-2022 Augustin Cavalier <waddlesplash@gmail.com>

libroot: Replace strftime/strptime/wcsftime implementations with musl's.

Now that we have locale_t, we can use the musl versions of these functions.
This also fixes a licensing issue: the strptime implementation had an
advertising clause (although in upstream *BSD it was removed, so we
likely could have managed to remove it anyway.)


# d02c0bad 26-Jul-2022 Trung Nguyen <trungnt282910@gmail.com>

libs/posix: Fix NULL pointer in uselocale

uselocale now attempts to create a backend and a databrige.

If the attempt fails due to a missing libroot-addon-icu, uselocale
does nothing (to support applications calling uselocale during
startup to enforce the C locale).

Else, uselocale will fail with ENOMEM.

LocaleBackend::CreateBackend() has been modified to return a status_t
that indicates whether NULL is returned due to out of memory (B_NO_MEMORY)
or due to being unable to load the ICU addon (B_MISSING_LIBRARY).

Change-Id: I0f62ebde5890364c64e6694ec58d38de43ec6841
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5505
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: waddlesplash <waddlesplash@gmail.com>


# d338200e 30-May-2022 Trung Nguyen <trungnt282910@gmail.com>

libs/posix: Implemented new locale functions

Implemented the missing POSIX functions in <locale.h>:
newlocale, duplocale, uselocale, and freelocale, and also
provided missing type definitions for <locale.h>.

Implemented missing POSIX locale-based function variants.

Modified LocaleBackend so that it could support thread-local
locales.

Some glibc-like locale-related variables supporting
ctype and printf family of functions have also been updated
to reflect the thread-local variables present in the latest
glibc sources.

As there have been some modifications to global symbols
in libroot, libroot_stubs.c has been regenerated.

Bug: #17168
Change-Id: Ibf296c58c47d42d1d1dfb2ce64042442f2679431
Reviewed-on: https://review.haiku-os.org/c/haiku/+/5351
Tested-by: Commit checker robot <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>