aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/src
diff options
context:
space:
mode:
authormikhnenko <mikhnenko@yandex-team.com>2024-12-18 19:08:08 +0300
committermikhnenko <mikhnenko@yandex-team.com>2024-12-18 19:29:26 +0300
commit7ed76959e6c06dbc4c249ce0f3b930463a6b65db (patch)
tree0e9528cb7261812a5ae7ed177048721eaebf8ed0 /contrib/libs/cxxsupp/libcxx/src
parent4c8e7f015711b5175d63e1a87cbd40c49ce7aa70 (diff)
downloadydb-7ed76959e6c06dbc4c249ce0f3b930463a6b65db.tar.gz
libc++: Run clang-format from upstream and update to 9783f28cbb155e4a8d49c12e1c60ce14dcfaf0c7
commit_hash:ca4954fe054e5a7190ad11ab71bfc7ca0965bca2
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src')
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/any.cpp16
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/atomic.cpp216
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/barrier.cpp106
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/bind.cpp23
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/call_once.cpp88
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/charconv.cpp33
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/chrono.cpp118
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp95
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/condition_variable_destructor.cpp20
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/exception.cpp26
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/directory_entry.cpp9
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp82
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/error.h24
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/file_descriptor.h51
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_clock.cpp20
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_error.cpp12
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/int128_builtins.cpp14
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp323
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/path.cpp79
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/path_parser.h62
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h231
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h164
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/functional.cpp10
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/future.cpp319
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/hash.cpp899
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/include/apple_availability.h34
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/include/atomic_support.h156
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/include/config_elast.h18
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/include/refstring.h152
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/include/ryu/ryu.h1
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/include/sso_allocator.h81
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/ios.cpp569
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/iostream.cpp227
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/locale.cpp9819
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/memory.cpp260
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/mutex.cpp209
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/mutex_destructor.cpp20
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/new.cpp12
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/optional.cpp14
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/random.cpp181
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp35
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/regex.cpp293
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/std_stream.h570
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/string.cpp368
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp30
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp27
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp42
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp139
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_glibcxx.ipp18
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxabi.ipp15
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxrt.ipp11
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_msvc.ipp145
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp73
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp61
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp71
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp43
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_default.ipp7
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_vcruntime.ipp2
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp167
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp246
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp162
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/system_error.cpp225
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/thread.cpp222
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp30
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/valarray.cpp56
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/variant.cpp6
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/vector.cpp8
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/verbose_abort.cpp6
68 files changed, 7892 insertions, 9979 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/any.cpp b/contrib/libs/cxxsupp/libcxx/src/any.cpp
index 36f95c0ec4..b0ad695669 100644
--- a/contrib/libs/cxxsupp/libcxx/src/any.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/any.cpp
@@ -9,11 +9,8 @@
#include <any>
namespace std {
-const char* bad_any_cast::what() const noexcept {
- return "bad any cast";
-}
-}
-
+const char* bad_any_cast::what() const noexcept { return "bad any cast"; }
+} // namespace std
#include <experimental/__config>
@@ -21,14 +18,11 @@ const char* bad_any_cast::what() const noexcept {
// Even though it no longer exists in a header file
_LIBCPP_BEGIN_NAMESPACE_LFTS
-class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast
-{
+class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_ANY_CAST bad_any_cast : public bad_cast {
public:
- virtual const char* what() const noexcept;
+ virtual const char* what() const noexcept;
};
-const char* bad_any_cast::what() const noexcept {
- return "bad any cast";
-}
+const char* bad_any_cast::what() const noexcept { return "bad any cast"; }
_LIBCPP_END_NAMESPACE_LFTS
diff --git a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp
index 133774bf13..2f0389ae69 100644
--- a/contrib/libs/cxxsupp/libcxx/src/atomic.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/atomic.cpp
@@ -16,20 +16,20 @@
#ifdef __linux__
-#include <unistd.h>
-#include <linux/futex.h>
-#include <sys/syscall.h>
+# include <linux/futex.h>
+# include <sys/syscall.h>
+# include <unistd.h>
// libc++ uses SYS_futex as a universal syscall name. However, on 32 bit architectures
// with a 64 bit time_t, we need to specify SYS_futex_time64.
-#if !defined(SYS_futex) && defined(SYS_futex_time64)
-# define SYS_futex SYS_futex_time64
-#endif
+# if !defined(SYS_futex) && defined(SYS_futex_time64)
+# define SYS_futex SYS_futex_time64
+# endif
#elif defined(__FreeBSD__)
-#include <sys/types.h>
-#include <sys/umtx.h>
+# include <sys/types.h>
+# include <sys/umtx.h>
#else // <- Add other operating systems here
@@ -41,40 +41,33 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#ifdef __linux__
-static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
- __cxx_contention_t __val)
-{
- static constexpr timespec __timeout = { 2, 0 };
- syscall(SYS_futex, __ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0);
+static void
+__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
+ static constexpr timespec __timeout = {2, 0};
+ syscall(SYS_futex, __ptr, FUTEX_WAIT_PRIVATE, __val, &__timeout, 0, 0);
}
-static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr,
- bool __notify_one)
-{
- syscall(SYS_futex, __ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0);
+static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
+ syscall(SYS_futex, __ptr, FUTEX_WAKE_PRIVATE, __notify_one ? 1 : INT_MAX, 0, 0, 0);
}
#elif defined(__APPLE__) && defined(_LIBCPP_USE_ULOCK)
-extern "C" int __ulock_wait(uint32_t operation, void *addr, uint64_t value,
- uint32_t timeout); /* timeout is specified in microseconds */
-extern "C" int __ulock_wake(uint32_t operation, void *addr, uint64_t wake_value);
+extern "C" int __ulock_wait(
+ uint32_t operation, void* addr, uint64_t value, uint32_t timeout); /* timeout is specified in microseconds */
+extern "C" int __ulock_wake(uint32_t operation, void* addr, uint64_t wake_value);
-#define UL_COMPARE_AND_WAIT 1
-#define ULF_WAKE_ALL 0x00000100
+# define UL_COMPARE_AND_WAIT 1
+# define ULF_WAKE_ALL 0x00000100
-static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
- __cxx_contention_t __val)
-{
- __ulock_wait(UL_COMPARE_AND_WAIT,
- const_cast<__cxx_atomic_contention_t*>(__ptr), __val, 0);
+static void
+__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
+ __ulock_wait(UL_COMPARE_AND_WAIT, const_cast<__cxx_atomic_contention_t*>(__ptr), __val, 0);
}
-static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr,
- bool __notify_one)
-{
- __ulock_wake(UL_COMPARE_AND_WAIT | (__notify_one ? 0 : ULF_WAKE_ALL),
- const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
+static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
+ __ulock_wake(
+ UL_COMPARE_AND_WAIT | (__notify_one ? 0 : ULF_WAKE_ALL), const_cast<__cxx_atomic_contention_t*>(__ptr), 0);
}
#elif defined(__FreeBSD__) && __SIZEOF_LONG__ == 8
@@ -84,53 +77,44 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
* limit its use to architectures where long and int64_t are synonyms.
*/
-static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
- __cxx_contention_t __val)
-{
- _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr),
- UMTX_OP_WAIT, __val, NULL, NULL);
+static void
+__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
+ _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, NULL, NULL);
}
-static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr,
- bool __notify_one)
-{
- _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr),
- UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL);
+static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
+ _umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL);
}
#else // <- Add other operating systems here
// Baseline is just a timed backoff
-static void __libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr,
- __cxx_contention_t __val)
-{
- __libcpp_thread_poll_with_backoff([=]() -> bool {
- return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__ptr, memory_order_relaxed), __val);
- }, __libcpp_timed_backoff_policy());
+static void
+__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
+ __libcpp_thread_poll_with_backoff(
+ [=]() -> bool { return !__cxx_nonatomic_compare_equal(__cxx_atomic_load(__ptr, memory_order_relaxed), __val); },
+ __libcpp_timed_backoff_policy());
}
-static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile*, bool) { }
+static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile*, bool) {}
#endif // __linux__
-static constexpr size_t __libcpp_contention_table_size = (1 << 8); /* < there's no magic in this number */
+static constexpr size_t __libcpp_contention_table_size = (1 << 8); /* < there's no magic in this number */
-struct alignas(64) /* aim to avoid false sharing */ __libcpp_contention_table_entry
-{
- __cxx_atomic_contention_t __contention_state;
- __cxx_atomic_contention_t __platform_state;
- inline constexpr __libcpp_contention_table_entry() :
- __contention_state(0), __platform_state(0) { }
+struct alignas(64) /* aim to avoid false sharing */ __libcpp_contention_table_entry {
+ __cxx_atomic_contention_t __contention_state;
+ __cxx_atomic_contention_t __platform_state;
+ inline constexpr __libcpp_contention_table_entry() : __contention_state(0), __platform_state(0) {}
};
-static __libcpp_contention_table_entry __libcpp_contention_table[ __libcpp_contention_table_size ];
+static __libcpp_contention_table_entry __libcpp_contention_table[__libcpp_contention_table_size];
static hash<void const volatile*> __libcpp_contention_hasher;
-static __libcpp_contention_table_entry* __libcpp_contention_state(void const volatile * p)
-{
- return &__libcpp_contention_table[__libcpp_contention_hasher(p) & (__libcpp_contention_table_size - 1)];
+static __libcpp_contention_table_entry* __libcpp_contention_state(void const volatile* p) {
+ return &__libcpp_contention_table[__libcpp_contention_hasher(p) & (__libcpp_contention_table_size - 1)];
}
/* Given an atomic to track contention and an atomic to actually wait on, which may be
@@ -138,81 +122,69 @@ static __libcpp_contention_table_entry* __libcpp_contention_state(void const vol
static void __libcpp_contention_notify(__cxx_atomic_contention_t volatile* __contention_state,
__cxx_atomic_contention_t const volatile* __platform_state,
- bool __notify_one)
-{
- if(0 != __cxx_atomic_load(__contention_state, memory_order_seq_cst))
- // We only call 'wake' if we consumed a contention bit here.
- __libcpp_platform_wake_by_address(__platform_state, __notify_one);
-}
-static __cxx_contention_t __libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* /*__contention_state*/,
- __cxx_atomic_contention_t const volatile* __platform_state)
-{
- // We will monitor this value.
- return __cxx_atomic_load(__platform_state, memory_order_acquire);
+ bool __notify_one) {
+ if (0 != __cxx_atomic_load(__contention_state, memory_order_seq_cst))
+ // We only call 'wake' if we consumed a contention bit here.
+ __libcpp_platform_wake_by_address(__platform_state, __notify_one);
+}
+static __cxx_contention_t
+__libcpp_contention_monitor_for_wait(__cxx_atomic_contention_t volatile* /*__contention_state*/,
+ __cxx_atomic_contention_t const volatile* __platform_state) {
+ // We will monitor this value.
+ return __cxx_atomic_load(__platform_state, memory_order_acquire);
}
static void __libcpp_contention_wait(__cxx_atomic_contention_t volatile* __contention_state,
__cxx_atomic_contention_t const volatile* __platform_state,
- __cxx_contention_t __old_value)
-{
- __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_seq_cst);
- // We sleep as long as the monitored value hasn't changed.
- __libcpp_platform_wait_on_address(__platform_state, __old_value);
- __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release);
+ __cxx_contention_t __old_value) {
+ __cxx_atomic_fetch_add(__contention_state, __cxx_contention_t(1), memory_order_seq_cst);
+ // We sleep as long as the monitored value hasn't changed.
+ __libcpp_platform_wait_on_address(__platform_state, __old_value);
+ __cxx_atomic_fetch_sub(__contention_state, __cxx_contention_t(1), memory_order_release);
}
/* When the incoming atomic is the wrong size for the platform wait size, need to
launder the value sequence through an atomic from our table. */
-static void __libcpp_atomic_notify(void const volatile* __location)
-{
- auto const __entry = __libcpp_contention_state(__location);
- // The value sequence laundering happens on the next line below.
- __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_release);
- __libcpp_contention_notify(&__entry->__contention_state,
- &__entry->__platform_state,
- false /* when laundering, we can't handle notify_one */);
-}
-_LIBCPP_EXPORTED_FROM_ABI
-void __cxx_atomic_notify_one(void const volatile* __location)
- { __libcpp_atomic_notify(__location); }
-_LIBCPP_EXPORTED_FROM_ABI
-void __cxx_atomic_notify_all(void const volatile* __location)
- { __libcpp_atomic_notify(__location); }
-_LIBCPP_EXPORTED_FROM_ABI
-__cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location)
-{
- auto const __entry = __libcpp_contention_state(__location);
- return __libcpp_contention_monitor_for_wait(&__entry->__contention_state, &__entry->__platform_state);
-}
-_LIBCPP_EXPORTED_FROM_ABI
-void __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value)
-{
- auto const __entry = __libcpp_contention_state(__location);
- __libcpp_contention_wait(&__entry->__contention_state, &__entry->__platform_state, __old_value);
+static void __libcpp_atomic_notify(void const volatile* __location) {
+ auto const __entry = __libcpp_contention_state(__location);
+ // The value sequence laundering happens on the next line below.
+ __cxx_atomic_fetch_add(&__entry->__platform_state, __cxx_contention_t(1), memory_order_release);
+ __libcpp_contention_notify(
+ &__entry->__contention_state,
+ &__entry->__platform_state,
+ false /* when laundering, we can't handle notify_one */);
+}
+_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(void const volatile* __location) {
+ __libcpp_atomic_notify(__location);
+}
+_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(void const volatile* __location) {
+ __libcpp_atomic_notify(__location);
+}
+_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t __libcpp_atomic_monitor(void const volatile* __location) {
+ auto const __entry = __libcpp_contention_state(__location);
+ return __libcpp_contention_monitor_for_wait(&__entry->__contention_state, &__entry->__platform_state);
+}
+_LIBCPP_EXPORTED_FROM_ABI void __libcpp_atomic_wait(void const volatile* __location, __cxx_contention_t __old_value) {
+ auto const __entry = __libcpp_contention_state(__location);
+ __libcpp_contention_wait(&__entry->__contention_state, &__entry->__platform_state, __old_value);
}
/* When the incoming atomic happens to be the platform wait size, we still need to use the
table for the contention detection, but we can use the atomic directly for the wait. */
-_LIBCPP_EXPORTED_FROM_ABI
-void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location)
-{
- __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, true);
-}
-_LIBCPP_EXPORTED_FROM_ABI
-void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location)
-{
- __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, false);
-}
-_LIBCPP_EXPORTED_FROM_ABI
-__cxx_contention_t __libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location)
-{
- return __libcpp_contention_monitor_for_wait(&__libcpp_contention_state(__location)->__contention_state, __location);
-}
-_LIBCPP_EXPORTED_FROM_ABI
-void __libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value)
-{
- __libcpp_contention_wait(&__libcpp_contention_state(__location)->__contention_state, __location, __old_value);
+_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_one(__cxx_atomic_contention_t const volatile* __location) {
+ __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, true);
+}
+_LIBCPP_EXPORTED_FROM_ABI void __cxx_atomic_notify_all(__cxx_atomic_contention_t const volatile* __location) {
+ __libcpp_contention_notify(&__libcpp_contention_state(__location)->__contention_state, __location, false);
+}
+_LIBCPP_EXPORTED_FROM_ABI __cxx_contention_t
+__libcpp_atomic_monitor(__cxx_atomic_contention_t const volatile* __location) {
+ return __libcpp_contention_monitor_for_wait(&__libcpp_contention_state(__location)->__contention_state, __location);
+}
+_LIBCPP_EXPORTED_FROM_ABI void
+__libcpp_atomic_wait(__cxx_atomic_contention_t const volatile* __location, __cxx_contention_t __old_value) {
+ __libcpp_contention_wait(&__libcpp_contention_state(__location)->__contention_state, __location, __old_value);
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/barrier.cpp b/contrib/libs/cxxsupp/libcxx/src/barrier.cpp
index 3242e0865b..baa26101cd 100644
--- a/contrib/libs/cxxsupp/libcxx/src/barrier.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/barrier.cpp
@@ -15,75 +15,59 @@ _LIBCPP_BEGIN_NAMESPACE_STD
class __barrier_algorithm_base {
public:
- struct alignas(64) /* naturally-align the heap state */ __state_t
- {
- struct {
- __atomic_base<__barrier_phase_t> __phase{0};
- } __tickets[64];
- };
+ struct alignas(64) /* naturally-align the heap state */ __state_t {
+ struct {
+ __atomic_base<__barrier_phase_t> __phase{0};
+ } __tickets[64];
+ };
- ptrdiff_t& __expected;
- unique_ptr<__state_t[]> __state;
+ ptrdiff_t& __expected;
+ unique_ptr<__state_t[]> __state;
- _LIBCPP_HIDDEN
- __barrier_algorithm_base(ptrdiff_t& __expected)
- : __expected(__expected)
- {
- size_t const __count = (__expected + 1) >> 1;
- __state = unique_ptr<__state_t[]>(new __state_t[__count]);
- }
- _LIBCPP_HIDDEN
- bool __arrive(__barrier_phase_t __old_phase)
- {
- __barrier_phase_t const __half_step = __old_phase + 1,
- __full_step = __old_phase + 2;
- size_t __current_expected = __expected,
- __current = hash<thread::id>()(this_thread::get_id()) % ((__expected + 1) >> 1);
- for(int __round = 0;; ++__round) {
- if(__current_expected <= 1)
- return true;
- size_t const __end_node = ((__current_expected + 1) >> 1),
- __last_node = __end_node - 1;
- for(;;++__current) {
- if(__current == __end_node)
- __current = 0;
- __barrier_phase_t expect = __old_phase;
- if(__current == __last_node && (__current_expected & 1))
- {
- if(__state[__current].__tickets[__round].__phase.compare_exchange_strong(expect, __full_step, memory_order_acq_rel))
- break; // I'm 1 in 1, go to next __round
- }
- else if(__state[__current].__tickets[__round].__phase.compare_exchange_strong(expect, __half_step, memory_order_acq_rel))
- {
- return false; // I'm 1 in 2, done with arrival
- }
- else if(expect == __half_step)
- {
- if(__state[__current].__tickets[__round].__phase.compare_exchange_strong(expect, __full_step, memory_order_acq_rel))
- break; // I'm 2 in 2, go to next __round
- }
- }
- __current_expected = __last_node + 1;
- __current >>= 1;
+ _LIBCPP_HIDDEN __barrier_algorithm_base(ptrdiff_t& __expected) : __expected(__expected) {
+ size_t const __count = (__expected + 1) >> 1;
+ __state = unique_ptr<__state_t[]>(new __state_t[__count]);
+ }
+ _LIBCPP_HIDDEN bool __arrive(__barrier_phase_t __old_phase) {
+ __barrier_phase_t const __half_step = __old_phase + 1, __full_step = __old_phase + 2;
+ size_t __current_expected = __expected,
+ __current = hash<thread::id>()(this_thread::get_id()) % ((__expected + 1) >> 1);
+ for (int __round = 0;; ++__round) {
+ if (__current_expected <= 1)
+ return true;
+ size_t const __end_node = ((__current_expected + 1) >> 1), __last_node = __end_node - 1;
+ for (;; ++__current) {
+ if (__current == __end_node)
+ __current = 0;
+ __barrier_phase_t expect = __old_phase;
+ if (__current == __last_node && (__current_expected & 1)) {
+ if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
+ expect, __full_step, memory_order_acq_rel))
+ break; // I'm 1 in 1, go to next __round
+ } else if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
+ expect, __half_step, memory_order_acq_rel)) {
+ return false; // I'm 1 in 2, done with arrival
+ } else if (expect == __half_step) {
+ if (__state[__current].__tickets[__round].__phase.compare_exchange_strong(
+ expect, __full_step, memory_order_acq_rel))
+ break; // I'm 2 in 2, go to next __round
}
+ }
+ __current_expected = __last_node + 1;
+ __current >>= 1;
}
+ }
};
-_LIBCPP_EXPORTED_FROM_ABI
-__barrier_algorithm_base * __construct_barrier_algorithm_base(ptrdiff_t& __expected)
-{
- return new __barrier_algorithm_base(__expected);
+_LIBCPP_EXPORTED_FROM_ABI __barrier_algorithm_base* __construct_barrier_algorithm_base(ptrdiff_t& __expected) {
+ return new __barrier_algorithm_base(__expected);
}
-_LIBCPP_EXPORTED_FROM_ABI
-bool __arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier,
- __barrier_phase_t __old_phase)
-{
- return __barrier->__arrive(__old_phase);
+_LIBCPP_EXPORTED_FROM_ABI bool
+__arrive_barrier_algorithm_base(__barrier_algorithm_base* __barrier, __barrier_phase_t __old_phase) {
+ return __barrier->__arrive(__old_phase);
}
-_LIBCPP_EXPORTED_FROM_ABI
-void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier)
-{
- delete __barrier;
+_LIBCPP_EXPORTED_FROM_ABI void __destroy_barrier_algorithm_base(__barrier_algorithm_base* __barrier) {
+ delete __barrier;
}
#endif // !defined(_LIBCPP_HAS_NO_TREE_BARRIER)
diff --git a/contrib/libs/cxxsupp/libcxx/src/bind.cpp b/contrib/libs/cxxsupp/libcxx/src/bind.cpp
index 0e217e5fc5..e057395842 100644
--- a/contrib/libs/cxxsupp/libcxx/src/bind.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/bind.cpp
@@ -10,20 +10,19 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-namespace placeholders
-{
+namespace placeholders {
-const __ph<1> _1{};
-const __ph<2> _2{};
-const __ph<3> _3{};
-const __ph<4> _4{};
-const __ph<5> _5{};
-const __ph<6> _6{};
-const __ph<7> _7{};
-const __ph<8> _8{};
-const __ph<9> _9{};
+const __ph<1> _1{};
+const __ph<2> _2{};
+const __ph<3> _3{};
+const __ph<4> _4{};
+const __ph<5> _5{};
+const __ph<6> _6{};
+const __ph<7> _7{};
+const __ph<8> _8{};
+const __ph<9> _9{};
const __ph<10> _10{};
-} // placeholders
+} // namespace placeholders
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/call_once.cpp b/contrib/libs/cxxsupp/libcxx/src/call_once.cpp
index a4fb1c35f1..7f5aef1db5 100644
--- a/contrib/libs/cxxsupp/libcxx/src/call_once.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/call_once.cpp
@@ -24,64 +24,62 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// keep in sync with: 7741191.
#ifndef _LIBCPP_HAS_NO_THREADS
-static constinit __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
+static constinit __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
static constinit __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
#endif
#ifdef _LIBCPP_ABI_MICROSOFT
-void __call_once(volatile std::atomic<once_flag::_State_type>& flag, void* arg,
- void (*func)(void*))
+void __call_once(volatile std::atomic<once_flag::_State_type>& flag, void* arg, void (*func)(void*))
#else
-void __call_once(volatile once_flag::_State_type& flag, void* arg,
- void (*func)(void*))
+void __call_once(volatile once_flag::_State_type& flag, void* arg, void (*func)(void*))
#endif
{
#if defined(_LIBCPP_HAS_NO_THREADS)
- if (flag == once_flag::_Unset) {
- auto guard = std::__make_exception_guard([&flag] { flag = once_flag::_Unset; });
- flag = once_flag::_Pending;
- func(arg);
- flag = once_flag::_Complete;
- guard.__complete();
- }
+ if (flag == once_flag::_Unset) {
+ auto guard = std::__make_exception_guard([&flag] { flag = once_flag::_Unset; });
+ flag = once_flag::_Pending;
+ func(arg);
+ flag = once_flag::_Complete;
+ guard.__complete();
+ }
#else // !_LIBCPP_HAS_NO_THREADS
- __libcpp_mutex_lock(&mut);
- while (flag == once_flag::_Pending)
- __libcpp_condvar_wait(&cv, &mut);
- if (flag == once_flag::_Unset) {
- auto guard = std::__make_exception_guard([&flag] {
- __libcpp_mutex_lock(&mut);
-#ifdef _LIBCPP_ABI_MICROSOFT
- flag.store(once_flag::_Unset);
-#else
- __libcpp_relaxed_store(&flag, once_flag::_Unset);
-#endif
- __libcpp_mutex_unlock(&mut);
- __libcpp_condvar_broadcast(&cv);
- });
+ __libcpp_mutex_lock(&mut);
+ while (flag == once_flag::_Pending)
+ __libcpp_condvar_wait(&cv, &mut);
+ if (flag == once_flag::_Unset) {
+ auto guard = std::__make_exception_guard([&flag] {
+ __libcpp_mutex_lock(&mut);
+# ifdef _LIBCPP_ABI_MICROSOFT
+ flag.store(once_flag::_Unset);
+# else
+ __libcpp_relaxed_store(&flag, once_flag::_Unset);
+# endif
+ __libcpp_mutex_unlock(&mut);
+ __libcpp_condvar_broadcast(&cv);
+ });
-#ifdef _LIBCPP_ABI_MICROSOFT
- flag.store(once_flag::_Pending, memory_order_relaxed);
-#else
- __libcpp_relaxed_store(&flag, once_flag::_Pending);
-#endif
- __libcpp_mutex_unlock(&mut);
- func(arg);
- __libcpp_mutex_lock(&mut);
-#ifdef _LIBCPP_ABI_MICROSOFT
- flag.store(once_flag::_Complete, memory_order_release);
-#else
- __libcpp_atomic_store(&flag, once_flag::_Complete, _AO_Release);
-#endif
- __libcpp_mutex_unlock(&mut);
- __libcpp_condvar_broadcast(&cv);
- guard.__complete();
- } else {
- __libcpp_mutex_unlock(&mut);
- }
+# ifdef _LIBCPP_ABI_MICROSOFT
+ flag.store(once_flag::_Pending, memory_order_relaxed);
+# else
+ __libcpp_relaxed_store(&flag, once_flag::_Pending);
+# endif
+ __libcpp_mutex_unlock(&mut);
+ func(arg);
+ __libcpp_mutex_lock(&mut);
+# ifdef _LIBCPP_ABI_MICROSOFT
+ flag.store(once_flag::_Complete, memory_order_release);
+# else
+ __libcpp_atomic_store(&flag, once_flag::_Complete, _AO_Release);
+# endif
+ __libcpp_mutex_unlock(&mut);
+ __libcpp_condvar_broadcast(&cv);
+ guard.__complete();
+ } else {
+ __libcpp_mutex_unlock(&mut);
+ }
#endif // !_LIBCPP_HAS_NO_THREADS
}
diff --git a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp
index aa52220413..4fd7a2c2c0 100644
--- a/contrib/libs/cxxsupp/libcxx/src/charconv.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/charconv.cpp
@@ -15,22 +15,13 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#ifndef _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
-namespace __itoa
-{
+namespace __itoa {
-_LIBCPP_EXPORTED_FROM_ABI char*
-__u32toa(uint32_t value, char* buffer) noexcept
-{
- return __base_10_u32(buffer, value);
-}
+_LIBCPP_EXPORTED_FROM_ABI char* __u32toa(uint32_t value, char* buffer) noexcept { return __base_10_u32(buffer, value); }
-_LIBCPP_EXPORTED_FROM_ABI char*
-__u64toa(uint64_t value, char* buffer) noexcept
-{
- return __base_10_u64(buffer, value);
-}
+_LIBCPP_EXPORTED_FROM_ABI char* __u64toa(uint64_t value, char* buffer) noexcept { return __base_10_u64(buffer, value); }
-} // namespace __itoa
+} // namespace __itoa
#endif // _LIBCPP_ABI_DO_NOT_EXPORT_TO_CHARS_BASE_10
@@ -51,8 +42,8 @@ to_chars_result to_chars(char* __first, char* __last, double __value) {
}
to_chars_result to_chars(char* __first, char* __last, long double __value) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(__first, __last, static_cast<double>(__value),
- chars_format{}, 0);
+ return _Floating_to_chars<_Floating_to_chars_overload::_Plain>(
+ __first, __last, static_cast<double>(__value), chars_format{}, 0);
}
to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt) {
@@ -64,18 +55,18 @@ to_chars_result to_chars(char* __first, char* __last, double __value, chars_form
}
to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(__first, __last, static_cast<double>(__value),
- __fmt, 0);
+ return _Floating_to_chars<_Floating_to_chars_overload::_Format_only>(
+ __first, __last, static_cast<double>(__value), __fmt, 0);
}
to_chars_result to_chars(char* __first, char* __last, float __value, chars_format __fmt, int __precision) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
- __precision);
+ return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(
+ __first, __last, __value, __fmt, __precision);
}
to_chars_result to_chars(char* __first, char* __last, double __value, chars_format __fmt, int __precision) {
- return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(__first, __last, __value, __fmt,
- __precision);
+ return _Floating_to_chars<_Floating_to_chars_overload::_Format_precision>(
+ __first, __last, __value, __fmt, __precision);
}
to_chars_result to_chars(char* __first, char* __last, long double __value, chars_format __fmt, int __precision) {
diff --git a/contrib/libs/cxxsupp/libcxx/src/chrono.cpp b/contrib/libs/cxxsupp/libcxx/src/chrono.cpp
index c4446070d0..c5e827c0cb 100644
--- a/contrib/libs/cxxsupp/libcxx/src/chrono.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/chrono.cpp
@@ -9,7 +9,7 @@
#if defined(__MVS__)
// As part of monotonic clock support on z/OS we need macro _LARGE_TIME_API
// to be defined before any system header to include definition of struct timespec64.
-#define _LARGE_TIME_API
+# define _LARGE_TIME_API
#endif
#include <__system_error/system_error.h>
@@ -17,22 +17,22 @@
#include <chrono>
#if defined(__MVS__)
-#include <__support/ibm/gettod_zos.h> // gettimeofdayMonotonic
+# include <__support/ibm/gettod_zos.h> // gettimeofdayMonotonic
#endif
-#include <time.h> // clock_gettime and CLOCK_{MONOTONIC,REALTIME,MONOTONIC_RAW}
#include "include/apple_availability.h"
+#include <time.h> // clock_gettime and CLOCK_{MONOTONIC,REALTIME,MONOTONIC_RAW}
#if __has_include(<unistd.h>)
-# include <unistd.h> // _POSIX_TIMERS
+# include <unistd.h> // _POSIX_TIMERS
#endif
#if __has_include(<sys/time.h>)
-# include <sys/time.h> // for gettimeofday and timeval
+# include <sys/time.h> // for gettimeofday and timeval
#endif
-#if defined(__APPLE__) || defined (__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
-# define _LIBCPP_HAS_CLOCK_GETTIME
+#if defined(__APPLE__) || defined(__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
+# define _LIBCPP_HAS_CLOCK_GETTIME
#endif
#if defined(_LIBCPP_WIN32API)
@@ -49,7 +49,7 @@
#endif
#if __has_include(<mach/mach_time.h>)
-# include <mach/mach_time.h>
+# include <mach/mach_time.h>
#endif
#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
@@ -58,8 +58,7 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-namespace chrono
-{
+namespace chrono {
//
// system_clock
@@ -67,17 +66,17 @@ namespace chrono
#if defined(_LIBCPP_WIN32API)
-#if _WIN32_WINNT < _WIN32_WINNT_WIN8
+# if _WIN32_WINNT < _WIN32_WINNT_WIN8
namespace {
-typedef void(WINAPI *GetSystemTimeAsFileTimePtr)(LPFILETIME);
+typedef void(WINAPI* GetSystemTimeAsFileTimePtr)(LPFILETIME);
class GetSystemTimeInit {
public:
GetSystemTimeInit() {
- fp = (GetSystemTimeAsFileTimePtr)GetProcAddress(
- GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime");
+ fp =
+ (GetSystemTimeAsFileTimePtr)GetProcAddress(GetModuleHandleW(L"kernel32.dll"), "GetSystemTimePreciseAsFileTime");
if (fp == nullptr)
fp = GetSystemTimeAsFileTime;
}
@@ -86,33 +85,30 @@ public:
// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority
// attribute with a value that's reserved for the implementation (we're the implementation).
-#include "chrono_system_time_init.h"
+# include "chrono_system_time_init.h"
} // namespace
-#endif
+# endif
static system_clock::time_point __libcpp_system_clock_now() {
// FILETIME is in 100ns units
using filetime_duration =
- std::chrono::duration<__int64,
- std::ratio_multiply<std::ratio<100, 1>,
- nanoseconds::period>>;
+ std::chrono::duration<__int64, std::ratio_multiply<std::ratio<100, 1>, nanoseconds::period>>;
// The Windows epoch is Jan 1 1601, the Unix epoch Jan 1 1970.
static constexpr const seconds nt_to_unix_epoch{11644473600};
FILETIME ft;
-#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) || \
- (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
+# if (_WIN32_WINNT >= _WIN32_WINNT_WIN8 && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)) || \
+ (_WIN32_WINNT >= _WIN32_WINNT_WIN10)
GetSystemTimePreciseAsFileTime(&ft);
-#elif !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+# elif !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
GetSystemTimeAsFileTime(&ft);
-#else
+# else
GetSystemTimeAsFileTimeFunc.fp(&ft);
-#endif
+# endif
- filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
- static_cast<__int64>(ft.dwLowDateTime)};
+ filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) | static_cast<__int64>(ft.dwLowDateTime)};
return system_clock::time_point(duration_cast<system_clock::duration>(d - nt_to_unix_epoch));
}
@@ -128,32 +124,22 @@ static system_clock::time_point __libcpp_system_clock_now() {
#else
static system_clock::time_point __libcpp_system_clock_now() {
- timeval tv;
- gettimeofday(&tv, 0);
- return system_clock::time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
+ timeval tv;
+ gettimeofday(&tv, 0);
+ return system_clock::time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
}
#endif
const bool system_clock::is_steady;
-system_clock::time_point
-system_clock::now() noexcept
-{
- return __libcpp_system_clock_now();
-}
+system_clock::time_point system_clock::now() noexcept { return __libcpp_system_clock_now(); }
-time_t
-system_clock::to_time_t(const time_point& t) noexcept
-{
- return time_t(duration_cast<seconds>(t.time_since_epoch()).count());
+time_t system_clock::to_time_t(const time_point& t) noexcept {
+ return time_t(duration_cast<seconds>(t.time_since_epoch()).count());
}
-system_clock::time_point
-system_clock::from_time_t(time_t t) noexcept
-{
- return system_clock::time_point(seconds(t));
-}
+system_clock::time_point system_clock::from_time_t(time_t t) noexcept { return system_clock::time_point(seconds(t)); }
//
// steady_clock
@@ -165,7 +151,7 @@ system_clock::from_time_t(time_t t) noexcept
#ifndef _LIBCPP_HAS_NO_MONOTONIC_CLOCK
-#if defined(__APPLE__)
+# if defined(__APPLE__)
// On Apple platforms, only CLOCK_UPTIME_RAW, CLOCK_MONOTONIC_RAW or
// mach_absolute_time are able to time functions in the nanosecond range.
@@ -173,39 +159,37 @@ system_clock::from_time_t(time_t t) noexcept
// also counts cycles when the system is asleep. Thus, it is the only
// acceptable implementation of steady_clock.
static steady_clock::time_point __libcpp_steady_clock_now() {
- struct timespec tp;
- if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp))
- __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed");
- return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+ struct timespec tp;
+ if (0 != clock_gettime(CLOCK_MONOTONIC_RAW, &tp))
+ __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC_RAW) failed");
+ return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
}
-#elif defined(_LIBCPP_WIN32API)
+# elif defined(_LIBCPP_WIN32API)
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms644905(v=vs.85).aspx says:
// If the function fails, the return value is zero. <snip>
// On systems that run Windows XP or later, the function will always succeed
// and will thus never return zero.
-static LARGE_INTEGER
-__QueryPerformanceFrequency()
-{
- LARGE_INTEGER val;
- (void) QueryPerformanceFrequency(&val);
- return val;
+static LARGE_INTEGER __QueryPerformanceFrequency() {
+ LARGE_INTEGER val;
+ (void)QueryPerformanceFrequency(&val);
+ return val;
}
static steady_clock::time_point __libcpp_steady_clock_now() {
static const LARGE_INTEGER freq = __QueryPerformanceFrequency();
LARGE_INTEGER counter;
- (void) QueryPerformanceCounter(&counter);
- auto seconds = counter.QuadPart / freq.QuadPart;
+ (void)QueryPerformanceCounter(&counter);
+ auto seconds = counter.QuadPart / freq.QuadPart;
auto fractions = counter.QuadPart % freq.QuadPart;
- auto dur = seconds * nano::den + fractions * nano::den / freq.QuadPart;
+ auto dur = seconds * nano::den + fractions * nano::den / freq.QuadPart;
return steady_clock::time_point(steady_clock::duration(dur));
}
-#elif defined(__MVS__)
+# elif defined(__MVS__)
static steady_clock::time_point __libcpp_steady_clock_now() {
struct timespec64 ts;
@@ -229,10 +213,10 @@ static steady_clock::time_point __libcpp_steady_clock_now() noexcept {
# elif defined(_LIBCPP_HAS_CLOCK_GETTIME)
static steady_clock::time_point __libcpp_steady_clock_now() {
- struct timespec tp;
- if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
- __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
- return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+ struct timespec tp;
+ if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
+ __throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
+ return steady_clock::time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
}
# else
@@ -241,14 +225,10 @@ static steady_clock::time_point __libcpp_steady_clock_now() {
const bool steady_clock::is_steady;
-steady_clock::time_point
-steady_clock::now() noexcept
-{
- return __libcpp_steady_clock_now();
-}
+steady_clock::time_point steady_clock::now() noexcept { return __libcpp_steady_clock_now(); }
#endif // !_LIBCPP_HAS_NO_MONOTONIC_CLOCK
-}
+} // namespace chrono
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp b/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp
index 33e19568b4..db60571cf5 100644
--- a/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/condition_variable.cpp
@@ -20,69 +20,50 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// ~condition_variable is defined elsewhere.
-void
-condition_variable::notify_one() noexcept
-{
- __libcpp_condvar_signal(&__cv_);
-}
+void condition_variable::notify_one() noexcept { __libcpp_condvar_signal(&__cv_); }
-void
-condition_variable::notify_all() noexcept
-{
- __libcpp_condvar_broadcast(&__cv_);
-}
+void condition_variable::notify_all() noexcept { __libcpp_condvar_broadcast(&__cv_); }
-void
-condition_variable::wait(unique_lock<mutex>& lk) noexcept
-{
- if (!lk.owns_lock())
- __throw_system_error(EPERM,
- "condition_variable::wait: mutex not locked");
- int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
- if (ec)
- __throw_system_error(ec, "condition_variable wait failed");
+void condition_variable::wait(unique_lock<mutex>& lk) noexcept {
+ if (!lk.owns_lock())
+ __throw_system_error(EPERM, "condition_variable::wait: mutex not locked");
+ int ec = __libcpp_condvar_wait(&__cv_, lk.mutex()->native_handle());
+ if (ec)
+ __throw_system_error(ec, "condition_variable wait failed");
}
-void
-condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
- chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) noexcept
-{
- using namespace chrono;
- if (!lk.owns_lock())
- __throw_system_error(EPERM,
- "condition_variable::timed wait: mutex not locked");
- nanoseconds d = tp.time_since_epoch();
- if (d > nanoseconds(0x59682F000000E941))
- d = nanoseconds(0x59682F000000E941);
- __libcpp_timespec_t ts;
- seconds s = duration_cast<seconds>(d);
- typedef decltype(ts.tv_sec) ts_sec;
- constexpr ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
- if (s.count() < ts_sec_max)
- {
- ts.tv_sec = static_cast<ts_sec>(s.count());
- ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
- }
- else
- {
- ts.tv_sec = ts_sec_max;
- ts.tv_nsec = giga::num - 1;
- }
- int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
- if (ec != 0 && ec != ETIMEDOUT)
- __throw_system_error(ec, "condition_variable timed_wait failed");
+void condition_variable::__do_timed_wait(unique_lock<mutex>& lk,
+ chrono::time_point<chrono::system_clock, chrono::nanoseconds> tp) noexcept {
+ using namespace chrono;
+ if (!lk.owns_lock())
+ __throw_system_error(EPERM, "condition_variable::timed wait: mutex not locked");
+ nanoseconds d = tp.time_since_epoch();
+ if (d > nanoseconds(0x59682F000000E941))
+ d = nanoseconds(0x59682F000000E941);
+ __libcpp_timespec_t ts;
+ seconds s = duration_cast<seconds>(d);
+ typedef decltype(ts.tv_sec) ts_sec;
+ constexpr ts_sec ts_sec_max = numeric_limits<ts_sec>::max();
+ if (s.count() < ts_sec_max) {
+ ts.tv_sec = static_cast<ts_sec>(s.count());
+ ts.tv_nsec = static_cast<decltype(ts.tv_nsec)>((d - s).count());
+ } else {
+ ts.tv_sec = ts_sec_max;
+ ts.tv_nsec = giga::num - 1;
+ }
+ int ec = __libcpp_condvar_timedwait(&__cv_, lk.mutex()->native_handle(), &ts);
+ if (ec != 0 && ec != ETIMEDOUT)
+ __throw_system_error(ec, "condition_variable timed_wait failed");
}
-void
-notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk)
-{
- auto& tl_ptr = __thread_local_data();
- // If this thread was not created using std::thread then it will not have
- // previously allocated.
- if (tl_ptr.get() == nullptr) {
- tl_ptr.set_pointer(new __thread_struct);
- }
- __thread_local_data()->notify_all_at_thread_exit(&cond, lk.release());
+void notify_all_at_thread_exit(condition_variable& cond, unique_lock<mutex> lk) {
+ auto& tl_ptr = __thread_local_data();
+ // If this thread was not created using std::thread then it will not have
+ // previously allocated.
+ if (tl_ptr.get() == nullptr) {
+ tl_ptr.set_pointer(new __thread_struct);
+ }
+ __thread_local_data()->notify_all_at_thread_exit(&cond, lk.release());
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/condition_variable_destructor.cpp b/contrib/libs/cxxsupp/libcxx/src/condition_variable_destructor.cpp
index d39c8f811d..8b62d41840 100644
--- a/contrib/libs/cxxsupp/libcxx/src/condition_variable_destructor.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/condition_variable_destructor.cpp
@@ -22,23 +22,19 @@ _LIBCPP_BEGIN_NAMESPACE_STD
#ifdef NEEDS_CONDVAR_DESTRUCTOR
-class _LIBCPP_EXPORTED_FROM_ABI condition_variable
-{
- __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
+class _LIBCPP_EXPORTED_FROM_ABI condition_variable {
+ __libcpp_condvar_t __cv_ = _LIBCPP_CONDVAR_INITIALIZER;
+
public:
- _LIBCPP_HIDE_FROM_ABI
- constexpr condition_variable() noexcept = default;
+ _LIBCPP_HIDE_FROM_ABI constexpr condition_variable() noexcept = default;
- ~condition_variable();
+ ~condition_variable();
- condition_variable(const condition_variable&) = delete;
- condition_variable& operator=(const condition_variable&) = delete;
+ condition_variable(const condition_variable&) = delete;
+ condition_variable& operator=(const condition_variable&) = delete;
};
-condition_variable::~condition_variable()
-{
- __libcpp_condvar_destroy(&__cv_);
-}
+condition_variable::~condition_variable() { __libcpp_condvar_destroy(&__cv_); }
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/exception.cpp b/contrib/libs/cxxsupp/libcxx/src/exception.cpp
index 915ab3fb64..6fdf211a2b 100644
--- a/contrib/libs/cxxsupp/libcxx/src/exception.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/exception.cpp
@@ -11,24 +11,24 @@
#include <typeinfo>
#if defined(LIBCXX_BUILDING_LIBCXXRT) || defined(LIBCXX_BUILDING_LIBCXXABI)
- #include <cxxabi.h>
- using namespace __cxxabiv1;
- #define HAVE_DEPENDENT_EH_ABI 1
+# include <cxxabi.h>
+using namespace __cxxabiv1;
+# define HAVE_DEPENDENT_EH_ABI 1
#endif
#if defined(_LIBCPP_ABI_MICROSOFT)
-#include "support/runtime/exception_msvc.ipp"
-#include "support/runtime/exception_pointer_msvc.ipp"
+# include "support/runtime/exception_msvc.ipp"
+# include "support/runtime/exception_pointer_msvc.ipp"
#elif defined(_LIBCPPABI_VERSION)
-#include "support/runtime/exception_libcxxabi.ipp"
-#include "support/runtime/exception_pointer_cxxabi.ipp"
+# include "support/runtime/exception_libcxxabi.ipp"
+# include "support/runtime/exception_pointer_cxxabi.ipp"
#elif defined(LIBCXX_BUILDING_LIBCXXRT)
-#include "support/runtime/exception_libcxxrt.ipp"
-#include "support/runtime/exception_pointer_cxxabi.ipp"
+# include "support/runtime/exception_libcxxrt.ipp"
+# include "support/runtime/exception_pointer_cxxabi.ipp"
#elif defined(__GLIBCXX__)
-#include "support/runtime/exception_glibcxx.ipp"
-#include "support/runtime/exception_pointer_glibcxx.ipp"
+# include "support/runtime/exception_glibcxx.ipp"
+# include "support/runtime/exception_pointer_glibcxx.ipp"
#else
-#include "support/runtime/exception_fallback.ipp"
-#include "support/runtime/exception_pointer_unimplemented.ipp"
+# include "support/runtime/exception_fallback.ipp"
+# include "support/runtime/exception_pointer_unimplemented.ipp"
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_entry.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_entry.cpp
index a71c2f9d24..1527152439 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_entry.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_entry.cpp
@@ -29,8 +29,8 @@ error_code directory_entry::__do_refresh() noexcept {
}
if (!filesystem::exists(st) || !filesystem::is_symlink(st)) {
- __data_.__cache_type_ = directory_entry::_RefreshNonSymlink;
- __data_.__type_ = st.type();
+ __data_.__cache_type_ = directory_entry::_RefreshNonSymlink;
+ __data_.__type_ = st.type();
__data_.__non_sym_perms_ = st.permissions();
} else { // we have a symlink
__data_.__sym_perms_ = st.permissions();
@@ -40,7 +40,7 @@ error_code directory_entry::__do_refresh() noexcept {
error_code ignored_ec;
st = detail::posix_stat(__p_, full_st, &ignored_ec);
- __data_.__type_ = st.type();
+ __data_.__type_ = st.type();
__data_.__non_sym_perms_ = st.permissions();
// If we failed to resolve the link, then only partially populate the
@@ -64,8 +64,7 @@ error_code directory_entry::__do_refresh() noexcept {
// file_time_type. For now we ignore the error, as we'll report it when
// the value is actually used.
error_code ignored_ec;
- __data_.__write_time_ =
- detail::__extract_last_write_time(__p_, full_st, &ignored_ec);
+ __data_.__write_time_ = detail::__extract_last_write_time(__p_, full_st, &ignored_ec);
}
return failure_ec;
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp
index a705c5b67e..d7ed9a358f 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/directory_iterator.cpp
@@ -17,11 +17,11 @@
#include "file_descriptor.h"
#if defined(_LIBCPP_WIN32API)
-# define WIN32_LEAN_AND_MEAN
-# define NOMINMAX
-# include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <windows.h>
#else
-# include <dirent.h> // for DIR & friends
+# include <dirent.h> // for DIR & friends
#endif
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -31,12 +31,11 @@ using detail::ErrorHandler;
#if defined(_LIBCPP_WIN32API)
class __dir_stream {
public:
- __dir_stream() = delete;
+ __dir_stream() = delete;
__dir_stream& operator=(const __dir_stream&) = delete;
- __dir_stream(__dir_stream&& __ds) noexcept : __stream_(__ds.__stream_),
- __root_(std::move(__ds.__root_)),
- __entry_(std::move(__ds.__entry_)) {
+ __dir_stream(__dir_stream&& __ds) noexcept
+ : __stream_(__ds.__stream_), __root_(std::move(__ds.__root_)), __entry_(std::move(__ds.__entry_)) {
__ds.__stream_ = INVALID_HANDLE_VALUE;
}
@@ -48,11 +47,9 @@ public:
}
__stream_ = ::FindFirstFileW((root / "*").c_str(), &__data_);
if (__stream_ == INVALID_HANDLE_VALUE) {
- ec = detail::make_windows_error(GetLastError());
- const bool ignore_permission_denied =
- bool(opts & directory_options::skip_permission_denied);
- if (ignore_permission_denied &&
- ec.value() == static_cast<int>(errc::permission_denied))
+ ec = detail::make_windows_error(GetLastError());
+ const bool ignore_permission_denied = bool(opts & directory_options::skip_permission_denied);
+ if (ignore_permission_denied && ec.value() == static_cast<int>(errc::permission_denied))
ec.clear();
return;
}
@@ -82,10 +79,11 @@ public:
return false;
__entry_.__assign_iter_entry(
__root_ / __data_.cFileName,
- directory_entry::__create_iter_cached_result(detail::get_file_type(__data_),
- detail::get_file_size(__data_),
- detail::get_file_perm(__data_),
- detail::get_write_time(__data_)));
+ directory_entry::__create_iter_cached_result(
+ detail::get_file_type(__data_),
+ detail::get_file_size(__data_),
+ detail::get_file_perm(__data_),
+ detail::get_write_time(__data_)));
return true;
}
@@ -108,21 +106,18 @@ public:
#else
class __dir_stream {
public:
- __dir_stream() = delete;
+ __dir_stream() = delete;
__dir_stream& operator=(const __dir_stream&) = delete;
- __dir_stream(__dir_stream&& other) noexcept : __stream_(other.__stream_),
- __root_(std::move(other.__root_)),
- __entry_(std::move(other.__entry_)) {
+ __dir_stream(__dir_stream&& other) noexcept
+ : __stream_(other.__stream_), __root_(std::move(other.__root_)), __entry_(std::move(other.__entry_)) {
other.__stream_ = nullptr;
}
- __dir_stream(const path& root, directory_options opts, error_code& ec)
- : __stream_(nullptr), __root_(root) {
+ __dir_stream(const path& root, directory_options opts, error_code& ec) : __stream_(nullptr), __root_(root) {
if ((__stream_ = ::opendir(root.c_str())) == nullptr) {
- ec = detail::capture_errno();
- const bool allow_eacces =
- bool(opts & directory_options::skip_permission_denied);
+ ec = detail::capture_errno();
+ const bool allow_eacces = bool(opts & directory_options::skip_permission_denied);
if (allow_eacces && ec.value() == EACCES)
ec.clear();
return;
@@ -140,16 +135,14 @@ public:
bool advance(error_code& ec) {
while (true) {
auto str_type_pair = detail::posix_readdir(__stream_, ec);
- auto& str = str_type_pair.first;
+ auto& str = str_type_pair.first;
if (str == "." || str == "..") {
continue;
} else if (ec || str.empty()) {
close();
return false;
} else {
- __entry_.__assign_iter_entry(
- __root_ / str,
- directory_entry::__create_iter_result(str_type_pair.second));
+ __entry_.__assign_iter_entry(__root_ / str, directory_entry::__create_iter_result(str_type_pair.second));
return true;
}
}
@@ -174,8 +167,7 @@ public:
// directory_iterator
-directory_iterator::directory_iterator(const path& p, error_code* ec,
- directory_options opts) {
+directory_iterator::directory_iterator(const path& p, error_code* ec, directory_options opts) {
ErrorHandler<void> err("directory_iterator::directory_iterator(...)", ec, &p);
error_code m_ec;
@@ -215,8 +207,7 @@ struct recursive_directory_iterator::__shared_imp {
directory_options __options_;
};
-recursive_directory_iterator::recursive_directory_iterator(
- const path& p, directory_options opt, error_code* ec)
+recursive_directory_iterator::recursive_directory_iterator(const path& p, directory_options opt, error_code* ec)
: __imp_(nullptr), __rec_(true) {
ErrorHandler<void> err("recursive_directory_iterator", ec, &p);
@@ -227,7 +218,7 @@ recursive_directory_iterator::recursive_directory_iterator(
if (m_ec || !new_s.good())
return;
- __imp_ = make_shared<__shared_imp>();
+ __imp_ = make_shared<__shared_imp>();
__imp_->__options_ = opt;
__imp_->__stack_.push(std::move(new_s));
}
@@ -243,20 +234,13 @@ void recursive_directory_iterator::__pop(error_code* ec) {
__advance(ec);
}
-directory_options recursive_directory_iterator::options() const {
- return __imp_->__options_;
-}
+directory_options recursive_directory_iterator::options() const { return __imp_->__options_; }
-int recursive_directory_iterator::depth() const {
- return __imp_->__stack_.size() - 1;
-}
+int recursive_directory_iterator::depth() const { return __imp_->__stack_.size() - 1; }
-const directory_entry& recursive_directory_iterator::__dereference() const {
- return __imp_->__stack_.top().__entry_;
-}
+const directory_entry& recursive_directory_iterator::__dereference() const { return __imp_->__stack_.top().__entry_; }
-recursive_directory_iterator&
-recursive_directory_iterator::__increment(error_code* ec) {
+recursive_directory_iterator& recursive_directory_iterator::__increment(error_code* ec) {
if (ec)
ec->clear();
if (recursion_pending()) {
@@ -322,16 +306,14 @@ bool recursive_directory_iterator::__try_recursion(error_code* ec) {
}
}
if (m_ec) {
- const bool allow_eacess =
- bool(__imp_->__options_ & directory_options::skip_permission_denied);
+ const bool allow_eacess = bool(__imp_->__options_ & directory_options::skip_permission_denied);
if (m_ec.value() == EACCES && allow_eacess) {
if (ec)
ec->clear();
} else {
path at_ent = std::move(curr_it.__entry_.__p_);
__imp_.reset();
- err.report(m_ec, "attempting recursion into " PATH_CSTR_FMT,
- at_ent.c_str());
+ err.report(m_ec, "attempting recursion into " PATH_CSTR_FMT, at_ent.c_str());
}
}
return false;
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h
index 93da758761..b86f4ed410 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/error.h
@@ -23,9 +23,9 @@
#include "format_string.h"
#if defined(_LIBCPP_WIN32API)
-# define WIN32_LEAN_AND_MEAN
-# define NOMINMAX
-# include <windows.h> // ERROR_* macros
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <windows.h> // ERROR_* macros
#endif
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -90,7 +90,7 @@ inline errc __win_err_to_errc(int err) {
{ERROR_WRITE_PROTECT, errc::permission_denied},
};
- for (const auto &pair : win_error_mapping)
+ for (const auto& pair : win_error_mapping)
if (pair.win == static_cast<DWORD>(err))
return pair.errc;
return errc::invalid_argument;
@@ -104,9 +104,7 @@ inline error_code capture_errno() {
}
#if defined(_LIBCPP_WIN32API)
-inline error_code make_windows_error(int err) {
- return make_error_code(__win_err_to_errc(err));
-}
+inline error_code make_windows_error(int err) { return make_error_code(__win_err_to_errc(err)); }
#endif
template <class T>
@@ -143,8 +141,7 @@ struct ErrorHandler {
const path* p1_ = nullptr;
const path* p2_ = nullptr;
- ErrorHandler(const char* fname, error_code* ec, const path* p1 = nullptr,
- const path* p2 = nullptr)
+ ErrorHandler(const char* fname, error_code* ec, const path* p1 = nullptr, const path* p2 = nullptr)
: func_name_(fname), ec_(ec), p1_(p1), p2_(p2) {
if (ec_)
ec_->clear();
@@ -173,8 +170,7 @@ struct ErrorHandler {
*ec_ = ec;
return;
}
- string what =
- string("in ") + func_name_ + ": " + detail::vformat_string(msg, ap);
+ string what = string("in ") + func_name_ + ": " + detail::vformat_string(msg, ap);
switch (bool(p1_) + bool(p2_)) {
case 0:
__throw_filesystem_error(what, ec);
@@ -204,9 +200,7 @@ struct ErrorHandler {
return error_value<T>();
}
- T report(errc const& err) const {
- return report(make_error_code(err));
- }
+ T report(errc const& err) const { return report(make_error_code(err)); }
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4)
T report(errc const& err, const char* msg, ...) const {
@@ -227,7 +221,7 @@ struct ErrorHandler {
}
private:
- ErrorHandler(ErrorHandler const&) = delete;
+ ErrorHandler(ErrorHandler const&) = delete;
ErrorHandler& operator=(ErrorHandler const&) = delete;
};
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/file_descriptor.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/file_descriptor.h
index 03c52e76e6..2c9e0d7f47 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/file_descriptor.h
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/file_descriptor.h
@@ -21,15 +21,15 @@
#include "time_utils.h"
#if defined(_LIBCPP_WIN32API)
-# define WIN32_LEAN_AND_MEAN
-# define NOMINMAX
-# include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <windows.h>
#else
-# include <dirent.h> // for DIR & friends
-# include <fcntl.h> // values for fchmodat
-# include <sys/stat.h>
-# include <sys/statvfs.h>
-# include <unistd.h>
+# include <dirent.h> // for DIR & friends
+# include <fcntl.h> // values for fchmodat
+# include <sys/stat.h>
+# include <sys/statvfs.h>
+# include <unistd.h>
#endif // defined(_LIBCPP_WIN32API)
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -38,7 +38,7 @@ namespace detail {
#if !defined(_LIBCPP_WIN32API)
-#if defined(DT_BLK)
+# if defined(DT_BLK)
template <class DirEntT, class = decltype(DirEntT::d_type)>
file_type get_file_type(DirEntT* ent, int) {
switch (ent->d_type) {
@@ -64,17 +64,16 @@ file_type get_file_type(DirEntT* ent, int) {
}
return file_type::none;
}
-#endif // defined(DT_BLK)
+# endif // defined(DT_BLK)
template <class DirEntT>
file_type get_file_type(DirEntT*, long) {
return file_type::none;
}
-inline pair<string_view, file_type> posix_readdir(DIR* dir_stream,
- error_code& ec) {
+inline pair<string_view, file_type> posix_readdir(DIR* dir_stream, error_code& ec) {
struct dirent* dir_entry_ptr = nullptr;
- errno = 0; // zero errno in order to detect errors
+ errno = 0; // zero errno in order to detect errors
ec.clear();
if ((dir_entry_ptr = ::readdir(dir_stream)) == nullptr) {
if (errno)
@@ -88,8 +87,7 @@ inline pair<string_view, file_type> posix_readdir(DIR* dir_stream,
#else // _LIBCPP_WIN32API
inline file_type get_file_type(const WIN32_FIND_DATAW& data) {
- if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT &&
- data.dwReserved0 == IO_REPARSE_TAG_SYMLINK)
+ if (data.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT && data.dwReserved0 == IO_REPARSE_TAG_SYMLINK)
return file_type::symlink;
if (data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
return file_type::directory;
@@ -101,7 +99,7 @@ inline uintmax_t get_file_size(const WIN32_FIND_DATAW& data) {
inline file_time_type get_write_time(const WIN32_FIND_DATAW& data) {
using detail::fs_time;
const FILETIME& time = data.ftLastWriteTime;
- auto ts = filetime_to_timespec(time);
+ auto ts = filetime_to_timespec(time);
if (!fs_time::is_representable(ts))
return file_time_type::min();
return fs_time::convert_from_timespec(ts);
@@ -117,7 +115,7 @@ inline perms get_file_perm(const WIN32_FIND_DATAW& data) {
// POSIX HELPERS
-using value_type = path::value_type;
+using value_type = path::value_type;
using string_type = path::string_type;
struct FileDescriptor {
@@ -156,8 +154,7 @@ struct FileDescriptor {
}
template <class... Args>
- static FileDescriptor create_with_status(const path* p, error_code& ec,
- Args... args) {
+ static FileDescriptor create_with_status(const path* p, error_code& ec, Args... args) {
FileDescriptor fd = create(p, ec, args...);
if (!ec)
fd.refresh_status(ec);
@@ -185,27 +182,23 @@ struct FileDescriptor {
}
FileDescriptor(FileDescriptor&& other)
- : name(other.name), fd(other.fd), m_stat(other.m_stat),
- m_status(other.m_status) {
- other.fd = -1;
+ : name(other.name), fd(other.fd), m_stat(other.m_stat), m_status(other.m_status) {
+ other.fd = -1;
other.m_status = file_status{};
}
~FileDescriptor() { close(); }
- FileDescriptor(FileDescriptor const&) = delete;
+ FileDescriptor(FileDescriptor const&) = delete;
FileDescriptor& operator=(FileDescriptor const&) = delete;
private:
explicit FileDescriptor(const path* p, int descriptor = -1) : name(*p), fd(descriptor) {}
};
-inline perms posix_get_perms(const StatT& st) noexcept {
- return static_cast<perms>(st.st_mode) & perms::mask;
-}
+inline perms posix_get_perms(const StatT& st) noexcept { return static_cast<perms>(st.st_mode) & perms::mask; }
-inline file_status create_file_status(error_code& m_ec, path const& p,
- const StatT& path_stat, error_code* ec) {
+inline file_status create_file_status(error_code& m_ec, path const& p, const StatT& path_stat, error_code* ec) {
if (ec)
*ec = m_ec;
if (m_ec && (m_ec.value() == ENOENT || m_ec.value() == ENOTDIR)) {
@@ -290,7 +283,7 @@ inline bool stat_equivalent(const StatT& st1, const StatT& st2) {
inline file_status FileDescriptor::refresh_status(error_code& ec) {
// FD must be open and good.
m_status = file_status{};
- m_stat = {};
+ m_stat = {};
error_code m_ec;
if (detail::fstat(fd, &m_stat) == -1)
m_ec = capture_errno();
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_clock.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_clock.cpp
index fbb19ac68d..e13b2853e3 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_clock.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_clock.cpp
@@ -16,21 +16,21 @@
#endif
#if defined(_LIBCPP_WIN32API)
-# define WIN32_LEAN_AND_MEAN
-# define NOMINMAX
-# include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <windows.h>
#endif
#if __has_include(<unistd.h>)
-# include <unistd.h> // _POSIX_TIMERS
+# include <unistd.h> // _POSIX_TIMERS
#endif
#if __has_include(<sys/time.h>)
-# include <sys/time.h> // for gettimeofday and timeval
+# include <sys/time.h> // for gettimeofday and timeval
#endif
-#if defined(__APPLE__) || defined (__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
-# define _LIBCPP_HAS_CLOCK_GETTIME
+#if defined(__APPLE__) || defined(__gnu_hurd__) || (defined(_POSIX_TIMERS) && _POSIX_TIMERS > 0)
+# define _LIBCPP_HAS_CLOCK_GETTIME
#endif
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -44,15 +44,13 @@ _FilesystemClock::time_point _FilesystemClock::now() noexcept {
FILETIME time;
GetSystemTimeAsFileTime(&time);
detail::TimeSpec tp = detail::filetime_to_timespec(time);
- return time_point(__secs(tp.tv_sec) +
- chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));
+ return time_point(__secs(tp.tv_sec) + chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));
#elif defined(_LIBCPP_HAS_CLOCK_GETTIME)
typedef chrono::duration<rep, nano> __nsecs;
struct timespec tp;
if (0 != clock_gettime(CLOCK_REALTIME, &tp))
__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
- return time_point(__secs(tp.tv_sec) +
- chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));
+ return time_point(__secs(tp.tv_sec) + chrono::duration_cast<duration>(__nsecs(tp.tv_nsec)));
#else
typedef chrono::duration<rep, micro> __microsecs;
timeval tv;
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_error.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_error.cpp
index 5faed3b89e..456b902c33 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_error.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/filesystem_error.cpp
@@ -19,16 +19,18 @@ filesystem_error::~filesystem_error() {}
void filesystem_error::__create_what(int __num_paths) {
const char* derived_what = system_error::what();
- __storage_->__what_ = [&]() -> string {
+ __storage_->__what_ = [&]() -> string {
switch (__num_paths) {
case 0:
return detail::format_string("filesystem error: %s", derived_what);
case 1:
- return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "]",
- derived_what, path1().c_str());
+ return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "]", derived_what, path1().c_str());
case 2:
- return detail::format_string("filesystem error: %s [" PATH_CSTR_FMT "] [" PATH_CSTR_FMT "]",
- derived_what, path1().c_str(), path2().c_str());
+ return detail::format_string(
+ "filesystem error: %s [" PATH_CSTR_FMT "] [" PATH_CSTR_FMT "]",
+ derived_what,
+ path1().c_str(),
+ path2().c_str());
}
__libcpp_unreachable();
}();
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/int128_builtins.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/int128_builtins.cpp
index 96bcc5fa67..72b7cb4a8d 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/int128_builtins.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/int128_builtins.cpp
@@ -18,13 +18,13 @@
#if !defined(_LIBCPP_HAS_NO_INT128)
-extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI
-__int128_t __muloti4(__int128_t a, __int128_t b, int* overflow) {
- const int N = (int)(sizeof(__int128_t) * CHAR_BIT);
+extern "C" __attribute__((no_sanitize("undefined"))) _LIBCPP_EXPORTED_FROM_ABI __int128_t
+__muloti4(__int128_t a, __int128_t b, int* overflow) {
+ const int N = (int)(sizeof(__int128_t) * CHAR_BIT);
const __int128_t MIN = (__int128_t)1 << (N - 1);
const __int128_t MAX = ~MIN;
- *overflow = 0;
- __int128_t result = a * b;
+ *overflow = 0;
+ __int128_t result = a * b;
if (a == MIN) {
if (b != 0 && b != 1)
*overflow = 1;
@@ -35,9 +35,9 @@ __int128_t __muloti4(__int128_t a, __int128_t b, int* overflow) {
*overflow = 1;
return result;
}
- __int128_t sa = a >> (N - 1);
+ __int128_t sa = a >> (N - 1);
__int128_t abs_a = (a ^ sa) - sa;
- __int128_t sb = b >> (N - 1);
+ __int128_t sb = b >> (N - 1);
__int128_t abs_b = (b ^ sb) - sb;
if (abs_a < 2 || abs_b < 2)
return result;
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp
index 61f2cc572e..1b9f260580 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/operations.cpp
@@ -25,31 +25,31 @@
#include "time_utils.h"
#if defined(_LIBCPP_WIN32API)
-# define WIN32_LEAN_AND_MEAN
-# define NOMINMAX
-# include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <windows.h>
#else
-# include <dirent.h>
-# include <sys/stat.h>
-# include <sys/statvfs.h>
-# include <unistd.h>
+# include <dirent.h>
+# include <sys/stat.h>
+# include <sys/statvfs.h>
+# include <unistd.h>
#endif
-#include <time.h>
#include <fcntl.h> /* values for fchmodat */
+#include <time.h>
#if __has_include(<sys/sendfile.h>) && !defined(__EMSCRIPTEN__)
-# include <sys/sendfile.h>
-# define _LIBCPP_FILESYSTEM_USE_SENDFILE
+# include <sys/sendfile.h>
+# define _LIBCPP_FILESYSTEM_USE_SENDFILE
#elif defined(__APPLE__) || __has_include(<copyfile.h>)
-# include <copyfile.h>
-# define _LIBCPP_FILESYSTEM_USE_COPYFILE
+# include <copyfile.h>
+# define _LIBCPP_FILESYSTEM_USE_COPYFILE
#else
-# include <fstream>
-# define _LIBCPP_FILESYSTEM_USE_FSTREAM
+# include <fstream>
+# define _LIBCPP_FILESYSTEM_USE_FSTREAM
#endif
#if defined(__ELF__) && defined(_LIBCPP_LINK_RT_LIB)
-# pragma comment(lib, "rt")
+# pragma comment(lib, "rt")
#endif
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -84,17 +84,16 @@ path __canonical(path const& orig_p, error_code* ec) {
path p = __do_absolute(orig_p, &cwd, ec);
#if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112) || defined(_LIBCPP_WIN32API)
- std::unique_ptr<path::value_type, decltype(&::free)>
- hold(detail::realpath(p.c_str(), nullptr), &::free);
+ std::unique_ptr<path::value_type, decltype(&::free)> hold(detail::realpath(p.c_str(), nullptr), &::free);
if (hold.get() == nullptr)
return err.report(capture_errno());
return {hold.get()};
#else
- #if defined(__MVS__) && !defined(PATH_MAX)
- path::value_type buff[ _XOPEN_PATH_MAX + 1 ];
- #else
- path::value_type buff[PATH_MAX + 1];
- #endif
+# if defined(__MVS__) && !defined(PATH_MAX)
+ path::value_type buff[_XOPEN_PATH_MAX + 1];
+# else
+ path::value_type buff[PATH_MAX + 1];
+# endif
path::value_type* ret;
if ((ret = detail::realpath(p.c_str(), buff)) == nullptr)
return err.report(capture_errno());
@@ -102,32 +101,27 @@ path __canonical(path const& orig_p, error_code* ec) {
#endif
}
-void __copy(const path& from, const path& to, copy_options options,
- error_code* ec) {
+void __copy(const path& from, const path& to, copy_options options, error_code* ec) {
ErrorHandler<void> err("copy", ec, &from, &to);
- const bool sym_status = bool(
- options & (copy_options::create_symlinks | copy_options::skip_symlinks));
+ const bool sym_status = bool(options & (copy_options::create_symlinks | copy_options::skip_symlinks));
const bool sym_status2 = bool(options & copy_options::copy_symlinks);
error_code m_ec1;
StatT f_st = {};
- const file_status f = sym_status || sym_status2
- ? detail::posix_lstat(from, f_st, &m_ec1)
- : detail::posix_stat(from, f_st, &m_ec1);
+ const file_status f =
+ sym_status || sym_status2 ? detail::posix_lstat(from, f_st, &m_ec1) : detail::posix_stat(from, f_st, &m_ec1);
if (m_ec1)
return err.report(m_ec1);
- StatT t_st = {};
- const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec1)
- : detail::posix_stat(to, t_st, &m_ec1);
+ StatT t_st = {};
+ const file_status t = sym_status ? detail::posix_lstat(to, t_st, &m_ec1) : detail::posix_stat(to, t_st, &m_ec1);
if (not status_known(t))
return err.report(m_ec1);
- if (!exists(f) || is_other(f) || is_other(t) ||
- (is_directory(f) && is_regular_file(t)) ||
+ if (!exists(f) || is_other(f) || is_other(t) || (is_directory(f) && is_regular_file(t)) ||
detail::stat_equivalent(f_st, t_st)) {
return err.report(errc::function_not_supported);
}
@@ -159,9 +153,7 @@ void __copy(const path& from, const path& to, copy_options options,
return;
} else if (is_directory(f) && bool(copy_options::create_symlinks & options)) {
return err.report(errc::is_a_directory);
- } else if (is_directory(f) && (bool(copy_options::recursive & options) ||
- copy_options::none == options)) {
-
+ } else if (is_directory(f) && (bool(copy_options::recursive & options) || copy_options::none == options)) {
if (!exists(t)) {
// create directory to with attributes from 'from'.
__create_directory(to, from, ec);
@@ -169,8 +161,7 @@ void __copy(const path& from, const path& to, copy_options options,
return;
}
}
- directory_iterator it =
- ec ? directory_iterator(from, *ec) : directory_iterator(from);
+ directory_iterator it = ec ? directory_iterator(from, *ec) : directory_iterator(from);
if (ec && *ec) {
return;
}
@@ -179,8 +170,7 @@ void __copy(const path& from, const path& to, copy_options options,
if (m_ec2) {
return err.report(m_ec2);
}
- __copy(it->path(), to / it->path().filename(),
- options | copy_options::__in_recursive_copy, ec);
+ __copy(it->path(), to / it->path().filename(), options | copy_options::__in_recursive_copy, ec);
if (ec && *ec) {
return;
}
@@ -192,95 +182,93 @@ namespace detail {
namespace {
#if defined(_LIBCPP_FILESYSTEM_USE_SENDFILE)
- bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
- size_t count = read_fd.get_stat().st_size;
- do {
- ssize_t res;
- if ((res = ::sendfile(write_fd.fd, read_fd.fd, nullptr, count)) == -1) {
- ec = capture_errno();
- return false;
- }
- count -= res;
- } while (count > 0);
-
- ec.clear();
-
- return true;
- }
-#elif defined(_LIBCPP_FILESYSTEM_USE_COPYFILE)
- bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
- struct CopyFileState {
- copyfile_state_t state;
- CopyFileState() { state = copyfile_state_alloc(); }
- ~CopyFileState() { copyfile_state_free(state); }
-
- private:
- CopyFileState(CopyFileState const&) = delete;
- CopyFileState& operator=(CopyFileState const&) = delete;
- };
-
- CopyFileState cfs;
- if (fcopyfile(read_fd.fd, write_fd.fd, cfs.state, COPYFILE_DATA) < 0) {
+bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
+ size_t count = read_fd.get_stat().st_size;
+ do {
+ ssize_t res;
+ if ((res = ::sendfile(write_fd.fd, read_fd.fd, nullptr, count)) == -1) {
ec = capture_errno();
return false;
}
+ count -= res;
+ } while (count > 0);
- ec.clear();
- return true;
+ ec.clear();
+
+ return true;
+}
+#elif defined(_LIBCPP_FILESYSTEM_USE_COPYFILE)
+bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
+ struct CopyFileState {
+ copyfile_state_t state;
+ CopyFileState() { state = copyfile_state_alloc(); }
+ ~CopyFileState() { copyfile_state_free(state); }
+
+ private:
+ CopyFileState(CopyFileState const&) = delete;
+ CopyFileState& operator=(CopyFileState const&) = delete;
+ };
+
+ CopyFileState cfs;
+ if (fcopyfile(read_fd.fd, write_fd.fd, cfs.state, COPYFILE_DATA) < 0) {
+ ec = capture_errno();
+ return false;
}
-#elif defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)
- bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
- ifstream in;
- in.__open(read_fd.fd, ios::binary);
- if (!in.is_open()) {
- // This assumes that __open didn't reset the error code.
- ec = capture_errno();
- return false;
- }
- read_fd.fd = -1;
- ofstream out;
- out.__open(write_fd.fd, ios::binary);
- if (!out.is_open()) {
- ec = capture_errno();
- return false;
- }
- write_fd.fd = -1;
-
- if (in.good() && out.good()) {
- using InIt = istreambuf_iterator<char>;
- using OutIt = ostreambuf_iterator<char>;
- InIt bin(in);
- InIt ein;
- OutIt bout(out);
- copy(bin, ein, bout);
- }
- if (out.fail() || in.fail()) {
- ec = make_error_code(errc::io_error);
- return false;
- }
- ec.clear();
- return true;
+ ec.clear();
+ return true;
+}
+#elif defined(_LIBCPP_FILESYSTEM_USE_FSTREAM)
+bool copy_file_impl(FileDescriptor& read_fd, FileDescriptor& write_fd, error_code& ec) {
+ ifstream in;
+ in.__open(read_fd.fd, ios::binary);
+ if (!in.is_open()) {
+ // This assumes that __open didn't reset the error code.
+ ec = capture_errno();
+ return false;
+ }
+ read_fd.fd = -1;
+ ofstream out;
+ out.__open(write_fd.fd, ios::binary);
+ if (!out.is_open()) {
+ ec = capture_errno();
+ return false;
+ }
+ write_fd.fd = -1;
+
+ if (in.good() && out.good()) {
+ using InIt = istreambuf_iterator<char>;
+ using OutIt = ostreambuf_iterator<char>;
+ InIt bin(in);
+ InIt ein;
+ OutIt bout(out);
+ copy(bin, ein, bout);
+ }
+ if (out.fail() || in.fail()) {
+ ec = make_error_code(errc::io_error);
+ return false;
}
+
+ ec.clear();
+ return true;
+}
#else
-# error "Unknown implementation for copy_file_impl"
+# error "Unknown implementation for copy_file_impl"
#endif // copy_file_impl implementation
} // end anonymous namespace
} // end namespace detail
-bool __copy_file(const path& from, const path& to, copy_options options,
- error_code* ec) {
+bool __copy_file(const path& from, const path& to, copy_options options, error_code* ec) {
using detail::FileDescriptor;
ErrorHandler<bool> err("copy_file", ec, &to, &from);
error_code m_ec;
- FileDescriptor from_fd = FileDescriptor::create_with_status(
- &from, m_ec, O_RDONLY | O_NONBLOCK | O_BINARY);
+ FileDescriptor from_fd = FileDescriptor::create_with_status(&from, m_ec, O_RDONLY | O_NONBLOCK | O_BINARY);
if (m_ec)
return err.report(m_ec);
- auto from_st = from_fd.get_status();
+ auto from_st = from_fd.get_status();
StatT const& from_stat = from_fd.get_stat();
if (!is_regular_file(from_st)) {
if (not m_ec)
@@ -288,10 +276,9 @@ bool __copy_file(const path& from, const path& to, copy_options options,
return err.report(m_ec);
}
- const bool skip_existing = bool(copy_options::skip_existing & options);
- const bool update_existing = bool(copy_options::update_existing & options);
- const bool overwrite_existing =
- bool(copy_options::overwrite_existing & options);
+ const bool skip_existing = bool(copy_options::skip_existing & options);
+ const bool update_existing = bool(copy_options::update_existing & options);
+ const bool overwrite_existing = bool(copy_options::overwrite_existing & options);
StatT to_stat_path;
file_status to_st = detail::posix_stat(to, to_stat_path, &m_ec);
@@ -311,11 +298,10 @@ bool __copy_file(const path& from, const path& to, copy_options options,
bool ShouldCopy = [&]() {
if (to_exists && update_existing) {
auto from_time = detail::extract_mtime(from_stat);
- auto to_time = detail::extract_mtime(to_stat_path);
+ auto to_time = detail::extract_mtime(to_stat_path);
if (from_time.tv_sec < to_time.tv_sec)
return false;
- if (from_time.tv_sec == to_time.tv_sec &&
- from_time.tv_nsec <= to_time.tv_nsec)
+ if (from_time.tv_sec == to_time.tv_sec && from_time.tv_nsec <= to_time.tv_nsec)
return false;
return true;
}
@@ -331,8 +317,7 @@ bool __copy_file(const path& from, const path& to, copy_options options,
int to_open_flags = O_WRONLY | O_BINARY;
if (!to_exists)
to_open_flags |= O_CREAT;
- FileDescriptor to_fd = FileDescriptor::create_with_status(
- &to, m_ec, to_open_flags, from_stat.st_mode);
+ FileDescriptor to_fd = FileDescriptor::create_with_status(&to, m_ec, to_open_flags, from_stat.st_mode);
if (m_ec)
return err.report(m_ec);
@@ -358,8 +343,7 @@ bool __copy_file(const path& from, const path& to, copy_options options,
return true;
}
-void __copy_symlink(const path& existing_symlink, const path& new_symlink,
- error_code* ec) {
+void __copy_symlink(const path& existing_symlink, const path& new_symlink, error_code* ec) {
const path real_path(__read_symlink(existing_symlink, ec));
if (ec && *ec) {
return;
@@ -431,8 +415,7 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {
if (!status_known(st))
return err.report(mec);
if (!is_directory(st))
- return err.report(errc::not_a_directory,
- "the specified attribute path is invalid");
+ return err.report(errc::not_a_directory, "the specified attribute path is invalid");
if (detail::mkdir(p.c_str(), attr_stat.st_mode) == 0)
return true;
@@ -448,8 +431,7 @@ bool __create_directory(path const& p, path const& attributes, error_code* ec) {
return false;
}
-void __create_directory_symlink(path const& from, path const& to,
- error_code* ec) {
+void __create_directory_symlink(path const& from, path const& to, error_code* ec) {
ErrorHandler<void> err("create_directory_symlink", ec, &from, &to);
if (detail::symlink_dir(from.c_str(), to.c_str()) == -1)
return err.report(capture_errno());
@@ -473,7 +455,7 @@ path __current_path(error_code* ec) {
#if defined(_LIBCPP_WIN32API) || defined(__GLIBC__) || defined(__APPLE__)
// Common extension outside of POSIX getcwd() spec, without needing to
// preallocate a buffer. Also supported by a number of other POSIX libcs.
- int size = 0;
+ int size = 0;
path::value_type* ptr = nullptr;
typedef decltype(&::free) Deleter;
Deleter deleter = &::free;
@@ -481,17 +463,18 @@ path __current_path(error_code* ec) {
auto size = ::pathconf(".", _PC_PATH_MAX);
_LIBCPP_ASSERT_UNCATEGORIZED(size >= 0, "pathconf returned a 0 as max size");
- auto buff = unique_ptr<path::value_type[]>(new path::value_type[size + 1]);
+ auto buff = unique_ptr<path::value_type[]>(new path::value_type[size + 1]);
path::value_type* ptr = buff.get();
// Preallocated buffer, don't free the buffer in the second unique_ptr
// below.
- struct Deleter { void operator()(void*) const {} };
+ struct Deleter {
+ void operator()(void*) const {}
+ };
Deleter deleter;
#endif
- unique_ptr<path::value_type, Deleter> hold(detail::getcwd(ptr, size),
- deleter);
+ unique_ptr<path::value_type, Deleter> hold(detail::getcwd(ptr, size), deleter);
if (hold.get() == nullptr)
return err.report(capture_errno(), "call to getcwd failed");
@@ -526,8 +509,7 @@ uintmax_t __file_size(const path& p, error_code* ec) {
StatT st;
file_status fst = detail::posix_stat(p, st, &m_ec);
if (!exists(fst) || !is_regular_file(fst)) {
- errc error_kind =
- is_directory(fst) ? errc::is_a_directory : errc::not_supported;
+ errc error_kind = is_directory(fst) ? errc::is_a_directory : errc::not_supported;
if (!m_ec)
m_ec = make_error_code(error_kind);
return err.report(m_ec);
@@ -597,7 +579,7 @@ void __last_write_time(const path& p, file_time_type new_time, error_code* ec) {
#else
error_code m_ec;
array<TimeSpec, 2> tbuf;
-#if !defined(_LIBCPP_USE_UTIMENSAT)
+# if !defined(_LIBCPP_USE_UTIMENSAT)
// This implementation has a race condition between determining the
// last access time and attempting to set it to the same value using
// ::utimes
@@ -606,10 +588,10 @@ void __last_write_time(const path& p, file_time_type new_time, error_code* ec) {
if (m_ec)
return err.report(m_ec);
tbuf[0] = detail::extract_atime(st);
-#else
- tbuf[0].tv_sec = 0;
+# else
+ tbuf[0].tv_sec = 0;
tbuf[0].tv_nsec = UTIME_OMIT;
-#endif
+# endif
if (!fs_time::convert_to_timespec(tbuf[1], new_time))
return err.report(errc::value_too_large);
@@ -619,14 +601,13 @@ void __last_write_time(const path& p, file_time_type new_time, error_code* ec) {
#endif
}
-void __permissions(const path& p, perms prms, perm_options opts,
- error_code* ec) {
+void __permissions(const path& p, perms prms, perm_options opts, error_code* ec) {
ErrorHandler<void> err("permissions", ec, &p);
- auto has_opt = [&](perm_options o) { return bool(o & opts); };
+ auto has_opt = [&](perm_options o) { return bool(o & opts); };
const bool resolve_symlinks = !has_opt(perm_options::nofollow);
- const bool add_perms = has_opt(perm_options::add);
- const bool remove_perms = has_opt(perm_options::remove);
+ const bool add_perms = has_opt(perm_options::add);
+ const bool remove_perms = has_opt(perm_options::remove);
_LIBCPP_ASSERT_UNCATEGORIZED(
(add_perms + remove_perms + has_opt(perm_options::replace)) == 1,
"One and only one of the perm_options constants replace, add, or remove "
@@ -636,13 +617,11 @@ void __permissions(const path& p, perms prms, perm_options opts,
prms &= perms::mask;
if (!resolve_symlinks || (add_perms || remove_perms)) {
error_code m_ec;
- file_status st = resolve_symlinks ? detail::posix_stat(p, &m_ec)
- : detail::posix_lstat(p, &m_ec);
- set_sym_perms = is_symlink(st);
+ file_status st = resolve_symlinks ? detail::posix_stat(p, &m_ec) : detail::posix_lstat(p, &m_ec);
+ set_sym_perms = is_symlink(st);
if (m_ec)
return err.report(m_ec);
- _LIBCPP_ASSERT_UNCATEGORIZED(st.permissions() != perms::unknown,
- "Permissions unexpectedly unknown");
+ _LIBCPP_ASSERT_UNCATEGORIZED(st.permissions() != perms::unknown, "Permissions unexpectedly unknown");
if (add_perms)
prms |= st.permissions();
else if (remove_perms)
@@ -668,12 +647,14 @@ path __read_symlink(const path& p, error_code* ec) {
ErrorHandler<path> err("read_symlink", ec, &p);
#if defined(PATH_MAX) || defined(MAX_SYMLINK_SIZE)
- struct NullDeleter { void operator()(void*) const {} };
-#ifdef MAX_SYMLINK_SIZE
+ struct NullDeleter {
+ void operator()(void*) const {}
+ };
+# ifdef MAX_SYMLINK_SIZE
const size_t size = MAX_SYMLINK_SIZE + 1;
-#else
+# else
const size_t size = PATH_MAX + 1;
-#endif
+# endif
path::value_type stack_buff[size];
auto buff = std::unique_ptr<path::value_type[], NullDeleter>(stack_buff);
#else
@@ -682,7 +663,7 @@ path __read_symlink(const path& p, error_code* ec) {
return err.report(capture_errno());
}
const size_t size = sb.st_size + 1;
- auto buff = unique_ptr<path::value_type[]>(new path::value_type[size]);
+ auto buff = unique_ptr<path::value_type[]>(new path::value_type[size]);
#endif
detail::SSizeT ret;
if ((ret = detail::readlink(p.c_str(), buff.get(), size)) == -1)
@@ -711,8 +692,8 @@ bool __remove(const path& p, error_code* ec) {
//
// The second implementation is used on platforms where `openat()` & friends are available,
// and it threads file descriptors through recursive calls to avoid such race conditions.
-#if defined(_LIBCPP_WIN32API) || defined (__MVS__)
-# define REMOVE_ALL_USE_DIRECTORY_ITERATOR
+#if defined(_LIBCPP_WIN32API) || defined(__MVS__)
+# define REMOVE_ALL_USE_DIRECTORY_ITERATOR
#endif
#if defined(REMOVE_ALL_USE_DIRECTORY_ITERATOR)
@@ -720,14 +701,13 @@ bool __remove(const path& p, error_code* ec) {
namespace {
uintmax_t remove_all_impl(path const& p, error_code& ec) {
- const auto npos = static_cast<uintmax_t>(-1);
+ const auto npos = static_cast<uintmax_t>(-1);
const file_status st = __symlink_status(p, &ec);
if (ec)
return npos;
uintmax_t count = 1;
if (is_directory(st)) {
- for (directory_iterator it(p, ec); !ec && it != directory_iterator();
- it.increment(ec)) {
+ for (directory_iterator it(p, ec); !ec && it != directory_iterator(); it.increment(ec)) {
auto other_count = remove_all_impl(it->path(), ec);
if (ec)
return npos;
@@ -762,9 +742,7 @@ namespace {
template <class Cleanup>
struct scope_exit {
- explicit scope_exit(Cleanup const& cleanup)
- : cleanup_(cleanup)
- { }
+ explicit scope_exit(Cleanup const& cleanup) : cleanup_(cleanup) {}
~scope_exit() { cleanup_(); }
@@ -776,7 +754,7 @@ _LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scope_exit);
uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {
// First, try to open the path as a directory.
const int options = O_CLOEXEC | O_RDONLY | O_DIRECTORY | O_NOFOLLOW;
- int fd = ::openat(parent_directory, p.c_str(), options);
+ int fd = ::openat(parent_directory, p.c_str(), options);
if (fd != -1) {
// If that worked, iterate over the contents of the directory and
// remove everything in it, recursively.
@@ -826,7 +804,7 @@ uintmax_t remove_all_impl(int parent_directory, const path& p, error_code& ec) {
// or ELOOP depending on the exact reason of the failure.
if (ec == errc::not_a_directory || ec == errc::too_many_symbolic_link_levels) {
ec.clear();
- if (::unlinkat(parent_directory, p.c_str(), /* flags = */0) == -1) {
+ if (::unlinkat(parent_directory, p.c_str(), /* flags = */ 0) == -1) {
ec = detail::capture_errno();
return 0;
}
@@ -883,13 +861,9 @@ space_info __space(const path& p, error_code* ec) {
return si;
}
-file_status __status(const path& p, error_code* ec) {
- return detail::posix_stat(p, ec);
-}
+file_status __status(const path& p, error_code* ec) { return detail::posix_stat(p, ec); }
-file_status __symlink_status(const path& p, error_code* ec) {
- return detail::posix_lstat(p, ec);
-}
+file_status __symlink_status(const path& p, error_code* ec) { return detail::posix_lstat(p, ec); }
path __temp_directory_path(error_code* ec) {
ErrorHandler<path> err("temp_directory_path", ec);
@@ -903,22 +877,22 @@ path __temp_directory_path(error_code* ec) {
return err.report(errc::filename_too_long);
// GetTempPathW returns a path with a trailing slash, which we
// shouldn't include for consistency.
- if (buf[retval-1] == L'\\')
- buf[retval-1] = L'\0';
+ if (buf[retval - 1] == L'\\')
+ buf[retval - 1] = L'\0';
path p(buf);
#else
const char* env_paths[] = {"TMPDIR", "TMP", "TEMP", "TEMPDIR"};
- const char* ret = nullptr;
+ const char* ret = nullptr;
for (auto& ep : env_paths)
if ((ret = getenv(ep)))
break;
if (ret == nullptr) {
-#if defined(__ANDROID__)
+# if defined(__ANDROID__)
ret = "/data/local/tmp";
-#else
+# else
ret = "/tmp";
-#endif
+# endif
}
path p(ret);
@@ -929,8 +903,7 @@ path __temp_directory_path(error_code* ec) {
return err.report(m_ec, "cannot access path " PATH_CSTR_FMT, p.c_str());
if (!exists(st) || !is_directory(st))
- return err.report(errc::not_a_directory,
- "path " PATH_CSTR_FMT " is not a directory", p.c_str());
+ return err.report(errc::not_a_directory, "path " PATH_CSTR_FMT " is not a directory", p.c_str());
return p;
}
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/path.cpp b/contrib/libs/cxxsupp/libcxx/src/filesystem/path.cpp
index 82f1ba7ba6..c89346aa51 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/path.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/path.cpp
@@ -74,19 +74,16 @@ string_view_t path::__root_path_raw() const {
return {};
}
-static bool ConsumeRootName(PathParser *PP) {
- static_assert(PathParser::PS_BeforeBegin == 1 &&
- PathParser::PS_InRootName == 2,
- "Values for enums are incorrect");
+static bool ConsumeRootName(PathParser* PP) {
+ static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2, "Values for enums are incorrect");
while (PP->State <= PathParser::PS_InRootName)
++(*PP);
return PP->State == PathParser::PS_AtEnd;
}
static bool ConsumeRootDir(PathParser* PP) {
- static_assert(PathParser::PS_BeforeBegin == 1 &&
- PathParser::PS_InRootName == 2 &&
- PathParser::PS_InRootDir == 3, "Values for enums are incorrect");
+ static_assert(PathParser::PS_BeforeBegin == 1 && PathParser::PS_InRootName == 2 && PathParser::PS_InRootDir == 3,
+ "Values for enums are incorrect");
while (PP->State <= PathParser::PS_InRootDir)
++(*PP);
return PP->State == PathParser::PS_AtEnd;
@@ -132,25 +129,14 @@ string_view_t path::__filename() const {
return *(--PathParser::CreateEnd(__pn_));
}
-string_view_t path::__stem() const {
- return parser::separate_filename(__filename()).first;
-}
+string_view_t path::__stem() const { return parser::separate_filename(__filename()).first; }
-string_view_t path::__extension() const {
- return parser::separate_filename(__filename()).second;
-}
+string_view_t path::__extension() const { return parser::separate_filename(__filename()).second; }
////////////////////////////////////////////////////////////////////////////
// path.gen
-enum PathPartKind : unsigned char {
- PK_None,
- PK_RootSep,
- PK_Filename,
- PK_Dot,
- PK_DotDot,
- PK_TrailingSep
-};
+enum PathPartKind : unsigned char { PK_None, PK_RootSep, PK_Filename, PK_Dot, PK_DotDot, PK_TrailingSep };
static PathPartKind ClassifyPathPart(string_view_t Part) {
if (Part.empty())
@@ -180,7 +166,7 @@ path path::lexically_normal() const {
// Track the total size of the parts as we collect them. This allows the
// resulting path to reserve the correct amount of memory.
size_t NewPathSize = 0;
- auto AddPart = [&](PathPartKind K, string_view_t P) {
+ auto AddPart = [&](PathPartKind K, string_view_t P) {
NewPathSize += P.size();
Parts.emplace_back(P, K);
};
@@ -194,7 +180,7 @@ path path::lexically_normal() const {
// Build a stack containing the remaining elements of the path, popping off
// elements which occur before a '..' entry.
for (auto PP = PathParser::CreateBegin(__pn_); PP; ++PP) {
- auto Part = *PP;
+ auto Part = *PP;
PathPartKind Kind = ClassifyPathPart(Part);
switch (Kind) {
case PK_Filename:
@@ -259,11 +245,10 @@ static int DetermineLexicalElementCount(PathParser PP) {
path path::lexically_relative(const path& base) const {
{ // perform root-name/root-directory mismatch checks
- auto PP = PathParser::CreateBegin(__pn_);
- auto PPBase = PathParser::CreateBegin(base.__pn_);
+ auto PP = PathParser::CreateBegin(__pn_);
+ auto PPBase = PathParser::CreateBegin(base.__pn_);
auto CheckIterMismatchAtBase = [&]() {
- return PP.State != PPBase.State &&
- (PP.inRootPath() || PPBase.inRootPath());
+ return PP.State != PPBase.State && (PP.inRootPath() || PPBase.inRootPath());
};
if (PP.inRootName() && PPBase.inRootName()) {
if (*PP != *PPBase)
@@ -280,7 +265,7 @@ path path::lexically_relative(const path& base) const {
}
// Find the first mismatching element
- auto PP = PathParser::CreateBegin(__pn_);
+ auto PP = PathParser::CreateBegin(__pn_);
auto PPBase = PathParser::CreateBegin(base.__pn_);
while (PP && PPBase && PP.State == PPBase.State && *PP == *PPBase) {
++PP;
@@ -314,20 +299,18 @@ path path::lexically_relative(const path& base) const {
////////////////////////////////////////////////////////////////////////////
// path.comparisons
-static int CompareRootName(PathParser *LHS, PathParser *RHS) {
+static int CompareRootName(PathParser* LHS, PathParser* RHS) {
if (!LHS->inRootName() && !RHS->inRootName())
return 0;
- auto GetRootName = [](PathParser *Parser) -> string_view_t {
- return Parser->inRootName() ? **Parser : PATHSTR("");
- };
- int res = GetRootName(LHS).compare(GetRootName(RHS));
+ auto GetRootName = [](PathParser* Parser) -> string_view_t { return Parser->inRootName() ? **Parser : PATHSTR(""); };
+ int res = GetRootName(LHS).compare(GetRootName(RHS));
ConsumeRootName(LHS);
ConsumeRootName(RHS);
return res;
}
-static int CompareRootDir(PathParser *LHS, PathParser *RHS) {
+static int CompareRootDir(PathParser* LHS, PathParser* RHS) {
if (!LHS->inRootDir() && RHS->inRootDir())
return -1;
else if (LHS->inRootDir() && !RHS->inRootDir())
@@ -339,9 +322,9 @@ static int CompareRootDir(PathParser *LHS, PathParser *RHS) {
}
}
-static int CompareRelative(PathParser *LHSPtr, PathParser *RHSPtr) {
- auto &LHS = *LHSPtr;
- auto &RHS = *RHSPtr;
+static int CompareRelative(PathParser* LHSPtr, PathParser* RHSPtr) {
+ auto& LHS = *LHSPtr;
+ auto& RHS = *RHSPtr;
int res;
while (LHS && RHS) {
@@ -353,7 +336,7 @@ static int CompareRelative(PathParser *LHSPtr, PathParser *RHSPtr) {
return 0;
}
-static int CompareEndState(PathParser *LHS, PathParser *RHS) {
+static int CompareEndState(PathParser* LHS, PathParser* RHS) {
if (LHS->atEnd() && !RHS->atEnd())
return -1;
else if (!LHS->atEnd() && RHS->atEnd())
@@ -381,7 +364,7 @@ int path::__compare(string_view_t __s) const {
////////////////////////////////////////////////////////////////////////////
// path.nonmembers
size_t hash_value(const path& __p) noexcept {
- auto PP = PathParser::CreateBegin(__p.native());
+ auto PP = PathParser::CreateBegin(__p.native());
size_t hash_value = 0;
hash<string_view_t> hasher;
while (PP) {
@@ -397,15 +380,15 @@ path::iterator path::begin() const {
auto PP = PathParser::CreateBegin(__pn_);
iterator it;
it.__path_ptr_ = this;
- it.__state_ = static_cast<path::iterator::_ParserState>(PP.State);
- it.__entry_ = PP.RawEntry;
+ it.__state_ = static_cast<path::iterator::_ParserState>(PP.State);
+ it.__entry_ = PP.RawEntry;
it.__stashed_elem_.__assign_view(*PP);
return it;
}
path::iterator path::end() const {
iterator it{};
- it.__state_ = path::iterator::_AtEnd;
+ it.__state_ = path::iterator::_AtEnd;
it.__path_ptr_ = this;
return it;
}
@@ -431,26 +414,24 @@ path::iterator& path::iterator::__decrement() {
#if defined(_LIBCPP_WIN32API)
////////////////////////////////////////////////////////////////////////////
// Windows path conversions
-size_t __wide_to_char(const wstring &str, char *out, size_t outlen) {
+size_t __wide_to_char(const wstring& str, char* out, size_t outlen) {
if (str.empty())
return 0;
ErrorHandler<size_t> err("__wide_to_char", nullptr);
- UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
+ UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
BOOL used_default = FALSE;
- int ret = WideCharToMultiByte(codepage, 0, str.data(), str.size(), out,
- outlen, nullptr, &used_default);
+ int ret = WideCharToMultiByte(codepage, 0, str.data(), str.size(), out, outlen, nullptr, &used_default);
if (ret <= 0 || used_default)
return err.report(errc::illegal_byte_sequence);
return ret;
}
-size_t __char_to_wide(const string &str, wchar_t *out, size_t outlen) {
+size_t __char_to_wide(const string& str, wchar_t* out, size_t outlen) {
if (str.empty())
return 0;
ErrorHandler<size_t> err("__char_to_wide", nullptr);
UINT codepage = AreFileApisANSI() ? CP_ACP : CP_OEMCP;
- int ret = MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, str.data(),
- str.size(), out, outlen);
+ int ret = MultiByteToWideChar(codepage, MB_ERR_INVALID_CHARS, str.data(), str.size(), out, outlen);
if (ret <= 0)
return err.report(errc::illegal_byte_sequence);
return ret;
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/path_parser.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/path_parser.h
index 630391fe6b..a546604062 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/path_parser.h
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/path_parser.h
@@ -29,25 +29,23 @@ inline bool isSeparator(path::value_type C) {
return false;
}
-inline bool isDriveLetter(path::value_type C) {
- return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z');
-}
+inline bool isDriveLetter(path::value_type C) { return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z'); }
namespace parser {
-using string_view_t = path::__string_view;
+using string_view_t = path::__string_view;
using string_view_pair = pair<string_view_t, string_view_t>;
-using PosPtr = path::value_type const*;
+using PosPtr = path::value_type const*;
struct PathParser {
enum ParserState : unsigned char {
// Zero is a special sentinel value used by default constructed iterators.
- PS_BeforeBegin = path::iterator::_BeforeBegin,
- PS_InRootName = path::iterator::_InRootName,
- PS_InRootDir = path::iterator::_InRootDir,
- PS_InFilenames = path::iterator::_InFilenames,
+ PS_BeforeBegin = path::iterator::_BeforeBegin,
+ PS_InRootName = path::iterator::_InRootName,
+ PS_InRootDir = path::iterator::_InRootDir,
+ PS_InFilenames = path::iterator::_InFilenames,
PS_InTrailingSep = path::iterator::_InTrailingSep,
- PS_AtEnd = path::iterator::_AtEnd
+ PS_AtEnd = path::iterator::_AtEnd
};
const string_view_t Path;
@@ -55,8 +53,7 @@ struct PathParser {
ParserState State;
private:
- PathParser(string_view_t P, ParserState State) noexcept : Path(P),
- State(State) {}
+ PathParser(string_view_t P, ParserState State) noexcept : Path(P), State(State) {}
public:
PathParser(string_view_t P, string_view_t E, unsigned char S)
@@ -77,12 +74,12 @@ public:
PosPtr peek() const noexcept {
auto TkEnd = getNextTokenStartPos();
- auto End = getAfterBack();
+ auto End = getAfterBack();
return TkEnd == End ? nullptr : TkEnd;
}
void increment() noexcept {
- const PosPtr End = getAfterBack();
+ const PosPtr End = getAfterBack();
const PosPtr Start = getNextTokenStartPos();
if (Start == End)
return makeState(PS_AtEnd);
@@ -123,7 +120,7 @@ public:
}
void decrement() noexcept {
- const PosPtr REnd = getBeforeFront();
+ const PosPtr REnd = getBeforeFront();
const PosPtr RStart = getCurrentTokenStartPos() - 1;
if (RStart == REnd) // we're decrementing the begin
return makeState(PS_BeforeBegin);
@@ -147,8 +144,7 @@ public:
}
}
case PS_InTrailingSep:
- return makeState(PS_InFilenames, consumeName(RStart, REnd) + 1,
- RStart + 1);
+ return makeState(PS_InFilenames, consumeName(RStart, REnd) + 1, RStart + 1);
case PS_InFilenames: {
PosPtr SepEnd = consumeAllSeparators(RStart, REnd);
if (SepEnd == REnd)
@@ -191,9 +187,7 @@ public:
__libcpp_unreachable();
}
- explicit operator bool() const noexcept {
- return State != PS_BeforeBegin && State != PS_AtEnd;
- }
+ explicit operator bool() const noexcept { return State != PS_BeforeBegin && State != PS_AtEnd; }
PathParser& operator++() noexcept {
increment();
@@ -205,29 +199,21 @@ public:
return *this;
}
- bool atEnd() const noexcept {
- return State == PS_AtEnd;
- }
+ bool atEnd() const noexcept { return State == PS_AtEnd; }
- bool inRootDir() const noexcept {
- return State == PS_InRootDir;
- }
+ bool inRootDir() const noexcept { return State == PS_InRootDir; }
- bool inRootName() const noexcept {
- return State == PS_InRootName;
- }
+ bool inRootName() const noexcept { return State == PS_InRootName; }
- bool inRootPath() const noexcept {
- return inRootName() || inRootDir();
- }
+ bool inRootPath() const noexcept { return inRootName() || inRootDir(); }
private:
void makeState(ParserState NewState, PosPtr Start, PosPtr End) noexcept {
- State = NewState;
+ State = NewState;
RawEntry = string_view_t(Start, End - Start);
}
void makeState(ParserState NewState) noexcept {
- State = NewState;
+ State = NewState;
RawEntry = {};
}
@@ -346,9 +332,7 @@ private:
return nullptr;
}
#else
- PosPtr consumeRootName(PosPtr /*P*/, PosPtr /*End*/) const noexcept {
- return nullptr;
- }
+ PosPtr consumeRootName(PosPtr /*P*/, PosPtr /*End*/) const noexcept { return nullptr; }
#endif
};
@@ -361,9 +345,7 @@ inline string_view_pair separate_filename(string_view_t const& s) {
return string_view_pair{s.substr(0, pos), s.substr(pos)};
}
-inline string_view_t createView(PosPtr S, PosPtr E) noexcept {
- return {S, static_cast<size_t>(E - S) + 1};
-}
+inline string_view_t createView(PosPtr S, PosPtr E) noexcept { return {S, static_cast<size_t>(E - S) + 1}; }
} // namespace parser
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h
index fb213d9ec1..ec2de49960 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/posix_compat.h
@@ -31,17 +31,17 @@
#include "time_utils.h"
#if defined(_LIBCPP_WIN32API)
-# define WIN32_LEAN_AND_MEAN
-# define NOMINMAX
-# include <windows.h>
-# include <io.h>
-# include <winioctl.h>
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <io.h>
+# include <windows.h>
+# include <winioctl.h>
#else
-# include <fcntl.h>
-# include <unistd.h>
-# include <sys/stat.h>
-# include <sys/statvfs.h>
-# include <sys/time.h>
+# include <fcntl.h>
+# include <sys/stat.h>
+# include <sys/statvfs.h>
+# include <sys/time.h>
+# include <unistd.h>
#endif
#include <stdlib.h>
#include <time.h>
@@ -50,7 +50,7 @@
// This struct isn't defined in the normal Windows SDK, but only in the
// Windows Driver Kit.
struct LIBCPP_REPARSE_DATA_BUFFER {
- unsigned long ReparseTag;
+ unsigned long ReparseTag;
unsigned short ReparseDataLength;
unsigned short Reserved;
union {
@@ -59,15 +59,15 @@ struct LIBCPP_REPARSE_DATA_BUFFER {
unsigned short SubstituteNameLength;
unsigned short PrintNameOffset;
unsigned short PrintNameLength;
- unsigned long Flags;
- wchar_t PathBuffer[1];
+ unsigned long Flags;
+ wchar_t PathBuffer[1];
} SymbolicLinkReparseBuffer;
struct {
unsigned short SubstituteNameOffset;
unsigned short SubstituteNameLength;
unsigned short PrintNameOffset;
unsigned short PrintNameLength;
- wchar_t PathBuffer[1];
+ wchar_t PathBuffer[1];
} MountPointReparseBuffer;
struct {
unsigned char DataBuffer[1];
@@ -86,41 +86,41 @@ namespace detail {
// provide our own implementation, undef all potential defines from the
// C runtime headers and provide a complete set of macros of our own.
-#undef _S_IFMT
-#undef _S_IFDIR
-#undef _S_IFCHR
-#undef _S_IFIFO
-#undef _S_IFREG
-#undef _S_IFBLK
-#undef _S_IFLNK
-#undef _S_IFSOCK
-
-#define _S_IFMT 0xF000
-#define _S_IFDIR 0x4000
-#define _S_IFCHR 0x2000
-#define _S_IFIFO 0x1000
-#define _S_IFREG 0x8000
-#define _S_IFBLK 0x6000
-#define _S_IFLNK 0xA000
-#define _S_IFSOCK 0xC000
-
-#undef S_ISDIR
-#undef S_ISFIFO
-#undef S_ISCHR
-#undef S_ISREG
-#undef S_ISLNK
-#undef S_ISBLK
-#undef S_ISSOCK
-
-#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
-#define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
-#define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
-#define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
-#define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
-#define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
-#define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK)
-
-#define O_NONBLOCK 0
+# undef _S_IFMT
+# undef _S_IFDIR
+# undef _S_IFCHR
+# undef _S_IFIFO
+# undef _S_IFREG
+# undef _S_IFBLK
+# undef _S_IFLNK
+# undef _S_IFSOCK
+
+# define _S_IFMT 0xF000
+# define _S_IFDIR 0x4000
+# define _S_IFCHR 0x2000
+# define _S_IFIFO 0x1000
+# define _S_IFREG 0x8000
+# define _S_IFBLK 0x6000
+# define _S_IFLNK 0xA000
+# define _S_IFSOCK 0xC000
+
+# undef S_ISDIR
+# undef S_ISFIFO
+# undef S_ISCHR
+# undef S_ISREG
+# undef S_ISLNK
+# undef S_ISBLK
+# undef S_ISSOCK
+
+# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
+# define S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
+# define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
+# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
+# define S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
+# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
+# define S_ISSOCK(m) (((m) & _S_IFMT) == _S_IFSOCK)
+
+# define O_NONBLOCK 0
inline int set_errno(int e = GetLastError()) {
errno = static_cast<int>(__win_err_to_errc(e));
@@ -129,10 +129,15 @@ inline int set_errno(int e = GetLastError()) {
class WinHandle {
public:
- WinHandle(const wchar_t *p, DWORD access, DWORD flags) {
+ WinHandle(const wchar_t* p, DWORD access, DWORD flags) {
h = CreateFileW(
- p, access, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
- nullptr, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS | flags, nullptr);
+ p,
+ access,
+ FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
+ nullptr,
+ OPEN_EXISTING,
+ FILE_FLAG_BACKUP_SEMANTICS | flags,
+ nullptr);
}
~WinHandle() {
if (h != INVALID_HANDLE_VALUE)
@@ -145,7 +150,7 @@ private:
HANDLE h;
};
-inline int stat_handle(HANDLE h, StatT *buf) {
+inline int stat_handle(HANDLE h, StatT* buf) {
FILE_BASIC_INFO basic;
if (!GetFileInformationByHandleEx(h, FileBasicInfo, &basic, sizeof(basic)))
return set_errno();
@@ -162,18 +167,16 @@ inline int stat_handle(HANDLE h, StatT *buf) {
}
if (basic.FileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
FILE_ATTRIBUTE_TAG_INFO tag;
- if (!GetFileInformationByHandleEx(h, FileAttributeTagInfo, &tag,
- sizeof(tag)))
+ if (!GetFileInformationByHandleEx(h, FileAttributeTagInfo, &tag, sizeof(tag)))
return set_errno();
if (tag.ReparseTag == IO_REPARSE_TAG_SYMLINK)
buf->st_mode = (buf->st_mode & ~_S_IFMT) | _S_IFLNK;
}
FILE_STANDARD_INFO standard;
- if (!GetFileInformationByHandleEx(h, FileStandardInfo, &standard,
- sizeof(standard)))
+ if (!GetFileInformationByHandleEx(h, FileStandardInfo, &standard, sizeof(standard)))
return set_errno();
buf->st_nlink = standard.NumberOfLinks;
- buf->st_size = standard.EndOfFile.QuadPart;
+ buf->st_size = standard.EndOfFile.QuadPart;
BY_HANDLE_FILE_INFORMATION info;
if (!GetFileInformationByHandle(h, &info))
return set_errno();
@@ -183,7 +186,7 @@ inline int stat_handle(HANDLE h, StatT *buf) {
return 0;
}
-inline int stat_file(const wchar_t *path, StatT *buf, DWORD flags) {
+inline int stat_file(const wchar_t* path, StatT* buf, DWORD flags) {
WinHandle h(path, FILE_READ_ATTRIBUTES, flags);
if (!h)
return set_errno();
@@ -191,32 +194,28 @@ inline int stat_file(const wchar_t *path, StatT *buf, DWORD flags) {
return ret;
}
-inline int stat(const wchar_t *path, StatT *buf) { return stat_file(path, buf, 0); }
+inline int stat(const wchar_t* path, StatT* buf) { return stat_file(path, buf, 0); }
-inline int lstat(const wchar_t *path, StatT *buf) {
- return stat_file(path, buf, FILE_FLAG_OPEN_REPARSE_POINT);
-}
+inline int lstat(const wchar_t* path, StatT* buf) { return stat_file(path, buf, FILE_FLAG_OPEN_REPARSE_POINT); }
-inline int fstat(int fd, StatT *buf) {
+inline int fstat(int fd, StatT* buf) {
HANDLE h = reinterpret_cast<HANDLE>(_get_osfhandle(fd));
return stat_handle(h, buf);
}
-inline int mkdir(const wchar_t *path, int permissions) {
+inline int mkdir(const wchar_t* path, int permissions) {
(void)permissions;
if (!CreateDirectoryW(path, nullptr))
return set_errno();
return 0;
}
-inline int symlink_file_dir(const wchar_t *oldname, const wchar_t *newname,
- bool is_dir) {
+inline int symlink_file_dir(const wchar_t* oldname, const wchar_t* newname, bool is_dir) {
path dest(oldname);
dest.make_preferred();
- oldname = dest.c_str();
+ oldname = dest.c_str();
DWORD flags = is_dir ? SYMBOLIC_LINK_FLAG_DIRECTORY : 0;
- if (CreateSymbolicLinkW(newname, oldname,
- flags | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE))
+ if (CreateSymbolicLinkW(newname, oldname, flags | SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE))
return 0;
int e = GetLastError();
if (e != ERROR_INVALID_PARAMETER)
@@ -226,21 +225,21 @@ inline int symlink_file_dir(const wchar_t *oldname, const wchar_t *newname,
return set_errno();
}
-inline int symlink_file(const wchar_t *oldname, const wchar_t *newname) {
+inline int symlink_file(const wchar_t* oldname, const wchar_t* newname) {
return symlink_file_dir(oldname, newname, false);
}
-inline int symlink_dir(const wchar_t *oldname, const wchar_t *newname) {
+inline int symlink_dir(const wchar_t* oldname, const wchar_t* newname) {
return symlink_file_dir(oldname, newname, true);
}
-inline int link(const wchar_t *oldname, const wchar_t *newname) {
+inline int link(const wchar_t* oldname, const wchar_t* newname) {
if (CreateHardLinkW(newname, oldname, nullptr))
return 0;
return set_errno();
}
-inline int remove(const wchar_t *path) {
+inline int remove(const wchar_t* path) {
detail::WinHandle h(path, DELETE, FILE_FLAG_OPEN_REPARSE_POINT);
if (!h)
return set_errno();
@@ -266,17 +265,15 @@ inline int ftruncate(int fd, off_t length) {
return truncate_handle(h, length);
}
-inline int truncate(const wchar_t *path, off_t length) {
+inline int truncate(const wchar_t* path, off_t length) {
detail::WinHandle h(path, GENERIC_WRITE, 0);
if (!h)
return set_errno();
return truncate_handle(h, length);
}
-inline int rename(const wchar_t *from, const wchar_t *to) {
- if (!(MoveFileExW(from, to,
- MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING |
- MOVEFILE_WRITE_THROUGH)))
+inline int rename(const wchar_t* from, const wchar_t* to) {
+ if (!(MoveFileExW(from, to, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH)))
return set_errno();
return 0;
}
@@ -294,7 +291,7 @@ struct StatVFS {
uint64_t f_bavail;
};
-inline int statvfs(const wchar_t *p, StatVFS *buf) {
+inline int statvfs(const wchar_t* p, StatVFS* buf) {
path dir = p;
while (true) {
error_code local_ec;
@@ -308,14 +305,13 @@ inline int statvfs(const wchar_t *p, StatVFS *buf) {
}
dir = parent;
}
- ULARGE_INTEGER free_bytes_available_to_caller, total_number_of_bytes,
- total_number_of_free_bytes;
- if (!GetDiskFreeSpaceExW(dir.c_str(), &free_bytes_available_to_caller,
- &total_number_of_bytes, &total_number_of_free_bytes))
+ ULARGE_INTEGER free_bytes_available_to_caller, total_number_of_bytes, total_number_of_free_bytes;
+ if (!GetDiskFreeSpaceExW(
+ dir.c_str(), &free_bytes_available_to_caller, &total_number_of_bytes, &total_number_of_free_bytes))
return set_errno();
buf->f_frsize = 1;
buf->f_blocks = total_number_of_bytes.QuadPart;
- buf->f_bfree = total_number_of_free_bytes.QuadPart;
+ buf->f_bfree = total_number_of_free_bytes.QuadPart;
buf->f_bavail = free_bytes_available_to_caller.QuadPart;
return 0;
}
@@ -340,10 +336,9 @@ inline wchar_t* getcwd([[maybe_unused]] wchar_t* in_buf, [[maybe_unused]] size_t
return buff.release();
}
-inline wchar_t *realpath(const wchar_t *path, [[maybe_unused]] wchar_t *resolved_name) {
+inline wchar_t* realpath(const wchar_t* path, [[maybe_unused]] wchar_t* resolved_name) {
// Only expected to be used with us allocating the buffer.
- _LIBCPP_ASSERT_UNCATEGORIZED(resolved_name == nullptr,
- "Windows realpath() assumes a null resolved_name");
+ _LIBCPP_ASSERT_UNCATEGORIZED(resolved_name == nullptr, "Windows realpath() assumes a null resolved_name");
WinHandle h(path, FILE_READ_ATTRIBUTES, 0);
if (!h) {
@@ -351,21 +346,18 @@ inline wchar_t *realpath(const wchar_t *path, [[maybe_unused]] wchar_t *resolved
return nullptr;
}
size_t buff_size = MAX_PATH + 10;
- std::unique_ptr<wchar_t, decltype(&::free)> buff(
- static_cast<wchar_t *>(malloc(buff_size * sizeof(wchar_t))), &::free);
- DWORD retval = GetFinalPathNameByHandleW(
- h, buff.get(), buff_size, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
+ std::unique_ptr<wchar_t, decltype(&::free)> buff(static_cast<wchar_t*>(malloc(buff_size * sizeof(wchar_t))), &::free);
+ DWORD retval = GetFinalPathNameByHandleW(h, buff.get(), buff_size, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
if (retval > buff_size) {
buff_size = retval;
- buff.reset(static_cast<wchar_t *>(malloc(buff_size * sizeof(wchar_t))));
- retval = GetFinalPathNameByHandleW(h, buff.get(), buff_size,
- FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
+ buff.reset(static_cast<wchar_t*>(malloc(buff_size * sizeof(wchar_t))));
+ retval = GetFinalPathNameByHandleW(h, buff.get(), buff_size, FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
}
if (!retval) {
set_errno();
return nullptr;
}
- wchar_t *ptr = buff.get();
+ wchar_t* ptr = buff.get();
if (!wcsncmp(ptr, L"\\\\?\\", 4)) {
if (ptr[5] == ':') { // \\?\X: -> X:
memmove(&ptr[0], &ptr[4], (wcslen(&ptr[4]) + 1) * sizeof(wchar_t));
@@ -377,8 +369,8 @@ inline wchar_t *realpath(const wchar_t *path, [[maybe_unused]] wchar_t *resolved
return buff.release();
}
-#define AT_FDCWD -1
-#define AT_SYMLINK_NOFOLLOW 1
+# define AT_FDCWD -1
+# define AT_SYMLINK_NOFOLLOW 1
using ModeT = int;
inline int fchmod_handle(HANDLE h, int perms) {
@@ -389,18 +381,16 @@ inline int fchmod_handle(HANDLE h, int perms) {
basic.FileAttributes &= ~FILE_ATTRIBUTE_READONLY;
if ((perms & 0222) == 0)
basic.FileAttributes |= FILE_ATTRIBUTE_READONLY;
- if (basic.FileAttributes != orig_attributes &&
- !SetFileInformationByHandle(h, FileBasicInfo, &basic, sizeof(basic)))
+ if (basic.FileAttributes != orig_attributes && !SetFileInformationByHandle(h, FileBasicInfo, &basic, sizeof(basic)))
return set_errno();
return 0;
}
-inline int fchmodat(int /*fd*/, const wchar_t *path, int perms, int flag) {
+inline int fchmodat(int /*fd*/, const wchar_t* path, int perms, int flag) {
DWORD attributes = GetFileAttributesW(path);
if (attributes == INVALID_FILE_ATTRIBUTES)
return set_errno();
- if (attributes & FILE_ATTRIBUTE_REPARSE_POINT &&
- !(flag & AT_SYMLINK_NOFOLLOW)) {
+ if (attributes & FILE_ATTRIBUTE_REPARSE_POINT && !(flag & AT_SYMLINK_NOFOLLOW)) {
// If the file is a symlink, and we are supposed to operate on the target
// of the symlink, we need to open a handle to it, without the
// FILE_FLAG_OPEN_REPARSE_POINT flag, to open the destination of the
@@ -427,21 +417,19 @@ inline int fchmod(int fd, int perms) {
return fchmod_handle(h, perms);
}
-#define MAX_SYMLINK_SIZE MAXIMUM_REPARSE_DATA_BUFFER_SIZE
+# define MAX_SYMLINK_SIZE MAXIMUM_REPARSE_DATA_BUFFER_SIZE
using SSizeT = ::int64_t;
-inline SSizeT readlink(const wchar_t *path, wchar_t *ret_buf, size_t bufsize) {
+inline SSizeT readlink(const wchar_t* path, wchar_t* ret_buf, size_t bufsize) {
uint8_t buf[MAXIMUM_REPARSE_DATA_BUFFER_SIZE];
detail::WinHandle h(path, FILE_READ_ATTRIBUTES, FILE_FLAG_OPEN_REPARSE_POINT);
if (!h)
return set_errno();
DWORD out;
- if (!DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf, sizeof(buf),
- &out, 0))
+ if (!DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, nullptr, 0, buf, sizeof(buf), &out, 0))
return set_errno();
- const auto *reparse = reinterpret_cast<LIBCPP_REPARSE_DATA_BUFFER *>(buf);
- size_t path_buf_offset = offsetof(LIBCPP_REPARSE_DATA_BUFFER,
- SymbolicLinkReparseBuffer.PathBuffer[0]);
+ const auto* reparse = reinterpret_cast<LIBCPP_REPARSE_DATA_BUFFER*>(buf);
+ size_t path_buf_offset = offsetof(LIBCPP_REPARSE_DATA_BUFFER, SymbolicLinkReparseBuffer.PathBuffer[0]);
if (out < path_buf_offset) {
errno = EINVAL;
return -1;
@@ -450,7 +438,7 @@ inline SSizeT readlink(const wchar_t *path, wchar_t *ret_buf, size_t bufsize) {
errno = EINVAL;
return -1;
}
- const auto &symlink = reparse->SymbolicLinkReparseBuffer;
+ const auto& symlink = reparse->SymbolicLinkReparseBuffer;
unsigned short name_offset, name_length;
if (symlink.PrintNameLength == 0) {
name_offset = symlink.SubstituteNameOffset;
@@ -468,23 +456,18 @@ inline SSizeT readlink(const wchar_t *path, wchar_t *ret_buf, size_t bufsize) {
errno = ENOMEM;
return -1;
}
- memcpy(ret_buf, &symlink.PathBuffer[name_offset / sizeof(wchar_t)],
- name_length);
+ memcpy(ret_buf, &symlink.PathBuffer[name_offset / sizeof(wchar_t)], name_length);
return name_length / sizeof(wchar_t);
}
#else
-inline int symlink_file(const char *oldname, const char *newname) {
- return ::symlink(oldname, newname);
-}
-inline int symlink_dir(const char *oldname, const char *newname) {
- return ::symlink(oldname, newname);
-}
+inline int symlink_file(const char* oldname, const char* newname) { return ::symlink(oldname, newname); }
+inline int symlink_dir(const char* oldname, const char* newname) { return ::symlink(oldname, newname); }
using ::chdir;
using ::fchmod;
-#if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD)
+# if defined(AT_SYMLINK_NOFOLLOW) && defined(AT_FDCWD)
using ::fchmodat;
-#endif
+# endif
using ::fstat;
using ::ftruncate;
using ::getcwd;
@@ -499,11 +482,11 @@ using ::stat;
using ::statvfs;
using ::truncate;
-#define O_BINARY 0
+# define O_BINARY 0
using StatVFS = struct statvfs;
-using ModeT = ::mode_t;
-using SSizeT = ::ssize_t;
+using ModeT = ::mode_t;
+using SSizeT = ::ssize_t;
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h b/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h
index eb41769368..e05f252868 100644
--- a/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h
+++ b/contrib/libs/cxxsupp/libcxx/src/filesystem/time_utils.h
@@ -23,18 +23,18 @@
#include "format_string.h"
#if defined(_LIBCPP_WIN32API)
-# define WIN32_LEAN_AND_MEAN
-# define NOMINMAX
-# include <windows.h>
+# define WIN32_LEAN_AND_MEAN
+# define NOMINMAX
+# include <windows.h>
#else
-# include <fcntl.h>
-# include <sys/stat.h>
-# include <sys/time.h> // for ::utimes as used in __last_write_time
+# include <fcntl.h>
+# include <sys/stat.h>
+# include <sys/time.h> // for ::utimes as used in __last_write_time
#endif
// We can use the presence of UTIME_OMIT to detect platforms that provide utimensat.
#if defined(UTIME_OMIT)
-# define _LIBCPP_USE_UTIMENSAT
+# define _LIBCPP_USE_UTIMENSAT
#endif
_LIBCPP_BEGIN_NAMESPACE_FILESYSTEM
@@ -59,7 +59,7 @@ struct StatT {
uint64_t st_dev; // FILE_ID_INFO::VolumeSerialNumber
struct FileIdStruct {
unsigned char id[16]; // FILE_ID_INFO::FileId
- bool operator==(const FileIdStruct &other) const {
+ bool operator==(const FileIdStruct& other) const {
for (int i = 0; i < 16; i++)
if (id[i] != other.id[i])
return false;
@@ -72,46 +72,45 @@ struct StatT {
// There were 369 years and 89 leap days from the Windows epoch
// (1601) to the Unix epoch (1970).
-#define FILE_TIME_OFFSET_SECS (uint64_t(369 * 365 + 89) * (24 * 60 * 60))
+# define FILE_TIME_OFFSET_SECS (uint64_t(369 * 365 + 89) * (24 * 60 * 60))
inline TimeSpec filetime_to_timespec(LARGE_INTEGER li) {
TimeSpec ret;
- ret.tv_sec = li.QuadPart / 10000000 - FILE_TIME_OFFSET_SECS;
+ ret.tv_sec = li.QuadPart / 10000000 - FILE_TIME_OFFSET_SECS;
ret.tv_nsec = (li.QuadPart % 10000000) * 100;
return ret;
}
inline TimeSpec filetime_to_timespec(FILETIME ft) {
LARGE_INTEGER li;
- li.LowPart = ft.dwLowDateTime;
+ li.LowPart = ft.dwLowDateTime;
li.HighPart = ft.dwHighDateTime;
return filetime_to_timespec(li);
}
inline FILETIME timespec_to_filetime(TimeSpec ts) {
LARGE_INTEGER li;
- li.QuadPart =
- ts.tv_nsec / 100 + (ts.tv_sec + FILE_TIME_OFFSET_SECS) * 10000000;
+ li.QuadPart = ts.tv_nsec / 100 + (ts.tv_sec + FILE_TIME_OFFSET_SECS) * 10000000;
FILETIME ft;
- ft.dwLowDateTime = li.LowPart;
+ ft.dwLowDateTime = li.LowPart;
ft.dwHighDateTime = li.HighPart;
return ft;
}
#else
using TimeSpec = struct timespec;
-using TimeVal = struct timeval;
-using StatT = struct stat;
+using TimeVal = struct timeval;
+using StatT = struct stat;
inline TimeVal make_timeval(TimeSpec const& ts) {
using namespace chrono;
auto Convert = [](long nsec) {
using int_type = decltype(std::declval<TimeVal>().tv_usec);
- auto dur = duration_cast<microseconds>(nanoseconds(nsec)).count();
+ auto dur = duration_cast<microseconds>(nanoseconds(nsec)).count();
return static_cast<int_type>(dur);
};
TimeVal TV = {};
- TV.tv_sec = ts.tv_sec;
+ TV.tv_sec = ts.tv_sec;
TV.tv_usec = Convert(ts.tv_nsec);
return TV;
}
@@ -120,42 +119,30 @@ inline TimeVal make_timeval(TimeSpec const& ts) {
using chrono::duration;
using chrono::duration_cast;
-template <class FileTimeT, class TimeT,
- bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>
+template <class FileTimeT, class TimeT, bool IsFloat = is_floating_point<typename FileTimeT::rep>::value>
struct time_util_base {
- using rep = typename FileTimeT::rep;
- using fs_duration = typename FileTimeT::duration;
- using fs_seconds = duration<rep>;
- using fs_nanoseconds = duration<rep, nano>;
+ using rep = typename FileTimeT::rep;
+ using fs_duration = typename FileTimeT::duration;
+ using fs_seconds = duration<rep>;
+ using fs_nanoseconds = duration<rep, nano>;
using fs_microseconds = duration<rep, micro>;
- static constexpr rep max_seconds =
- duration_cast<fs_seconds>(FileTimeT::duration::max()).count();
+ static constexpr rep max_seconds = duration_cast<fs_seconds>(FileTimeT::duration::max()).count();
static constexpr rep max_nsec =
- duration_cast<fs_nanoseconds>(FileTimeT::duration::max() -
- fs_seconds(max_seconds))
- .count();
+ duration_cast<fs_nanoseconds>(FileTimeT::duration::max() - fs_seconds(max_seconds)).count();
- static constexpr rep min_seconds =
- duration_cast<fs_seconds>(FileTimeT::duration::min()).count();
+ static constexpr rep min_seconds = duration_cast<fs_seconds>(FileTimeT::duration::min()).count();
static constexpr rep min_nsec_timespec =
- duration_cast<fs_nanoseconds>(
- (FileTimeT::duration::min() - fs_seconds(min_seconds)) +
- fs_seconds(1))
- .count();
+ duration_cast<fs_nanoseconds>((FileTimeT::duration::min() - fs_seconds(min_seconds)) + fs_seconds(1)).count();
private:
static constexpr fs_duration get_min_nsecs() {
- return duration_cast<fs_duration>(
- fs_nanoseconds(min_nsec_timespec) -
- duration_cast<fs_nanoseconds>(fs_seconds(1)));
+ return duration_cast<fs_duration>(fs_nanoseconds(min_nsec_timespec) - duration_cast<fs_nanoseconds>(fs_seconds(1)));
}
// Static assert that these values properly round trip.
- static_assert(fs_seconds(min_seconds) + get_min_nsecs() ==
- FileTimeT::duration::min(),
- "value doesn't roundtrip");
+ static_assert(fs_seconds(min_seconds) + get_min_nsecs() == FileTimeT::duration::min(), "value doesn't roundtrip");
static constexpr bool check_range() {
// This kinda sucks, but it's what happens when we don't have __int128_t.
@@ -164,8 +151,7 @@ private:
return duration_cast<Years>(fs_seconds(max_seconds)) > Years(250) &&
duration_cast<Years>(fs_seconds(min_seconds)) < Years(-250);
}
- return max_seconds >= numeric_limits<TimeT>::max() &&
- min_seconds <= numeric_limits<TimeT>::min();
+ return max_seconds >= numeric_limits<TimeT>::max() && min_seconds <= numeric_limits<TimeT>::min();
}
#if _LIBCPP_STD_VER >= 14
static_assert(check_range(), "the representable range is unacceptable small");
@@ -174,10 +160,10 @@ private:
template <class FileTimeT, class TimeT>
struct time_util_base<FileTimeT, TimeT, true> {
- using rep = typename FileTimeT::rep;
- using fs_duration = typename FileTimeT::duration;
- using fs_seconds = duration<rep>;
- using fs_nanoseconds = duration<rep, nano>;
+ using rep = typename FileTimeT::rep;
+ using fs_duration = typename FileTimeT::duration;
+ using fs_seconds = duration<rep>;
+ using fs_nanoseconds = duration<rep, nano>;
using fs_microseconds = duration<rep, micro>;
static const rep max_seconds;
@@ -187,28 +173,20 @@ struct time_util_base<FileTimeT, TimeT, true> {
};
template <class FileTimeT, class TimeT>
-const typename FileTimeT::rep
- time_util_base<FileTimeT, TimeT, true>::max_seconds =
- duration_cast<fs_seconds>(FileTimeT::duration::max()).count();
+const typename FileTimeT::rep time_util_base<FileTimeT, TimeT, true>::max_seconds =
+ duration_cast<fs_seconds>(FileTimeT::duration::max()).count();
template <class FileTimeT, class TimeT>
const typename FileTimeT::rep time_util_base<FileTimeT, TimeT, true>::max_nsec =
- duration_cast<fs_nanoseconds>(FileTimeT::duration::max() -
- fs_seconds(max_seconds))
- .count();
+ duration_cast<fs_nanoseconds>(FileTimeT::duration::max() - fs_seconds(max_seconds)).count();
template <class FileTimeT, class TimeT>
-const typename FileTimeT::rep
- time_util_base<FileTimeT, TimeT, true>::min_seconds =
- duration_cast<fs_seconds>(FileTimeT::duration::min()).count();
+const typename FileTimeT::rep time_util_base<FileTimeT, TimeT, true>::min_seconds =
+ duration_cast<fs_seconds>(FileTimeT::duration::min()).count();
template <class FileTimeT, class TimeT>
-const typename FileTimeT::rep
- time_util_base<FileTimeT, TimeT, true>::min_nsec_timespec =
- duration_cast<fs_nanoseconds>((FileTimeT::duration::min() -
- fs_seconds(min_seconds)) +
- fs_seconds(1))
- .count();
+const typename FileTimeT::rep time_util_base<FileTimeT, TimeT, true>::min_nsec_timespec =
+ duration_cast<fs_nanoseconds>((FileTimeT::duration::min() - fs_seconds(min_seconds)) + fs_seconds(1)).count();
template <class FileTimeT, class TimeT, class TimeSpecT>
struct time_util : time_util_base<FileTimeT, TimeT> {
@@ -225,8 +203,7 @@ struct time_util : time_util_base<FileTimeT, TimeT> {
public:
template <class CType, class ChronoType>
- static constexpr bool checked_set(CType* out,
- ChronoType time) {
+ static constexpr bool checked_set(CType* out, ChronoType time) {
using Lim = numeric_limits<CType>;
if (time > Lim::max() || time < Lim::min())
return false;
@@ -236,8 +213,7 @@ public:
static constexpr bool is_representable(TimeSpecT tm) {
if (tm.tv_sec >= 0) {
- return tm.tv_sec < max_seconds ||
- (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
+ return tm.tv_sec < max_seconds || (tm.tv_sec == max_seconds && tm.tv_nsec <= max_nsec);
} else if (tm.tv_sec == (min_seconds - 1)) {
return tm.tv_nsec >= min_nsec_timespec;
} else {
@@ -246,10 +222,10 @@ public:
}
static constexpr bool is_representable(FileTimeT tm) {
- auto secs = duration_cast<fs_seconds>(tm.time_since_epoch());
+ auto secs = duration_cast<fs_seconds>(tm.time_since_epoch());
auto nsecs = duration_cast<fs_nanoseconds>(tm.time_since_epoch() - secs);
if (nsecs.count() < 0) {
- secs = secs + fs_seconds(1);
+ secs = secs + fs_seconds(1);
nsecs = nsecs + fs_seconds(1);
}
using TLim = numeric_limits<TimeT>;
@@ -258,39 +234,33 @@ public:
return secs.count() >= TLim::min();
}
- static constexpr FileTimeT
- convert_from_timespec(TimeSpecT tm) {
+ static constexpr FileTimeT convert_from_timespec(TimeSpecT tm) {
if (tm.tv_sec >= 0 || tm.tv_nsec == 0) {
- return FileTimeT(fs_seconds(tm.tv_sec) +
- duration_cast<fs_duration>(fs_nanoseconds(tm.tv_nsec)));
+ return FileTimeT(fs_seconds(tm.tv_sec) + duration_cast<fs_duration>(fs_nanoseconds(tm.tv_nsec)));
} else { // tm.tv_sec < 0
- auto adj_subsec = duration_cast<fs_duration>(fs_seconds(1) -
- fs_nanoseconds(tm.tv_nsec));
- auto Dur = fs_seconds(tm.tv_sec + 1) - adj_subsec;
+ auto adj_subsec = duration_cast<fs_duration>(fs_seconds(1) - fs_nanoseconds(tm.tv_nsec));
+ auto Dur = fs_seconds(tm.tv_sec + 1) - adj_subsec;
return FileTimeT(Dur);
}
}
template <class SubSecT>
- static constexpr bool
- set_times_checked(TimeT* sec_out, SubSecT* subsec_out, FileTimeT tp) {
- auto dur = tp.time_since_epoch();
- auto sec_dur = duration_cast<fs_seconds>(dur);
+ static constexpr bool set_times_checked(TimeT* sec_out, SubSecT* subsec_out, FileTimeT tp) {
+ auto dur = tp.time_since_epoch();
+ auto sec_dur = duration_cast<fs_seconds>(dur);
auto subsec_dur = duration_cast<fs_nanoseconds>(dur - sec_dur);
// The tv_nsec and tv_usec fields must not be negative so adjust accordingly
if (subsec_dur.count() < 0) {
if (sec_dur.count() > min_seconds) {
- sec_dur = sec_dur - fs_seconds(1);
+ sec_dur = sec_dur - fs_seconds(1);
subsec_dur = subsec_dur + fs_seconds(1);
} else {
subsec_dur = fs_nanoseconds::zero();
}
}
- return checked_set(sec_out, sec_dur.count()) &&
- checked_set(subsec_out, subsec_dur.count());
+ return checked_set(sec_out, sec_dur.count()) && checked_set(subsec_out, subsec_dur.count());
}
- static constexpr bool convert_to_timespec(TimeSpecT& dest,
- FileTimeT tp) {
+ static constexpr bool convert_to_timespec(TimeSpecT& dest, FileTimeT tp) {
if (!is_representable(tp))
return false;
return set_times_checked(&dest.tv_sec, &dest.tv_nsec, tp);
@@ -331,9 +301,8 @@ inline TimeSpec extract_atime(StatT const& st) { return st.st_atim; }
#ifndef _LIBCPP_HAS_NO_FILESYSTEM
-#if !defined(_LIBCPP_WIN32API)
-inline bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS,
- error_code& ec) {
+# if !defined(_LIBCPP_WIN32API)
+inline bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS, error_code& ec) {
TimeVal ConvertedTS[2] = {make_timeval(TS[0]), make_timeval(TS[1])};
if (::utimes(p.c_str(), ConvertedTS) == -1) {
ec = capture_errno();
@@ -342,30 +311,27 @@ inline bool posix_utimes(const path& p, std::array<TimeSpec, 2> const& TS,
return false;
}
-#if defined(_LIBCPP_USE_UTIMENSAT)
-inline bool posix_utimensat(const path& p, std::array<TimeSpec, 2> const& TS,
- error_code& ec) {
+# if defined(_LIBCPP_USE_UTIMENSAT)
+inline bool posix_utimensat(const path& p, std::array<TimeSpec, 2> const& TS, error_code& ec) {
if (::utimensat(AT_FDCWD, p.c_str(), TS.data(), 0) == -1) {
ec = capture_errno();
return true;
}
return false;
}
-#endif
+# endif
-inline bool set_file_times(const path& p, std::array<TimeSpec, 2> const& TS,
- error_code& ec) {
-#if !defined(_LIBCPP_USE_UTIMENSAT)
+inline bool set_file_times(const path& p, std::array<TimeSpec, 2> const& TS, error_code& ec) {
+# if !defined(_LIBCPP_USE_UTIMENSAT)
return posix_utimes(p, TS, ec);
-#else
+# else
return posix_utimensat(p, TS, ec);
-#endif
+# endif
}
-#endif // !_LIBCPP_WIN32API
+# endif // !_LIBCPP_WIN32API
-inline file_time_type __extract_last_write_time(const path& p, const StatT& st,
- error_code* ec) {
+inline file_time_type __extract_last_write_time(const path& p, const StatT& st, error_code* ec) {
using detail::fs_time;
ErrorHandler<file_time_type> err("last_write_time", ec, &p);
diff --git a/contrib/libs/cxxsupp/libcxx/src/functional.cpp b/contrib/libs/cxxsupp/libcxx/src/functional.cpp
index ca1079cdd8..570bb78e15 100644
--- a/contrib/libs/cxxsupp/libcxx/src/functional.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/functional.cpp
@@ -11,17 +11,11 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_KEY_FUNCTION
-bad_function_call::~bad_function_call() noexcept
-{
-}
+bad_function_call::~bad_function_call() noexcept {}
#endif
#ifdef _LIBCPP_ABI_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
-const char*
-bad_function_call::what() const noexcept
-{
- return "std::bad_function_call";
-}
+const char* bad_function_call::what() const noexcept { return "std::bad_function_call"; }
#endif
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/future.cpp b/contrib/libs/cxxsupp/libcxx/src/future.cpp
index 0e3f7b12b8..e2c14c8321 100644
--- a/contrib/libs/cxxsupp/libcxx/src/future.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/future.cpp
@@ -11,256 +11,187 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-class _LIBCPP_HIDDEN __future_error_category
- : public __do_message
-{
+class _LIBCPP_HIDDEN __future_error_category : public __do_message {
public:
- virtual const char* name() const noexcept;
- virtual string message(int ev) const;
+ virtual const char* name() const noexcept;
+ virtual string message(int ev) const;
};
-const char*
-__future_error_category::name() const noexcept
-{
- return "future";
-}
+const char* __future_error_category::name() const noexcept { return "future"; }
_LIBCPP_DIAGNOSTIC_PUSH
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wswitch")
_LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wswitch")
-string
-__future_error_category::message(int ev) const
-{
- switch (static_cast<future_errc>(ev))
- {
- case future_errc(0): // For backwards compatibility with C++11 (LWG 2056)
- case future_errc::broken_promise:
- return string("The associated promise has been destructed prior "
- "to the associated state becoming ready.");
- case future_errc::future_already_retrieved:
- return string("The future has already been retrieved from "
- "the promise or packaged_task.");
- case future_errc::promise_already_satisfied:
- return string("The state of the promise has already been set.");
- case future_errc::no_state:
- return string("Operation not permitted on an object without "
- "an associated state.");
- }
- return string("unspecified future_errc value\n");
+string __future_error_category::message(int ev) const {
+ switch (static_cast<future_errc>(ev)) {
+ case future_errc(0): // For backwards compatibility with C++11 (LWG 2056)
+ case future_errc::broken_promise:
+ return string("The associated promise has been destructed prior "
+ "to the associated state becoming ready.");
+ case future_errc::future_already_retrieved:
+ return string("The future has already been retrieved from "
+ "the promise or packaged_task.");
+ case future_errc::promise_already_satisfied:
+ return string("The state of the promise has already been set.");
+ case future_errc::no_state:
+ return string("Operation not permitted on an object without "
+ "an associated state.");
+ }
+ return string("unspecified future_errc value\n");
}
_LIBCPP_DIAGNOSTIC_POP
-const error_category&
-future_category() noexcept
-{
- union AvoidDestroyingFutureCategory {
- __future_error_category future_error_category;
- constexpr explicit AvoidDestroyingFutureCategory() : future_error_category() {}
- ~AvoidDestroyingFutureCategory() {}
- };
- constinit static AvoidDestroyingFutureCategory helper;
- return helper.future_error_category;
+const error_category& future_category() noexcept {
+ union AvoidDestroyingFutureCategory {
+ __future_error_category future_error_category;
+ constexpr explicit AvoidDestroyingFutureCategory() : future_error_category() {}
+ ~AvoidDestroyingFutureCategory() {}
+ };
+ constinit static AvoidDestroyingFutureCategory helper;
+ return helper.future_error_category;
}
-future_error::future_error(error_code __ec)
- : logic_error(__ec.message()),
- __ec_(__ec)
-{
-}
+future_error::future_error(error_code __ec) : logic_error(__ec.message()), __ec_(__ec) {}
-future_error::~future_error() noexcept
-{
-}
+future_error::~future_error() noexcept {}
-void
-__assoc_sub_state::__on_zero_shared() noexcept
-{
- delete this;
-}
+void __assoc_sub_state::__on_zero_shared() noexcept { delete this; }
-void
-__assoc_sub_state::set_value()
-{
- unique_lock<mutex> __lk(__mut_);
- if (__has_value())
- __throw_future_error(future_errc::promise_already_satisfied);
- __state_ |= __constructed | ready;
- __cv_.notify_all();
+void __assoc_sub_state::set_value() {
+ unique_lock<mutex> __lk(__mut_);
+ if (__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __state_ |= __constructed | ready;
+ __cv_.notify_all();
}
-void
-__assoc_sub_state::set_value_at_thread_exit()
-{
- unique_lock<mutex> __lk(__mut_);
- if (__has_value())
- __throw_future_error(future_errc::promise_already_satisfied);
- __state_ |= __constructed;
- __thread_local_data()->__make_ready_at_thread_exit(this);
+void __assoc_sub_state::set_value_at_thread_exit() {
+ unique_lock<mutex> __lk(__mut_);
+ if (__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __state_ |= __constructed;
+ __thread_local_data()->__make_ready_at_thread_exit(this);
}
-void
-__assoc_sub_state::set_exception(exception_ptr __p)
-{
- unique_lock<mutex> __lk(__mut_);
- if (__has_value())
- __throw_future_error(future_errc::promise_already_satisfied);
- __exception_ = __p;
- __state_ |= ready;
- __cv_.notify_all();
+void __assoc_sub_state::set_exception(exception_ptr __p) {
+ unique_lock<mutex> __lk(__mut_);
+ if (__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __exception_ = __p;
+ __state_ |= ready;
+ __cv_.notify_all();
}
-void
-__assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p)
-{
- unique_lock<mutex> __lk(__mut_);
- if (__has_value())
- __throw_future_error(future_errc::promise_already_satisfied);
- __exception_ = __p;
- __thread_local_data()->__make_ready_at_thread_exit(this);
+void __assoc_sub_state::set_exception_at_thread_exit(exception_ptr __p) {
+ unique_lock<mutex> __lk(__mut_);
+ if (__has_value())
+ __throw_future_error(future_errc::promise_already_satisfied);
+ __exception_ = __p;
+ __thread_local_data()->__make_ready_at_thread_exit(this);
}
-void
-__assoc_sub_state::__make_ready()
-{
- unique_lock<mutex> __lk(__mut_);
- __state_ |= ready;
- __cv_.notify_all();
+void __assoc_sub_state::__make_ready() {
+ unique_lock<mutex> __lk(__mut_);
+ __state_ |= ready;
+ __cv_.notify_all();
}
-void
-__assoc_sub_state::copy()
-{
- unique_lock<mutex> __lk(__mut_);
- __sub_wait(__lk);
- if (__exception_ != nullptr)
- rethrow_exception(__exception_);
+void __assoc_sub_state::copy() {
+ unique_lock<mutex> __lk(__mut_);
+ __sub_wait(__lk);
+ if (__exception_ != nullptr)
+ rethrow_exception(__exception_);
}
-void
-__assoc_sub_state::wait()
-{
- unique_lock<mutex> __lk(__mut_);
- __sub_wait(__lk);
+void __assoc_sub_state::wait() {
+ unique_lock<mutex> __lk(__mut_);
+ __sub_wait(__lk);
}
-void
-__assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk)
-{
- if (!__is_ready())
- {
- if (__state_ & static_cast<unsigned>(deferred))
- {
- __state_ &= ~static_cast<unsigned>(deferred);
- __lk.unlock();
- __execute();
- }
- else
- while (!__is_ready())
- __cv_.wait(__lk);
- }
+void __assoc_sub_state::__sub_wait(unique_lock<mutex>& __lk) {
+ if (!__is_ready()) {
+ if (__state_ & static_cast<unsigned>(deferred)) {
+ __state_ &= ~static_cast<unsigned>(deferred);
+ __lk.unlock();
+ __execute();
+ } else
+ while (!__is_ready())
+ __cv_.wait(__lk);
+ }
}
-void
-__assoc_sub_state::__execute()
-{
- __throw_future_error(future_errc::no_state);
-}
+void __assoc_sub_state::__execute() { __throw_future_error(future_errc::no_state); }
-future<void>::future(__assoc_sub_state* __state)
- : __state_(__state)
-{
- __state_->__attach_future();
-}
+future<void>::future(__assoc_sub_state* __state) : __state_(__state) { __state_->__attach_future(); }
-future<void>::~future()
-{
- if (__state_)
- __state_->__release_shared();
+future<void>::~future() {
+ if (__state_)
+ __state_->__release_shared();
}
-void
-future<void>::get()
-{
- unique_ptr<__shared_count, __release_shared_count> __(__state_);
- __assoc_sub_state* __s = __state_;
- __state_ = nullptr;
- __s->copy();
+void future<void>::get() {
+ unique_ptr<__shared_count, __release_shared_count> __(__state_);
+ __assoc_sub_state* __s = __state_;
+ __state_ = nullptr;
+ __s->copy();
}
-promise<void>::promise()
- : __state_(new __assoc_sub_state)
-{
-}
+promise<void>::promise() : __state_(new __assoc_sub_state) {}
-promise<void>::~promise()
-{
- if (__state_)
- {
+promise<void>::~promise() {
+ if (__state_) {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- if (!__state_->__has_value() && __state_->use_count() > 1)
- __state_->set_exception(make_exception_ptr(future_error(future_errc::broken_promise)));
+ if (!__state_->__has_value() && __state_->use_count() > 1)
+ __state_->set_exception(make_exception_ptr(future_error(future_errc::broken_promise)));
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
- __state_->__release_shared();
- }
+ __state_->__release_shared();
+ }
}
-future<void>
-promise<void>::get_future()
-{
- if (__state_ == nullptr)
- __throw_future_error(future_errc::no_state);
- return future<void>(__state_);
+future<void> promise<void>::get_future() {
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ return future<void>(__state_);
}
-void
-promise<void>::set_value()
-{
- if (__state_ == nullptr)
- __throw_future_error(future_errc::no_state);
- __state_->set_value();
+void promise<void>::set_value() {
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value();
}
-void
-promise<void>::set_exception(exception_ptr __p)
-{
- if (__state_ == nullptr)
- __throw_future_error(future_errc::no_state);
- __state_->set_exception(__p);
+void promise<void>::set_exception(exception_ptr __p) {
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_exception(__p);
}
-void
-promise<void>::set_value_at_thread_exit()
-{
- if (__state_ == nullptr)
- __throw_future_error(future_errc::no_state);
- __state_->set_value_at_thread_exit();
+void promise<void>::set_value_at_thread_exit() {
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_value_at_thread_exit();
}
-void
-promise<void>::set_exception_at_thread_exit(exception_ptr __p)
-{
- if (__state_ == nullptr)
- __throw_future_error(future_errc::no_state);
- __state_->set_exception_at_thread_exit(__p);
+void promise<void>::set_exception_at_thread_exit(exception_ptr __p) {
+ if (__state_ == nullptr)
+ __throw_future_error(future_errc::no_state);
+ __state_->set_exception_at_thread_exit(__p);
}
-shared_future<void>::~shared_future()
-{
- if (__state_)
- __state_->__release_shared();
+shared_future<void>::~shared_future() {
+ if (__state_)
+ __state_->__release_shared();
}
-shared_future<void>&
-shared_future<void>::operator=(const shared_future& __rhs)
-{
- if (__rhs.__state_)
- __rhs.__state_->__add_shared();
- if (__state_)
- __state_->__release_shared();
- __state_ = __rhs.__state_;
- return *this;
+shared_future<void>& shared_future<void>::operator=(const shared_future& __rhs) {
+ if (__rhs.__state_)
+ __rhs.__state_->__add_shared();
+ if (__state_)
+ __state_->__release_shared();
+ __state_ = __rhs.__state_;
+ return *this;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/hash.cpp b/contrib/libs/cxxsupp/libcxx/src/hash.cpp
index f5bd3e9684..34b02b8eaf 100644
--- a/contrib/libs/cxxsupp/libcxx/src/hash.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/hash.cpp
@@ -18,114 +18,20 @@ _LIBCPP_BEGIN_NAMESPACE_STD
namespace {
// handle all next_prime(i) for i in [1, 210), special case 0
-const unsigned small_primes[] =
-{
- 0,
- 2,
- 3,
- 5,
- 7,
- 11,
- 13,
- 17,
- 19,
- 23,
- 29,
- 31,
- 37,
- 41,
- 43,
- 47,
- 53,
- 59,
- 61,
- 67,
- 71,
- 73,
- 79,
- 83,
- 89,
- 97,
- 101,
- 103,
- 107,
- 109,
- 113,
- 127,
- 131,
- 137,
- 139,
- 149,
- 151,
- 157,
- 163,
- 167,
- 173,
- 179,
- 181,
- 191,
- 193,
- 197,
- 199,
- 211
-};
+const unsigned small_primes[] = {
+ 0, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47,
+ 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127,
+ 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211};
// potential primes = 210*k + indices[i], k >= 1
// these numbers are not divisible by 2, 3, 5 or 7
// (or any integer 2 <= j <= 10 for that matter).
-const unsigned indices[] =
-{
- 1,
- 11,
- 13,
- 17,
- 19,
- 23,
- 29,
- 31,
- 37,
- 41,
- 43,
- 47,
- 53,
- 59,
- 61,
- 67,
- 71,
- 73,
- 79,
- 83,
- 89,
- 97,
- 101,
- 103,
- 107,
- 109,
- 113,
- 121,
- 127,
- 131,
- 137,
- 139,
- 143,
- 149,
- 151,
- 157,
- 163,
- 167,
- 169,
- 173,
- 179,
- 181,
- 187,
- 191,
- 193,
- 197,
- 199,
- 209
-};
+const unsigned indices[] = {
+ 1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,
+ 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139,
+ 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209};
-}
+} // namespace
// Returns: If n == 0, returns 0. Else returns the lowest prime number that
// is greater than or equal to n.
@@ -147,413 +53,400 @@ const unsigned indices[] =
// against.
template <size_t _Sz = sizeof(size_t)>
-inline _LIBCPP_HIDE_FROM_ABI
-typename enable_if<_Sz == 4, void>::type
-__check_for_overflow(size_t N)
-{
- if (N > 0xFFFFFFFB)
- __throw_overflow_error("__next_prime overflow");
+inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 4, void>::type __check_for_overflow(size_t N) {
+ if (N > 0xFFFFFFFB)
+ __throw_overflow_error("__next_prime overflow");
}
template <size_t _Sz = sizeof(size_t)>
-inline _LIBCPP_HIDE_FROM_ABI
-typename enable_if<_Sz == 8, void>::type
-__check_for_overflow(size_t N)
-{
- if (N > 0xFFFFFFFFFFFFFFC5ull)
- __throw_overflow_error("__next_prime overflow");
+inline _LIBCPP_HIDE_FROM_ABI typename enable_if<_Sz == 8, void>::type __check_for_overflow(size_t N) {
+ if (N > 0xFFFFFFFFFFFFFFC5ull)
+ __throw_overflow_error("__next_prime overflow");
}
-size_t
-__next_prime(size_t n)
-{
- const size_t L = 210;
- const size_t N = sizeof(small_primes) / sizeof(small_primes[0]);
- // If n is small enough, search in small_primes
- if (n <= small_primes[N-1])
- return *std::lower_bound(small_primes, small_primes + N, n);
- // Else n > largest small_primes
- // Check for overflow
- __check_for_overflow(n);
- // Start searching list of potential primes: L * k0 + indices[in]
- const size_t M = sizeof(indices) / sizeof(indices[0]);
- // Select first potential prime >= n
- // Known a-priori n >= L
- size_t k0 = n / L;
- size_t in = static_cast<size_t>(std::lower_bound(indices, indices + M, n - k0 * L)
- - indices);
- n = L * k0 + indices[in];
- while (true)
+size_t __next_prime(size_t n) {
+ const size_t L = 210;
+ const size_t N = sizeof(small_primes) / sizeof(small_primes[0]);
+ // If n is small enough, search in small_primes
+ if (n <= small_primes[N - 1])
+ return *std::lower_bound(small_primes, small_primes + N, n);
+ // Else n > largest small_primes
+ // Check for overflow
+ __check_for_overflow(n);
+ // Start searching list of potential primes: L * k0 + indices[in]
+ const size_t M = sizeof(indices) / sizeof(indices[0]);
+ // Select first potential prime >= n
+ // Known a-priori n >= L
+ size_t k0 = n / L;
+ size_t in = static_cast<size_t>(std::lower_bound(indices, indices + M, n - k0 * L) - indices);
+ n = L * k0 + indices[in];
+ while (true) {
+ // Divide n by all primes or potential primes (i) until:
+ // 1. The division is even, so try next potential prime.
+ // 2. The i > sqrt(n), in which case n is prime.
+ // It is known a-priori that n is not divisible by 2, 3, 5 or 7,
+ // so don't test those (j == 5 -> divide by 11 first). And the
+ // potential primes start with 211, so don't test against the last
+ // small prime.
+ for (size_t j = 5; j < N - 1; ++j) {
+ const std::size_t p = small_primes[j];
+ const std::size_t q = n / p;
+ if (q < p)
+ return n;
+ if (n == q * p)
+ goto next;
+ }
+ // n wasn't divisible by small primes, try potential primes
{
- // Divide n by all primes or potential primes (i) until:
- // 1. The division is even, so try next potential prime.
- // 2. The i > sqrt(n), in which case n is prime.
- // It is known a-priori that n is not divisible by 2, 3, 5 or 7,
- // so don't test those (j == 5 -> divide by 11 first). And the
- // potential primes start with 211, so don't test against the last
- // small prime.
- for (size_t j = 5; j < N - 1; ++j)
- {
- const std::size_t p = small_primes[j];
- const std::size_t q = n / p;
- if (q < p)
- return n;
- if (n == q * p)
- goto next;
- }
- // n wasn't divisible by small primes, try potential primes
- {
- size_t i = 211;
- while (true)
- {
- std::size_t q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 10;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 8;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 8;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 6;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 4;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 2;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- i += 10;
- q = n / i;
- if (q < i)
- return n;
- if (n == q * i)
- break;
-
- // This will loop i to the next "plane" of potential primes
- i += 2;
- }
- }
-next:
- // n is not prime. Increment n to next potential prime.
- if (++in == M)
- {
- ++k0;
- in = 0;
- }
- n = L * k0 + indices[in];
+ size_t i = 211;
+ while (true) {
+ std::size_t q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 10;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 8;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 8;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 6;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 4;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 2;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ i += 10;
+ q = n / i;
+ if (q < i)
+ return n;
+ if (n == q * i)
+ break;
+
+ // This will loop i to the next "plane" of potential primes
+ i += 2;
+ }
}
+ next:
+ // n is not prime. Increment n to next potential prime.
+ if (++in == M) {
+ ++k0;
+ in = 0;
+ }
+ n = L * k0 + indices[in];
+ }
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/include/apple_availability.h b/contrib/libs/cxxsupp/libcxx/src/include/apple_availability.h
index c8d158e990..fc2ad15065 100644
--- a/contrib/libs/cxxsupp/libcxx/src/include/apple_availability.h
+++ b/contrib/libs/cxxsupp/libcxx/src/include/apple_availability.h
@@ -11,23 +11,23 @@
#if defined(__APPLE__)
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500
-#define _LIBCPP_USE_ULOCK
-#endif
-#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000
-#define _LIBCPP_USE_ULOCK
-#endif
-#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000
-#define _LIBCPP_USE_ULOCK
-#endif
-#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000
-#define _LIBCPP_USE_ULOCK
-#endif
-#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
+# if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
+# if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101500
+# define _LIBCPP_USE_ULOCK
+# endif
+# elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
+# if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 130000
+# define _LIBCPP_USE_ULOCK
+# endif
+# elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
+# if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 130000
+# define _LIBCPP_USE_ULOCK
+# endif
+# elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
+# if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 60000
+# define _LIBCPP_USE_ULOCK
+# endif
+# endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
#endif // __APPLE__
diff --git a/contrib/libs/cxxsupp/libcxx/src/include/atomic_support.h b/contrib/libs/cxxsupp/libcxx/src/include/atomic_support.h
index debeb745f4..9ce41b3229 100644
--- a/contrib/libs/cxxsupp/libcxx/src/include/atomic_support.h
+++ b/contrib/libs/cxxsupp/libcxx/src/include/atomic_support.h
@@ -12,28 +12,21 @@
#include <__config>
#include <memory> // for __libcpp_relaxed_load
-#if defined(__clang__) && __has_builtin(__atomic_load_n) \
- && __has_builtin(__atomic_store_n) \
- && __has_builtin(__atomic_add_fetch) \
- && __has_builtin(__atomic_exchange_n) \
- && __has_builtin(__atomic_compare_exchange_n) \
- && defined(__ATOMIC_RELAXED) \
- && defined(__ATOMIC_CONSUME) \
- && defined(__ATOMIC_ACQUIRE) \
- && defined(__ATOMIC_RELEASE) \
- && defined(__ATOMIC_ACQ_REL) \
- && defined(__ATOMIC_SEQ_CST)
-# define _LIBCPP_HAS_ATOMIC_BUILTINS
+#if defined(__clang__) && __has_builtin(__atomic_load_n) && __has_builtin(__atomic_store_n) && \
+ __has_builtin(__atomic_add_fetch) && __has_builtin(__atomic_exchange_n) && \
+ __has_builtin(__atomic_compare_exchange_n) && defined(__ATOMIC_RELAXED) && defined(__ATOMIC_CONSUME) && \
+ defined(__ATOMIC_ACQUIRE) && defined(__ATOMIC_RELEASE) && defined(__ATOMIC_ACQ_REL) && defined(__ATOMIC_SEQ_CST)
+# define _LIBCPP_HAS_ATOMIC_BUILTINS
#elif defined(_LIBCPP_COMPILER_GCC)
-# define _LIBCPP_HAS_ATOMIC_BUILTINS
+# define _LIBCPP_HAS_ATOMIC_BUILTINS
#endif
#if !defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
-# if defined(_LIBCPP_WARNING)
- _LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
-# else
-# warning Building libc++ without __atomic builtins is unsupported
-# endif
+# if defined(_LIBCPP_WARNING)
+_LIBCPP_WARNING("Building libc++ without __atomic builtins is unsupported")
+# else
+# warning Building libc++ without __atomic builtins is unsupported
+# endif
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -43,128 +36,91 @@ namespace {
#if defined(_LIBCPP_HAS_ATOMIC_BUILTINS) && !defined(_LIBCPP_HAS_NO_THREADS)
enum __libcpp_atomic_order {
- _AO_Relaxed = __ATOMIC_RELAXED,
- _AO_Consume = __ATOMIC_CONSUME,
- _AO_Acquire = __ATOMIC_ACQUIRE,
- _AO_Release = __ATOMIC_RELEASE,
- _AO_Acq_Rel = __ATOMIC_ACQ_REL,
- _AO_Seq = __ATOMIC_SEQ_CST
+ _AO_Relaxed = __ATOMIC_RELAXED,
+ _AO_Consume = __ATOMIC_CONSUME,
+ _AO_Acquire = __ATOMIC_ACQUIRE,
+ _AO_Release = __ATOMIC_RELEASE,
+ _AO_Acq_Rel = __ATOMIC_ACQ_REL,
+ _AO_Seq = __ATOMIC_SEQ_CST
};
template <class _ValueType, class _FromType>
-inline _LIBCPP_HIDE_FROM_ABI
-void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
- int __order = _AO_Seq)
-{
- __atomic_store_n(__dest, __val, __order);
+inline _LIBCPP_HIDE_FROM_ABI void __libcpp_atomic_store(_ValueType* __dest, _FromType __val, int __order = _AO_Seq) {
+ __atomic_store_n(__dest, __val, __order);
}
template <class _ValueType, class _FromType>
-inline _LIBCPP_HIDE_FROM_ABI
-void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
-{
- __atomic_store_n(__dest, __val, _AO_Relaxed);
+inline _LIBCPP_HIDE_FROM_ABI void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val) {
+ __atomic_store_n(__dest, __val, _AO_Relaxed);
}
template <class _ValueType>
-inline _LIBCPP_HIDE_FROM_ABI
-_ValueType __libcpp_atomic_load(_ValueType const* __val,
- int __order = _AO_Seq)
-{
- return __atomic_load_n(__val, __order);
+inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_atomic_load(_ValueType const* __val, int __order = _AO_Seq) {
+ return __atomic_load_n(__val, __order);
}
template <class _ValueType, class _AddType>
-inline _LIBCPP_HIDE_FROM_ABI
-_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
- int __order = _AO_Seq)
-{
- return __atomic_add_fetch(__val, __a, __order);
+inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a, int __order = _AO_Seq) {
+ return __atomic_add_fetch(__val, __a, __order);
}
template <class _ValueType>
-inline _LIBCPP_HIDE_FROM_ABI
-_ValueType __libcpp_atomic_exchange(_ValueType* __target,
- _ValueType __value, int __order = _AO_Seq)
-{
- return __atomic_exchange_n(__target, __value, __order);
+inline _LIBCPP_HIDE_FROM_ABI _ValueType
+__libcpp_atomic_exchange(_ValueType* __target, _ValueType __value, int __order = _AO_Seq) {
+ return __atomic_exchange_n(__target, __value, __order);
}
template <class _ValueType>
-inline _LIBCPP_HIDE_FROM_ABI
-bool __libcpp_atomic_compare_exchange(_ValueType* __val,
- _ValueType* __expected, _ValueType __after,
+inline _LIBCPP_HIDE_FROM_ABI bool __libcpp_atomic_compare_exchange(
+ _ValueType* __val,
+ _ValueType* __expected,
+ _ValueType __after,
int __success_order = _AO_Seq,
- int __fail_order = _AO_Seq)
-{
- return __atomic_compare_exchange_n(__val, __expected, __after, true,
- __success_order, __fail_order);
+ int __fail_order = _AO_Seq) {
+ return __atomic_compare_exchange_n(__val, __expected, __after, true, __success_order, __fail_order);
}
#else // _LIBCPP_HAS_NO_THREADS
-enum __libcpp_atomic_order {
- _AO_Relaxed,
- _AO_Consume,
- _AO_Acquire,
- _AO_Release,
- _AO_Acq_Rel,
- _AO_Seq
-};
+enum __libcpp_atomic_order { _AO_Relaxed, _AO_Consume, _AO_Acquire, _AO_Release, _AO_Acq_Rel, _AO_Seq };
template <class _ValueType, class _FromType>
-inline _LIBCPP_HIDE_FROM_ABI
-void __libcpp_atomic_store(_ValueType* __dest, _FromType __val,
- int = 0)
-{
- *__dest = __val;
+inline _LIBCPP_HIDE_FROM_ABI void __libcpp_atomic_store(_ValueType* __dest, _FromType __val, int = 0) {
+ *__dest = __val;
}
template <class _ValueType, class _FromType>
-inline _LIBCPP_HIDE_FROM_ABI
-void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val)
-{
- *__dest = __val;
+inline _LIBCPP_HIDE_FROM_ABI void __libcpp_relaxed_store(_ValueType* __dest, _FromType __val) {
+ *__dest = __val;
}
template <class _ValueType>
-inline _LIBCPP_HIDE_FROM_ABI
-_ValueType __libcpp_atomic_load(_ValueType const* __val,
- int = 0)
-{
- return *__val;
+inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_atomic_load(_ValueType const* __val, int = 0) {
+ return *__val;
}
template <class _ValueType, class _AddType>
-inline _LIBCPP_HIDE_FROM_ABI
-_ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a,
- int = 0)
-{
- return *__val += __a;
+inline _LIBCPP_HIDE_FROM_ABI _ValueType __libcpp_atomic_add(_ValueType* __val, _AddType __a, int = 0) {
+ return *__val += __a;
}
template <class _ValueType>
-inline _LIBCPP_HIDE_FROM_ABI
-_ValueType __libcpp_atomic_exchange(_ValueType* __target,
- _ValueType __value, int = _AO_Seq)
-{
- _ValueType old = *__target;
- *__target = __value;
- return old;
+inline _LIBCPP_HIDE_FROM_ABI _ValueType
+__libcpp_atomic_exchange(_ValueType* __target, _ValueType __value, int = _AO_Seq) {
+ _ValueType old = *__target;
+ *__target = __value;
+ return old;
}
template <class _ValueType>
-inline _LIBCPP_HIDE_FROM_ABI
-bool __libcpp_atomic_compare_exchange(_ValueType* __val,
- _ValueType* __expected, _ValueType __after,
- int = 0, int = 0)
-{
- if (*__val == *__expected) {
- *__val = __after;
- return true;
- }
- *__expected = *__val;
- return false;
+inline _LIBCPP_HIDE_FROM_ABI bool
+__libcpp_atomic_compare_exchange(_ValueType* __val, _ValueType* __expected, _ValueType __after, int = 0, int = 0) {
+ if (*__val == *__expected) {
+ *__val = __after;
+ return true;
+ }
+ *__expected = *__val;
+ return false;
}
#endif // _LIBCPP_HAS_NO_THREADS
diff --git a/contrib/libs/cxxsupp/libcxx/src/include/config_elast.h b/contrib/libs/cxxsupp/libcxx/src/include/config_elast.h
index a772ea7a01..899e124ad2 100644
--- a/contrib/libs/cxxsupp/libcxx/src/include/config_elast.h
+++ b/contrib/libs/cxxsupp/libcxx/src/include/config_elast.h
@@ -12,17 +12,17 @@
#include <__config>
#if defined(_LIBCPP_MSVCRT_LIKE)
-#include <stdlib.h>
+# include <stdlib.h>
#else
-#include <errno.h>
+# include <errno.h>
#endif
// Note: _LIBCPP_ELAST needs to be defined only on platforms
// where strerror/strerror_r can't handle out-of-range errno values.
#if defined(ELAST)
-#define _LIBCPP_ELAST ELAST
+# define _LIBCPP_ELAST ELAST
#elif defined(_NEWLIB_VERSION)
-#define _LIBCPP_ELAST __ELASTERROR
+# define _LIBCPP_ELAST __ELASTERROR
#elif defined(__NuttX__)
// No _LIBCPP_ELAST needed on NuttX
#elif defined(__Fuchsia__)
@@ -32,18 +32,18 @@
#elif defined(__EMSCRIPTEN__)
// No _LIBCPP_ELAST needed on Emscripten
#elif defined(__linux__) || defined(_LIBCPP_HAS_MUSL_LIBC)
-#define _LIBCPP_ELAST 4095
+# define _LIBCPP_ELAST 4095
#elif defined(__APPLE__)
// No _LIBCPP_ELAST needed on Apple
#elif defined(__MVS__)
-#define _LIBCPP_ELAST 1160
+# define _LIBCPP_ELAST 1160
#elif defined(_LIBCPP_MSVCRT_LIKE)
-#define _LIBCPP_ELAST (_sys_nerr - 1)
+# define _LIBCPP_ELAST (_sys_nerr - 1)
#elif defined(_AIX)
-#define _LIBCPP_ELAST 127
+# define _LIBCPP_ELAST 127
#else
// Warn here so that the person doing the libcxx port has an easier time:
-#warning ELAST for this platform not yet implemented
+# warning ELAST for this platform not yet implemented
#endif
#endif // _LIBCPP_CONFIG_ELAST
diff --git a/contrib/libs/cxxsupp/libcxx/src/include/refstring.h b/contrib/libs/cxxsupp/libcxx/src/include/refstring.h
index c32630c6c2..72daaef62b 100644
--- a/contrib/libs/cxxsupp/libcxx/src/include/refstring.h
+++ b/contrib/libs/cxxsupp/libcxx/src/include/refstring.h
@@ -10,15 +10,15 @@
#define _LIBCPP_REFSTRING_H
#include <__config>
-#include <stdexcept>
#include <cstddef>
#include <cstring>
+#include <stdexcept>
#if !defined(_LIBCPP_HAS_NO_THREADS) && !defined(_LIBCPP_CXX03_LANG) && !defined(_LIBCPP_USE_ATOMIC)
-#define _LIBCPP_USE_ATOMIC
-#include <atomic>
+# define _LIBCPP_USE_ATOMIC
+# include <atomic>
#else
-#include "atomic_support.h"
+# include "atomic_support.h"
#endif
// MacOS and iOS used to ship with libstdc++, and still support old applications
@@ -31,134 +31,122 @@
// string singleton before manipulating the reference count. This is done so that
// if an exception is created with a zero-length string in libstdc++, libc++abi
// won't try to delete the memory.
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || \
- defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
-# define _LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE
-# include <dlfcn.h>
-# include <mach-o/dyld.h>
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
+# define _LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE
+# include <dlfcn.h>
+# include <mach-o/dyld.h>
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-namespace __refstring_imp { namespace {
+namespace __refstring_imp {
+namespace {
typedef int count_t;
struct _Rep_base {
- std::size_t len;
- std::size_t cap;
+ std::size_t len;
+ std::size_t cap;
#ifdef _LIBCPP_USE_ATOMIC
- std::atomic<count_t> count;
+ std::atomic<count_t> count;
#else
- count_t count;
+ count_t count;
#endif
};
-inline _Rep_base* rep_from_data(const char *data_) noexcept {
- char *data = const_cast<char *>(data_);
- return reinterpret_cast<_Rep_base *>(data - sizeof(_Rep_base));
+inline _Rep_base* rep_from_data(const char* data_) noexcept {
+ char* data = const_cast<char*>(data_);
+ return reinterpret_cast<_Rep_base*>(data - sizeof(_Rep_base));
}
-inline char * data_from_rep(_Rep_base *rep) noexcept {
- char *data = reinterpret_cast<char *>(rep);
- return data + sizeof(*rep);
+inline char* data_from_rep(_Rep_base* rep) noexcept {
+ char* data = reinterpret_cast<char*>(rep);
+ return data + sizeof(*rep);
}
#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)
-inline
-const char* compute_gcc_empty_string_storage() noexcept
-{
- void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
- if (handle == nullptr)
- return nullptr;
- void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
- if (sym == nullptr)
- return nullptr;
- return data_from_rep(reinterpret_cast<_Rep_base *>(sym));
+inline const char* compute_gcc_empty_string_storage() noexcept {
+ void* handle = dlopen("/usr/lib/libstdc++.6.dylib", RTLD_NOLOAD);
+ if (handle == nullptr)
+ return nullptr;
+ void* sym = dlsym(handle, "_ZNSs4_Rep20_S_empty_rep_storageE");
+ if (sym == nullptr)
+ return nullptr;
+ return data_from_rep(reinterpret_cast<_Rep_base*>(sym));
}
-inline
-const char*
-get_gcc_empty_string_storage() noexcept
-{
- static const char* p = compute_gcc_empty_string_storage();
- return p;
+inline const char* get_gcc_empty_string_storage() noexcept {
+ static const char* p = compute_gcc_empty_string_storage();
+ return p;
}
#endif
-}} // namespace __refstring_imp
+} // namespace
+} // namespace __refstring_imp
using namespace __refstring_imp;
-inline
-__libcpp_refstring::__libcpp_refstring(const char* msg) {
- std::size_t len = strlen(msg);
- _Rep_base* rep = static_cast<_Rep_base *>(::operator new(sizeof(*rep) + len + 1));
- rep->len = len;
- rep->cap = len;
- rep->count = 0;
- char *data = data_from_rep(rep);
- std::memcpy(data, msg, len + 1);
- __imp_ = data;
+inline __libcpp_refstring::__libcpp_refstring(const char* msg) {
+ std::size_t len = strlen(msg);
+ _Rep_base* rep = static_cast<_Rep_base*>(::operator new(sizeof(*rep) + len + 1));
+ rep->len = len;
+ rep->cap = len;
+ rep->count = 0;
+ char* data = data_from_rep(rep);
+ std::memcpy(data, msg, len + 1);
+ __imp_ = data;
}
-inline
-__libcpp_refstring::__libcpp_refstring(const __libcpp_refstring &s) noexcept
- : __imp_(s.__imp_)
-{
- if (__uses_refcount())
+inline __libcpp_refstring::__libcpp_refstring(const __libcpp_refstring& s) noexcept : __imp_(s.__imp_) {
+ if (__uses_refcount())
#ifdef _LIBCPP_USE_ATOMIC
- rep_from_data(__imp_)->count.fetch_add(1);
+ rep_from_data(__imp_)->count.fetch_add(1);
#else
- __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
+ __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
#endif
}
-inline
-__libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) noexcept {
- bool adjust_old_count = __uses_refcount();
- struct _Rep_base *old_rep = rep_from_data(__imp_);
- __imp_ = s.__imp_;
- if (__uses_refcount())
+inline __libcpp_refstring& __libcpp_refstring::operator=(__libcpp_refstring const& s) noexcept {
+ bool adjust_old_count = __uses_refcount();
+ struct _Rep_base* old_rep = rep_from_data(__imp_);
+ __imp_ = s.__imp_;
+ if (__uses_refcount())
#ifdef _LIBCPP_USE_ATOMIC
- rep_from_data(__imp_)->count.fetch_add(1);
+ rep_from_data(__imp_)->count.fetch_add(1);
#else
- __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
+ __libcpp_atomic_add(&rep_from_data(__imp_)->count, 1);
#endif
- if (adjust_old_count)
- {
+ if (adjust_old_count) {
#ifdef _LIBCPP_USE_ATOMIC
- if (old_rep->count.fetch_sub(1) == 0)
+ if (old_rep->count.fetch_sub(1) == 0)
#else
- if (__libcpp_atomic_add(&old_rep->count, count_t(-1)) < 0)
+ if (__libcpp_atomic_add(&old_rep->count, count_t(-1)) < 0)
#endif
- {
- ::operator delete(old_rep);
- }
+ {
+ ::operator delete(old_rep);
}
- return *this;
+ }
+ return *this;
}
-inline
-__libcpp_refstring::~__libcpp_refstring() {
- if (__uses_refcount()) {
- _Rep_base* rep = rep_from_data(__imp_);
+inline __libcpp_refstring::~__libcpp_refstring() {
+ if (__uses_refcount()) {
+ _Rep_base* rep = rep_from_data(__imp_);
#ifdef _LIBCPP_USE_ATOMIC
- if (rep->count.fetch_sub(1) == 0) {
+ if (rep->count.fetch_sub(1) == 0) {
#else
- if (__libcpp_atomic_add(&rep->count, count_t(-1)) < 0) {
+ if (__libcpp_atomic_add(&rep->count, count_t(-1)) < 0) {
#endif
- ::operator delete(rep);
- }
+ ::operator delete(rep);
}
+ }
}
-inline
-bool __libcpp_refstring::__uses_refcount() const {
+inline bool __libcpp_refstring::__uses_refcount() const {
#if defined(_LIBCPP_CHECK_FOR_GCC_EMPTY_STRING_STORAGE)
- return __imp_ != get_gcc_empty_string_storage();
+ return __imp_ != get_gcc_empty_string_storage();
#else
- return true;
+ return true;
#endif
}
diff --git a/contrib/libs/cxxsupp/libcxx/src/include/ryu/ryu.h b/contrib/libs/cxxsupp/libcxx/src/include/ryu/ryu.h
index 3f4afa5d60..7b19ecfec5 100644
--- a/contrib/libs/cxxsupp/libcxx/src/include/ryu/ryu.h
+++ b/contrib/libs/cxxsupp/libcxx/src/include/ryu/ryu.h
@@ -10,7 +10,6 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-
// Copyright 2018 Ulf Adams
// Copyright (c) Microsoft Corporation. All rights reserved.
diff --git a/contrib/libs/cxxsupp/libcxx/src/include/sso_allocator.h b/contrib/libs/cxxsupp/libcxx/src/include/sso_allocator.h
index 679a3b9a15..4e6761c580 100644
--- a/contrib/libs/cxxsupp/libcxx/src/include/sso_allocator.h
+++ b/contrib/libs/cxxsupp/libcxx/src/include/sso_allocator.h
@@ -17,65 +17,62 @@
#include <type_traits>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
-#pragma GCC system_header
+# pragma GCC system_header
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-template <class _Tp, size_t _Np> class _LIBCPP_HIDDEN __sso_allocator;
+template <class _Tp, size_t _Np>
+class _LIBCPP_HIDDEN __sso_allocator;
template <size_t _Np>
-class _LIBCPP_HIDDEN __sso_allocator<void, _Np>
-{
+class _LIBCPP_HIDDEN __sso_allocator<void, _Np> {
public:
- typedef const void* const_pointer;
- typedef void value_type;
+ typedef const void* const_pointer;
+ typedef void value_type;
};
template <class _Tp, size_t _Np>
-class _LIBCPP_HIDDEN __sso_allocator
-{
- alignas(_Tp) std::byte buf_[sizeof(_Tp) * _Np];
- bool __allocated_;
+class _LIBCPP_HIDDEN __sso_allocator {
+ alignas(_Tp) std::byte buf_[sizeof(_Tp) * _Np];
+ bool __allocated_;
+
public:
- typedef size_t size_type;
- typedef _Tp* pointer;
- typedef _Tp value_type;
+ typedef size_t size_type;
+ typedef _Tp* pointer;
+ typedef _Tp value_type;
+
+ template <class U>
+ struct rebind {
+ using other = __sso_allocator<U, _Np>;
+ };
- template <class U>
- struct rebind {
- using other = __sso_allocator<U, _Np>;
- };
+ _LIBCPP_HIDE_FROM_ABI __sso_allocator() throw() : __allocated_(false) {}
+ _LIBCPP_HIDE_FROM_ABI __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
+ template <class _Up>
+ _LIBCPP_HIDE_FROM_ABI __sso_allocator(const __sso_allocator<_Up, _Np>&) throw() : __allocated_(false) {}
- _LIBCPP_HIDE_FROM_ABI __sso_allocator() throw() : __allocated_(false) {}
- _LIBCPP_HIDE_FROM_ABI __sso_allocator(const __sso_allocator&) throw() : __allocated_(false) {}
- template <class _Up> _LIBCPP_HIDE_FROM_ABI __sso_allocator(const __sso_allocator<_Up, _Np>&) throw()
- : __allocated_(false) {}
private:
- __sso_allocator& operator=(const __sso_allocator&);
+ __sso_allocator& operator=(const __sso_allocator&);
+
public:
- _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = nullptr)
- {
- if (!__allocated_ && __n <= _Np)
- {
- __allocated_ = true;
- return (pointer)&buf_;
- }
- return allocator<_Tp>().allocate(__n);
- }
- _LIBCPP_HIDE_FROM_ABI void deallocate(pointer __p, size_type __n)
- {
- if (__p == (pointer)&buf_)
- __allocated_ = false;
- else
- allocator<_Tp>().deallocate(__p, __n);
+ _LIBCPP_HIDE_FROM_ABI pointer allocate(size_type __n, typename __sso_allocator<void, _Np>::const_pointer = nullptr) {
+ if (!__allocated_ && __n <= _Np) {
+ __allocated_ = true;
+ return (pointer)&buf_;
}
- _LIBCPP_HIDE_FROM_ABI size_type max_size() const throw() {return size_type(~0) / sizeof(_Tp);}
+ return allocator<_Tp>().allocate(__n);
+ }
+ _LIBCPP_HIDE_FROM_ABI void deallocate(pointer __p, size_type __n) {
+ if (__p == (pointer)&buf_)
+ __allocated_ = false;
+ else
+ allocator<_Tp>().deallocate(__p, __n);
+ }
+ _LIBCPP_HIDE_FROM_ABI size_type max_size() const throw() { return size_type(~0) / sizeof(_Tp); }
- _LIBCPP_HIDE_FROM_ABI
- bool operator==(const __sso_allocator& __a) const {return &buf_ == &__a.buf_;}
- _LIBCPP_HIDE_FROM_ABI
- bool operator!=(const __sso_allocator& __a) const {return &buf_ != &__a.buf_;}
+ _LIBCPP_HIDE_FROM_ABI bool operator==(const __sso_allocator& __a) const { return &buf_ == &__a.buf_; }
+ _LIBCPP_HIDE_FROM_ABI bool operator!=(const __sso_allocator& __a) const { return &buf_ != &__a.buf_; }
};
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/ios.cpp b/contrib/libs/cxxsupp/libcxx/src/ios.cpp
index e80007d42c..d58827fa12 100644
--- a/contrib/libs/cxxsupp/libcxx/src/ios.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/ios.cpp
@@ -23,59 +23,41 @@ _LIBCPP_PUSH_MACROS
_LIBCPP_BEGIN_NAMESPACE_STD
-class _LIBCPP_HIDDEN __iostream_category
- : public __do_message
-{
+class _LIBCPP_HIDDEN __iostream_category : public __do_message {
public:
- virtual const char* name() const noexcept;
- virtual string message(int ev) const;
+ virtual const char* name() const noexcept;
+ virtual string message(int ev) const;
};
-const char*
-__iostream_category::name() const noexcept
-{
- return "iostream";
-}
+const char* __iostream_category::name() const noexcept { return "iostream"; }
-string
-__iostream_category::message(int ev) const
-{
- if (ev != static_cast<int>(io_errc::stream)
+string __iostream_category::message(int ev) const {
+ if (ev != static_cast<int>(io_errc::stream)
#ifdef _LIBCPP_ELAST
- && ev <= _LIBCPP_ELAST
+ && ev <= _LIBCPP_ELAST
#endif // _LIBCPP_ELAST
- )
- return __do_message::message(ev);
- return string("unspecified iostream_category error");
+ )
+ return __do_message::message(ev);
+ return string("unspecified iostream_category error");
}
-const error_category&
-iostream_category() noexcept
-{
- union AvoidDestroyingIostreamCategory {
- __iostream_category iostream_error_category;
- constexpr explicit AvoidDestroyingIostreamCategory() : iostream_error_category() {}
- ~AvoidDestroyingIostreamCategory() {}
- };
- constinit static AvoidDestroyingIostreamCategory helper;
- return helper.iostream_error_category;
+const error_category& iostream_category() noexcept {
+ union AvoidDestroyingIostreamCategory {
+ __iostream_category iostream_error_category;
+ constexpr explicit AvoidDestroyingIostreamCategory() : iostream_error_category() {}
+ ~AvoidDestroyingIostreamCategory() {}
+ };
+ constinit static AvoidDestroyingIostreamCategory helper;
+ return helper.iostream_error_category;
}
// ios_base::failure
-ios_base::failure::failure(const string& msg, const error_code& ec)
- : system_error(ec, msg)
-{
-}
+ios_base::failure::failure(const string& msg, const error_code& ec) : system_error(ec, msg) {}
-ios_base::failure::failure(const char* msg, const error_code& ec)
- : system_error(ec, msg)
-{
-}
+ios_base::failure::failure(const char* msg, const error_code& ec) : system_error(ec, msg) {}
-ios_base::failure::~failure() throw()
-{
-}
+ios_base::failure::~failure() throw() {}
// ios_base locale
@@ -110,34 +92,27 @@ const ios_base::openmode ios_base::in;
const ios_base::openmode ios_base::out;
const ios_base::openmode ios_base::trunc;
-void
-ios_base::__call_callbacks(event ev)
-{
- for (size_t i = __event_size_; i;)
- {
- --i;
- __fn_[i](ev, *this, __index_[i]);
- }
+void ios_base::__call_callbacks(event ev) {
+ for (size_t i = __event_size_; i;) {
+ --i;
+ __fn_[i](ev, *this, __index_[i]);
+ }
}
// locale
-locale
-ios_base::imbue(const locale& newloc)
-{
- static_assert(sizeof(locale) == sizeof(__loc_), "");
- locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
- locale oldloc = loc_storage;
- loc_storage = newloc;
- __call_callbacks(imbue_event);
- return oldloc;
+locale ios_base::imbue(const locale& newloc) {
+ static_assert(sizeof(locale) == sizeof(__loc_), "");
+ locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
+ locale oldloc = loc_storage;
+ loc_storage = newloc;
+ __call_callbacks(imbue_event);
+ return oldloc;
}
-locale
-ios_base::getloc() const
-{
- const locale& loc_storage = *reinterpret_cast<const locale*>(&__loc_);
- return loc_storage;
+locale ios_base::getloc() const {
+ const locale& loc_storage = *reinterpret_cast<const locale*>(&__loc_);
+ return loc_storage;
}
// xalloc
@@ -148,299 +123,259 @@ int ios_base::__xindex_ = 0;
#endif
template <typename _Tp>
-static size_t __ios_new_cap(size_t __req_size, size_t __current_cap)
-{ // Precondition: __req_size > __current_cap
- const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
- if (__req_size < mx/2)
- return std::max(2 * __current_cap, __req_size);
- else
- return mx;
-}
-
-int
-ios_base::xalloc()
-{
- return __xindex_++;
+static size_t __ios_new_cap(size_t __req_size, size_t __current_cap) { // Precondition: __req_size > __current_cap
+ const size_t mx = std::numeric_limits<size_t>::max() / sizeof(_Tp);
+ if (__req_size < mx / 2)
+ return std::max(2 * __current_cap, __req_size);
+ else
+ return mx;
}
-long&
-ios_base::iword(int index)
-{
- size_t req_size = static_cast<size_t>(index)+1;
- if (req_size > __iarray_cap_)
- {
- size_t newcap = __ios_new_cap<long>(req_size, __iarray_cap_);
- long* iarray = static_cast<long*>(realloc(__iarray_, newcap * sizeof(long)));
- if (iarray == 0)
- {
- setstate(badbit);
- static long error;
- error = 0;
- return error;
- }
- __iarray_ = iarray;
- for (long* p = __iarray_ + __iarray_size_; p < __iarray_ + newcap; ++p)
- *p = 0;
- __iarray_cap_ = newcap;
+int ios_base::xalloc() { return __xindex_++; }
+
+long& ios_base::iword(int index) {
+ size_t req_size = static_cast<size_t>(index) + 1;
+ if (req_size > __iarray_cap_) {
+ size_t newcap = __ios_new_cap<long>(req_size, __iarray_cap_);
+ long* iarray = static_cast<long*>(realloc(__iarray_, newcap * sizeof(long)));
+ if (iarray == 0) {
+ setstate(badbit);
+ static long error;
+ error = 0;
+ return error;
}
- __iarray_size_ = max<size_t>(__iarray_size_, req_size);
- return __iarray_[index];
+ __iarray_ = iarray;
+ for (long* p = __iarray_ + __iarray_size_; p < __iarray_ + newcap; ++p)
+ *p = 0;
+ __iarray_cap_ = newcap;
+ }
+ __iarray_size_ = max<size_t>(__iarray_size_, req_size);
+ return __iarray_[index];
}
-void*&
-ios_base::pword(int index)
-{
- size_t req_size = static_cast<size_t>(index)+1;
- if (req_size > __parray_cap_)
- {
- size_t newcap = __ios_new_cap<void *>(req_size, __iarray_cap_);
- void** parray = static_cast<void**>(realloc(__parray_, newcap * sizeof(void *)));
- if (parray == 0)
- {
- setstate(badbit);
- static void* error;
- error = 0;
- return error;
- }
- __parray_ = parray;
- for (void** p = __parray_ + __parray_size_; p < __parray_ + newcap; ++p)
- *p = 0;
- __parray_cap_ = newcap;
+void*& ios_base::pword(int index) {
+ size_t req_size = static_cast<size_t>(index) + 1;
+ if (req_size > __parray_cap_) {
+ size_t newcap = __ios_new_cap<void*>(req_size, __iarray_cap_);
+ void** parray = static_cast<void**>(realloc(__parray_, newcap * sizeof(void*)));
+ if (parray == 0) {
+ setstate(badbit);
+ static void* error;
+ error = 0;
+ return error;
}
- __parray_size_ = max<size_t>(__parray_size_, req_size);
- return __parray_[index];
+ __parray_ = parray;
+ for (void** p = __parray_ + __parray_size_; p < __parray_ + newcap; ++p)
+ *p = 0;
+ __parray_cap_ = newcap;
+ }
+ __parray_size_ = max<size_t>(__parray_size_, req_size);
+ return __parray_[index];
}
// register_callback
-void
-ios_base::register_callback(event_callback fn, int index)
-{
- size_t req_size = __event_size_ + 1;
- if (req_size > __event_cap_)
- {
- size_t newcap = __ios_new_cap<event_callback>(req_size, __event_cap_);
- event_callback* fns = static_cast<event_callback*>(realloc(__fn_, newcap * sizeof(event_callback)));
- if (fns == 0)
- setstate(badbit);
- __fn_ = fns;
- int* indxs = static_cast<int *>(realloc(__index_, newcap * sizeof(int)));
- if (indxs == 0)
- setstate(badbit);
- __index_ = indxs;
- __event_cap_ = newcap;
- }
- __fn_[__event_size_] = fn;
- __index_[__event_size_] = index;
- ++__event_size_;
+void ios_base::register_callback(event_callback fn, int index) {
+ size_t req_size = __event_size_ + 1;
+ if (req_size > __event_cap_) {
+ size_t newcap = __ios_new_cap<event_callback>(req_size, __event_cap_);
+ event_callback* fns = static_cast<event_callback*>(realloc(__fn_, newcap * sizeof(event_callback)));
+ if (fns == 0)
+ setstate(badbit);
+ __fn_ = fns;
+ int* indxs = static_cast<int*>(realloc(__index_, newcap * sizeof(int)));
+ if (indxs == 0)
+ setstate(badbit);
+ __index_ = indxs;
+ __event_cap_ = newcap;
+ }
+ __fn_[__event_size_] = fn;
+ __index_[__event_size_] = index;
+ ++__event_size_;
}
-ios_base::~ios_base()
-{
- __call_callbacks(erase_event);
- locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
- loc_storage.~locale();
- free(__fn_);
- free(__index_);
- free(__iarray_);
- free(__parray_);
+ios_base::~ios_base() {
+ __call_callbacks(erase_event);
+ locale& loc_storage = *reinterpret_cast<locale*>(&__loc_);
+ loc_storage.~locale();
+ free(__fn_);
+ free(__index_);
+ free(__iarray_);
+ free(__parray_);
}
// iostate
-void
-ios_base::clear(iostate state)
-{
- if (__rdbuf_)
- __rdstate_ = state;
- else
- __rdstate_ = state | badbit;
+void ios_base::clear(iostate state) {
+ if (__rdbuf_)
+ __rdstate_ = state;
+ else
+ __rdstate_ = state | badbit;
- if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0)
- __throw_failure("ios_base::clear");
+ if (((state | (__rdbuf_ ? goodbit : badbit)) & __exceptions_) != 0)
+ __throw_failure("ios_base::clear");
}
// init
-void
-ios_base::init(void* sb)
-{
- __rdbuf_ = sb;
- __rdstate_ = __rdbuf_ ? goodbit : badbit;
- __exceptions_ = goodbit;
- __fmtflags_ = skipws | dec;
- __width_ = 0;
- __precision_ = 6;
- __fn_ = 0;
- __index_ = 0;
- __event_size_ = 0;
- __event_cap_ = 0;
- __iarray_ = 0;
- __iarray_size_ = 0;
- __iarray_cap_ = 0;
- __parray_ = 0;
- __parray_size_ = 0;
- __parray_cap_ = 0;
- ::new(&__loc_) locale;
+void ios_base::init(void* sb) {
+ __rdbuf_ = sb;
+ __rdstate_ = __rdbuf_ ? goodbit : badbit;
+ __exceptions_ = goodbit;
+ __fmtflags_ = skipws | dec;
+ __width_ = 0;
+ __precision_ = 6;
+ __fn_ = 0;
+ __index_ = 0;
+ __event_size_ = 0;
+ __event_cap_ = 0;
+ __iarray_ = 0;
+ __iarray_size_ = 0;
+ __iarray_cap_ = 0;
+ __parray_ = 0;
+ __parray_size_ = 0;
+ __parray_cap_ = 0;
+ ::new (&__loc_) locale;
}
-void
-ios_base::copyfmt(const ios_base& rhs)
-{
- // If we can't acquire the needed resources, throw bad_alloc (can't set badbit)
- // Don't alter *this until all needed resources are acquired
- unique_ptr<event_callback, void (*)(void*)> new_callbacks(0, free);
- unique_ptr<int, void (*)(void*)> new_ints(0, free);
- unique_ptr<long, void (*)(void*)> new_longs(0, free);
- unique_ptr<void*, void (*)(void*)> new_pointers(0, free);
- if (__event_cap_ < rhs.__event_size_)
- {
- size_t newesize = sizeof(event_callback) * rhs.__event_size_;
- new_callbacks.reset(static_cast<event_callback*>(malloc(newesize)));
- if (!new_callbacks)
- __throw_bad_alloc();
-
- size_t newisize = sizeof(int) * rhs.__event_size_;
- new_ints.reset(static_cast<int *>(malloc(newisize)));
- if (!new_ints)
- __throw_bad_alloc();
- }
- if (__iarray_cap_ < rhs.__iarray_size_)
- {
- size_t newsize = sizeof(long) * rhs.__iarray_size_;
- new_longs.reset(static_cast<long*>(malloc(newsize)));
- if (!new_longs)
- __throw_bad_alloc();
- }
- if (__parray_cap_ < rhs.__parray_size_)
- {
- size_t newsize = sizeof(void*) * rhs.__parray_size_;
- new_pointers.reset(static_cast<void**>(malloc(newsize)));
- if (!new_pointers)
- __throw_bad_alloc();
- }
- // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_
- __fmtflags_ = rhs.__fmtflags_;
- __precision_ = rhs.__precision_;
- __width_ = rhs.__width_;
- locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
- const locale& rhs_loc = *reinterpret_cast<const locale*>(&rhs.__loc_);
- lhs_loc = rhs_loc;
- if (__event_cap_ < rhs.__event_size_)
- {
- free(__fn_);
- __fn_ = new_callbacks.release();
- free(__index_);
- __index_ = new_ints.release();
- __event_cap_ = rhs.__event_size_;
- }
- for (__event_size_ = 0; __event_size_ < rhs.__event_size_; ++__event_size_)
- {
- __fn_[__event_size_] = rhs.__fn_[__event_size_];
- __index_[__event_size_] = rhs.__index_[__event_size_];
- }
- if (__iarray_cap_ < rhs.__iarray_size_)
- {
- free(__iarray_);
- __iarray_ = new_longs.release();
- __iarray_cap_ = rhs.__iarray_size_;
- }
- for (__iarray_size_ = 0; __iarray_size_ < rhs.__iarray_size_; ++__iarray_size_)
- __iarray_[__iarray_size_] = rhs.__iarray_[__iarray_size_];
- if (__parray_cap_ < rhs.__parray_size_)
- {
- free(__parray_);
- __parray_ = new_pointers.release();
- __parray_cap_ = rhs.__parray_size_;
- }
- for (__parray_size_ = 0; __parray_size_ < rhs.__parray_size_; ++__parray_size_)
- __parray_[__parray_size_] = rhs.__parray_[__parray_size_];
+void ios_base::copyfmt(const ios_base& rhs) {
+ // If we can't acquire the needed resources, throw bad_alloc (can't set badbit)
+ // Don't alter *this until all needed resources are acquired
+ unique_ptr<event_callback, void (*)(void*)> new_callbacks(0, free);
+ unique_ptr<int, void (*)(void*)> new_ints(0, free);
+ unique_ptr<long, void (*)(void*)> new_longs(0, free);
+ unique_ptr<void*, void (*)(void*)> new_pointers(0, free);
+ if (__event_cap_ < rhs.__event_size_) {
+ size_t newesize = sizeof(event_callback) * rhs.__event_size_;
+ new_callbacks.reset(static_cast<event_callback*>(malloc(newesize)));
+ if (!new_callbacks)
+ __throw_bad_alloc();
+
+ size_t newisize = sizeof(int) * rhs.__event_size_;
+ new_ints.reset(static_cast<int*>(malloc(newisize)));
+ if (!new_ints)
+ __throw_bad_alloc();
+ }
+ if (__iarray_cap_ < rhs.__iarray_size_) {
+ size_t newsize = sizeof(long) * rhs.__iarray_size_;
+ new_longs.reset(static_cast<long*>(malloc(newsize)));
+ if (!new_longs)
+ __throw_bad_alloc();
+ }
+ if (__parray_cap_ < rhs.__parray_size_) {
+ size_t newsize = sizeof(void*) * rhs.__parray_size_;
+ new_pointers.reset(static_cast<void**>(malloc(newsize)));
+ if (!new_pointers)
+ __throw_bad_alloc();
+ }
+ // Got everything we need. Copy everything but __rdstate_, __rdbuf_ and __exceptions_
+ __fmtflags_ = rhs.__fmtflags_;
+ __precision_ = rhs.__precision_;
+ __width_ = rhs.__width_;
+ locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
+ const locale& rhs_loc = *reinterpret_cast<const locale*>(&rhs.__loc_);
+ lhs_loc = rhs_loc;
+ if (__event_cap_ < rhs.__event_size_) {
+ free(__fn_);
+ __fn_ = new_callbacks.release();
+ free(__index_);
+ __index_ = new_ints.release();
+ __event_cap_ = rhs.__event_size_;
+ }
+ for (__event_size_ = 0; __event_size_ < rhs.__event_size_; ++__event_size_) {
+ __fn_[__event_size_] = rhs.__fn_[__event_size_];
+ __index_[__event_size_] = rhs.__index_[__event_size_];
+ }
+ if (__iarray_cap_ < rhs.__iarray_size_) {
+ free(__iarray_);
+ __iarray_ = new_longs.release();
+ __iarray_cap_ = rhs.__iarray_size_;
+ }
+ for (__iarray_size_ = 0; __iarray_size_ < rhs.__iarray_size_; ++__iarray_size_)
+ __iarray_[__iarray_size_] = rhs.__iarray_[__iarray_size_];
+ if (__parray_cap_ < rhs.__parray_size_) {
+ free(__parray_);
+ __parray_ = new_pointers.release();
+ __parray_cap_ = rhs.__parray_size_;
+ }
+ for (__parray_size_ = 0; __parray_size_ < rhs.__parray_size_; ++__parray_size_)
+ __parray_[__parray_size_] = rhs.__parray_[__parray_size_];
}
-void
-ios_base::move(ios_base& rhs)
-{
- // *this is uninitialized
- __fmtflags_ = rhs.__fmtflags_;
- __precision_ = rhs.__precision_;
- __width_ = rhs.__width_;
- __rdstate_ = rhs.__rdstate_;
- __exceptions_ = rhs.__exceptions_;
- __rdbuf_ = 0;
- locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
- ::new(&__loc_) locale(rhs_loc);
- __fn_ = rhs.__fn_;
- rhs.__fn_ = 0;
- __index_ = rhs.__index_;
- rhs.__index_ = 0;
- __event_size_ = rhs.__event_size_;
- rhs.__event_size_ = 0;
- __event_cap_ = rhs.__event_cap_;
- rhs.__event_cap_ = 0;
- __iarray_ = rhs.__iarray_;
- rhs.__iarray_ = 0;
- __iarray_size_ = rhs.__iarray_size_;
- rhs.__iarray_size_ = 0;
- __iarray_cap_ = rhs.__iarray_cap_;
- rhs.__iarray_cap_ = 0;
- __parray_ = rhs.__parray_;
- rhs.__parray_ = 0;
- __parray_size_ = rhs.__parray_size_;
- rhs.__parray_size_ = 0;
- __parray_cap_ = rhs.__parray_cap_;
- rhs.__parray_cap_ = 0;
+void ios_base::move(ios_base& rhs) {
+ // *this is uninitialized
+ __fmtflags_ = rhs.__fmtflags_;
+ __precision_ = rhs.__precision_;
+ __width_ = rhs.__width_;
+ __rdstate_ = rhs.__rdstate_;
+ __exceptions_ = rhs.__exceptions_;
+ __rdbuf_ = 0;
+ locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
+ ::new (&__loc_) locale(rhs_loc);
+ __fn_ = rhs.__fn_;
+ rhs.__fn_ = 0;
+ __index_ = rhs.__index_;
+ rhs.__index_ = 0;
+ __event_size_ = rhs.__event_size_;
+ rhs.__event_size_ = 0;
+ __event_cap_ = rhs.__event_cap_;
+ rhs.__event_cap_ = 0;
+ __iarray_ = rhs.__iarray_;
+ rhs.__iarray_ = 0;
+ __iarray_size_ = rhs.__iarray_size_;
+ rhs.__iarray_size_ = 0;
+ __iarray_cap_ = rhs.__iarray_cap_;
+ rhs.__iarray_cap_ = 0;
+ __parray_ = rhs.__parray_;
+ rhs.__parray_ = 0;
+ __parray_size_ = rhs.__parray_size_;
+ rhs.__parray_size_ = 0;
+ __parray_cap_ = rhs.__parray_cap_;
+ rhs.__parray_cap_ = 0;
}
-void
-ios_base::swap(ios_base& rhs) noexcept
-{
- std::swap(__fmtflags_, rhs.__fmtflags_);
- std::swap(__precision_, rhs.__precision_);
- std::swap(__width_, rhs.__width_);
- std::swap(__rdstate_, rhs.__rdstate_);
- std::swap(__exceptions_, rhs.__exceptions_);
- locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
- locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
- std::swap(lhs_loc, rhs_loc);
- std::swap(__fn_, rhs.__fn_);
- std::swap(__index_, rhs.__index_);
- std::swap(__event_size_, rhs.__event_size_);
- std::swap(__event_cap_, rhs.__event_cap_);
- std::swap(__iarray_, rhs.__iarray_);
- std::swap(__iarray_size_, rhs.__iarray_size_);
- std::swap(__iarray_cap_, rhs.__iarray_cap_);
- std::swap(__parray_, rhs.__parray_);
- std::swap(__parray_size_, rhs.__parray_size_);
- std::swap(__parray_cap_, rhs.__parray_cap_);
+void ios_base::swap(ios_base& rhs) noexcept {
+ std::swap(__fmtflags_, rhs.__fmtflags_);
+ std::swap(__precision_, rhs.__precision_);
+ std::swap(__width_, rhs.__width_);
+ std::swap(__rdstate_, rhs.__rdstate_);
+ std::swap(__exceptions_, rhs.__exceptions_);
+ locale& lhs_loc = *reinterpret_cast<locale*>(&__loc_);
+ locale& rhs_loc = *reinterpret_cast<locale*>(&rhs.__loc_);
+ std::swap(lhs_loc, rhs_loc);
+ std::swap(__fn_, rhs.__fn_);
+ std::swap(__index_, rhs.__index_);
+ std::swap(__event_size_, rhs.__event_size_);
+ std::swap(__event_cap_, rhs.__event_cap_);
+ std::swap(__iarray_, rhs.__iarray_);
+ std::swap(__iarray_size_, rhs.__iarray_size_);
+ std::swap(__iarray_cap_, rhs.__iarray_cap_);
+ std::swap(__parray_, rhs.__parray_);
+ std::swap(__parray_size_, rhs.__parray_size_);
+ std::swap(__parray_cap_, rhs.__parray_cap_);
}
-void
-ios_base::__set_badbit_and_consider_rethrow()
-{
- __rdstate_ |= badbit;
+void ios_base::__set_badbit_and_consider_rethrow() {
+ __rdstate_ |= badbit;
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- if (__exceptions_ & badbit)
- throw;
+ if (__exceptions_ & badbit)
+ throw;
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
-void
-ios_base::__set_failbit_and_consider_rethrow()
-{
- __rdstate_ |= failbit;
+void ios_base::__set_failbit_and_consider_rethrow() {
+ __rdstate_ |= failbit;
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- if (__exceptions_ & failbit)
- throw;
+ if (__exceptions_ & failbit)
+ throw;
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
-bool
-ios_base::sync_with_stdio(bool sync)
-{
- static bool previous_state = true;
- bool r = previous_state;
- previous_state = sync;
- return r;
+bool ios_base::sync_with_stdio(bool sync) {
+ static bool previous_state = true;
+ bool r = previous_state;
+ previous_state = sync;
+ return r;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/iostream.cpp b/contrib/libs/cxxsupp/libcxx/src/iostream.cpp
index 4ac686e186..93edf3a0d5 100644
--- a/contrib/libs/cxxsupp/libcxx/src/iostream.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/iostream.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include <__locale>
#include "std_stream.h"
+#include <__locale>
#include <new>
#include <string>
@@ -22,111 +22,127 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
-_ALIGNAS_TYPE (istream) char _cin [sizeof(istream)];
+_ALIGNAS_TYPE(istream) char _cin[sizeof(istream)];
_LIBCPP_EXPORTED_FROM_ABI istream& cin = *reinterpret_cast<istream*>(_cin);
#else
-_ALIGNAS_TYPE (istream) _LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)]
-#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
-#endif
-;
-#endif
-_ALIGNAS_TYPE (__stdinbuf<char> ) static char __cin[sizeof(__stdinbuf <char>)];
+_ALIGNAS_TYPE(istream)
+_LIBCPP_EXPORTED_FROM_ABI char cin[sizeof(istream)]
+# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+ __asm__("?cin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
+ "@std@@@12@A")
+# endif
+ ;
+#endif
+_ALIGNAS_TYPE(__stdinbuf<char>) static char __cin[sizeof(__stdinbuf<char>)];
static mbstate_t mb_cin;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
-_ALIGNAS_TYPE (wistream) char _wcin [sizeof(wistream)];
+# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE(wistream) char _wcin[sizeof(wistream)];
_LIBCPP_EXPORTED_FROM_ABI wistream& wcin = *reinterpret_cast<wistream*>(_wcin);
-#else
-_ALIGNAS_TYPE (wistream) _LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)]
-#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
-#endif
-;
-#endif
-_ALIGNAS_TYPE (__stdinbuf<wchar_t> ) static char __wcin[sizeof(__stdinbuf <wchar_t>)];
+# else
+_ALIGNAS_TYPE(wistream)
+_LIBCPP_EXPORTED_FROM_ABI char wcin[sizeof(wistream)]
+# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+ __asm__("?wcin@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_istream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
+ "@std@@@12@A")
+# endif
+ ;
+# endif
+_ALIGNAS_TYPE(__stdinbuf<wchar_t>) static char __wcin[sizeof(__stdinbuf<wchar_t>)];
static mbstate_t mb_wcin;
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
-_ALIGNAS_TYPE (ostream) char _cout[sizeof(ostream)];
+_ALIGNAS_TYPE(ostream) char _cout[sizeof(ostream)];
_LIBCPP_EXPORTED_FROM_ABI ostream& cout = *reinterpret_cast<ostream*>(_cout);
#else
-_ALIGNAS_TYPE (ostream) _LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)]
-#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
-#endif
-;
-#endif
-_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
+_ALIGNAS_TYPE(ostream)
+_LIBCPP_EXPORTED_FROM_ABI char cout[sizeof(ostream)]
+# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+ __asm__("?cout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
+ "@std@@@12@A")
+# endif
+ ;
+#endif
+_ALIGNAS_TYPE(__stdoutbuf<char>) static char __cout[sizeof(__stdoutbuf<char>)];
static mbstate_t mb_cout;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
-_ALIGNAS_TYPE (wostream) char _wcout[sizeof(wostream)];
+# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE(wostream) char _wcout[sizeof(wostream)];
_LIBCPP_EXPORTED_FROM_ABI wostream& wcout = *reinterpret_cast<wostream*>(_wcout);
-#else
-_ALIGNAS_TYPE (wostream) _LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)]
-#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
-#endif
-;
-#endif
-_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
+# else
+_ALIGNAS_TYPE(wostream)
+_LIBCPP_EXPORTED_FROM_ABI char wcout[sizeof(wostream)]
+# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+ __asm__("?wcout@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
+ "@std@@@12@A")
+# endif
+ ;
+# endif
+_ALIGNAS_TYPE(__stdoutbuf<wchar_t>) static char __wcout[sizeof(__stdoutbuf<wchar_t>)];
static mbstate_t mb_wcout;
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
-_ALIGNAS_TYPE (ostream) char _cerr[sizeof(ostream)];
+_ALIGNAS_TYPE(ostream) char _cerr[sizeof(ostream)];
_LIBCPP_EXPORTED_FROM_ABI ostream& cerr = *reinterpret_cast<ostream*>(_cerr);
#else
-_ALIGNAS_TYPE (ostream) _LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)]
-#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
-#endif
-;
-#endif
-_ALIGNAS_TYPE (__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
+_ALIGNAS_TYPE(ostream)
+_LIBCPP_EXPORTED_FROM_ABI char cerr[sizeof(ostream)]
+# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+ __asm__("?cerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
+ "@std@@@12@A")
+# endif
+ ;
+#endif
+_ALIGNAS_TYPE(__stdoutbuf<char>) static char __cerr[sizeof(__stdoutbuf<char>)];
static mbstate_t mb_cerr;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
-_ALIGNAS_TYPE (wostream) char _wcerr[sizeof(wostream)];
+# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE(wostream) char _wcerr[sizeof(wostream)];
_LIBCPP_EXPORTED_FROM_ABI wostream& wcerr = *reinterpret_cast<wostream*>(_wcerr);
-#else
-_ALIGNAS_TYPE (wostream) _LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)]
-#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
-#endif
-;
-#endif
-_ALIGNAS_TYPE (__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
+# else
+_ALIGNAS_TYPE(wostream)
+_LIBCPP_EXPORTED_FROM_ABI char wcerr[sizeof(wostream)]
+# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+ __asm__("?wcerr@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
+ "@std@@@12@A")
+# endif
+ ;
+# endif
+_ALIGNAS_TYPE(__stdoutbuf<wchar_t>) static char __wcerr[sizeof(__stdoutbuf<wchar_t>)];
static mbstate_t mb_wcerr;
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
-_ALIGNAS_TYPE (ostream) char _clog[sizeof(ostream)];
+_ALIGNAS_TYPE(ostream) char _clog[sizeof(ostream)];
_LIBCPP_EXPORTED_FROM_ABI ostream& clog = *reinterpret_cast<ostream*>(_clog);
#else
-_ALIGNAS_TYPE (ostream) _LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]
-#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
-#endif
-;
+_ALIGNAS_TYPE(ostream)
+_LIBCPP_EXPORTED_FROM_ABI char clog[sizeof(ostream)]
+# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+ __asm__("?clog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@DU?$char_traits@D@" _LIBCPP_ABI_NAMESPACE_STR
+ "@std@@@12@A")
+# endif
+ ;
#endif
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
-_ALIGNAS_TYPE (wostream) char _wclog[sizeof(wostream)];
+# if defined(_LIBCPP_ABI_MICROSOFT) && !defined(__clang__)
+_ALIGNAS_TYPE(wostream) char _wclog[sizeof(wostream)];
_LIBCPP_EXPORTED_FROM_ABI wostream& wclog = *reinterpret_cast<wostream*>(_wclog);
-#else
-_ALIGNAS_TYPE (wostream) _LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)]
-#if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
-__asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR "@std@@@12@A")
-#endif
-;
-#endif
+# else
+_ALIGNAS_TYPE(wostream)
+_LIBCPP_EXPORTED_FROM_ABI char wclog[sizeof(wostream)]
+# if defined(_LIBCPP_ABI_MICROSOFT) && defined(__clang__)
+ __asm__("?wclog@" _LIBCPP_ABI_NAMESPACE_STR "@std@@3V?$basic_ostream@_WU?$char_traits@_W@" _LIBCPP_ABI_NAMESPACE_STR
+ "@std@@@12@A")
+# endif
+ ;
+# endif
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// Pretend we're inside a system header so the compiler doesn't flag the use of the init_priority
@@ -141,8 +157,8 @@ static void force_locale_initialization() {
static bool once = []() {
auto loc = newlocale(LC_ALL_MASK, "C", 0);
{
- __libcpp_locale_guard g(loc); // forces initialization of locale TLS
- ((void)g);
+ __libcpp_locale_guard g(loc); // forces initialization of locale TLS
+ ((void)g);
}
freelocale(loc);
return true;
@@ -153,56 +169,51 @@ static void force_locale_initialization() {
class DoIOSInit {
public:
- DoIOSInit();
- ~DoIOSInit();
+ DoIOSInit();
+ ~DoIOSInit();
};
-DoIOSInit::DoIOSInit()
-{
- force_locale_initialization();
+DoIOSInit::DoIOSInit() {
+ force_locale_initialization();
- istream* cin_ptr = ::new(&cin) istream(::new(__cin) __stdinbuf <char>(stdin, &mb_cin));
- ostream* cout_ptr = ::new(&cout) ostream(::new(__cout) __stdoutbuf<char>(stdout, &mb_cout));
- ostream* cerr_ptr = ::new(&cerr) ostream(::new(__cerr) __stdoutbuf<char>(stderr, &mb_cerr));
- ::new(&clog) ostream(cerr_ptr->rdbuf());
- cin_ptr->tie(cout_ptr);
- std::unitbuf(*cerr_ptr);
- cerr_ptr->tie(cout_ptr);
+ istream* cin_ptr = ::new (&cin) istream(::new (__cin) __stdinbuf<char>(stdin, &mb_cin));
+ ostream* cout_ptr = ::new (&cout) ostream(::new (__cout) __stdoutbuf<char>(stdout, &mb_cout));
+ ostream* cerr_ptr = ::new (&cerr) ostream(::new (__cerr) __stdoutbuf<char>(stderr, &mb_cerr));
+ ::new (&clog) ostream(cerr_ptr->rdbuf());
+ cin_ptr->tie(cout_ptr);
+ std::unitbuf(*cerr_ptr);
+ cerr_ptr->tie(cout_ptr);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- wistream* wcin_ptr = ::new(&wcin) wistream(::new(__wcin) __stdinbuf <wchar_t>(stdin, &mb_wcin));
- wostream* wcout_ptr = ::new(&wcout) wostream(::new(__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));
- wostream* wcerr_ptr = ::new(&wcerr) wostream(::new(__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));
- ::new(&wclog) wostream(wcerr_ptr->rdbuf());
-
- wcin_ptr->tie(wcout_ptr);
- std::unitbuf(*wcerr_ptr);
- wcerr_ptr->tie(wcout_ptr);
+ wistream* wcin_ptr = ::new (&wcin) wistream(::new (__wcin) __stdinbuf<wchar_t>(stdin, &mb_wcin));
+ wostream* wcout_ptr = ::new (&wcout) wostream(::new (__wcout) __stdoutbuf<wchar_t>(stdout, &mb_wcout));
+ wostream* wcerr_ptr = ::new (&wcerr) wostream(::new (__wcerr) __stdoutbuf<wchar_t>(stderr, &mb_wcerr));
+ ::new (&wclog) wostream(wcerr_ptr->rdbuf());
+
+ wcin_ptr->tie(wcout_ptr);
+ std::unitbuf(*wcerr_ptr);
+ wcerr_ptr->tie(wcout_ptr);
#endif
}
-DoIOSInit::~DoIOSInit()
-{
- ostream* cout_ptr = reinterpret_cast<ostream*>(&cout);
- cout_ptr->flush();
- ostream* clog_ptr = reinterpret_cast<ostream*>(&clog);
- clog_ptr->flush();
+DoIOSInit::~DoIOSInit() {
+ ostream* cout_ptr = reinterpret_cast<ostream*>(&cout);
+ cout_ptr->flush();
+ ostream* clog_ptr = reinterpret_cast<ostream*>(&clog);
+ clog_ptr->flush();
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- wostream* wcout_ptr = reinterpret_cast<wostream*>(&wcout);
- wcout_ptr->flush();
- wostream* wclog_ptr = reinterpret_cast<wostream*>(&wclog);
- wclog_ptr->flush();
+ wostream* wcout_ptr = reinterpret_cast<wostream*>(&wcout);
+ wcout_ptr->flush();
+ wostream* wclog_ptr = reinterpret_cast<wostream*>(&wclog);
+ wclog_ptr->flush();
#endif
}
-ios_base::Init::Init()
-{
- static DoIOSInit init_the_streams; // gets initialized once
+ios_base::Init::Init() {
+ static DoIOSInit init_the_streams; // gets initialized once
}
-ios_base::Init::~Init()
-{
-}
+ios_base::Init::~Init() {}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/locale.cpp b/contrib/libs/cxxsupp/libcxx/src/locale.cpp
index ca3c81c85e..433394d58f 100644
--- a/contrib/libs/cxxsupp/libcxx/src/locale.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/locale.cpp
@@ -23,21 +23,21 @@
#include <vector>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-# include <cwctype>
+# include <cwctype>
#endif
#if defined(_AIX)
-# include <sys/localedef.h> // for __lc_ctype_ptr
+# include <sys/localedef.h> // for __lc_ctype_ptr
#endif
#if defined(_LIBCPP_MSVCRT)
-# define _CTYPE_DISABLE_MACROS
+# define _CTYPE_DISABLE_MACROS
#endif
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
-# include "__support/win32/locale_win32.h"
+# include "__support/win32/locale_win32.h"
#elif !defined(__BIONIC__) && !defined(__NuttX__)
-# include <langinfo.h>
+# include <langinfo.h>
#endif
#include "include/sso_allocator.h"
@@ -65,6 +65,7 @@ struct __libcpp_unique_locale {
locale_t& get() { return __loc_; }
locale_t __loc_;
+
private:
__libcpp_unique_locale(__libcpp_unique_locale const&);
__libcpp_unique_locale& operator=(__libcpp_unique_locale const&);
@@ -86,44 +87,34 @@ struct releaser {
void operator()(locale::facet* p) { p->__release_shared(); }
};
-template <class T, class ...Args>
-T& make(Args ...args)
-{
- alignas(T) static std::byte buf[sizeof(T)];
- auto *obj = ::new (&buf) T(args...);
- return *obj;
+template <class T, class... Args>
+T& make(Args... args) {
+ alignas(T) static std::byte buf[sizeof(T)];
+ auto* obj = ::new (&buf) T(args...);
+ return *obj;
}
template <typename T, size_t N>
-inline
-constexpr
-size_t
-countof(const T (&)[N])
-{
- return N;
+inline constexpr size_t countof(const T (&)[N]) {
+ return N;
}
template <typename T>
-inline
-constexpr
-size_t
-countof(const T * const begin, const T * const end)
-{
- return static_cast<size_t>(end - begin);
-}
-
+inline constexpr size_t countof(const T* const begin, const T* const end) {
+ return static_cast<size_t>(end - begin);
}
-string
-build_name(const string& other, const string& one, locale::category c) {
- if (other == "*" || one == "*")
- return "*";
- if (c == locale::none || other == one)
- return other;
+} // namespace
- // FIXME: Handle the more complicated cases, such as when the locale has
- // different names for different categories.
+string build_name(const string& other, const string& one, locale::category c) {
+ if (other == "*" || one == "*")
return "*";
+ if (c == locale::none || other == one)
+ return other;
+
+ // FIXME: Handle the more complicated cases, such as when the locale has
+ // different names for different categories.
+ return "*";
}
const locale::category locale::none;
@@ -135,408 +126,366 @@ const locale::category locale::time;
const locale::category locale::messages;
const locale::category locale::all;
-class _LIBCPP_HIDDEN locale::__imp
- : public facet
-{
- enum {N = 30};
- vector<facet*, __sso_allocator<facet*, N> > facets_;
- string name_;
+class _LIBCPP_HIDDEN locale::__imp : public facet {
+ enum { N = 30 };
+ vector<facet*, __sso_allocator<facet*, N> > facets_;
+ string name_;
+
public:
- explicit __imp(size_t refs = 0);
- explicit __imp(const string& name, size_t refs = 0);
- __imp(const __imp&);
- __imp(const __imp&, const string&, locale::category c);
- __imp(const __imp& other, const __imp& one, locale::category c);
- __imp(const __imp&, facet* f, long id);
- ~__imp();
-
- const string& name() const {return name_;}
- bool has_facet(long id) const
- {return static_cast<size_t>(id) < facets_.size() && facets_[static_cast<size_t>(id)];}
- const locale::facet* use_facet(long id) const;
-
- void acquire();
- void release();
- static __no_destroy<__imp> classic_locale_imp_;
-
- private:
- void install(facet* f, long id);
- template <class F> void install(F* f) {install(f, f->id.__get());}
- template <class F> void install_from(const __imp& other);
+ explicit __imp(size_t refs = 0);
+ explicit __imp(const string& name, size_t refs = 0);
+ __imp(const __imp&);
+ __imp(const __imp&, const string&, locale::category c);
+ __imp(const __imp& other, const __imp& one, locale::category c);
+ __imp(const __imp&, facet* f, long id);
+ ~__imp();
+
+ const string& name() const { return name_; }
+ bool has_facet(long id) const { return static_cast<size_t>(id) < facets_.size() && facets_[static_cast<size_t>(id)]; }
+ const locale::facet* use_facet(long id) const;
+
+ void acquire();
+ void release();
+ static __no_destroy<__imp> classic_locale_imp_;
+
+private:
+ void install(facet* f, long id);
+ template <class F>
+ void install(F* f) {
+ install(f, f->id.__get());
+ }
+ template <class F>
+ void install_from(const __imp& other);
};
-locale::__imp::__imp(size_t refs)
- : facet(refs),
- facets_(N),
- name_("C")
-{
- facets_.clear();
- install(&make<std::collate<char> >(1u));
+locale::__imp::__imp(size_t refs) : facet(refs), facets_(N), name_("C") {
+ facets_.clear();
+ install(&make<std::collate<char> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<std::collate<wchar_t> >(1u));
+ install(&make<std::collate<wchar_t> >(1u));
#endif
- install(&make<std::ctype<char> >(nullptr, false, 1u));
+ install(&make<std::ctype<char> >(nullptr, false, 1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<std::ctype<wchar_t> >(1u));
+ install(&make<std::ctype<wchar_t> >(1u));
#endif
- install(&make<codecvt<char, char, mbstate_t> >(1u));
+ install(&make<codecvt<char, char, mbstate_t> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));
+ install(&make<codecvt<wchar_t, char, mbstate_t> >(1u));
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- install(&make<codecvt<char16_t, char, mbstate_t> >(1u));
- install(&make<codecvt<char32_t, char, mbstate_t> >(1u));
-_LIBCPP_SUPPRESS_DEPRECATED_POP
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ install(&make<codecvt<char16_t, char, mbstate_t> >(1u));
+ install(&make<codecvt<char32_t, char, mbstate_t> >(1u));
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
#ifndef _LIBCPP_HAS_NO_CHAR8_T
- install(&make<codecvt<char16_t, char8_t, mbstate_t> >(1u));
- install(&make<codecvt<char32_t, char8_t, mbstate_t> >(1u));
+ install(&make<codecvt<char16_t, char8_t, mbstate_t> >(1u));
+ install(&make<codecvt<char32_t, char8_t, mbstate_t> >(1u));
#endif
- install(&make<numpunct<char> >(1u));
+ install(&make<numpunct<char> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<numpunct<wchar_t> >(1u));
+ install(&make<numpunct<wchar_t> >(1u));
#endif
- install(&make<num_get<char> >(1u));
+ install(&make<num_get<char> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<num_get<wchar_t> >(1u));
+ install(&make<num_get<wchar_t> >(1u));
#endif
- install(&make<num_put<char> >(1u));
+ install(&make<num_put<char> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<num_put<wchar_t> >(1u));
+ install(&make<num_put<wchar_t> >(1u));
#endif
- install(&make<moneypunct<char, false> >(1u));
- install(&make<moneypunct<char, true> >(1u));
+ install(&make<moneypunct<char, false> >(1u));
+ install(&make<moneypunct<char, true> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<moneypunct<wchar_t, false> >(1u));
- install(&make<moneypunct<wchar_t, true> >(1u));
+ install(&make<moneypunct<wchar_t, false> >(1u));
+ install(&make<moneypunct<wchar_t, true> >(1u));
#endif
- install(&make<money_get<char> >(1u));
+ install(&make<money_get<char> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<money_get<wchar_t> >(1u));
+ install(&make<money_get<wchar_t> >(1u));
#endif
- install(&make<money_put<char> >(1u));
+ install(&make<money_put<char> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<money_put<wchar_t> >(1u));
+ install(&make<money_put<wchar_t> >(1u));
#endif
- install(&make<time_get<char> >(1u));
+ install(&make<time_get<char> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<time_get<wchar_t> >(1u));
+ install(&make<time_get<wchar_t> >(1u));
#endif
- install(&make<time_put<char> >(1u));
+ install(&make<time_put<char> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<time_put<wchar_t> >(1u));
+ install(&make<time_put<wchar_t> >(1u));
#endif
- install(&make<std::messages<char> >(1u));
+ install(&make<std::messages<char> >(1u));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(&make<std::messages<wchar_t> >(1u));
+ install(&make<std::messages<wchar_t> >(1u));
#endif
}
-locale::__imp::__imp(const string& name, size_t refs)
- : facet(refs),
- facets_(N),
- name_(name)
-{
+locale::__imp::__imp(const string& name, size_t refs) : facet(refs), facets_(N), name_(name) {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- try
- {
+ try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
- facets_ = locale::classic().__locale_->facets_;
- for (unsigned i = 0; i < facets_.size(); ++i)
- if (facets_[i])
- facets_[i]->__add_shared();
- install(new collate_byname<char>(name_));
+ facets_ = locale::classic().__locale_->facets_;
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
+ install(new collate_byname<char>(name_));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new collate_byname<wchar_t>(name_));
+ install(new collate_byname<wchar_t>(name_));
#endif
- install(new ctype_byname<char>(name_));
+ install(new ctype_byname<char>(name_));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new ctype_byname<wchar_t>(name_));
+ install(new ctype_byname<wchar_t>(name_));
#endif
- install(new codecvt_byname<char, char, mbstate_t>(name_));
+ install(new codecvt_byname<char, char, mbstate_t>(name_));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new codecvt_byname<wchar_t, char, mbstate_t>(name_));
+ install(new codecvt_byname<wchar_t, char, mbstate_t>(name_));
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- install(new codecvt_byname<char16_t, char, mbstate_t>(name_));
- install(new codecvt_byname<char32_t, char, mbstate_t>(name_));
-_LIBCPP_SUPPRESS_DEPRECATED_POP
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ install(new codecvt_byname<char16_t, char, mbstate_t>(name_));
+ install(new codecvt_byname<char32_t, char, mbstate_t>(name_));
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
#ifndef _LIBCPP_HAS_NO_CHAR8_T
- install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_));
- install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_));
+ install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name_));
+ install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name_));
#endif
- install(new numpunct_byname<char>(name_));
+ install(new numpunct_byname<char>(name_));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new numpunct_byname<wchar_t>(name_));
+ install(new numpunct_byname<wchar_t>(name_));
#endif
- install(new moneypunct_byname<char, false>(name_));
- install(new moneypunct_byname<char, true>(name_));
+ install(new moneypunct_byname<char, false>(name_));
+ install(new moneypunct_byname<char, true>(name_));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new moneypunct_byname<wchar_t, false>(name_));
- install(new moneypunct_byname<wchar_t, true>(name_));
+ install(new moneypunct_byname<wchar_t, false>(name_));
+ install(new moneypunct_byname<wchar_t, true>(name_));
#endif
- install(new time_get_byname<char>(name_));
+ install(new time_get_byname<char>(name_));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new time_get_byname<wchar_t>(name_));
+ install(new time_get_byname<wchar_t>(name_));
#endif
- install(new time_put_byname<char>(name_));
+ install(new time_put_byname<char>(name_));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new time_put_byname<wchar_t>(name_));
+ install(new time_put_byname<wchar_t>(name_));
#endif
- install(new messages_byname<char>(name_));
+ install(new messages_byname<char>(name_));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new messages_byname<wchar_t>(name_));
+ install(new messages_byname<wchar_t>(name_));
#endif
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- }
- catch (...)
- {
- for (unsigned i = 0; i < facets_.size(); ++i)
- if (facets_[i])
- facets_[i]->__release_shared();
- throw;
- }
+ } catch (...) {
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__release_shared();
+ throw;
+ }
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
-locale::__imp::__imp(const __imp& other)
- : facets_(max<size_t>(N, other.facets_.size())),
- name_(other.name_)
-{
- facets_ = other.facets_;
- for (unsigned i = 0; i < facets_.size(); ++i)
- if (facets_[i])
- facets_[i]->__add_shared();
+locale::__imp::__imp(const __imp& other) : facets_(max<size_t>(N, other.facets_.size())), name_(other.name_) {
+ facets_ = other.facets_;
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
}
locale::__imp::__imp(const __imp& other, const string& name, locale::category c)
- : facets_(N), name_(build_name(other.name_, name, c))
-{
- facets_ = other.facets_;
- for (unsigned i = 0; i < facets_.size(); ++i)
- if (facets_[i])
- facets_[i]->__add_shared();
+ : facets_(N), name_(build_name(other.name_, name, c)) {
+ facets_ = other.facets_;
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- try
- {
+ try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
- if (c & locale::collate)
- {
- install(new collate_byname<char>(name));
+ if (c & locale::collate) {
+ install(new collate_byname<char>(name));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new collate_byname<wchar_t>(name));
+ install(new collate_byname<wchar_t>(name));
#endif
- }
- if (c & locale::ctype)
- {
- install(new ctype_byname<char>(name));
+ }
+ if (c & locale::ctype) {
+ install(new ctype_byname<char>(name));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new ctype_byname<wchar_t>(name));
+ install(new ctype_byname<wchar_t>(name));
#endif
- install(new codecvt_byname<char, char, mbstate_t>(name));
+ install(new codecvt_byname<char, char, mbstate_t>(name));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new codecvt_byname<wchar_t, char, mbstate_t>(name));
+ install(new codecvt_byname<wchar_t, char, mbstate_t>(name));
#endif
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- install(new codecvt_byname<char16_t, char, mbstate_t>(name));
- install(new codecvt_byname<char32_t, char, mbstate_t>(name));
-_LIBCPP_SUPPRESS_DEPRECATED_POP
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ install(new codecvt_byname<char16_t, char, mbstate_t>(name));
+ install(new codecvt_byname<char32_t, char, mbstate_t>(name));
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
#ifndef _LIBCPP_HAS_NO_CHAR8_T
- install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name));
- install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name));
+ install(new codecvt_byname<char16_t, char8_t, mbstate_t>(name));
+ install(new codecvt_byname<char32_t, char8_t, mbstate_t>(name));
#endif
- }
- if (c & locale::monetary)
- {
- install(new moneypunct_byname<char, false>(name));
- install(new moneypunct_byname<char, true>(name));
+ }
+ if (c & locale::monetary) {
+ install(new moneypunct_byname<char, false>(name));
+ install(new moneypunct_byname<char, true>(name));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new moneypunct_byname<wchar_t, false>(name));
- install(new moneypunct_byname<wchar_t, true>(name));
+ install(new moneypunct_byname<wchar_t, false>(name));
+ install(new moneypunct_byname<wchar_t, true>(name));
#endif
- }
- if (c & locale::numeric)
- {
- install(new numpunct_byname<char>(name));
+ }
+ if (c & locale::numeric) {
+ install(new numpunct_byname<char>(name));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new numpunct_byname<wchar_t>(name));
+ install(new numpunct_byname<wchar_t>(name));
#endif
- }
- if (c & locale::time)
- {
- install(new time_get_byname<char>(name));
+ }
+ if (c & locale::time) {
+ install(new time_get_byname<char>(name));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new time_get_byname<wchar_t>(name));
+ install(new time_get_byname<wchar_t>(name));
#endif
- install(new time_put_byname<char>(name));
+ install(new time_put_byname<char>(name));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new time_put_byname<wchar_t>(name));
+ install(new time_put_byname<wchar_t>(name));
#endif
- }
- if (c & locale::messages)
- {
- install(new messages_byname<char>(name));
+ }
+ if (c & locale::messages) {
+ install(new messages_byname<char>(name));
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install(new messages_byname<wchar_t>(name));
+ install(new messages_byname<wchar_t>(name));
#endif
- }
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- }
- catch (...)
- {
- for (unsigned i = 0; i < facets_.size(); ++i)
- if (facets_[i])
- facets_[i]->__release_shared();
- throw;
}
+#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+ } catch (...) {
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__release_shared();
+ throw;
+ }
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
-template<class F>
-inline
-void
-locale::__imp::install_from(const locale::__imp& one)
-{
- long id = F::id.__get();
- install(const_cast<F*>(static_cast<const F*>(one.use_facet(id))), id);
+template <class F>
+inline void locale::__imp::install_from(const locale::__imp& one) {
+ long id = F::id.__get();
+ install(const_cast<F*>(static_cast<const F*>(one.use_facet(id))), id);
}
locale::__imp::__imp(const __imp& other, const __imp& one, locale::category c)
- : facets_(N), name_(build_name(other.name_, one.name_, c))
-{
- facets_ = other.facets_;
- for (unsigned i = 0; i < facets_.size(); ++i)
- if (facets_[i])
- facets_[i]->__add_shared();
+ : facets_(N), name_(build_name(other.name_, one.name_, c)) {
+ facets_ = other.facets_;
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- try
- {
+ try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
- if (c & locale::collate)
- {
- install_from<std::collate<char> >(one);
+ if (c & locale::collate) {
+ install_from<std::collate<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<std::collate<wchar_t> >(one);
+ install_from<std::collate<wchar_t> >(one);
#endif
- }
- if (c & locale::ctype)
- {
- install_from<std::ctype<char> >(one);
+ }
+ if (c & locale::ctype) {
+ install_from<std::ctype<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<std::ctype<wchar_t> >(one);
+ install_from<std::ctype<wchar_t> >(one);
#endif
- install_from<std::codecvt<char, char, mbstate_t> >(one);
-_LIBCPP_SUPPRESS_DEPRECATED_PUSH
- install_from<std::codecvt<char16_t, char, mbstate_t> >(one);
- install_from<std::codecvt<char32_t, char, mbstate_t> >(one);
-_LIBCPP_SUPPRESS_DEPRECATED_POP
+ install_from<std::codecvt<char, char, mbstate_t> >(one);
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ install_from<std::codecvt<char16_t, char, mbstate_t> >(one);
+ install_from<std::codecvt<char32_t, char, mbstate_t> >(one);
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
#ifndef _LIBCPP_HAS_NO_CHAR8_T
- install_from<std::codecvt<char16_t, char8_t, mbstate_t> >(one);
- install_from<std::codecvt<char32_t, char8_t, mbstate_t> >(one);
+ install_from<std::codecvt<char16_t, char8_t, mbstate_t> >(one);
+ install_from<std::codecvt<char32_t, char8_t, mbstate_t> >(one);
#endif
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<std::codecvt<wchar_t, char, mbstate_t> >(one);
+ install_from<std::codecvt<wchar_t, char, mbstate_t> >(one);
#endif
- }
- if (c & locale::monetary)
- {
- install_from<moneypunct<char, false> >(one);
- install_from<moneypunct<char, true> >(one);
+ }
+ if (c & locale::monetary) {
+ install_from<moneypunct<char, false> >(one);
+ install_from<moneypunct<char, true> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<moneypunct<wchar_t, false> >(one);
- install_from<moneypunct<wchar_t, true> >(one);
+ install_from<moneypunct<wchar_t, false> >(one);
+ install_from<moneypunct<wchar_t, true> >(one);
#endif
- install_from<money_get<char> >(one);
+ install_from<money_get<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<money_get<wchar_t> >(one);
+ install_from<money_get<wchar_t> >(one);
#endif
- install_from<money_put<char> >(one);
+ install_from<money_put<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<money_put<wchar_t> >(one);
+ install_from<money_put<wchar_t> >(one);
#endif
- }
- if (c & locale::numeric)
- {
- install_from<numpunct<char> >(one);
+ }
+ if (c & locale::numeric) {
+ install_from<numpunct<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<numpunct<wchar_t> >(one);
+ install_from<numpunct<wchar_t> >(one);
#endif
- install_from<num_get<char> >(one);
+ install_from<num_get<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<num_get<wchar_t> >(one);
+ install_from<num_get<wchar_t> >(one);
#endif
- install_from<num_put<char> >(one);
+ install_from<num_put<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<num_put<wchar_t> >(one);
+ install_from<num_put<wchar_t> >(one);
#endif
- }
- if (c & locale::time)
- {
- install_from<time_get<char> >(one);
+ }
+ if (c & locale::time) {
+ install_from<time_get<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<time_get<wchar_t> >(one);
+ install_from<time_get<wchar_t> >(one);
#endif
- install_from<time_put<char> >(one);
+ install_from<time_put<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<time_put<wchar_t> >(one);
+ install_from<time_put<wchar_t> >(one);
#endif
- }
- if (c & locale::messages)
- {
- install_from<std::messages<char> >(one);
+ }
+ if (c & locale::messages) {
+ install_from<std::messages<char> >(one);
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- install_from<std::messages<wchar_t> >(one);
+ install_from<std::messages<wchar_t> >(one);
#endif
- }
-#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- }
- catch (...)
- {
- for (unsigned i = 0; i < facets_.size(); ++i)
- if (facets_[i])
- facets_[i]->__release_shared();
- throw;
}
+#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
+ } catch (...) {
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__release_shared();
+ throw;
+ }
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
locale::__imp::__imp(const __imp& other, facet* f, long id)
- : facets_(max<size_t>(N, other.facets_.size()+1)),
- name_("*")
-{
- f->__add_shared();
- unique_ptr<facet, releaser> hold(f);
- facets_ = other.facets_;
- for (unsigned i = 0; i < other.facets_.size(); ++i)
- if (facets_[i])
- facets_[i]->__add_shared();
- install(hold.get(), id);
-}
-
-locale::__imp::~__imp()
-{
- for (unsigned i = 0; i < facets_.size(); ++i)
- if (facets_[i])
- facets_[i]->__release_shared();
+ : facets_(max<size_t>(N, other.facets_.size() + 1)), name_("*") {
+ f->__add_shared();
+ unique_ptr<facet, releaser> hold(f);
+ facets_ = other.facets_;
+ for (unsigned i = 0; i < other.facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__add_shared();
+ install(hold.get(), id);
+}
+
+locale::__imp::~__imp() {
+ for (unsigned i = 0; i < facets_.size(); ++i)
+ if (facets_[i])
+ facets_[i]->__release_shared();
}
-void
-locale::__imp::install(facet* f, long id)
-{
- f->__add_shared();
- unique_ptr<facet, releaser> hold(f);
- if (static_cast<size_t>(id) >= facets_.size())
- facets_.resize(static_cast<size_t>(id+1));
- if (facets_[static_cast<size_t>(id)])
- facets_[static_cast<size_t>(id)]->__release_shared();
- facets_[static_cast<size_t>(id)] = hold.release();
+void locale::__imp::install(facet* f, long id) {
+ f->__add_shared();
+ unique_ptr<facet, releaser> hold(f);
+ if (static_cast<size_t>(id) >= facets_.size())
+ facets_.resize(static_cast<size_t>(id + 1));
+ if (facets_[static_cast<size_t>(id)])
+ facets_[static_cast<size_t>(id)]->__release_shared();
+ facets_[static_cast<size_t>(id)] = hold.release();
}
-const locale::facet*
-locale::__imp::use_facet(long id) const
-{
- if (!has_facet(id))
- __throw_bad_cast();
- return facets_[static_cast<size_t>(id)];
+const locale::facet* locale::__imp::use_facet(long id) const {
+ if (!has_facet(id))
+ __throw_bad_cast();
+ return facets_[static_cast<size_t>(id)];
}
// locale
@@ -579,9 +528,7 @@ locale::locale(const locale& l) noexcept : __locale_(l.__locale_) { __locale_->a
locale::~locale() { __locale_->release(); }
-const locale&
-locale::operator=(const locale& other) noexcept
-{
+const locale& locale::operator=(const locale& other) noexcept {
other.__locale_->acquire();
__locale_->release();
__locale_ = other.__locale_;
@@ -589,9 +536,7 @@ locale::operator=(const locale& other) noexcept
}
locale::locale(const char* name)
- : __locale_(name ? new __imp(name)
- : (__throw_runtime_error("locale constructed with null"), nullptr))
-{
+ : __locale_(name ? new __imp(name) : (__throw_runtime_error("locale constructed with null"), nullptr)) {
__locale_->acquire();
}
@@ -599,194 +544,156 @@ locale::locale(const string& name) : __locale_(new __imp(name)) { __locale_->acq
locale::locale(const locale& other, const char* name, category c)
: __locale_(name ? new __imp(*other.__locale_, name, c)
- : (__throw_runtime_error("locale constructed with null"), nullptr))
-{
+ : (__throw_runtime_error("locale constructed with null"), nullptr)) {
__locale_->acquire();
}
-locale::locale(const locale& other, const string& name, category c)
- : __locale_(new __imp(*other.__locale_, name, c))
-{
+locale::locale(const locale& other, const string& name, category c) : __locale_(new __imp(*other.__locale_, name, c)) {
__locale_->acquire();
}
locale::locale(const locale& other, const locale& one, category c)
- : __locale_(new __imp(*other.__locale_, *one.__locale_, c))
-{
+ : __locale_(new __imp(*other.__locale_, *one.__locale_, c)) {
__locale_->acquire();
}
-string
-locale::name() const
-{
- return __locale_->name();
-}
+string locale::name() const { return __locale_->name(); }
-void
-locale::__install_ctor(const locale& other, facet* f, long id)
-{
- if (f)
- __locale_ = new __imp(*other.__locale_, f, id);
- else
- __locale_ = other.__locale_;
- __locale_->acquire();
+void locale::__install_ctor(const locale& other, facet* f, long id) {
+ if (f)
+ __locale_ = new __imp(*other.__locale_, f, id);
+ else
+ __locale_ = other.__locale_;
+ __locale_->acquire();
}
-locale
-locale::global(const locale& loc)
-{
- locale& g = __global();
- locale r = g;
- g = loc;
- if (g.name() != "*")
- setlocale(LC_ALL, g.name().c_str());
- return r;
+locale locale::global(const locale& loc) {
+ locale& g = __global();
+ locale r = g;
+ g = loc;
+ if (g.name() != "*")
+ setlocale(LC_ALL, g.name().c_str());
+ return r;
}
-bool
-locale::has_facet(id& x) const
-{
- return __locale_->has_facet(x.__get());
-}
+bool locale::has_facet(id& x) const { return __locale_->has_facet(x.__get()); }
-const locale::facet*
-locale::use_facet(id& x) const
-{
- return __locale_->use_facet(x.__get());
-}
+const locale::facet* locale::use_facet(id& x) const { return __locale_->use_facet(x.__get()); }
-bool
-locale::operator==(const locale& y) const
-{
- return (__locale_ == y.__locale_)
- || (__locale_->name() != "*" && __locale_->name() == y.__locale_->name());
+bool locale::operator==(const locale& y) const {
+ return (__locale_ == y.__locale_) || (__locale_->name() != "*" && __locale_->name() == y.__locale_->name());
}
// locale::facet
-locale::facet::~facet()
-{
-}
+locale::facet::~facet() {}
-void
-locale::facet::__on_zero_shared() noexcept
-{
- delete this;
-}
+void locale::facet::__on_zero_shared() noexcept { delete this; }
// locale::id
constinit int32_t locale::id::__next_id = 0;
long locale::id::__get() {
- int32_t result = __id_.load(std::memory_order_acquire);
+ int32_t result = __id_.load(std::memory_order_acquire);
+ if (result == 0) {
+ static std::mutex m;
+ std::lock_guard<std::mutex> guard(m);
+ result = __id_.load(std::memory_order_acquire);
if (result == 0) {
- static std::mutex m;
- std::lock_guard<std::mutex> guard(m);
- result = __id_.load(std::memory_order_acquire);
- if (result == 0) {
- result = ++__next_id;
- __id_.store(result, std::memory_order_release);
- }
+ result = ++__next_id;
+ __id_.store(result, std::memory_order_release);
}
- return result - 1;
+ }
+ return result - 1;
}
// template <> class collate_byname<char>
collate_byname<char>::collate_byname(const char* n, size_t refs)
- : collate<char>(refs),
- __l_(newlocale(LC_ALL_MASK, n, 0))
-{
- if (__l_ == 0)
- __throw_runtime_error(("collate_byname<char>::collate_byname"
- " failed to construct for " + string(n)).c_str());
+ : collate<char>(refs), __l_(newlocale(LC_ALL_MASK, n, 0)) {
+ if (__l_ == 0)
+ __throw_runtime_error(
+ ("collate_byname<char>::collate_byname"
+ " failed to construct for " +
+ string(n))
+ .c_str());
}
collate_byname<char>::collate_byname(const string& name, size_t refs)
- : collate<char>(refs),
- __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
-{
- if (__l_ == 0)
- __throw_runtime_error(("collate_byname<char>::collate_byname"
- " failed to construct for " + name).c_str());
-}
-
-collate_byname<char>::~collate_byname()
-{
- freelocale(__l_);
-}
-
-int
-collate_byname<char>::do_compare(const char_type* __lo1, const char_type* __hi1,
- const char_type* __lo2, const char_type* __hi2) const
-{
- string_type lhs(__lo1, __hi1);
- string_type rhs(__lo2, __hi2);
- int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l_);
- if (r < 0)
- return -1;
- if (r > 0)
- return 1;
- return r;
+ : collate<char>(refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) {
+ if (__l_ == 0)
+ __throw_runtime_error(
+ ("collate_byname<char>::collate_byname"
+ " failed to construct for " +
+ name)
+ .c_str());
+}
+
+collate_byname<char>::~collate_byname() { freelocale(__l_); }
+
+int collate_byname<char>::do_compare(
+ const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const {
+ string_type lhs(__lo1, __hi1);
+ string_type rhs(__lo2, __hi2);
+ int r = strcoll_l(lhs.c_str(), rhs.c_str(), __l_);
+ if (r < 0)
+ return -1;
+ if (r > 0)
+ return 1;
+ return r;
}
-collate_byname<char>::string_type
-collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const
-{
- const string_type in(lo, hi);
- string_type out(strxfrm_l(0, in.c_str(), 0, __l_), char());
- strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size()+1, __l_);
- return out;
+collate_byname<char>::string_type collate_byname<char>::do_transform(const char_type* lo, const char_type* hi) const {
+ const string_type in(lo, hi);
+ string_type out(strxfrm_l(0, in.c_str(), 0, __l_), char());
+ strxfrm_l(const_cast<char*>(out.c_str()), in.c_str(), out.size() + 1, __l_);
+ return out;
}
// template <> class collate_byname<wchar_t>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
collate_byname<wchar_t>::collate_byname(const char* n, size_t refs)
- : collate<wchar_t>(refs),
- __l_(newlocale(LC_ALL_MASK, n, 0))
-{
- if (__l_ == 0)
- __throw_runtime_error(("collate_byname<wchar_t>::collate_byname(size_t refs)"
- " failed to construct for " + string(n)).c_str());
+ : collate<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, n, 0)) {
+ if (__l_ == 0)
+ __throw_runtime_error(
+ ("collate_byname<wchar_t>::collate_byname(size_t refs)"
+ " failed to construct for " +
+ string(n))
+ .c_str());
}
collate_byname<wchar_t>::collate_byname(const string& name, size_t refs)
- : collate<wchar_t>(refs),
- __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
-{
- if (__l_ == 0)
- __throw_runtime_error(("collate_byname<wchar_t>::collate_byname(size_t refs)"
- " failed to construct for " + name).c_str());
-}
-
-collate_byname<wchar_t>::~collate_byname()
-{
- freelocale(__l_);
-}
-
-int
-collate_byname<wchar_t>::do_compare(const char_type* __lo1, const char_type* __hi1,
- const char_type* __lo2, const char_type* __hi2) const
-{
- string_type lhs(__lo1, __hi1);
- string_type rhs(__lo2, __hi2);
- int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l_);
- if (r < 0)
- return -1;
- if (r > 0)
- return 1;
- return r;
+ : collate<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) {
+ if (__l_ == 0)
+ __throw_runtime_error(
+ ("collate_byname<wchar_t>::collate_byname(size_t refs)"
+ " failed to construct for " +
+ name)
+ .c_str());
+}
+
+collate_byname<wchar_t>::~collate_byname() { freelocale(__l_); }
+
+int collate_byname<wchar_t>::do_compare(
+ const char_type* __lo1, const char_type* __hi1, const char_type* __lo2, const char_type* __hi2) const {
+ string_type lhs(__lo1, __hi1);
+ string_type rhs(__lo2, __hi2);
+ int r = wcscoll_l(lhs.c_str(), rhs.c_str(), __l_);
+ if (r < 0)
+ return -1;
+ if (r > 0)
+ return 1;
+ return r;
}
collate_byname<wchar_t>::string_type
-collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const
-{
- const string_type in(lo, hi);
- string_type out(wcsxfrm_l(0, in.c_str(), 0, __l_), wchar_t());
- wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size()+1, __l_);
- return out;
+collate_byname<wchar_t>::do_transform(const char_type* lo, const char_type* hi) const {
+ const string_type in(lo, hi);
+ string_type out(wcsxfrm_l(0, in.c_str(), 0, __l_), wchar_t());
+ wcsxfrm_l(const_cast<wchar_t*>(out.c_str()), in.c_str(), out.size() + 1, __l_);
+ return out;
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -808,132 +715,97 @@ const ctype_base::mask ctype_base::graph;
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
constinit locale::id ctype<wchar_t>::id;
-ctype<wchar_t>::~ctype()
-{
-}
+ctype<wchar_t>::~ctype() {}
-bool
-ctype<wchar_t>::do_is(mask m, char_type c) const
-{
- return isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false;
+bool ctype<wchar_t>::do_is(mask m, char_type c) const {
+ return isascii(c) ? (ctype<char>::classic_table()[c] & m) != 0 : false;
}
-const wchar_t*
-ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
-{
- for (; low != high; ++low, ++vec)
- *vec = static_cast<mask>(isascii(*low) ?
- ctype<char>::classic_table()[*low] : 0);
- return low;
+const wchar_t* ctype<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const {
+ for (; low != high; ++low, ++vec)
+ *vec = static_cast<mask>(isascii(*low) ? ctype<char>::classic_table()[*low] : 0);
+ return low;
}
-const wchar_t*
-ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
- if (isascii(*low) && (ctype<char>::classic_table()[*low] & m))
- break;
- return low;
+const wchar_t* ctype<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
+ if (isascii(*low) && (ctype<char>::classic_table()[*low] & m))
+ break;
+ return low;
}
-const wchar_t*
-ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
- if (!(isascii(*low) && (ctype<char>::classic_table()[*low] & m)))
- break;
- return low;
+const wchar_t* ctype<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
+ if (!(isascii(*low) && (ctype<char>::classic_table()[*low] & m)))
+ break;
+ return low;
}
-wchar_t
-ctype<wchar_t>::do_toupper(char_type c) const
-{
-#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
- return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
- defined(__NetBSD__) || defined(__MVS__)
- return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
-#else
- return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'a'+L'A' : c;
-#endif
+wchar_t ctype<wchar_t>::do_toupper(char_type c) const {
+# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ return isascii(c) ? _DefaultRuneLocale.__mapupper[c] : c;
+# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
+ return isascii(c) ? ctype<char>::__classic_upper_table()[c] : c;
+# else
+ return (isascii(c) && iswlower_l(c, _LIBCPP_GET_C_LOCALE)) ? c - L'a' + L'A' : c;
+# endif
}
-const wchar_t*
-ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
-#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
- *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
- defined(__NetBSD__) || defined(__MVS__)
- *low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low]
- : *low;
-#else
- *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? (*low-L'a'+L'A') : *low;
-#endif
- return low;
+const wchar_t* ctype<wchar_t>::do_toupper(char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
+# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ *low = isascii(*low) ? _DefaultRuneLocale.__mapupper[*low] : *low;
+# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
+ *low = isascii(*low) ? ctype<char>::__classic_upper_table()[*low] : *low;
+# else
+ *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? (*low - L'a' + L'A') : *low;
+# endif
+ return low;
}
-wchar_t
-ctype<wchar_t>::do_tolower(char_type c) const
-{
-#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
- return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
- defined(__NetBSD__) || defined(__MVS__)
- return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
-#else
- return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-L'A'+'a' : c;
-#endif
+wchar_t ctype<wchar_t>::do_tolower(char_type c) const {
+# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ return isascii(c) ? _DefaultRuneLocale.__maplower[c] : c;
+# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
+ return isascii(c) ? ctype<char>::__classic_lower_table()[c] : c;
+# else
+ return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c - L'A' + 'a' : c;
+# endif
}
-const wchar_t*
-ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
-#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
- *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
-#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || \
- defined(__NetBSD__) || defined(__MVS__)
- *low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low]
- : *low;
-#else
- *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-L'A'+L'a' : *low;
-#endif
- return low;
+const wchar_t* ctype<wchar_t>::do_tolower(char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
+# ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
+ *low = isascii(*low) ? _DefaultRuneLocale.__maplower[*low] : *low;
+# elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__NetBSD__) || defined(__MVS__)
+ *low = isascii(*low) ? ctype<char>::__classic_lower_table()[*low] : *low;
+# else
+ *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low - L'A' + L'a' : *low;
+# endif
+ return low;
}
-wchar_t
-ctype<wchar_t>::do_widen(char c) const
-{
- return c;
-}
+wchar_t ctype<wchar_t>::do_widen(char c) const { return c; }
-const char*
-ctype<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
-{
- for (; low != high; ++low, ++dest)
- *dest = *low;
- return low;
+const char* ctype<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const {
+ for (; low != high; ++low, ++dest)
+ *dest = *low;
+ return low;
}
-char
-ctype<wchar_t>::do_narrow(char_type c, char dfault) const
-{
- if (isascii(c))
- return static_cast<char>(c);
- return dfault;
+char ctype<wchar_t>::do_narrow(char_type c, char dfault) const {
+ if (isascii(c))
+ return static_cast<char>(c);
+ return dfault;
}
-const wchar_t*
-ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
-{
- for (; low != high; ++low, ++dest)
- if (isascii(*low))
- *dest = static_cast<char>(*low);
- else
- *dest = dfault;
- return low;
+const wchar_t* ctype<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const {
+ for (; low != high; ++low, ++dest)
+ if (isascii(*low))
+ *dest = static_cast<char>(*low);
+ else
+ *dest = dfault;
+ return low;
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -943,124 +815,95 @@ constinit locale::id ctype<char>::id;
const size_t ctype<char>::table_size;
-ctype<char>::ctype(const mask* tab, bool del, size_t refs)
- : locale::facet(refs),
- __tab_(tab),
- __del_(del)
-{
+ctype<char>::ctype(const mask* tab, bool del, size_t refs) : locale::facet(refs), __tab_(tab), __del_(del) {
if (__tab_ == 0)
- __tab_ = classic_table();
+ __tab_ = classic_table();
}
-ctype<char>::~ctype()
-{
- if (__tab_ && __del_)
- delete [] __tab_;
+ctype<char>::~ctype() {
+ if (__tab_ && __del_)
+ delete[] __tab_;
}
-char
-ctype<char>::do_toupper(char_type c) const
-{
+char ctype<char>::do_toupper(char_type c) const {
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
- return isascii(c) ?
- static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c;
+ return isascii(c) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(c)]) : c;
#elif defined(__NetBSD__)
- return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);
+ return static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]);
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
- return isascii(c) ?
- static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
+ return isascii(c) ? static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(c)]) : c;
#else
- return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'a'+'A' : c;
+ return (isascii(c) && islower_l(c, _LIBCPP_GET_C_LOCALE)) ? c - 'a' + 'A' : c;
#endif
}
-const char*
-ctype<char>::do_toupper(char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
+const char* ctype<char>::do_toupper(char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
- *low = isascii(*low) ?
- static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) : *low;
+ *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__mapupper[static_cast<ptrdiff_t>(*low)]) : *low;
#elif defined(__NetBSD__)
- *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]);
+ *low = static_cast<char>(__classic_upper_table()[static_cast<unsigned char>(*low)]);
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
- *low = isascii(*low) ?
- static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
+ *low = isascii(*low) ? static_cast<char>(__classic_upper_table()[static_cast<size_t>(*low)]) : *low;
#else
- *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'a'+'A' : *low;
+ *low = (isascii(*low) && islower_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'a' + 'A' : *low;
#endif
- return low;
+ return low;
}
-char
-ctype<char>::do_tolower(char_type c) const
-{
+char ctype<char>::do_tolower(char_type c) const {
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
- return isascii(c) ?
- static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c;
+ return isascii(c) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(c)]) : c;
#elif defined(__NetBSD__)
- return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]);
+ return static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(c)]);
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
- return isascii(c) ?
- static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
+ return isascii(c) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(c)]) : c;
#else
- return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c-'A'+'a' : c;
+ return (isascii(c) && isupper_l(c, _LIBCPP_GET_C_LOCALE)) ? c - 'A' + 'a' : c;
#endif
}
-const char*
-ctype<char>::do_tolower(char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
+const char* ctype<char>::do_tolower(char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
#ifdef _LIBCPP_HAS_DEFAULTRUNELOCALE
- *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) : *low;
+ *low = isascii(*low) ? static_cast<char>(_DefaultRuneLocale.__maplower[static_cast<ptrdiff_t>(*low)]) : *low;
#elif defined(__NetBSD__)
- *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]);
+ *low = static_cast<char>(__classic_lower_table()[static_cast<unsigned char>(*low)]);
#elif defined(__GLIBC__) || defined(__EMSCRIPTEN__) || defined(__MVS__)
- *low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
+ *low = isascii(*low) ? static_cast<char>(__classic_lower_table()[static_cast<size_t>(*low)]) : *low;
#else
- *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low-'A'+'a' : *low;
+ *low = (isascii(*low) && isupper_l(*low, _LIBCPP_GET_C_LOCALE)) ? *low - 'A' + 'a' : *low;
#endif
- return low;
+ return low;
}
-char
-ctype<char>::do_widen(char c) const
-{
- return c;
-}
+char ctype<char>::do_widen(char c) const { return c; }
-const char*
-ctype<char>::do_widen(const char* low, const char* high, char_type* dest) const
-{
- for (; low != high; ++low, ++dest)
- *dest = *low;
- return low;
+const char* ctype<char>::do_widen(const char* low, const char* high, char_type* dest) const {
+ for (; low != high; ++low, ++dest)
+ *dest = *low;
+ return low;
}
-char
-ctype<char>::do_narrow(char_type c, char dfault) const
-{
- if (isascii(c))
- return static_cast<char>(c);
- return dfault;
+char ctype<char>::do_narrow(char_type c, char dfault) const {
+ if (isascii(c))
+ return static_cast<char>(c);
+ return dfault;
}
-const char*
-ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
-{
- for (; low != high; ++low, ++dest)
- if (isascii(*low))
- *dest = *low;
- else
- *dest = dfault;
- return low;
+const char* ctype<char>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const {
+ for (; low != high; ++low, ++dest)
+ if (isascii(*low))
+ *dest = *low;
+ else
+ *dest = dfault;
+ return low;
}
#if defined(__EMSCRIPTEN__)
-extern "C" const unsigned short ** __ctype_b_loc();
-extern "C" const int ** __ctype_tolower_loc();
-extern "C" const int ** __ctype_toupper_loc();
+extern "C" const unsigned short** __ctype_b_loc();
+extern "C" const int** __ctype_tolower_loc();
+extern "C" const int** __ctype_toupper_loc();
#endif
#if defined(__ANDROID__)
@@ -1069,9 +912,7 @@ extern "C" const unsigned short* const _ctype_android;
#endif
#ifdef _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
-const ctype<char>::mask*
-ctype<char>::classic_table() noexcept
-{
+const ctype<char>::mask* ctype<char>::classic_table() noexcept {
// clang-format off
static constexpr const ctype<char>::mask builtin_table[table_size] = {
cntrl, cntrl,
@@ -1148,356 +989,312 @@ ctype<char>::classic_table() noexcept
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
// clang-format on
- return builtin_table;
+ return builtin_table;
}
#else
-const ctype<char>::mask*
-ctype<char>::classic_table() noexcept
-{
-#if defined(__APPLE__) || defined(__FreeBSD__)
- return _DefaultRuneLocale.__runetype;
-#elif defined(__NetBSD__)
- return _C_ctype_tab_ + 1;
-#elif defined(__GLIBC__)
- return _LIBCPP_GET_C_LOCALE->__ctype_b;
-#elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
- return __pctype_func();
-#elif defined(__EMSCRIPTEN__)
- return *__ctype_b_loc();
-#elif defined(_NEWLIB_VERSION)
- // Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1].
- return _ctype_ + 1;
-#elif defined(__ANDROID__)
- return _ctype_android;
-#elif defined(_AIX)
- return (const unsigned int *)__lc_ctype_ptr->obj->mask;
-#elif defined(__MVS__)
-# if defined(__NATIVE_ASCII_F)
- return const_cast<const ctype<char>::mask*> (__OBJ_DATA(__lc_ctype_a)->mask);
-# else
- return const_cast<const ctype<char>::mask*> (__ctypec);
-# endif
-#else
- // Platform not supported: abort so the person doing the port knows what to
- // fix
-# warning ctype<char>::classic_table() is not implemented
- printf("ctype<char>::classic_table() is not implemented\n");
- abort();
- return NULL;
-#endif
+const ctype<char>::mask* ctype<char>::classic_table() noexcept {
+# if defined(__APPLE__) || defined(__FreeBSD__)
+ return _DefaultRuneLocale.__runetype;
+# elif defined(__NetBSD__)
+ return _C_ctype_tab_ + 1;
+# elif defined(__GLIBC__)
+ return _LIBCPP_GET_C_LOCALE->__ctype_b;
+# elif defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ return __pctype_func();
+# elif defined(__EMSCRIPTEN__)
+ return *__ctype_b_loc();
+# elif defined(_NEWLIB_VERSION)
+ // Newlib has a 257-entry table in ctype_.c, where (char)0 starts at [1].
+ return _ctype_ + 1;
+# elif defined(__ANDROID__)
+ return _ctype_android;
+# elif defined(_AIX)
+ return (const unsigned int*)__lc_ctype_ptr->obj->mask;
+# elif defined(__MVS__)
+# if defined(__NATIVE_ASCII_F)
+ return const_cast<const ctype<char>::mask*>(__OBJ_DATA(__lc_ctype_a)->mask);
+# else
+ return const_cast<const ctype<char>::mask*>(__ctypec);
+# endif
+# else
+ // Platform not supported: abort so the person doing the port knows what to
+ // fix
+# warning ctype<char>::classic_table() is not implemented
+ printf("ctype<char>::classic_table() is not implemented\n");
+ abort();
+ return NULL;
+# endif
}
#endif
#if defined(__GLIBC__)
-const int*
-ctype<char>::__classic_lower_table() noexcept
-{
- return _LIBCPP_GET_C_LOCALE->__ctype_tolower;
-}
+const int* ctype<char>::__classic_lower_table() noexcept { return _LIBCPP_GET_C_LOCALE->__ctype_tolower; }
-const int*
-ctype<char>::__classic_upper_table() noexcept
-{
- return _LIBCPP_GET_C_LOCALE->__ctype_toupper;
-}
+const int* ctype<char>::__classic_upper_table() noexcept { return _LIBCPP_GET_C_LOCALE->__ctype_toupper; }
#elif defined(__NetBSD__)
-const short*
-ctype<char>::__classic_lower_table() noexcept
-{
- return _C_tolower_tab_ + 1;
-}
+const short* ctype<char>::__classic_lower_table() noexcept { return _C_tolower_tab_ + 1; }
-const short*
-ctype<char>::__classic_upper_table() noexcept
-{
- return _C_toupper_tab_ + 1;
-}
+const short* ctype<char>::__classic_upper_table() noexcept { return _C_toupper_tab_ + 1; }
#elif defined(__EMSCRIPTEN__)
-const int*
-ctype<char>::__classic_lower_table() noexcept
-{
- return *__ctype_tolower_loc();
-}
+const int* ctype<char>::__classic_lower_table() noexcept { return *__ctype_tolower_loc(); }
-const int*
-ctype<char>::__classic_upper_table() noexcept
-{
- return *__ctype_toupper_loc();
-}
+const int* ctype<char>::__classic_upper_table() noexcept { return *__ctype_toupper_loc(); }
#elif defined(__MVS__)
-const unsigned short*
-ctype<char>::__classic_lower_table() _NOEXCEPT
-{
-# if defined(__NATIVE_ASCII_F)
+const unsigned short* ctype<char>::__classic_lower_table() _NOEXCEPT {
+# if defined(__NATIVE_ASCII_F)
return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->lower);
-# else
+# else
return const_cast<const unsigned short*>(__ctype + __TOLOWER_INDEX);
-# endif
+# endif
}
-const unsigned short *
-ctype<char>::__classic_upper_table() _NOEXCEPT
-{
-# if defined(__NATIVE_ASCII_F)
+const unsigned short* ctype<char>::__classic_upper_table() _NOEXCEPT {
+# if defined(__NATIVE_ASCII_F)
return const_cast<const unsigned short*>(__OBJ_DATA(__lc_ctype_a)->upper);
-# else
+# else
return const_cast<const unsigned short*>(__ctype + __TOUPPER_INDEX);
-# endif
+# endif
}
#endif // __GLIBC__ || __NETBSD__ || __EMSCRIPTEN__ || __MVS__
// template <> class ctype_byname<char>
ctype_byname<char>::ctype_byname(const char* name, size_t refs)
- : ctype<char>(0, false, refs),
- __l_(newlocale(LC_ALL_MASK, name, 0))
-{
- if (__l_ == 0)
- __throw_runtime_error(("ctype_byname<char>::ctype_byname"
- " failed to construct for " + string(name)).c_str());
+ : ctype<char>(0, false, refs), __l_(newlocale(LC_ALL_MASK, name, 0)) {
+ if (__l_ == 0)
+ __throw_runtime_error(
+ ("ctype_byname<char>::ctype_byname"
+ " failed to construct for " +
+ string(name))
+ .c_str());
}
ctype_byname<char>::ctype_byname(const string& name, size_t refs)
- : ctype<char>(0, false, refs),
- __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
-{
- if (__l_ == 0)
- __throw_runtime_error(("ctype_byname<char>::ctype_byname"
- " failed to construct for " + name).c_str());
+ : ctype<char>(0, false, refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) {
+ if (__l_ == 0)
+ __throw_runtime_error(
+ ("ctype_byname<char>::ctype_byname"
+ " failed to construct for " +
+ name)
+ .c_str());
}
-ctype_byname<char>::~ctype_byname()
-{
- freelocale(__l_);
-}
+ctype_byname<char>::~ctype_byname() { freelocale(__l_); }
-char
-ctype_byname<char>::do_toupper(char_type c) const
-{
- return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l_));
+char ctype_byname<char>::do_toupper(char_type c) const {
+ return static_cast<char>(toupper_l(static_cast<unsigned char>(c), __l_));
}
-const char*
-ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
- *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l_));
- return low;
+const char* ctype_byname<char>::do_toupper(char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
+ *low = static_cast<char>(toupper_l(static_cast<unsigned char>(*low), __l_));
+ return low;
}
-char
-ctype_byname<char>::do_tolower(char_type c) const
-{
- return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l_));
+char ctype_byname<char>::do_tolower(char_type c) const {
+ return static_cast<char>(tolower_l(static_cast<unsigned char>(c), __l_));
}
-const char*
-ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
- *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l_));
- return low;
+const char* ctype_byname<char>::do_tolower(char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
+ *low = static_cast<char>(tolower_l(static_cast<unsigned char>(*low), __l_));
+ return low;
}
// template <> class ctype_byname<wchar_t>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
ctype_byname<wchar_t>::ctype_byname(const char* name, size_t refs)
- : ctype<wchar_t>(refs),
- __l_(newlocale(LC_ALL_MASK, name, 0))
-{
- if (__l_ == 0)
- __throw_runtime_error(("ctype_byname<wchar_t>::ctype_byname"
- " failed to construct for " + string(name)).c_str());
+ : ctype<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, name, 0)) {
+ if (__l_ == 0)
+ __throw_runtime_error(
+ ("ctype_byname<wchar_t>::ctype_byname"
+ " failed to construct for " +
+ string(name))
+ .c_str());
}
ctype_byname<wchar_t>::ctype_byname(const string& name, size_t refs)
- : ctype<wchar_t>(refs),
- __l_(newlocale(LC_ALL_MASK, name.c_str(), 0))
-{
- if (__l_ == 0)
- __throw_runtime_error(("ctype_byname<wchar_t>::ctype_byname"
- " failed to construct for " + name).c_str());
-}
-
-ctype_byname<wchar_t>::~ctype_byname()
-{
- freelocale(__l_);
-}
-
-bool
-ctype_byname<wchar_t>::do_is(mask m, char_type c) const
-{
-#ifdef _LIBCPP_WCTYPE_IS_MASK
- return static_cast<bool>(iswctype_l(c, m, __l_));
-#else
- bool result = false;
- wint_t ch = static_cast<wint_t>(c);
- if ((m & space) == space) result |= (iswspace_l(ch, __l_) != 0);
- if ((m & print) == print) result |= (iswprint_l(ch, __l_) != 0);
- if ((m & cntrl) == cntrl) result |= (iswcntrl_l(ch, __l_) != 0);
- if ((m & upper) == upper) result |= (iswupper_l(ch, __l_) != 0);
- if ((m & lower) == lower) result |= (iswlower_l(ch, __l_) != 0);
- if ((m & alpha) == alpha) result |= (iswalpha_l(ch, __l_) != 0);
- if ((m & digit) == digit) result |= (iswdigit_l(ch, __l_) != 0);
- if ((m & punct) == punct) result |= (iswpunct_l(ch, __l_) != 0);
- if ((m & xdigit) == xdigit) result |= (iswxdigit_l(ch, __l_) != 0);
- if ((m & blank) == blank) result |= (iswblank_l(ch, __l_) != 0);
- return result;
-#endif
-}
-
-const wchar_t*
-ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const
-{
- for (; low != high; ++low, ++vec)
- {
- if (isascii(*low))
- *vec = static_cast<mask>(ctype<char>::classic_table()[*low]);
- else
- {
- *vec = 0;
- wint_t ch = static_cast<wint_t>(*low);
- if (iswspace_l(ch, __l_))
- *vec |= space;
-#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
- if (iswprint_l(ch, __l_))
- *vec |= print;
-#endif
- if (iswcntrl_l(ch, __l_))
- *vec |= cntrl;
- if (iswupper_l(ch, __l_))
- *vec |= upper;
- if (iswlower_l(ch, __l_))
- *vec |= lower;
-#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
- if (iswalpha_l(ch, __l_))
- *vec |= alpha;
-#endif
- if (iswdigit_l(ch, __l_))
- *vec |= digit;
- if (iswpunct_l(ch, __l_))
- *vec |= punct;
-#ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
- if (iswxdigit_l(ch, __l_))
- *vec |= xdigit;
-#endif
- if (iswblank_l(ch, __l_))
- *vec |= blank;
- }
- }
- return low;
-}
-
-const wchar_t*
-ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
- {
-#ifdef _LIBCPP_WCTYPE_IS_MASK
- if (iswctype_l(*low, m, __l_))
- break;
-#else
- wint_t ch = static_cast<wint_t>(*low);
- if ((m & space) == space && iswspace_l(ch, __l_)) break;
- if ((m & print) == print && iswprint_l(ch, __l_)) break;
- if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) break;
- if ((m & upper) == upper && iswupper_l(ch, __l_)) break;
- if ((m & lower) == lower && iswlower_l(ch, __l_)) break;
- if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) break;
- if ((m & digit) == digit && iswdigit_l(ch, __l_)) break;
- if ((m & punct) == punct && iswpunct_l(ch, __l_)) break;
- if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) break;
- if ((m & blank) == blank && iswblank_l(ch, __l_)) break;
-#endif
- }
- return low;
-}
-
-const wchar_t*
-ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
- {
-#ifdef _LIBCPP_WCTYPE_IS_MASK
- if (!iswctype_l(*low, m, __l_))
- break;
-#else
- wint_t ch = static_cast<wint_t>(*low);
- if ((m & space) == space && iswspace_l(ch, __l_)) continue;
- if ((m & print) == print && iswprint_l(ch, __l_)) continue;
- if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_)) continue;
- if ((m & upper) == upper && iswupper_l(ch, __l_)) continue;
- if ((m & lower) == lower && iswlower_l(ch, __l_)) continue;
- if ((m & alpha) == alpha && iswalpha_l(ch, __l_)) continue;
- if ((m & digit) == digit && iswdigit_l(ch, __l_)) continue;
- if ((m & punct) == punct && iswpunct_l(ch, __l_)) continue;
- if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_)) continue;
- if ((m & blank) == blank && iswblank_l(ch, __l_)) continue;
- break;
-#endif
+ : ctype<wchar_t>(refs), __l_(newlocale(LC_ALL_MASK, name.c_str(), 0)) {
+ if (__l_ == 0)
+ __throw_runtime_error(
+ ("ctype_byname<wchar_t>::ctype_byname"
+ " failed to construct for " +
+ name)
+ .c_str());
+}
+
+ctype_byname<wchar_t>::~ctype_byname() { freelocale(__l_); }
+
+bool ctype_byname<wchar_t>::do_is(mask m, char_type c) const {
+# ifdef _LIBCPP_WCTYPE_IS_MASK
+ return static_cast<bool>(iswctype_l(c, m, __l_));
+# else
+ bool result = false;
+ wint_t ch = static_cast<wint_t>(c);
+ if ((m & space) == space)
+ result |= (iswspace_l(ch, __l_) != 0);
+ if ((m & print) == print)
+ result |= (iswprint_l(ch, __l_) != 0);
+ if ((m & cntrl) == cntrl)
+ result |= (iswcntrl_l(ch, __l_) != 0);
+ if ((m & upper) == upper)
+ result |= (iswupper_l(ch, __l_) != 0);
+ if ((m & lower) == lower)
+ result |= (iswlower_l(ch, __l_) != 0);
+ if ((m & alpha) == alpha)
+ result |= (iswalpha_l(ch, __l_) != 0);
+ if ((m & digit) == digit)
+ result |= (iswdigit_l(ch, __l_) != 0);
+ if ((m & punct) == punct)
+ result |= (iswpunct_l(ch, __l_) != 0);
+ if ((m & xdigit) == xdigit)
+ result |= (iswxdigit_l(ch, __l_) != 0);
+ if ((m & blank) == blank)
+ result |= (iswblank_l(ch, __l_) != 0);
+ return result;
+# endif
+}
+
+const wchar_t* ctype_byname<wchar_t>::do_is(const char_type* low, const char_type* high, mask* vec) const {
+ for (; low != high; ++low, ++vec) {
+ if (isascii(*low))
+ *vec = static_cast<mask>(ctype<char>::classic_table()[*low]);
+ else {
+ *vec = 0;
+ wint_t ch = static_cast<wint_t>(*low);
+ if (iswspace_l(ch, __l_))
+ *vec |= space;
+# ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_PRINT
+ if (iswprint_l(ch, __l_))
+ *vec |= print;
+# endif
+ if (iswcntrl_l(ch, __l_))
+ *vec |= cntrl;
+ if (iswupper_l(ch, __l_))
+ *vec |= upper;
+ if (iswlower_l(ch, __l_))
+ *vec |= lower;
+# ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_ALPHA
+ if (iswalpha_l(ch, __l_))
+ *vec |= alpha;
+# endif
+ if (iswdigit_l(ch, __l_))
+ *vec |= digit;
+ if (iswpunct_l(ch, __l_))
+ *vec |= punct;
+# ifndef _LIBCPP_CTYPE_MASK_IS_COMPOSITE_XDIGIT
+ if (iswxdigit_l(ch, __l_))
+ *vec |= xdigit;
+# endif
+ if (iswblank_l(ch, __l_))
+ *vec |= blank;
}
- return low;
+ }
+ return low;
+}
+
+const wchar_t* ctype_byname<wchar_t>::do_scan_is(mask m, const char_type* low, const char_type* high) const {
+ for (; low != high; ++low) {
+# ifdef _LIBCPP_WCTYPE_IS_MASK
+ if (iswctype_l(*low, m, __l_))
+ break;
+# else
+ wint_t ch = static_cast<wint_t>(*low);
+ if ((m & space) == space && iswspace_l(ch, __l_))
+ break;
+ if ((m & print) == print && iswprint_l(ch, __l_))
+ break;
+ if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_))
+ break;
+ if ((m & upper) == upper && iswupper_l(ch, __l_))
+ break;
+ if ((m & lower) == lower && iswlower_l(ch, __l_))
+ break;
+ if ((m & alpha) == alpha && iswalpha_l(ch, __l_))
+ break;
+ if ((m & digit) == digit && iswdigit_l(ch, __l_))
+ break;
+ if ((m & punct) == punct && iswpunct_l(ch, __l_))
+ break;
+ if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_))
+ break;
+ if ((m & blank) == blank && iswblank_l(ch, __l_))
+ break;
+# endif
+ }
+ return low;
+}
+
+const wchar_t* ctype_byname<wchar_t>::do_scan_not(mask m, const char_type* low, const char_type* high) const {
+ for (; low != high; ++low) {
+# ifdef _LIBCPP_WCTYPE_IS_MASK
+ if (!iswctype_l(*low, m, __l_))
+ break;
+# else
+ wint_t ch = static_cast<wint_t>(*low);
+ if ((m & space) == space && iswspace_l(ch, __l_))
+ continue;
+ if ((m & print) == print && iswprint_l(ch, __l_))
+ continue;
+ if ((m & cntrl) == cntrl && iswcntrl_l(ch, __l_))
+ continue;
+ if ((m & upper) == upper && iswupper_l(ch, __l_))
+ continue;
+ if ((m & lower) == lower && iswlower_l(ch, __l_))
+ continue;
+ if ((m & alpha) == alpha && iswalpha_l(ch, __l_))
+ continue;
+ if ((m & digit) == digit && iswdigit_l(ch, __l_))
+ continue;
+ if ((m & punct) == punct && iswpunct_l(ch, __l_))
+ continue;
+ if ((m & xdigit) == xdigit && iswxdigit_l(ch, __l_))
+ continue;
+ if ((m & blank) == blank && iswblank_l(ch, __l_))
+ continue;
+ break;
+# endif
+ }
+ return low;
}
-wchar_t
-ctype_byname<wchar_t>::do_toupper(char_type c) const
-{
- return towupper_l(c, __l_);
-}
+wchar_t ctype_byname<wchar_t>::do_toupper(char_type c) const { return towupper_l(c, __l_); }
-const wchar_t*
-ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
- *low = towupper_l(*low, __l_);
- return low;
+const wchar_t* ctype_byname<wchar_t>::do_toupper(char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
+ *low = towupper_l(*low, __l_);
+ return low;
}
-wchar_t
-ctype_byname<wchar_t>::do_tolower(char_type c) const
-{
- return towlower_l(c, __l_);
-}
+wchar_t ctype_byname<wchar_t>::do_tolower(char_type c) const { return towlower_l(c, __l_); }
-const wchar_t*
-ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const
-{
- for (; low != high; ++low)
- *low = towlower_l(*low, __l_);
- return low;
+const wchar_t* ctype_byname<wchar_t>::do_tolower(char_type* low, const char_type* high) const {
+ for (; low != high; ++low)
+ *low = towlower_l(*low, __l_);
+ return low;
}
-wchar_t
-ctype_byname<wchar_t>::do_widen(char c) const
-{
- return __libcpp_btowc_l(c, __l_);
-}
+wchar_t ctype_byname<wchar_t>::do_widen(char c) const { return __libcpp_btowc_l(c, __l_); }
-const char*
-ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const
-{
- for (; low != high; ++low, ++dest)
- *dest = __libcpp_btowc_l(*low, __l_);
- return low;
+const char* ctype_byname<wchar_t>::do_widen(const char* low, const char* high, char_type* dest) const {
+ for (; low != high; ++low, ++dest)
+ *dest = __libcpp_btowc_l(*low, __l_);
+ return low;
}
-char
-ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const
-{
- int r = __libcpp_wctob_l(c, __l_);
- return (r != EOF) ? static_cast<char>(r) : dfault;
+char ctype_byname<wchar_t>::do_narrow(char_type c, char dfault) const {
+ int r = __libcpp_wctob_l(c, __l_);
+ return (r != EOF) ? static_cast<char>(r) : dfault;
}
const wchar_t*
-ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const
-{
- for (; low != high; ++low, ++dest)
- {
- int r = __libcpp_wctob_l(*low, __l_);
- *dest = (r != EOF) ? static_cast<char>(r) : dfault;
- }
- return low;
+ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, char dfault, char* dest) const {
+ for (; low != high; ++low, ++dest) {
+ int r = __libcpp_wctob_l(*low, __l_);
+ *dest = (r != EOF) ? static_cast<char>(r) : dfault;
+ }
+ return low;
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -1505,277 +1302,245 @@ ctype_byname<wchar_t>::do_narrow(const char_type* low, const char_type* high, ch
constinit locale::id codecvt<char, char, mbstate_t>::id;
-codecvt<char, char, mbstate_t>::~codecvt()
-{
-}
-
-codecvt<char, char, mbstate_t>::result
-codecvt<char, char, mbstate_t>::do_out(state_type&,
- const intern_type* frm, const intern_type*, const intern_type*& frm_nxt,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- frm_nxt = frm;
- to_nxt = to;
- return noconv;
+codecvt<char, char, mbstate_t>::~codecvt() {}
+
+codecvt<char, char, mbstate_t>::result codecvt<char, char, mbstate_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type*,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type*,
+ extern_type*& to_nxt) const {
+ frm_nxt = frm;
+ to_nxt = to;
+ return noconv;
+}
+
+codecvt<char, char, mbstate_t>::result codecvt<char, char, mbstate_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type*,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type*,
+ intern_type*& to_nxt) const {
+ frm_nxt = frm;
+ to_nxt = to;
+ return noconv;
}
codecvt<char, char, mbstate_t>::result
-codecvt<char, char, mbstate_t>::do_in(state_type&,
- const extern_type* frm, const extern_type*, const extern_type*& frm_nxt,
- intern_type* to, intern_type*, intern_type*& to_nxt) const
-{
- frm_nxt = frm;
- to_nxt = to;
- return noconv;
+codecvt<char, char, mbstate_t>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-codecvt<char, char, mbstate_t>::result
-codecvt<char, char, mbstate_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+int codecvt<char, char, mbstate_t>::do_encoding() const noexcept { return 1; }
-int
-codecvt<char, char, mbstate_t>::do_encoding() const noexcept
-{
- return 1;
-}
+bool codecvt<char, char, mbstate_t>::do_always_noconv() const noexcept { return true; }
-bool
-codecvt<char, char, mbstate_t>::do_always_noconv() const noexcept
-{
- return true;
+int codecvt<char, char, mbstate_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* end, size_t mx) const {
+ return static_cast<int>(min<size_t>(mx, static_cast<size_t>(end - frm)));
}
-int
-codecvt<char, char, mbstate_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* end, size_t mx) const
-{
- return static_cast<int>(min<size_t>(mx, static_cast<size_t>(end-frm)));
-}
-
-int
-codecvt<char, char, mbstate_t>::do_max_length() const noexcept
-{
- return 1;
-}
+int codecvt<char, char, mbstate_t>::do_max_length() const noexcept { return 1; }
// template <> class codecvt<wchar_t, char, mbstate_t>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
constinit locale::id codecvt<wchar_t, char, mbstate_t>::id;
-codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs)
- : locale::facet(refs),
- __l_(_LIBCPP_GET_C_LOCALE)
-{
-}
+codecvt<wchar_t, char, mbstate_t>::codecvt(size_t refs) : locale::facet(refs), __l_(_LIBCPP_GET_C_LOCALE) {}
codecvt<wchar_t, char, mbstate_t>::codecvt(const char* nm, size_t refs)
- : locale::facet(refs),
- __l_(newlocale(LC_ALL_MASK, nm, 0))
-{
- if (__l_ == 0)
- __throw_runtime_error(("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
- " failed to construct for " + string(nm)).c_str());
-}
-
-codecvt<wchar_t, char, mbstate_t>::~codecvt()
-{
- if (__l_ != _LIBCPP_GET_C_LOCALE)
- freelocale(__l_);
-}
-
-codecvt<wchar_t, char, mbstate_t>::result
-codecvt<wchar_t, char, mbstate_t>::do_out(state_type& st,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- // look for first internal null in frm
- const intern_type* fend = frm;
- for (; fend != frm_end; ++fend)
- if (*fend == 0)
- break;
- // loop over all null-terminated sequences in frm
- to_nxt = to;
- for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt)
- {
- // save state in case it is needed to recover to_nxt on error
- mbstate_t save_state = st;
- size_t n = __libcpp_wcsnrtombs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
- static_cast<size_t>(to_end-to), &st, __l_);
- if (n == size_t(-1))
- {
- // need to recover to_nxt
- for (to_nxt = to; frm != frm_nxt; ++frm)
- {
- n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l_);
- if (n == size_t(-1))
- break;
- to_nxt += n;
- }
- frm_nxt = frm;
- return error;
- }
- if (n == 0)
- return partial;
- to_nxt += n;
- if (to_nxt == to_end)
- break;
- if (fend != frm_end) // set up next null terminated sequence
- {
- // Try to write the terminating null
- extern_type tmp[MB_LEN_MAX];
- n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);
- if (n == size_t(-1)) // on error
- return error;
- if (n > static_cast<size_t>(to_end-to_nxt)) // is there room?
- return partial;
- for (extern_type* p = tmp; n; --n) // write it
- *to_nxt++ = *p++;
- ++frm_nxt;
- // look for next null in frm
- for (fend = frm_nxt; fend != frm_end; ++fend)
- if (*fend == 0)
- break;
- }
- }
- return frm_nxt == frm_end ? ok : partial;
+ : locale::facet(refs), __l_(newlocale(LC_ALL_MASK, nm, 0)) {
+ if (__l_ == 0)
+ __throw_runtime_error(
+ ("codecvt_byname<wchar_t, char, mbstate_t>::codecvt_byname"
+ " failed to construct for " +
+ string(nm))
+ .c_str());
}
-codecvt<wchar_t, char, mbstate_t>::result
-codecvt<wchar_t, char, mbstate_t>::do_in(state_type& st,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- // look for first internal null in frm
- const extern_type* fend = frm;
- for (; fend != frm_end; ++fend)
- if (*fend == 0)
- break;
- // loop over all null-terminated sequences in frm
- to_nxt = to;
- for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt)
- {
- // save state in case it is needed to recover to_nxt on error
- mbstate_t save_state = st;
- size_t n = __libcpp_mbsnrtowcs_l(to, &frm_nxt, static_cast<size_t>(fend-frm),
- static_cast<size_t>(to_end-to), &st, __l_);
- if (n == size_t(-1))
- {
- // need to recover to_nxt
- for (to_nxt = to; frm != frm_nxt; ++to_nxt)
- {
- n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend-frm),
- &save_state, __l_);
- switch (n)
- {
- case 0:
- ++frm;
- break;
- case size_t(-1):
- frm_nxt = frm;
- return error;
- case size_t(-2):
- frm_nxt = frm;
- return partial;
- default:
- frm += n;
- break;
- }
- }
- frm_nxt = frm;
- return frm_nxt == frm_end ? ok : partial;
- }
+codecvt<wchar_t, char, mbstate_t>::~codecvt() {
+ if (__l_ != _LIBCPP_GET_C_LOCALE)
+ freelocale(__l_);
+}
+
+codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_out(
+ state_type& st,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ // look for first internal null in frm
+ const intern_type* fend = frm;
+ for (; fend != frm_end; ++fend)
+ if (*fend == 0)
+ break;
+ // loop over all null-terminated sequences in frm
+ to_nxt = to;
+ for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt) {
+ // save state in case it is needed to recover to_nxt on error
+ mbstate_t save_state = st;
+ size_t n = __libcpp_wcsnrtombs_l(
+ to, &frm_nxt, static_cast<size_t>(fend - frm), static_cast<size_t>(to_end - to), &st, __l_);
+ if (n == size_t(-1)) {
+ // need to recover to_nxt
+ for (to_nxt = to; frm != frm_nxt; ++frm) {
+ n = __libcpp_wcrtomb_l(to_nxt, *frm, &save_state, __l_);
if (n == size_t(-1))
- return error;
+ break;
to_nxt += n;
- if (to_nxt == to_end)
- break;
- if (fend != frm_end) // set up next null terminated sequence
- {
- // Try to write the terminating null
- n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l_);
- if (n != 0) // on error
- return error;
- ++to_nxt;
- ++frm_nxt;
- // look for next null in frm
- for (fend = frm_nxt; fend != frm_end; ++fend)
- if (*fend == 0)
- break;
- }
+ }
+ frm_nxt = frm;
+ return error;
}
- return frm_nxt == frm_end ? ok : partial;
-}
-
-codecvt<wchar_t, char, mbstate_t>::result
-codecvt<wchar_t, char, mbstate_t>::do_unshift(state_type& st,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- to_nxt = to;
- extern_type tmp[MB_LEN_MAX];
- size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);
- if (n == size_t(-1) || n == 0) // on error
+ if (n == 0)
+ return partial;
+ to_nxt += n;
+ if (to_nxt == to_end)
+ break;
+ if (fend != frm_end) // set up next null terminated sequence
+ {
+ // Try to write the terminating null
+ extern_type tmp[MB_LEN_MAX];
+ n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);
+ if (n == size_t(-1)) // on error
return error;
- --n;
- if (n > static_cast<size_t>(to_end-to_nxt)) // is there room?
+ if (n > static_cast<size_t>(to_end - to_nxt)) // is there room?
return partial;
- for (extern_type* p = tmp; n; --n) // write it
+ for (extern_type* p = tmp; n; --n) // write it
*to_nxt++ = *p++;
- return ok;
-}
-
-int
-codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept
-{
- if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l_) != 0)
- return -1;
-
- // stateless encoding
- if (__l_ == 0 || __libcpp_mb_cur_max_l(__l_) == 1) // there are no known constant length encodings
- return 1; // which take more than 1 char to form a wchar_t
- return 0;
-}
-
-bool
-codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const noexcept
-{
- return false;
-}
-
-int
-codecvt<wchar_t, char, mbstate_t>::do_length(state_type& st,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- int nbytes = 0;
- for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t)
- {
- size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end-frm), &st, __l_);
- switch (n)
- {
+ ++frm_nxt;
+ // look for next null in frm
+ for (fend = frm_nxt; fend != frm_end; ++fend)
+ if (*fend == 0)
+ break;
+ }
+ }
+ return frm_nxt == frm_end ? ok : partial;
+}
+
+codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_in(
+ state_type& st,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ // look for first internal null in frm
+ const extern_type* fend = frm;
+ for (; fend != frm_end; ++fend)
+ if (*fend == 0)
+ break;
+ // loop over all null-terminated sequences in frm
+ to_nxt = to;
+ for (frm_nxt = frm; frm != frm_end && to != to_end; frm = frm_nxt, to = to_nxt) {
+ // save state in case it is needed to recover to_nxt on error
+ mbstate_t save_state = st;
+ size_t n = __libcpp_mbsnrtowcs_l(
+ to, &frm_nxt, static_cast<size_t>(fend - frm), static_cast<size_t>(to_end - to), &st, __l_);
+ if (n == size_t(-1)) {
+ // need to recover to_nxt
+ for (to_nxt = to; frm != frm_nxt; ++to_nxt) {
+ n = __libcpp_mbrtowc_l(to_nxt, frm, static_cast<size_t>(fend - frm), &save_state, __l_);
+ switch (n) {
case 0:
- ++nbytes;
- ++frm;
- break;
+ ++frm;
+ break;
case size_t(-1):
+ frm_nxt = frm;
+ return error;
case size_t(-2):
- return nbytes;
+ frm_nxt = frm;
+ return partial;
default:
- nbytes += n;
- frm += n;
- break;
+ frm += n;
+ break;
}
+ }
+ frm_nxt = frm;
+ return frm_nxt == frm_end ? ok : partial;
+ }
+ if (n == size_t(-1))
+ return error;
+ to_nxt += n;
+ if (to_nxt == to_end)
+ break;
+ if (fend != frm_end) // set up next null terminated sequence
+ {
+ // Try to write the terminating null
+ n = __libcpp_mbrtowc_l(to_nxt, frm_nxt, 1, &st, __l_);
+ if (n != 0) // on error
+ return error;
+ ++to_nxt;
+ ++frm_nxt;
+ // look for next null in frm
+ for (fend = frm_nxt; fend != frm_end; ++fend)
+ if (*fend == 0)
+ break;
+ }
+ }
+ return frm_nxt == frm_end ? ok : partial;
+}
+
+codecvt<wchar_t, char, mbstate_t>::result codecvt<wchar_t, char, mbstate_t>::do_unshift(
+ state_type& st, extern_type* to, extern_type* to_end, extern_type*& to_nxt) const {
+ to_nxt = to;
+ extern_type tmp[MB_LEN_MAX];
+ size_t n = __libcpp_wcrtomb_l(tmp, intern_type(), &st, __l_);
+ if (n == size_t(-1) || n == 0) // on error
+ return error;
+ --n;
+ if (n > static_cast<size_t>(to_end - to_nxt)) // is there room?
+ return partial;
+ for (extern_type* p = tmp; n; --n) // write it
+ *to_nxt++ = *p++;
+ return ok;
+}
+
+int codecvt<wchar_t, char, mbstate_t>::do_encoding() const noexcept {
+ if (__libcpp_mbtowc_l(nullptr, nullptr, MB_LEN_MAX, __l_) != 0)
+ return -1;
+
+ // stateless encoding
+ if (__l_ == 0 || __libcpp_mb_cur_max_l(__l_) == 1) // there are no known constant length encodings
+ return 1; // which take more than 1 char to form a wchar_t
+ return 0;
+}
+
+bool codecvt<wchar_t, char, mbstate_t>::do_always_noconv() const noexcept { return false; }
+
+int codecvt<wchar_t, char, mbstate_t>::do_length(
+ state_type& st, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ int nbytes = 0;
+ for (size_t nwchar_t = 0; nwchar_t < mx && frm != frm_end; ++nwchar_t) {
+ size_t n = __libcpp_mbrlen_l(frm, static_cast<size_t>(frm_end - frm), &st, __l_);
+ switch (n) {
+ case 0:
+ ++nbytes;
+ ++frm;
+ break;
+ case size_t(-1):
+ case size_t(-2):
+ return nbytes;
+ default:
+ nbytes += n;
+ frm += n;
+ break;
}
- return nbytes;
+ }
+ return nbytes;
}
-int
-codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept
-{
- return __l_ == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l_));
+int codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept {
+ return __l_ == 0 ? 1 : static_cast<int>(__libcpp_mb_cur_max_l(__l_));
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
@@ -1794,1403 +1559,1211 @@ codecvt<wchar_t, char, mbstate_t>::do_max_length() const noexcept
// 100000 - 10FFFF DBC0 - DBFF, DC00 - DFFF F4 - F4, 80 - 8F, 80 - BF, 80 - BF 65536
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-static
-codecvt_base::result
-utf16_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
- uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & generate_header)
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xEF);
- *to_nxt++ = static_cast<uint8_t>(0xBB);
- *to_nxt++ = static_cast<uint8_t>(0xBF);
- }
- for (; frm_nxt < frm_end; ++frm_nxt)
- {
- uint16_t wc1 = *frm_nxt;
- if (wc1 > Maxcode)
- return codecvt_base::error;
- if (wc1 < 0x0080)
- {
- if (to_end-to_nxt < 1)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(wc1);
- }
- else if (wc1 < 0x0800)
- {
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
- }
- else if (wc1 < 0xD800)
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
- }
- else if (wc1 < 0xDC00)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint16_t wc2 = frm_nxt[1];
- if ((wc2 & 0xFC00) != 0xDC00)
- return codecvt_base::error;
- if (to_end-to_nxt < 4)
- return codecvt_base::partial;
- if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
- ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
- return codecvt_base::error;
- ++frm_nxt;
- uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
- *to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4) | ((wc1 & 0x003C) >> 2));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc2 & 0x003F));
- }
- else if (wc1 < 0xE000)
- {
- return codecvt_base::error;
- }
- else
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
- }
- }
- return codecvt_base::ok;
-}
-
-static
-codecvt_base::result
-utf16_to_utf8(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
- uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & generate_header)
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xEF);
- *to_nxt++ = static_cast<uint8_t>(0xBB);
- *to_nxt++ = static_cast<uint8_t>(0xBF);
- }
- for (; frm_nxt < frm_end; ++frm_nxt)
- {
- uint16_t wc1 = static_cast<uint16_t>(*frm_nxt);
- if (wc1 > Maxcode)
- return codecvt_base::error;
- if (wc1 < 0x0080)
- {
- if (to_end-to_nxt < 1)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(wc1);
- }
- else if (wc1 < 0x0800)
- {
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
- }
- else if (wc1 < 0xD800)
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
- }
- else if (wc1 < 0xDC00)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint16_t wc2 = static_cast<uint16_t>(frm_nxt[1]);
- if ((wc2 & 0xFC00) != 0xDC00)
- return codecvt_base::error;
- if (to_end-to_nxt < 4)
- return codecvt_base::partial;
- if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) +
- ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
- return codecvt_base::error;
- ++frm_nxt;
- uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
- *to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4) | ((wc1 & 0x003C) >> 2));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc2 & 0x003F));
- }
- else if (wc1 < 0xE000)
- {
- return codecvt_base::error;
- }
- else
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
- }
- }
- return codecvt_base::ok;
-}
-
-static
-codecvt_base::result
-utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
- uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
- frm_nxt[2] == 0xBF)
- frm_nxt += 3;
- }
- for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
- {
- uint8_t c1 = *frm_nxt;
- if (c1 > Maxcode)
- return codecvt_base::error;
- if (c1 < 0x80)
- {
- *to_nxt = static_cast<uint16_t>(c1);
- ++frm_nxt;
- }
- else if (c1 < 0xC2)
- {
- return codecvt_base::error;
- }
- else if (c1 < 0xE0)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = t;
- frm_nxt += 2;
- }
- else if (c1 < 0xF0)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- switch (c1)
- {
- case 0xE0:
- if ((c2 & 0xE0) != 0xA0)
- return codecvt_base::error;
- break;
- case 0xED:
- if ((c2 & 0xE0) != 0x80)
- return codecvt_base::error;
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- break;
- }
- if (frm_end-frm_nxt < 3)
- return codecvt_base::partial;
- uint8_t c3 = frm_nxt[2];
- if ((c3 & 0xC0) != 0x80)
- return codecvt_base::error;
- uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12)
- | ((c2 & 0x3F) << 6)
- | (c3 & 0x3F));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = t;
- frm_nxt += 3;
- }
- else if (c1 < 0xF5)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- switch (c1)
- {
- case 0xF0:
- if (!(0x90 <= c2 && c2 <= 0xBF))
- return codecvt_base::error;
- break;
- case 0xF4:
- if ((c2 & 0xF0) != 0x80)
- return codecvt_base::error;
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- break;
- }
- if (frm_end-frm_nxt < 3)
- return codecvt_base::partial;
- uint8_t c3 = frm_nxt[2];
- if ((c3 & 0xC0) != 0x80)
- return codecvt_base::error;
- if (frm_end-frm_nxt < 4)
- return codecvt_base::partial;
- uint8_t c4 = frm_nxt[3];
- if ((c4 & 0xC0) != 0x80)
- return codecvt_base::error;
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- if ((((c1 & 7UL) << 18) +
- ((c2 & 0x3FUL) << 12) +
- ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
- return codecvt_base::error;
- *to_nxt = static_cast<uint16_t>(
- 0xD800
- | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6)
- | ((c2 & 0x0F) << 2)
- | ((c3 & 0x30) >> 4));
- *++to_nxt = static_cast<uint16_t>(
- 0xDC00
- | ((c3 & 0x0F) << 6)
- | (c4 & 0x3F));
- frm_nxt += 4;
- }
- else
- {
- return codecvt_base::error;
- }
- }
- return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-}
-
-static
-codecvt_base::result
-utf8_to_utf16(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
- uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
- frm_nxt[2] == 0xBF)
- frm_nxt += 3;
- }
- for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
- {
- uint8_t c1 = *frm_nxt;
- if (c1 > Maxcode)
- return codecvt_base::error;
- if (c1 < 0x80)
- {
- *to_nxt = static_cast<uint32_t>(c1);
- ++frm_nxt;
- }
- else if (c1 < 0xC2)
- {
- return codecvt_base::error;
- }
- else if (c1 < 0xE0)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = static_cast<uint32_t>(t);
- frm_nxt += 2;
- }
- else if (c1 < 0xF0)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- switch (c1)
- {
- case 0xE0:
- if ((c2 & 0xE0) != 0xA0)
- return codecvt_base::error;
- break;
- case 0xED:
- if ((c2 & 0xE0) != 0x80)
- return codecvt_base::error;
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- break;
- }
- if (frm_end-frm_nxt < 3)
- return codecvt_base::partial;
- uint8_t c3 = frm_nxt[2];
- if ((c3 & 0xC0) != 0x80)
- return codecvt_base::error;
- uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12)
- | ((c2 & 0x3F) << 6)
- | (c3 & 0x3F));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = static_cast<uint32_t>(t);
- frm_nxt += 3;
- }
- else if (c1 < 0xF5)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- switch (c1)
- {
- case 0xF0:
- if (!(0x90 <= c2 && c2 <= 0xBF))
- return codecvt_base::error;
- break;
- case 0xF4:
- if ((c2 & 0xF0) != 0x80)
- return codecvt_base::error;
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- break;
- }
- if (frm_end-frm_nxt < 3)
- return codecvt_base::partial;
- uint8_t c3 = frm_nxt[2];
- if ((c3 & 0xC0) != 0x80)
- return codecvt_base::error;
- if (frm_end-frm_nxt < 4)
- return codecvt_base::partial;
- uint8_t c4 = frm_nxt[3];
- if ((c4 & 0xC0) != 0x80)
- return codecvt_base::error;
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- if ((((c1 & 7UL) << 18) +
- ((c2 & 0x3FUL) << 12) +
- ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
- return codecvt_base::error;
- *to_nxt = static_cast<uint32_t>(
- 0xD800
- | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6)
- | ((c2 & 0x0F) << 2)
- | ((c3 & 0x30) >> 4));
- *++to_nxt = static_cast<uint32_t>(
- 0xDC00
- | ((c3 & 0x0F) << 6)
- | (c4 & 0x3F));
- frm_nxt += 4;
- }
- else
- {
- return codecvt_base::error;
- }
- }
- return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-}
-
-static
-int
-utf8_to_utf16_length(const uint8_t* frm, const uint8_t* frm_end,
- size_t mx, unsigned long Maxcode = 0x10FFFF,
- codecvt_mode mode = codecvt_mode(0))
-{
- const uint8_t* frm_nxt = frm;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
- frm_nxt[2] == 0xBF)
- frm_nxt += 3;
- }
- for (size_t nchar16_t = 0; frm_nxt < frm_end && nchar16_t < mx; ++nchar16_t)
- {
- uint8_t c1 = *frm_nxt;
- if (c1 > Maxcode)
- break;
- if (c1 < 0x80)
- {
- ++frm_nxt;
- }
- else if (c1 < 0xC2)
- {
- break;
- }
- else if (c1 < 0xE0)
- {
- if ((frm_end-frm_nxt < 2) || (frm_nxt[1] & 0xC0) != 0x80)
- break;
- uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (frm_nxt[1] & 0x3F));
- if (t > Maxcode)
- break;
- frm_nxt += 2;
- }
- else if (c1 < 0xF0)
- {
- if (frm_end-frm_nxt < 3)
- break;
- uint8_t c2 = frm_nxt[1];
- uint8_t c3 = frm_nxt[2];
- switch (c1)
- {
- case 0xE0:
- if ((c2 & 0xE0) != 0xA0)
- return static_cast<int>(frm_nxt - frm);
- break;
- case 0xED:
- if ((c2 & 0xE0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- }
- if ((c3 & 0xC0) != 0x80)
- break;
- if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
- break;
- frm_nxt += 3;
- }
- else if (c1 < 0xF5)
- {
- if (frm_end-frm_nxt < 4 || mx-nchar16_t < 2)
- break;
- uint8_t c2 = frm_nxt[1];
- uint8_t c3 = frm_nxt[2];
- uint8_t c4 = frm_nxt[3];
- switch (c1)
- {
- case 0xF0:
- if (!(0x90 <= c2 && c2 <= 0xBF))
- return static_cast<int>(frm_nxt - frm);
- break;
- case 0xF4:
- if ((c2 & 0xF0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- }
- if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
- break;
- if ((((c1 & 7UL) << 18) +
- ((c2 & 0x3FUL) << 12) +
- ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
- break;
- ++nchar16_t;
- frm_nxt += 4;
- }
- else
- {
- break;
- }
- }
- return static_cast<int>(frm_nxt - frm);
-}
-
-static
-codecvt_base::result
-ucs4_to_utf8(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
- uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & generate_header)
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xEF);
- *to_nxt++ = static_cast<uint8_t>(0xBB);
- *to_nxt++ = static_cast<uint8_t>(0xBF);
- }
- for (; frm_nxt < frm_end; ++frm_nxt)
- {
- uint32_t wc = *frm_nxt;
- if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
- return codecvt_base::error;
- if (wc < 0x000080)
- {
- if (to_end-to_nxt < 1)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(wc);
- }
- else if (wc < 0x000800)
- {
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
- }
- else if (wc < 0x010000)
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc >> 12));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x003F));
- }
- else // if (wc < 0x110000)
- {
- if (to_end-to_nxt < 4)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xF0 | (wc >> 18));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x03F000) >> 12));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x000FC0) >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x00003F));
- }
- }
- return codecvt_base::ok;
-}
-
-static
-codecvt_base::result
-utf8_to_ucs4(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
- uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
- frm_nxt[2] == 0xBF)
- frm_nxt += 3;
- }
- for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
- {
- uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
- if (c1 < 0x80)
- {
- if (c1 > Maxcode)
- return codecvt_base::error;
- *to_nxt = static_cast<uint32_t>(c1);
- ++frm_nxt;
- }
- else if (c1 < 0xC2)
- {
- return codecvt_base::error;
- }
- else if (c1 < 0xE0)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- uint32_t t = static_cast<uint32_t>(((c1 & 0x1F) << 6)
- | (c2 & 0x3F));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = t;
- frm_nxt += 2;
- }
- else if (c1 < 0xF0)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- switch (c1)
- {
- case 0xE0:
- if ((c2 & 0xE0) != 0xA0)
- return codecvt_base::error;
- break;
- case 0xED:
- if ((c2 & 0xE0) != 0x80)
- return codecvt_base::error;
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- break;
- }
- if (frm_end-frm_nxt < 3)
- return codecvt_base::partial;
- uint8_t c3 = frm_nxt[2];
- if ((c3 & 0xC0) != 0x80)
- return codecvt_base::error;
- uint32_t t = static_cast<uint32_t>(((c1 & 0x0F) << 12)
- | ((c2 & 0x3F) << 6)
- | (c3 & 0x3F));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = t;
- frm_nxt += 3;
- }
- else if (c1 < 0xF5)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- switch (c1)
- {
- case 0xF0:
- if (!(0x90 <= c2 && c2 <= 0xBF))
- return codecvt_base::error;
- break;
- case 0xF4:
- if ((c2 & 0xF0) != 0x80)
- return codecvt_base::error;
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- break;
- }
- if (frm_end-frm_nxt < 3)
- return codecvt_base::partial;
- uint8_t c3 = frm_nxt[2];
- if ((c3 & 0xC0) != 0x80)
- return codecvt_base::error;
- if (frm_end-frm_nxt < 4)
- return codecvt_base::partial;
- uint8_t c4 = frm_nxt[3];
- if ((c4 & 0xC0) != 0x80)
- return codecvt_base::error;
- uint32_t t = static_cast<uint32_t>(((c1 & 0x07) << 18)
- | ((c2 & 0x3F) << 12)
- | ((c3 & 0x3F) << 6)
- | (c4 & 0x3F));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = t;
- frm_nxt += 4;
- }
- else
- {
- return codecvt_base::error;
- }
- }
- return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-}
-
-static
-int
-utf8_to_ucs4_length(const uint8_t* frm, const uint8_t* frm_end,
- size_t mx, unsigned long Maxcode = 0x10FFFF,
- codecvt_mode mode = codecvt_mode(0))
-{
- const uint8_t* frm_nxt = frm;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
- frm_nxt[2] == 0xBF)
- frm_nxt += 3;
- }
- for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t)
- {
- uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
- if (c1 < 0x80)
- {
- if (c1 > Maxcode)
- break;
- ++frm_nxt;
- }
- else if (c1 < 0xC2)
- {
- break;
- }
- else if (c1 < 0xE0)
- {
- if ((frm_end-frm_nxt < 2) || ((frm_nxt[1] & 0xC0) != 0x80))
- break;
- if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
- break;
- frm_nxt += 2;
- }
- else if (c1 < 0xF0)
- {
- if (frm_end-frm_nxt < 3)
- break;
- uint8_t c2 = frm_nxt[1];
- uint8_t c3 = frm_nxt[2];
- switch (c1)
- {
- case 0xE0:
- if ((c2 & 0xE0) != 0xA0)
- return static_cast<int>(frm_nxt - frm);
- break;
- case 0xED:
- if ((c2 & 0xE0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- }
- if ((c3 & 0xC0) != 0x80)
- break;
- if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
- break;
- frm_nxt += 3;
- }
- else if (c1 < 0xF5)
- {
- if (frm_end-frm_nxt < 4)
- break;
- uint8_t c2 = frm_nxt[1];
- uint8_t c3 = frm_nxt[2];
- uint8_t c4 = frm_nxt[3];
- switch (c1)
- {
- case 0xF0:
- if (!(0x90 <= c2 && c2 <= 0xBF))
- return static_cast<int>(frm_nxt - frm);
- break;
- case 0xF4:
- if ((c2 & 0xF0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- }
- if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
- break;
- if ((((c1 & 0x07u) << 18) | ((c2 & 0x3Fu) << 12) |
- ((c3 & 0x3Fu) << 6) | (c4 & 0x3Fu)) > Maxcode)
- break;
- frm_nxt += 4;
- }
- else
- {
- break;
- }
- }
- return static_cast<int>(frm_nxt - frm);
-}
-
-static
-codecvt_base::result
-ucs2_to_utf8(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
- uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & generate_header)
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xEF);
- *to_nxt++ = static_cast<uint8_t>(0xBB);
- *to_nxt++ = static_cast<uint8_t>(0xBF);
- }
- for (; frm_nxt < frm_end; ++frm_nxt)
- {
- uint16_t wc = *frm_nxt;
- if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
- return codecvt_base::error;
- if (wc < 0x0080)
- {
- if (to_end-to_nxt < 1)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(wc);
- }
- else if (wc < 0x0800)
- {
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
- }
- else // if (wc <= 0xFFFF)
- {
- if (to_end-to_nxt < 3)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc >> 12));
- *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
- *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x003F));
- }
- }
- return codecvt_base::ok;
-}
-
-static
-codecvt_base::result
-utf8_to_ucs2(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
- uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
- frm_nxt[2] == 0xBF)
- frm_nxt += 3;
- }
- for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt)
- {
- uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
- if (c1 < 0x80)
- {
- if (c1 > Maxcode)
- return codecvt_base::error;
- *to_nxt = static_cast<uint16_t>(c1);
- ++frm_nxt;
- }
- else if (c1 < 0xC2)
- {
- return codecvt_base::error;
- }
- else if (c1 < 0xE0)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6)
- | (c2 & 0x3F));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = t;
- frm_nxt += 2;
- }
- else if (c1 < 0xF0)
- {
- if (frm_end-frm_nxt < 2)
- return codecvt_base::partial;
- uint8_t c2 = frm_nxt[1];
- switch (c1)
- {
- case 0xE0:
- if ((c2 & 0xE0) != 0xA0)
- return codecvt_base::error;
- break;
- case 0xED:
- if ((c2 & 0xE0) != 0x80)
- return codecvt_base::error;
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return codecvt_base::error;
- break;
- }
- if (frm_end-frm_nxt < 3)
- return codecvt_base::partial;
- uint8_t c3 = frm_nxt[2];
- if ((c3 & 0xC0) != 0x80)
- return codecvt_base::error;
- uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12)
- | ((c2 & 0x3F) << 6)
- | (c3 & 0x3F));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = t;
- frm_nxt += 3;
- }
- else
- {
- return codecvt_base::error;
- }
- }
- return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-}
-
-static
-int
-utf8_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
- size_t mx, unsigned long Maxcode = 0x10FFFF,
- codecvt_mode mode = codecvt_mode(0))
-{
- const uint8_t* frm_nxt = frm;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB &&
- frm_nxt[2] == 0xBF)
- frm_nxt += 3;
- }
- for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t)
- {
- uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
- if (c1 < 0x80)
- {
- if (c1 > Maxcode)
- break;
- ++frm_nxt;
- }
- else if (c1 < 0xC2)
- {
- break;
- }
- else if (c1 < 0xE0)
- {
- if ((frm_end-frm_nxt < 2) || ((frm_nxt[1] & 0xC0) != 0x80))
- break;
- if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
- break;
- frm_nxt += 2;
- }
- else if (c1 < 0xF0)
- {
- if (frm_end-frm_nxt < 3)
- break;
- uint8_t c2 = frm_nxt[1];
- uint8_t c3 = frm_nxt[2];
- switch (c1)
- {
- case 0xE0:
- if ((c2 & 0xE0) != 0xA0)
- return static_cast<int>(frm_nxt - frm);
- break;
- case 0xED:
- if ((c2 & 0xE0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- default:
- if ((c2 & 0xC0) != 0x80)
- return static_cast<int>(frm_nxt - frm);
- break;
- }
- if ((c3 & 0xC0) != 0x80)
- break;
- if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
- break;
- frm_nxt += 3;
- }
- else
- {
- break;
- }
- }
- return static_cast<int>(frm_nxt - frm);
-}
-
-static
-codecvt_base::result
-ucs4_to_utf16be(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
- uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & generate_header)
- {
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xFE);
- *to_nxt++ = static_cast<uint8_t>(0xFF);
- }
- for (; frm_nxt < frm_end; ++frm_nxt)
- {
- uint32_t wc = *frm_nxt;
- if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
- return codecvt_base::error;
- if (wc < 0x010000)
- {
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(wc >> 8);
- *to_nxt++ = static_cast<uint8_t>(wc);
- }
- else
- {
- if (to_end-to_nxt < 4)
- return codecvt_base::partial;
- uint16_t t = static_cast<uint16_t>(
- 0xD800
- | ((((wc & 0x1F0000) >> 16) - 1) << 6)
- | ((wc & 0x00FC00) >> 10));
- *to_nxt++ = static_cast<uint8_t>(t >> 8);
- *to_nxt++ = static_cast<uint8_t>(t);
- t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
- *to_nxt++ = static_cast<uint8_t>(t >> 8);
- *to_nxt++ = static_cast<uint8_t>(t);
- }
- }
- return codecvt_base::ok;
-}
-
-static
-codecvt_base::result
-utf16be_to_ucs4(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
- uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
- frm_nxt += 2;
- }
- for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
- {
- uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
- if ((c1 & 0xFC00) == 0xDC00)
- return codecvt_base::error;
- if ((c1 & 0xFC00) != 0xD800)
- {
- if (c1 > Maxcode)
- return codecvt_base::error;
- *to_nxt = static_cast<uint32_t>(c1);
- frm_nxt += 2;
- }
- else
- {
- if (frm_end-frm_nxt < 4)
- return codecvt_base::partial;
- uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
- if ((c2 & 0xFC00) != 0xDC00)
- return codecvt_base::error;
- uint32_t t = static_cast<uint32_t>(
- ((((c1 & 0x03C0) >> 6) + 1) << 16)
- | ((c1 & 0x003F) << 10)
- | (c2 & 0x03FF));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = t;
- frm_nxt += 4;
- }
- }
- return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-}
-
-static
-int
-utf16be_to_ucs4_length(const uint8_t* frm, const uint8_t* frm_end,
- size_t mx, unsigned long Maxcode = 0x10FFFF,
- codecvt_mode mode = codecvt_mode(0))
-{
- const uint8_t* frm_nxt = frm;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
- frm_nxt += 2;
- }
- for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t)
- {
- uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
- if ((c1 & 0xFC00) == 0xDC00)
- break;
- if ((c1 & 0xFC00) != 0xD800)
- {
- if (c1 > Maxcode)
- break;
- frm_nxt += 2;
- }
- else
- {
- if (frm_end-frm_nxt < 4)
- break;
- uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
- if ((c2 & 0xFC00) != 0xDC00)
- break;
- uint32_t t = static_cast<uint32_t>(
- ((((c1 & 0x03C0) >> 6) + 1) << 16)
- | ((c1 & 0x003F) << 10)
- | (c2 & 0x03FF));
- if (t > Maxcode)
- break;
- frm_nxt += 4;
- }
- }
- return static_cast<int>(frm_nxt - frm);
-}
-
-static
-codecvt_base::result
-ucs4_to_utf16le(const uint32_t* frm, const uint32_t* frm_end, const uint32_t*& frm_nxt,
- uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & generate_header)
- {
- if (to_end - to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xFF);
- *to_nxt++ = static_cast<uint8_t>(0xFE);
- }
- for (; frm_nxt < frm_end; ++frm_nxt)
- {
- uint32_t wc = *frm_nxt;
- if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
- return codecvt_base::error;
- if (wc < 0x010000)
- {
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(wc);
- *to_nxt++ = static_cast<uint8_t>(wc >> 8);
- }
- else
- {
- if (to_end-to_nxt < 4)
- return codecvt_base::partial;
- uint16_t t = static_cast<uint16_t>(
- 0xD800
- | ((((wc & 0x1F0000) >> 16) - 1) << 6)
- | ((wc & 0x00FC00) >> 10));
- *to_nxt++ = static_cast<uint8_t>(t);
- *to_nxt++ = static_cast<uint8_t>(t >> 8);
- t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
- *to_nxt++ = static_cast<uint8_t>(t);
- *to_nxt++ = static_cast<uint8_t>(t >> 8);
- }
+static codecvt_base::result utf16_to_utf8(
+ const uint16_t* frm,
+ const uint16_t* frm_end,
+ const uint16_t*& frm_nxt,
+ uint8_t* to,
+ uint8_t* to_end,
+ uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header) {
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xEF);
+ *to_nxt++ = static_cast<uint8_t>(0xBB);
+ *to_nxt++ = static_cast<uint8_t>(0xBF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt) {
+ uint16_t wc1 = *frm_nxt;
+ if (wc1 > Maxcode)
+ return codecvt_base::error;
+ if (wc1 < 0x0080) {
+ if (to_end - to_nxt < 1)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc1);
+ } else if (wc1 < 0x0800) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
+ } else if (wc1 < 0xD800) {
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
+ } else if (wc1 < 0xDC00) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint16_t wc2 = frm_nxt[1];
+ if ((wc2 & 0xFC00) != 0xDC00)
+ return codecvt_base::error;
+ if (to_end - to_nxt < 4)
+ return codecvt_base::partial;
+ if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) + ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
+ return codecvt_base::error;
+ ++frm_nxt;
+ uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
+ *to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4) | ((wc1 & 0x003C) >> 2));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc2 & 0x003F));
+ } else if (wc1 < 0xE000) {
+ return codecvt_base::error;
+ } else {
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
}
- return codecvt_base::ok;
-}
-
-static
-codecvt_base::result
-utf16le_to_ucs4(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
- uint32_t* to, uint32_t* to_end, uint32_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
- frm_nxt += 2;
+ }
+ return codecvt_base::ok;
+}
+
+static codecvt_base::result utf16_to_utf8(
+ const uint32_t* frm,
+ const uint32_t* frm_end,
+ const uint32_t*& frm_nxt,
+ uint8_t* to,
+ uint8_t* to_end,
+ uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header) {
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xEF);
+ *to_nxt++ = static_cast<uint8_t>(0xBB);
+ *to_nxt++ = static_cast<uint8_t>(0xBF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt) {
+ uint16_t wc1 = static_cast<uint16_t>(*frm_nxt);
+ if (wc1 > Maxcode)
+ return codecvt_base::error;
+ if (wc1 < 0x0080) {
+ if (to_end - to_nxt < 1)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc1);
+ } else if (wc1 < 0x0800) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc1 >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x03F));
+ } else if (wc1 < 0xD800) {
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
+ } else if (wc1 < 0xDC00) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint16_t wc2 = static_cast<uint16_t>(frm_nxt[1]);
+ if ((wc2 & 0xFC00) != 0xDC00)
+ return codecvt_base::error;
+ if (to_end - to_nxt < 4)
+ return codecvt_base::partial;
+ if (((((wc1 & 0x03C0UL) >> 6) + 1) << 16) + ((wc1 & 0x003FUL) << 10) + (wc2 & 0x03FF) > Maxcode)
+ return codecvt_base::error;
+ ++frm_nxt;
+ uint8_t z = ((wc1 & 0x03C0) >> 6) + 1;
+ *to_nxt++ = static_cast<uint8_t>(0xF0 | (z >> 2));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((z & 0x03) << 4) | ((wc1 & 0x003C) >> 2));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0003) << 4) | ((wc2 & 0x03C0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc2 & 0x003F));
+ } else if (wc1 < 0xE000) {
+ return codecvt_base::error;
+ } else {
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc1 >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc1 & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc1 & 0x003F));
}
- for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
- {
- uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
- if ((c1 & 0xFC00) == 0xDC00)
- return codecvt_base::error;
- if ((c1 & 0xFC00) != 0xD800)
- {
- if (c1 > Maxcode)
- return codecvt_base::error;
- *to_nxt = static_cast<uint32_t>(c1);
- frm_nxt += 2;
- }
- else
- {
- if (frm_end-frm_nxt < 4)
- return codecvt_base::partial;
- uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
- if ((c2 & 0xFC00) != 0xDC00)
- return codecvt_base::error;
- uint32_t t = static_cast<uint32_t>(
- ((((c1 & 0x03C0) >> 6) + 1) << 16)
- | ((c1 & 0x003F) << 10)
- | (c2 & 0x03FF));
- if (t > Maxcode)
- return codecvt_base::error;
- *to_nxt = t;
- frm_nxt += 4;
- }
+ }
+ return codecvt_base::ok;
+}
+
+static codecvt_base::result utf8_to_utf16(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ const uint8_t*& frm_nxt,
+ uint16_t* to,
+ uint16_t* to_end,
+ uint16_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt) {
+ uint8_t c1 = *frm_nxt;
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ if (c1 < 0x80) {
+ *to_nxt = static_cast<uint16_t>(c1);
+ ++frm_nxt;
+ } else if (c1 < 0xC2) {
+ return codecvt_base::error;
+ } else if (c1 < 0xE0) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 2;
+ } else if (c1 < 0xF0) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ switch (c1) {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return codecvt_base::error;
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if (frm_end - frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c3 = frm_nxt[2];
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 3;
+ } else if (c1 < 0xF5) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ switch (c1) {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return codecvt_base::error;
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if (frm_end - frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c3 = frm_nxt[2];
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ if (frm_end - frm_nxt < 4)
+ return codecvt_base::partial;
+ uint8_t c4 = frm_nxt[3];
+ if ((c4 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ if ((((c1 & 7UL) << 18) + ((c2 & 0x3FUL) << 12) + ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint16_t>(
+ 0xD800 | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6) | ((c2 & 0x0F) << 2) | ((c3 & 0x30) >> 4));
+ *++to_nxt = static_cast<uint16_t>(0xDC00 | ((c3 & 0x0F) << 6) | (c4 & 0x3F));
+ frm_nxt += 4;
+ } else {
+ return codecvt_base::error;
}
- return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-}
-
-static
-int
-utf16le_to_ucs4_length(const uint8_t* frm, const uint8_t* frm_end,
- size_t mx, unsigned long Maxcode = 0x10FFFF,
- codecvt_mode mode = codecvt_mode(0))
-{
- const uint8_t* frm_nxt = frm;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
- frm_nxt += 2;
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static codecvt_base::result utf8_to_utf16(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ const uint8_t*& frm_nxt,
+ uint32_t* to,
+ uint32_t* to_end,
+ uint32_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt) {
+ uint8_t c1 = *frm_nxt;
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ if (c1 < 0x80) {
+ *to_nxt = static_cast<uint32_t>(c1);
+ ++frm_nxt;
+ } else if (c1 < 0xC2) {
+ return codecvt_base::error;
+ } else if (c1 < 0xE0) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(t);
+ frm_nxt += 2;
+ } else if (c1 < 0xF0) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ switch (c1) {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return codecvt_base::error;
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if (frm_end - frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c3 = frm_nxt[2];
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(t);
+ frm_nxt += 3;
+ } else if (c1 < 0xF5) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ switch (c1) {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return codecvt_base::error;
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if (frm_end - frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c3 = frm_nxt[2];
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ if (frm_end - frm_nxt < 4)
+ return codecvt_base::partial;
+ uint8_t c4 = frm_nxt[3];
+ if ((c4 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ if ((((c1 & 7UL) << 18) + ((c2 & 0x3FUL) << 12) + ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(
+ 0xD800 | (((((c1 & 0x07) << 2) | ((c2 & 0x30) >> 4)) - 1) << 6) | ((c2 & 0x0F) << 2) | ((c3 & 0x30) >> 4));
+ *++to_nxt = static_cast<uint32_t>(0xDC00 | ((c3 & 0x0F) << 6) | (c4 & 0x3F));
+ frm_nxt += 4;
+ } else {
+ return codecvt_base::error;
}
- for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t)
- {
- uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
- if ((c1 & 0xFC00) == 0xDC00)
- break;
- if ((c1 & 0xFC00) != 0xD800)
- {
- if (c1 > Maxcode)
- break;
- frm_nxt += 2;
- }
- else
- {
- if (frm_end-frm_nxt < 4)
- break;
- uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
- if ((c2 & 0xFC00) != 0xDC00)
- break;
- uint32_t t = static_cast<uint32_t>(
- ((((c1 & 0x03C0) >> 6) + 1) << 16)
- | ((c1 & 0x003F) << 10)
- | (c2 & 0x03FF));
- if (t > Maxcode)
- break;
- frm_nxt += 4;
- }
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static int utf8_to_utf16_length(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ size_t mx,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (size_t nchar16_t = 0; frm_nxt < frm_end && nchar16_t < mx; ++nchar16_t) {
+ uint8_t c1 = *frm_nxt;
+ if (c1 > Maxcode)
+ break;
+ if (c1 < 0x80) {
+ ++frm_nxt;
+ } else if (c1 < 0xC2) {
+ break;
+ } else if (c1 < 0xE0) {
+ if ((frm_end - frm_nxt < 2) || (frm_nxt[1] & 0xC0) != 0x80)
+ break;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (frm_nxt[1] & 0x3F));
+ if (t > Maxcode)
+ break;
+ frm_nxt += 2;
+ } else if (c1 < 0xF0) {
+ if (frm_end - frm_nxt < 3)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1) {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 3;
+ } else if (c1 < 0xF5) {
+ if (frm_end - frm_nxt < 4 || mx - nchar16_t < 2)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ uint8_t c4 = frm_nxt[3];
+ switch (c1) {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 7UL) << 18) + ((c2 & 0x3FUL) << 12) + ((c3 & 0x3FUL) << 6) + (c4 & 0x3F)) > Maxcode)
+ break;
+ ++nchar16_t;
+ frm_nxt += 4;
+ } else {
+ break;
}
- return static_cast<int>(frm_nxt - frm);
-}
-
-static
-codecvt_base::result
-ucs2_to_utf16be(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
- uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & generate_header)
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static codecvt_base::result ucs4_to_utf8(
+ const uint32_t* frm,
+ const uint32_t* frm_end,
+ const uint32_t*& frm_nxt,
+ uint8_t* to,
+ uint8_t* to_end,
+ uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header) {
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xEF);
+ *to_nxt++ = static_cast<uint8_t>(0xBB);
+ *to_nxt++ = static_cast<uint8_t>(0xBF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt) {
+ uint32_t wc = *frm_nxt;
+ if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (wc < 0x000080) {
+ if (to_end - to_nxt < 1)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ } else if (wc < 0x000800) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
+ } else if (wc < 0x010000) {
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x003F));
+ } else // if (wc < 0x110000)
{
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xFE);
- *to_nxt++ = static_cast<uint8_t>(0xFF);
+ if (to_end - to_nxt < 4)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xF0 | (wc >> 18));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x03F000) >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x000FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x00003F));
}
- for (; frm_nxt < frm_end; ++frm_nxt)
- {
- uint16_t wc = *frm_nxt;
- if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
- return codecvt_base::error;
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(wc >> 8);
- *to_nxt++ = static_cast<uint8_t>(wc);
+ }
+ return codecvt_base::ok;
+}
+
+static codecvt_base::result utf8_to_ucs4(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ const uint8_t*& frm_nxt,
+ uint32_t* to,
+ uint32_t* to_end,
+ uint32_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt) {
+ uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+ if (c1 < 0x80) {
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(c1);
+ ++frm_nxt;
+ } else if (c1 < 0xC2) {
+ return codecvt_base::error;
+ } else if (c1 < 0xE0) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 2;
+ } else if (c1 < 0xF0) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ switch (c1) {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return codecvt_base::error;
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if (frm_end - frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c3 = frm_nxt[2];
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 3;
+ } else if (c1 < 0xF5) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ switch (c1) {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return codecvt_base::error;
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if (frm_end - frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c3 = frm_nxt[2];
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ if (frm_end - frm_nxt < 4)
+ return codecvt_base::partial;
+ uint8_t c4 = frm_nxt[3];
+ if ((c4 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(((c1 & 0x07) << 18) | ((c2 & 0x3F) << 12) | ((c3 & 0x3F) << 6) | (c4 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 4;
+ } else {
+ return codecvt_base::error;
}
- return codecvt_base::ok;
-}
-
-static
-codecvt_base::result
-utf16be_to_ucs2(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
- uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
- frm_nxt += 2;
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static int utf8_to_ucs4_length(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ size_t mx,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t) {
+ uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+ if (c1 < 0x80) {
+ if (c1 > Maxcode)
+ break;
+ ++frm_nxt;
+ } else if (c1 < 0xC2) {
+ break;
+ } else if (c1 < 0xE0) {
+ if ((frm_end - frm_nxt < 2) || ((frm_nxt[1] & 0xC0) != 0x80))
+ break;
+ if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 2;
+ } else if (c1 < 0xF0) {
+ if (frm_end - frm_nxt < 3)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1) {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 3;
+ } else if (c1 < 0xF5) {
+ if (frm_end - frm_nxt < 4)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ uint8_t c4 = frm_nxt[3];
+ switch (c1) {
+ case 0xF0:
+ if (!(0x90 <= c2 && c2 <= 0xBF))
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xF4:
+ if ((c2 & 0xF0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80 || (c4 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 0x07u) << 18) | ((c2 & 0x3Fu) << 12) | ((c3 & 0x3Fu) << 6) | (c4 & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 4;
+ } else {
+ break;
}
- for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static codecvt_base::result ucs2_to_utf8(
+ const uint16_t* frm,
+ const uint16_t* frm_end,
+ const uint16_t*& frm_nxt,
+ uint8_t* to,
+ uint8_t* to_end,
+ uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header) {
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xEF);
+ *to_nxt++ = static_cast<uint8_t>(0xBB);
+ *to_nxt++ = static_cast<uint8_t>(0xBF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt) {
+ uint16_t wc = *frm_nxt;
+ if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (wc < 0x0080) {
+ if (to_end - to_nxt < 1)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ } else if (wc < 0x0800) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xC0 | (wc >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x03F));
+ } else // if (wc <= 0xFFFF)
{
- uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
- if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
- return codecvt_base::error;
- *to_nxt = c1;
- frm_nxt += 2;
+ if (to_end - to_nxt < 3)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xE0 | (wc >> 12));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | ((wc & 0x0FC0) >> 6));
+ *to_nxt++ = static_cast<uint8_t>(0x80 | (wc & 0x003F));
}
- return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-}
-
-static
-int
-utf16be_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
- size_t mx, unsigned long Maxcode = 0x10FFFF,
- codecvt_mode mode = codecvt_mode(0))
-{
- const uint8_t* frm_nxt = frm;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
- frm_nxt += 2;
+ }
+ return codecvt_base::ok;
+}
+
+static codecvt_base::result utf8_to_ucs2(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ const uint8_t*& frm_nxt,
+ uint16_t* to,
+ uint16_t* to_end,
+ uint16_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (; frm_nxt < frm_end && to_nxt < to_end; ++to_nxt) {
+ uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+ if (c1 < 0x80) {
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint16_t>(c1);
+ ++frm_nxt;
+ } else if (c1 < 0xC2) {
+ return codecvt_base::error;
+ } else if (c1 < 0xE0) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x1F) << 6) | (c2 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 2;
+ } else if (c1 < 0xF0) {
+ if (frm_end - frm_nxt < 2)
+ return codecvt_base::partial;
+ uint8_t c2 = frm_nxt[1];
+ switch (c1) {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return codecvt_base::error;
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return codecvt_base::error;
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ break;
+ }
+ if (frm_end - frm_nxt < 3)
+ return codecvt_base::partial;
+ uint8_t c3 = frm_nxt[2];
+ if ((c3 & 0xC0) != 0x80)
+ return codecvt_base::error;
+ uint16_t t = static_cast<uint16_t>(((c1 & 0x0F) << 12) | ((c2 & 0x3F) << 6) | (c3 & 0x3F));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 3;
+ } else {
+ return codecvt_base::error;
}
- for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t)
- {
- uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
- if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
- break;
- frm_nxt += 2;
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static int utf8_to_ucs2_length(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ size_t mx,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 3 && frm_nxt[0] == 0xEF && frm_nxt[1] == 0xBB && frm_nxt[2] == 0xBF)
+ frm_nxt += 3;
+ }
+ for (size_t nchar32_t = 0; frm_nxt < frm_end && nchar32_t < mx; ++nchar32_t) {
+ uint8_t c1 = static_cast<uint8_t>(*frm_nxt);
+ if (c1 < 0x80) {
+ if (c1 > Maxcode)
+ break;
+ ++frm_nxt;
+ } else if (c1 < 0xC2) {
+ break;
+ } else if (c1 < 0xE0) {
+ if ((frm_end - frm_nxt < 2) || ((frm_nxt[1] & 0xC0) != 0x80))
+ break;
+ if ((((c1 & 0x1Fu) << 6) | (frm_nxt[1] & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 2;
+ } else if (c1 < 0xF0) {
+ if (frm_end - frm_nxt < 3)
+ break;
+ uint8_t c2 = frm_nxt[1];
+ uint8_t c3 = frm_nxt[2];
+ switch (c1) {
+ case 0xE0:
+ if ((c2 & 0xE0) != 0xA0)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ case 0xED:
+ if ((c2 & 0xE0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ default:
+ if ((c2 & 0xC0) != 0x80)
+ return static_cast<int>(frm_nxt - frm);
+ break;
+ }
+ if ((c3 & 0xC0) != 0x80)
+ break;
+ if ((((c1 & 0x0Fu) << 12) | ((c2 & 0x3Fu) << 6) | (c3 & 0x3Fu)) > Maxcode)
+ break;
+ frm_nxt += 3;
+ } else {
+ break;
}
- return static_cast<int>(frm_nxt - frm);
-}
-
-static
-codecvt_base::result
-ucs2_to_utf16le(const uint16_t* frm, const uint16_t* frm_end, const uint16_t*& frm_nxt,
- uint8_t* to, uint8_t* to_end, uint8_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & generate_header)
- {
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(0xFF);
- *to_nxt++ = static_cast<uint8_t>(0xFE);
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static codecvt_base::result ucs4_to_utf16be(
+ const uint32_t* frm,
+ const uint32_t* frm_end,
+ const uint32_t*& frm_nxt,
+ uint8_t* to,
+ uint8_t* to_end,
+ uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xFE);
+ *to_nxt++ = static_cast<uint8_t>(0xFF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt) {
+ uint32_t wc = *frm_nxt;
+ if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (wc < 0x010000) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ } else {
+ if (to_end - to_nxt < 4)
+ return codecvt_base::partial;
+ uint16_t t = static_cast<uint16_t>(0xD800 | ((((wc & 0x1F0000) >> 16) - 1) << 6) | ((wc & 0x00FC00) >> 10));
+ *to_nxt++ = static_cast<uint8_t>(t >> 8);
+ *to_nxt++ = static_cast<uint8_t>(t);
+ t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
+ *to_nxt++ = static_cast<uint8_t>(t >> 8);
+ *to_nxt++ = static_cast<uint8_t>(t);
}
- for (; frm_nxt < frm_end; ++frm_nxt)
- {
- uint16_t wc = *frm_nxt;
- if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
- return codecvt_base::error;
- if (to_end-to_nxt < 2)
- return codecvt_base::partial;
- *to_nxt++ = static_cast<uint8_t>(wc);
- *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+ }
+ return codecvt_base::ok;
+}
+
+static codecvt_base::result utf16be_to_ucs4(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ const uint8_t*& frm_nxt,
+ uint32_t* to,
+ uint32_t* to_end,
+ uint32_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+ frm_nxt += 2;
+ }
+ for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt) {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+ if ((c1 & 0xFC00) == 0xDC00)
+ return codecvt_base::error;
+ if ((c1 & 0xFC00) != 0xD800) {
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(c1);
+ frm_nxt += 2;
+ } else {
+ if (frm_end - frm_nxt < 4)
+ return codecvt_base::partial;
+ uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
+ if ((c2 & 0xFC00) != 0xDC00)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 4;
}
- return codecvt_base::ok;
-}
-
-static
-codecvt_base::result
-utf16le_to_ucs2(const uint8_t* frm, const uint8_t* frm_end, const uint8_t*& frm_nxt,
- uint16_t* to, uint16_t* to_end, uint16_t*& to_nxt,
- unsigned long Maxcode = 0x10FFFF, codecvt_mode mode = codecvt_mode(0))
-{
- frm_nxt = frm;
- to_nxt = to;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
- frm_nxt += 2;
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static int utf16be_to_ucs4_length(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ size_t mx,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+ frm_nxt += 2;
+ }
+ for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t) {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+ if ((c1 & 0xFC00) == 0xDC00)
+ break;
+ if ((c1 & 0xFC00) != 0xD800) {
+ if (c1 > Maxcode)
+ break;
+ frm_nxt += 2;
+ } else {
+ if (frm_end - frm_nxt < 4)
+ break;
+ uint16_t c2 = static_cast<uint16_t>(frm_nxt[2] << 8 | frm_nxt[3]);
+ if ((c2 & 0xFC00) != 0xDC00)
+ break;
+ uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
+ if (t > Maxcode)
+ break;
+ frm_nxt += 4;
}
- for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt)
- {
- uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
- if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
- return codecvt_base::error;
- *to_nxt = c1;
- frm_nxt += 2;
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static codecvt_base::result ucs4_to_utf16le(
+ const uint32_t* frm,
+ const uint32_t* frm_end,
+ const uint32_t*& frm_nxt,
+ uint8_t* to,
+ uint8_t* to_end,
+ uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xFF);
+ *to_nxt++ = static_cast<uint8_t>(0xFE);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt) {
+ uint32_t wc = *frm_nxt;
+ if ((wc & 0xFFFFF800) == 0x00D800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (wc < 0x010000) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+ } else {
+ if (to_end - to_nxt < 4)
+ return codecvt_base::partial;
+ uint16_t t = static_cast<uint16_t>(0xD800 | ((((wc & 0x1F0000) >> 16) - 1) << 6) | ((wc & 0x00FC00) >> 10));
+ *to_nxt++ = static_cast<uint8_t>(t);
+ *to_nxt++ = static_cast<uint8_t>(t >> 8);
+ t = static_cast<uint16_t>(0xDC00 | (wc & 0x03FF));
+ *to_nxt++ = static_cast<uint8_t>(t);
+ *to_nxt++ = static_cast<uint8_t>(t >> 8);
}
- return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
-}
-
-static
-int
-utf16le_to_ucs2_length(const uint8_t* frm, const uint8_t* frm_end,
- size_t mx, unsigned long Maxcode = 0x10FFFF,
- codecvt_mode mode = codecvt_mode(0))
-{
- const uint8_t* frm_nxt = frm;
- frm_nxt = frm;
- if (mode & consume_header)
- {
- if (frm_end-frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
- frm_nxt += 2;
+ }
+ return codecvt_base::ok;
+}
+
+static codecvt_base::result utf16le_to_ucs4(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ const uint8_t*& frm_nxt,
+ uint32_t* to,
+ uint32_t* to_end,
+ uint32_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+ frm_nxt += 2;
+ }
+ for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt) {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+ if ((c1 & 0xFC00) == 0xDC00)
+ return codecvt_base::error;
+ if ((c1 & 0xFC00) != 0xD800) {
+ if (c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = static_cast<uint32_t>(c1);
+ frm_nxt += 2;
+ } else {
+ if (frm_end - frm_nxt < 4)
+ return codecvt_base::partial;
+ uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
+ if ((c2 & 0xFC00) != 0xDC00)
+ return codecvt_base::error;
+ uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
+ if (t > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = t;
+ frm_nxt += 4;
}
- for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t)
- {
- uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
- if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
- break;
- frm_nxt += 2;
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static int utf16le_to_ucs4_length(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ size_t mx,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+ frm_nxt += 2;
+ }
+ for (size_t nchar32_t = 0; frm_nxt < frm_end - 1 && nchar32_t < mx; ++nchar32_t) {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+ if ((c1 & 0xFC00) == 0xDC00)
+ break;
+ if ((c1 & 0xFC00) != 0xD800) {
+ if (c1 > Maxcode)
+ break;
+ frm_nxt += 2;
+ } else {
+ if (frm_end - frm_nxt < 4)
+ break;
+ uint16_t c2 = static_cast<uint16_t>(frm_nxt[3] << 8 | frm_nxt[2]);
+ if ((c2 & 0xFC00) != 0xDC00)
+ break;
+ uint32_t t = static_cast<uint32_t>(((((c1 & 0x03C0) >> 6) + 1) << 16) | ((c1 & 0x003F) << 10) | (c2 & 0x03FF));
+ if (t > Maxcode)
+ break;
+ frm_nxt += 4;
}
- return static_cast<int>(frm_nxt - frm);
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static codecvt_base::result ucs2_to_utf16be(
+ const uint16_t* frm,
+ const uint16_t* frm_end,
+ const uint16_t*& frm_nxt,
+ uint8_t* to,
+ uint8_t* to_end,
+ uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xFE);
+ *to_nxt++ = static_cast<uint8_t>(0xFF);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt) {
+ uint16_t wc = *frm_nxt;
+ if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ }
+ return codecvt_base::ok;
+}
+
+static codecvt_base::result utf16be_to_ucs2(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ const uint8_t*& frm_nxt,
+ uint16_t* to,
+ uint16_t* to_end,
+ uint16_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+ frm_nxt += 2;
+ }
+ for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt) {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+ if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = c1;
+ frm_nxt += 2;
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static int utf16be_to_ucs2_length(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ size_t mx,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ const uint8_t* frm_nxt = frm;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFE && frm_nxt[1] == 0xFF)
+ frm_nxt += 2;
+ }
+ for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t) {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[0] << 8 | frm_nxt[1]);
+ if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+ break;
+ frm_nxt += 2;
+ }
+ return static_cast<int>(frm_nxt - frm);
+}
+
+static codecvt_base::result ucs2_to_utf16le(
+ const uint16_t* frm,
+ const uint16_t* frm_end,
+ const uint16_t*& frm_nxt,
+ uint8_t* to,
+ uint8_t* to_end,
+ uint8_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & generate_header) {
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(0xFF);
+ *to_nxt++ = static_cast<uint8_t>(0xFE);
+ }
+ for (; frm_nxt < frm_end; ++frm_nxt) {
+ uint16_t wc = *frm_nxt;
+ if ((wc & 0xF800) == 0xD800 || wc > Maxcode)
+ return codecvt_base::error;
+ if (to_end - to_nxt < 2)
+ return codecvt_base::partial;
+ *to_nxt++ = static_cast<uint8_t>(wc);
+ *to_nxt++ = static_cast<uint8_t>(wc >> 8);
+ }
+ return codecvt_base::ok;
+}
+
+static codecvt_base::result utf16le_to_ucs2(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ const uint8_t*& frm_nxt,
+ uint16_t* to,
+ uint16_t* to_end,
+ uint16_t*& to_nxt,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ frm_nxt = frm;
+ to_nxt = to;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+ frm_nxt += 2;
+ }
+ for (; frm_nxt < frm_end - 1 && to_nxt < to_end; ++to_nxt) {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+ if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+ return codecvt_base::error;
+ *to_nxt = c1;
+ frm_nxt += 2;
+ }
+ return frm_nxt < frm_end ? codecvt_base::partial : codecvt_base::ok;
+}
+
+static int utf16le_to_ucs2_length(
+ const uint8_t* frm,
+ const uint8_t* frm_end,
+ size_t mx,
+ unsigned long Maxcode = 0x10FFFF,
+ codecvt_mode mode = codecvt_mode(0)) {
+ const uint8_t* frm_nxt = frm;
+ frm_nxt = frm;
+ if (mode & consume_header) {
+ if (frm_end - frm_nxt >= 2 && frm_nxt[0] == 0xFF && frm_nxt[1] == 0xFE)
+ frm_nxt += 2;
+ }
+ for (size_t nchar16_t = 0; frm_nxt < frm_end - 1 && nchar16_t < mx; ++nchar16_t) {
+ uint16_t c1 = static_cast<uint16_t>(frm_nxt[1] << 8 | frm_nxt[0]);
+ if ((c1 & 0xF800) == 0xD800 || c1 > Maxcode)
+ break;
+ frm_nxt += 2;
+ }
+ return static_cast<int>(frm_nxt - frm);
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
@@ -3199,78 +2772,66 @@ _LIBCPP_SUPPRESS_DEPRECATED_POP
constinit locale::id codecvt<char16_t, char, mbstate_t>::id;
-codecvt<char16_t, char, mbstate_t>::~codecvt()
-{
-}
-
-codecvt<char16_t, char, mbstate_t>::result
-codecvt<char16_t, char, mbstate_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
-}
-
-codecvt<char16_t, char, mbstate_t>::result
-codecvt<char16_t, char, mbstate_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
- result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+codecvt<char16_t, char, mbstate_t>::~codecvt() {}
+
+codecvt<char16_t, char, mbstate_t>::result codecvt<char16_t, char, mbstate_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char16_t, char, mbstate_t>::result codecvt<char16_t, char, mbstate_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
codecvt<char16_t, char, mbstate_t>::result
-codecvt<char16_t, char, mbstate_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
+codecvt<char16_t, char, mbstate_t>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-int
-codecvt<char16_t, char, mbstate_t>::do_encoding() const noexcept
-{
- return 0;
-}
+int codecvt<char16_t, char, mbstate_t>::do_encoding() const noexcept { return 0; }
-bool
-codecvt<char16_t, char, mbstate_t>::do_always_noconv() const noexcept
-{
- return false;
-}
+bool codecvt<char16_t, char, mbstate_t>::do_always_noconv() const noexcept { return false; }
-int
-codecvt<char16_t, char, mbstate_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf8_to_utf16_length(_frm, _frm_end, mx);
+int codecvt<char16_t, char, mbstate_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx);
}
-int
-codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept
-{
- return 4;
-}
+int codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept { return 4; }
#ifndef _LIBCPP_HAS_NO_CHAR8_T
@@ -3278,78 +2839,66 @@ codecvt<char16_t, char, mbstate_t>::do_max_length() const noexcept
constinit locale::id codecvt<char16_t, char8_t, mbstate_t>::id;
-codecvt<char16_t, char8_t, mbstate_t>::~codecvt()
-{
-}
-
-codecvt<char16_t, char8_t, mbstate_t>::result
-codecvt<char16_t, char8_t, mbstate_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
-}
-
-codecvt<char16_t, char8_t, mbstate_t>::result
-codecvt<char16_t, char8_t, mbstate_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
- result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
-}
-
-codecvt<char16_t, char8_t, mbstate_t>::result
-codecvt<char16_t, char8_t, mbstate_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
-
-int
-codecvt<char16_t, char8_t, mbstate_t>::do_encoding() const noexcept
-{
- return 0;
-}
-
-bool
-codecvt<char16_t, char8_t, mbstate_t>::do_always_noconv() const noexcept
-{
- return false;
-}
-
-int
-codecvt<char16_t, char8_t, mbstate_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf8_to_utf16_length(_frm, _frm_end, mx);
-}
-
-int
-codecvt<char16_t, char8_t, mbstate_t>::do_max_length() const noexcept
-{
- return 4;
-}
+codecvt<char16_t, char8_t, mbstate_t>::~codecvt() {}
+
+codecvt<char16_t, char8_t, mbstate_t>::result codecvt<char16_t, char8_t, mbstate_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char16_t, char8_t, mbstate_t>::result codecvt<char16_t, char8_t, mbstate_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char16_t, char8_t, mbstate_t>::result codecvt<char16_t, char8_t, mbstate_t>::do_unshift(
+ state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
+}
+
+int codecvt<char16_t, char8_t, mbstate_t>::do_encoding() const noexcept { return 0; }
+
+bool codecvt<char16_t, char8_t, mbstate_t>::do_always_noconv() const noexcept { return false; }
+
+int codecvt<char16_t, char8_t, mbstate_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx);
+}
+
+int codecvt<char16_t, char8_t, mbstate_t>::do_max_length() const noexcept { return 4; }
#endif
@@ -3357,78 +2906,66 @@ codecvt<char16_t, char8_t, mbstate_t>::do_max_length() const noexcept
constinit locale::id codecvt<char32_t, char, mbstate_t>::id;
-codecvt<char32_t, char, mbstate_t>::~codecvt()
-{
+codecvt<char32_t, char, mbstate_t>::~codecvt() {}
+
+codecvt<char32_t, char, mbstate_t>::result codecvt<char32_t, char, mbstate_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char32_t, char, mbstate_t>::result codecvt<char32_t, char, mbstate_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
codecvt<char32_t, char, mbstate_t>::result
-codecvt<char32_t, char, mbstate_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+codecvt<char32_t, char, mbstate_t>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-codecvt<char32_t, char, mbstate_t>::result
-codecvt<char32_t, char, mbstate_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
- result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
-}
+int codecvt<char32_t, char, mbstate_t>::do_encoding() const noexcept { return 0; }
-codecvt<char32_t, char, mbstate_t>::result
-codecvt<char32_t, char, mbstate_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+bool codecvt<char32_t, char, mbstate_t>::do_always_noconv() const noexcept { return false; }
-int
-codecvt<char32_t, char, mbstate_t>::do_encoding() const noexcept
-{
- return 0;
+int codecvt<char32_t, char, mbstate_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_ucs4_length(_frm, _frm_end, mx);
}
-bool
-codecvt<char32_t, char, mbstate_t>::do_always_noconv() const noexcept
-{
- return false;
-}
-
-int
-codecvt<char32_t, char, mbstate_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf8_to_ucs4_length(_frm, _frm_end, mx);
-}
-
-int
-codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept
-{
- return 4;
-}
+int codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept { return 4; }
#ifndef _LIBCPP_HAS_NO_CHAR8_T
@@ -3436,1148 +2973,999 @@ codecvt<char32_t, char, mbstate_t>::do_max_length() const noexcept
constinit locale::id codecvt<char32_t, char8_t, mbstate_t>::id;
-codecvt<char32_t, char8_t, mbstate_t>::~codecvt()
-{
-}
-
-codecvt<char32_t, char8_t, mbstate_t>::result
-codecvt<char32_t, char8_t, mbstate_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
-}
-
-codecvt<char32_t, char8_t, mbstate_t>::result
-codecvt<char32_t, char8_t, mbstate_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
- result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
-}
-
-codecvt<char32_t, char8_t, mbstate_t>::result
-codecvt<char32_t, char8_t, mbstate_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
-
-int
-codecvt<char32_t, char8_t, mbstate_t>::do_encoding() const noexcept
-{
- return 0;
-}
-
-bool
-codecvt<char32_t, char8_t, mbstate_t>::do_always_noconv() const noexcept
-{
- return false;
-}
-
-int
-codecvt<char32_t, char8_t, mbstate_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf8_to_ucs4_length(_frm, _frm_end, mx);
-}
-
-int
-codecvt<char32_t, char8_t, mbstate_t>::do_max_length() const noexcept
-{
- return 4;
-}
+codecvt<char32_t, char8_t, mbstate_t>::~codecvt() {}
+
+codecvt<char32_t, char8_t, mbstate_t>::result codecvt<char32_t, char8_t, mbstate_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char32_t, char8_t, mbstate_t>::result codecvt<char32_t, char8_t, mbstate_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+codecvt<char32_t, char8_t, mbstate_t>::result codecvt<char32_t, char8_t, mbstate_t>::do_unshift(
+ state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
+}
+
+int codecvt<char32_t, char8_t, mbstate_t>::do_encoding() const noexcept { return 0; }
+
+bool codecvt<char32_t, char8_t, mbstate_t>::do_always_noconv() const noexcept { return false; }
+
+int codecvt<char32_t, char8_t, mbstate_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_ucs4_length(_frm, _frm_end, mx);
+}
+
+int codecvt<char32_t, char8_t, mbstate_t>::do_max_length() const noexcept { return 4; }
#endif
// __codecvt_utf8<wchar_t>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-__codecvt_utf8<wchar_t>::result
-__codecvt_utf8<wchar_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
-#if defined(_LIBCPP_SHORT_WCHAR)
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
-#else
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
-#endif
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
-#if defined(_LIBCPP_SHORT_WCHAR)
- result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#else
- result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#endif
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8<wchar_t>::result __codecvt_utf8<wchar_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+# if defined(_LIBCPP_SHORT_WCHAR)
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+# else
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+# endif
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+# if defined(_LIBCPP_SHORT_WCHAR)
+ result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# else
+ result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8<wchar_t>::result __codecvt_utf8<wchar_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+# if defined(_LIBCPP_SHORT_WCHAR)
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# else
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf8<wchar_t>::result
-__codecvt_utf8<wchar_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
-#if defined(_LIBCPP_SHORT_WCHAR)
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
- result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#else
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
- result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#endif
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8<wchar_t>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf8<wchar_t>::result
-__codecvt_utf8<wchar_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+int __codecvt_utf8<wchar_t>::do_encoding() const noexcept { return 0; }
-int
-__codecvt_utf8<wchar_t>::do_encoding() const noexcept
-{
- return 0;
-}
+bool __codecvt_utf8<wchar_t>::do_always_noconv() const noexcept { return false; }
-bool
-__codecvt_utf8<wchar_t>::do_always_noconv() const noexcept
-{
- return false;
-}
-
-int
-__codecvt_utf8<wchar_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-#if defined(_LIBCPP_SHORT_WCHAR)
- return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
-#else
- return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
-#endif
+int __codecvt_utf8<wchar_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+# if defined(_LIBCPP_SHORT_WCHAR)
+ return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+# else
+ return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+# endif
}
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-int
-__codecvt_utf8<wchar_t>::do_max_length() const noexcept
-{
-#if defined(_LIBCPP_SHORT_WCHAR)
- if (__mode_ & consume_header)
- return 6;
- return 3;
-#else
- if (__mode_ & consume_header)
- return 7;
- return 4;
-#endif
+int __codecvt_utf8<wchar_t>::do_max_length() const noexcept {
+# if defined(_LIBCPP_SHORT_WCHAR)
+ if (__mode_ & consume_header)
+ return 6;
+ return 3;
+# else
+ if (__mode_ & consume_header)
+ return 7;
+ return 4;
+# endif
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// __codecvt_utf8<char16_t>
-__codecvt_utf8<char16_t>::result
-__codecvt_utf8<char16_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8<char16_t>::result __codecvt_utf8<char16_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs2_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8<char16_t>::result __codecvt_utf8<char16_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf8<char16_t>::result
-__codecvt_utf8<char16_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
- result r = utf8_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8<char16_t>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf8<char16_t>::result
-__codecvt_utf8<char16_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
-
-int
-__codecvt_utf8<char16_t>::do_encoding() const noexcept
-{
- return 0;
-}
+int __codecvt_utf8<char16_t>::do_encoding() const noexcept { return 0; }
-bool
-__codecvt_utf8<char16_t>::do_always_noconv() const noexcept
-{
- return false;
-}
+bool __codecvt_utf8<char16_t>::do_always_noconv() const noexcept { return false; }
-int
-__codecvt_utf8<char16_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+int __codecvt_utf8<char16_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
}
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-int
-__codecvt_utf8<char16_t>::do_max_length() const noexcept
-{
- if (__mode_ & consume_header)
- return 6;
- return 3;
+int __codecvt_utf8<char16_t>::do_max_length() const noexcept {
+ if (__mode_ & consume_header)
+ return 6;
+ return 3;
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf8<char32_t>
-__codecvt_utf8<char32_t>::result
-__codecvt_utf8<char32_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8<char32_t>::result __codecvt_utf8<char32_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs4_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8<char32_t>::result __codecvt_utf8<char32_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf8<char32_t>::result
-__codecvt_utf8<char32_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
- result r = utf8_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8<char32_t>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf8<char32_t>::result
-__codecvt_utf8<char32_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+int __codecvt_utf8<char32_t>::do_encoding() const noexcept { return 0; }
-int
-__codecvt_utf8<char32_t>::do_encoding() const noexcept
-{
- return 0;
-}
+bool __codecvt_utf8<char32_t>::do_always_noconv() const noexcept { return false; }
-bool
-__codecvt_utf8<char32_t>::do_always_noconv() const noexcept
-{
- return false;
-}
-
-int
-__codecvt_utf8<char32_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+int __codecvt_utf8<char32_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
}
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-int
-__codecvt_utf8<char32_t>::do_max_length() const noexcept
-{
- if (__mode_ & consume_header)
- return 7;
- return 4;
+int __codecvt_utf8<char32_t>::do_max_length() const noexcept {
+ if (__mode_ & consume_header)
+ return 7;
+ return 4;
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf16<wchar_t, false>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-__codecvt_utf16<wchar_t, false>::result
-__codecvt_utf16<wchar_t, false>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
-#if defined(_LIBCPP_SHORT_WCHAR)
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
-#else
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
-#endif
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
-#if defined(_LIBCPP_SHORT_WCHAR)
- result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#else
- result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#endif
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<wchar_t, false>::result __codecvt_utf16<wchar_t, false>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+# if defined(_LIBCPP_SHORT_WCHAR)
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+# else
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+# endif
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+# if defined(_LIBCPP_SHORT_WCHAR)
+ result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# else
+ result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<wchar_t, false>::result __codecvt_utf16<wchar_t, false>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+# if defined(_LIBCPP_SHORT_WCHAR)
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# else
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf16<wchar_t, false>::result
-__codecvt_utf16<wchar_t, false>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
-#if defined(_LIBCPP_SHORT_WCHAR)
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
- result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#else
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
- result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#endif
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<wchar_t, false>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf16<wchar_t, false>::result
-__codecvt_utf16<wchar_t, false>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+int __codecvt_utf16<wchar_t, false>::do_encoding() const noexcept { return 0; }
-int
-__codecvt_utf16<wchar_t, false>::do_encoding() const noexcept
-{
- return 0;
-}
+bool __codecvt_utf16<wchar_t, false>::do_always_noconv() const noexcept { return false; }
-bool
-__codecvt_utf16<wchar_t, false>::do_always_noconv() const noexcept
-{
- return false;
-}
-
-int
-__codecvt_utf16<wchar_t, false>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-#if defined(_LIBCPP_SHORT_WCHAR)
- return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
-#else
- return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
-#endif
+int __codecvt_utf16<wchar_t, false>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+# if defined(_LIBCPP_SHORT_WCHAR)
+ return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+# else
+ return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+# endif
}
-int
-__codecvt_utf16<wchar_t, false>::do_max_length() const noexcept
-{
-#if defined(_LIBCPP_SHORT_WCHAR)
- if (__mode_ & consume_header)
- return 4;
- return 2;
-#else
- if (__mode_ & consume_header)
- return 6;
+int __codecvt_utf16<wchar_t, false>::do_max_length() const noexcept {
+# if defined(_LIBCPP_SHORT_WCHAR)
+ if (__mode_ & consume_header)
return 4;
-#endif
+ return 2;
+# else
+ if (__mode_ & consume_header)
+ return 6;
+ return 4;
+# endif
}
// __codecvt_utf16<wchar_t, true>
-__codecvt_utf16<wchar_t, true>::result
-__codecvt_utf16<wchar_t, true>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
-#if defined(_LIBCPP_SHORT_WCHAR)
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
-#else
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
-#endif
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
-#if defined(_LIBCPP_SHORT_WCHAR)
- result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#else
- result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#endif
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<wchar_t, true>::result __codecvt_utf16<wchar_t, true>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+# if defined(_LIBCPP_SHORT_WCHAR)
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+# else
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+# endif
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+# if defined(_LIBCPP_SHORT_WCHAR)
+ result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# else
+ result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<wchar_t, true>::result __codecvt_utf16<wchar_t, true>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+# if defined(_LIBCPP_SHORT_WCHAR)
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# else
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+# endif
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf16<wchar_t, true>::result
-__codecvt_utf16<wchar_t, true>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
-#if defined(_LIBCPP_SHORT_WCHAR)
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
- result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#else
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
- result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
-#endif
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<wchar_t, true>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf16<wchar_t, true>::result
-__codecvt_utf16<wchar_t, true>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+int __codecvt_utf16<wchar_t, true>::do_encoding() const noexcept { return 0; }
-int
-__codecvt_utf16<wchar_t, true>::do_encoding() const noexcept
-{
- return 0;
-}
+bool __codecvt_utf16<wchar_t, true>::do_always_noconv() const noexcept { return false; }
-bool
-__codecvt_utf16<wchar_t, true>::do_always_noconv() const noexcept
-{
- return false;
+int __codecvt_utf16<wchar_t, true>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+# if defined(_LIBCPP_SHORT_WCHAR)
+ return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+# else
+ return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+# endif
}
-int
-__codecvt_utf16<wchar_t, true>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
-#if defined(_LIBCPP_SHORT_WCHAR)
- return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
-#else
- return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
-#endif
-}
-
-int
-__codecvt_utf16<wchar_t, true>::do_max_length() const noexcept
-{
-#if defined(_LIBCPP_SHORT_WCHAR)
- if (__mode_ & consume_header)
- return 4;
- return 2;
-#else
- if (__mode_ & consume_header)
- return 6;
+int __codecvt_utf16<wchar_t, true>::do_max_length() const noexcept {
+# if defined(_LIBCPP_SHORT_WCHAR)
+ if (__mode_ & consume_header)
return 4;
-#endif
+ return 2;
+# else
+ if (__mode_ & consume_header)
+ return 6;
+ return 4;
+# endif
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// __codecvt_utf16<char16_t, false>
-__codecvt_utf16<char16_t, false>::result
-__codecvt_utf16<char16_t, false>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
-}
-
-__codecvt_utf16<char16_t, false>::result
-__codecvt_utf16<char16_t, false>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
- result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<char16_t, false>::result __codecvt_utf16<char16_t, false>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs2_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char16_t, false>::result __codecvt_utf16<char16_t, false>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf16be_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf16<char16_t, false>::result
-__codecvt_utf16<char16_t, false>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
+__codecvt_utf16<char16_t, false>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-int
-__codecvt_utf16<char16_t, false>::do_encoding() const noexcept
-{
- return 0;
-}
+int __codecvt_utf16<char16_t, false>::do_encoding() const noexcept { return 0; }
-bool
-__codecvt_utf16<char16_t, false>::do_always_noconv() const noexcept
-{
- return false;
-}
+bool __codecvt_utf16<char16_t, false>::do_always_noconv() const noexcept { return false; }
-int
-__codecvt_utf16<char16_t, false>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+int __codecvt_utf16<char16_t, false>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf16be_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
}
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-int
-__codecvt_utf16<char16_t, false>::do_max_length() const noexcept
-{
- if (__mode_ & consume_header)
- return 4;
- return 2;
+int __codecvt_utf16<char16_t, false>::do_max_length() const noexcept {
+ if (__mode_ & consume_header)
+ return 4;
+ return 2;
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf16<char16_t, true>
-__codecvt_utf16<char16_t, true>::result
-__codecvt_utf16<char16_t, true>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<char16_t, true>::result __codecvt_utf16<char16_t, true>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char16_t, true>::result __codecvt_utf16<char16_t, true>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf16<char16_t, true>::result
-__codecvt_utf16<char16_t, true>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
- result r = utf16le_to_ucs2(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<char16_t, true>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf16<char16_t, true>::result
-__codecvt_utf16<char16_t, true>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+int __codecvt_utf16<char16_t, true>::do_encoding() const noexcept { return 0; }
-int
-__codecvt_utf16<char16_t, true>::do_encoding() const noexcept
-{
- return 0;
-}
-
-bool
-__codecvt_utf16<char16_t, true>::do_always_noconv() const noexcept
-{
- return false;
-}
+bool __codecvt_utf16<char16_t, true>::do_always_noconv() const noexcept { return false; }
-int
-__codecvt_utf16<char16_t, true>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+int __codecvt_utf16<char16_t, true>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf16le_to_ucs2_length(_frm, _frm_end, mx, __maxcode_, __mode_);
}
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-int
-__codecvt_utf16<char16_t, true>::do_max_length() const noexcept
-{
- if (__mode_ & consume_header)
- return 4;
- return 2;
+int __codecvt_utf16<char16_t, true>::do_max_length() const noexcept {
+ if (__mode_ & consume_header)
+ return 4;
+ return 2;
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf16<char32_t, false>
-__codecvt_utf16<char32_t, false>::result
-__codecvt_utf16<char32_t, false>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<char32_t, false>::result __codecvt_utf16<char32_t, false>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = ucs4_to_utf16be(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char32_t, false>::result __codecvt_utf16<char32_t, false>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf16<char32_t, false>::result
-__codecvt_utf16<char32_t, false>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
- result r = utf16be_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<char32_t, false>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf16<char32_t, false>::result
-__codecvt_utf16<char32_t, false>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+int __codecvt_utf16<char32_t, false>::do_encoding() const noexcept { return 0; }
-int
-__codecvt_utf16<char32_t, false>::do_encoding() const noexcept
-{
- return 0;
-}
+bool __codecvt_utf16<char32_t, false>::do_always_noconv() const noexcept { return false; }
-bool
-__codecvt_utf16<char32_t, false>::do_always_noconv() const noexcept
-{
- return false;
-}
-
-int
-__codecvt_utf16<char32_t, false>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+int __codecvt_utf16<char32_t, false>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf16be_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
}
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-int
-__codecvt_utf16<char32_t, false>::do_max_length() const noexcept
-{
- if (__mode_ & consume_header)
- return 6;
- return 4;
+int __codecvt_utf16<char32_t, false>::do_max_length() const noexcept {
+ if (__mode_ & consume_header)
+ return 6;
+ return 4;
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf16<char32_t, true>
-__codecvt_utf16<char32_t, true>::result
-__codecvt_utf16<char32_t, true>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
+__codecvt_utf16<char32_t, true>::result __codecvt_utf16<char32_t, true>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
#if defined(_LIBCPP_SHORT_WCHAR)
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
#else
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
#endif
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
#if defined(_LIBCPP_SHORT_WCHAR)
- result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
+ result r = ucs2_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
#else
- result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
+ result r = ucs4_to_utf16le(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
#endif
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf16<char32_t, true>::result __codecvt_utf16<char32_t, true>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+ result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf16<char32_t, true>::result
-__codecvt_utf16<char32_t, true>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
- result r = utf16le_to_ucs4(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf16<char32_t, true>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf16<char32_t, true>::result
-__codecvt_utf16<char32_t, true>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
-
-int
-__codecvt_utf16<char32_t, true>::do_encoding() const noexcept
-{
- return 0;
-}
+int __codecvt_utf16<char32_t, true>::do_encoding() const noexcept { return 0; }
-bool
-__codecvt_utf16<char32_t, true>::do_always_noconv() const noexcept
-{
- return false;
-}
+bool __codecvt_utf16<char32_t, true>::do_always_noconv() const noexcept { return false; }
-int
-__codecvt_utf16<char32_t, true>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+int __codecvt_utf16<char32_t, true>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf16le_to_ucs4_length(_frm, _frm_end, mx, __maxcode_, __mode_);
}
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-int
-__codecvt_utf16<char32_t, true>::do_max_length() const noexcept
-{
- if (__mode_ & consume_header)
- return 6;
- return 4;
+int __codecvt_utf16<char32_t, true>::do_max_length() const noexcept {
+ if (__mode_ & consume_header)
+ return 6;
+ return 4;
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf8_utf16<wchar_t>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-__codecvt_utf8_utf16<wchar_t>::result
-__codecvt_utf8_utf16<wchar_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
-#ifdef _WIN32
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
-#else
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
-#endif
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8_utf16<wchar_t>::result __codecvt_utf8_utf16<wchar_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+# ifdef _WIN32
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+# else
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+# endif
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8_utf16<wchar_t>::result __codecvt_utf8_utf16<wchar_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+# ifdef _WIN32
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+# else
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
+# endif
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf8_utf16<wchar_t>::result
-__codecvt_utf8_utf16<wchar_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
-#ifdef _WIN32
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
-#else
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
-#endif
- result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8_utf16<wchar_t>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf8_utf16<wchar_t>::result
-__codecvt_utf8_utf16<wchar_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+int __codecvt_utf8_utf16<wchar_t>::do_encoding() const noexcept { return 0; }
-int
-__codecvt_utf8_utf16<wchar_t>::do_encoding() const noexcept
-{
- return 0;
-}
-
-bool
-__codecvt_utf8_utf16<wchar_t>::do_always_noconv() const noexcept
-{
- return false;
-}
+bool __codecvt_utf8_utf16<wchar_t>::do_always_noconv() const noexcept { return false; }
-int
-__codecvt_utf8_utf16<wchar_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+int __codecvt_utf8_utf16<wchar_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
}
-int
-__codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept
-{
- if (__mode_ & consume_header)
- return 7;
- return 4;
+int __codecvt_utf8_utf16<wchar_t>::do_max_length() const noexcept {
+ if (__mode_ & consume_header)
+ return 7;
+ return 4;
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// __codecvt_utf8_utf16<char16_t>
-__codecvt_utf8_utf16<char16_t>::result
-__codecvt_utf8_utf16<char16_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
- const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
- const uint16_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8_utf16<char16_t>::result __codecvt_utf8_utf16<char16_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint16_t* _frm = reinterpret_cast<const uint16_t*>(frm);
+ const uint16_t* _frm_end = reinterpret_cast<const uint16_t*>(frm_end);
+ const uint16_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8_utf16<char16_t>::result __codecvt_utf8_utf16<char16_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf8_utf16<char16_t>::result
-__codecvt_utf8_utf16<char16_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
- result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+__codecvt_utf8_utf16<char16_t>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-__codecvt_utf8_utf16<char16_t>::result
-__codecvt_utf8_utf16<char16_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
-}
+int __codecvt_utf8_utf16<char16_t>::do_encoding() const noexcept { return 0; }
-int
-__codecvt_utf8_utf16<char16_t>::do_encoding() const noexcept
-{
- return 0;
-}
+bool __codecvt_utf8_utf16<char16_t>::do_always_noconv() const noexcept { return false; }
-bool
-__codecvt_utf8_utf16<char16_t>::do_always_noconv() const noexcept
-{
- return false;
-}
-
-int
-__codecvt_utf8_utf16<char16_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+int __codecvt_utf8_utf16<char16_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
}
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-int
-__codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept
-{
- if (__mode_ & consume_header)
- return 7;
- return 4;
+int __codecvt_utf8_utf16<char16_t>::do_max_length() const noexcept {
+ if (__mode_ & consume_header)
+ return 7;
+ return 4;
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
// __codecvt_utf8_utf16<char32_t>
-__codecvt_utf8_utf16<char32_t>::result
-__codecvt_utf8_utf16<char32_t>::do_out(state_type&,
- const intern_type* frm, const intern_type* frm_end, const intern_type*& frm_nxt,
- extern_type* to, extern_type* to_end, extern_type*& to_nxt) const
-{
- const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
- const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
- const uint32_t* _frm_nxt = _frm;
- uint8_t* _to = reinterpret_cast<uint8_t*>(to);
- uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
- uint8_t* _to_nxt = _to;
- result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
-}
-
-__codecvt_utf8_utf16<char32_t>::result
-__codecvt_utf8_utf16<char32_t>::do_in(state_type&,
- const extern_type* frm, const extern_type* frm_end, const extern_type*& frm_nxt,
- intern_type* to, intern_type* to_end, intern_type*& to_nxt) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- const uint8_t* _frm_nxt = _frm;
+__codecvt_utf8_utf16<char32_t>::result __codecvt_utf8_utf16<char32_t>::do_out(
+ state_type&,
+ const intern_type* frm,
+ const intern_type* frm_end,
+ const intern_type*& frm_nxt,
+ extern_type* to,
+ extern_type* to_end,
+ extern_type*& to_nxt) const {
+ const uint32_t* _frm = reinterpret_cast<const uint32_t*>(frm);
+ const uint32_t* _frm_end = reinterpret_cast<const uint32_t*>(frm_end);
+ const uint32_t* _frm_nxt = _frm;
+ uint8_t* _to = reinterpret_cast<uint8_t*>(to);
+ uint8_t* _to_end = reinterpret_cast<uint8_t*>(to_end);
+ uint8_t* _to_nxt = _to;
+ result r = utf16_to_utf8(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
+}
+
+__codecvt_utf8_utf16<char32_t>::result __codecvt_utf8_utf16<char32_t>::do_in(
+ state_type&,
+ const extern_type* frm,
+ const extern_type* frm_end,
+ const extern_type*& frm_nxt,
+ intern_type* to,
+ intern_type* to_end,
+ intern_type*& to_nxt) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ const uint8_t* _frm_nxt = _frm;
#if defined(_LIBCPP_SHORT_WCHAR)
- uint16_t* _to = reinterpret_cast<uint16_t*>(to);
- uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
- uint16_t* _to_nxt = _to;
+ uint16_t* _to = reinterpret_cast<uint16_t*>(to);
+ uint16_t* _to_end = reinterpret_cast<uint16_t*>(to_end);
+ uint16_t* _to_nxt = _to;
#else
- uint32_t* _to = reinterpret_cast<uint32_t*>(to);
- uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
- uint32_t* _to_nxt = _to;
+ uint32_t* _to = reinterpret_cast<uint32_t*>(to);
+ uint32_t* _to_end = reinterpret_cast<uint32_t*>(to_end);
+ uint32_t* _to_nxt = _to;
#endif
- result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt,
- __maxcode_, __mode_);
- frm_nxt = frm + (_frm_nxt - _frm);
- to_nxt = to + (_to_nxt - _to);
- return r;
+ result r = utf8_to_utf16(_frm, _frm_end, _frm_nxt, _to, _to_end, _to_nxt, __maxcode_, __mode_);
+ frm_nxt = frm + (_frm_nxt - _frm);
+ to_nxt = to + (_to_nxt - _to);
+ return r;
}
__codecvt_utf8_utf16<char32_t>::result
-__codecvt_utf8_utf16<char32_t>::do_unshift(state_type&,
- extern_type* to, extern_type*, extern_type*& to_nxt) const
-{
- to_nxt = to;
- return noconv;
+__codecvt_utf8_utf16<char32_t>::do_unshift(state_type&, extern_type* to, extern_type*, extern_type*& to_nxt) const {
+ to_nxt = to;
+ return noconv;
}
-int
-__codecvt_utf8_utf16<char32_t>::do_encoding() const noexcept
-{
- return 0;
-}
+int __codecvt_utf8_utf16<char32_t>::do_encoding() const noexcept { return 0; }
-bool
-__codecvt_utf8_utf16<char32_t>::do_always_noconv() const noexcept
-{
- return false;
-}
+bool __codecvt_utf8_utf16<char32_t>::do_always_noconv() const noexcept { return false; }
-int
-__codecvt_utf8_utf16<char32_t>::do_length(state_type&,
- const extern_type* frm, const extern_type* frm_end, size_t mx) const
-{
- const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
- const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
- return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
+int __codecvt_utf8_utf16<char32_t>::do_length(
+ state_type&, const extern_type* frm, const extern_type* frm_end, size_t mx) const {
+ const uint8_t* _frm = reinterpret_cast<const uint8_t*>(frm);
+ const uint8_t* _frm_end = reinterpret_cast<const uint8_t*>(frm_end);
+ return utf8_to_utf16_length(_frm, _frm_end, mx, __maxcode_, __mode_);
}
_LIBCPP_SUPPRESS_DEPRECATED_PUSH
-int
-__codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept
-{
- if (__mode_ & consume_header)
- return 7;
- return 4;
+int __codecvt_utf8_utf16<char32_t>::do_max_length() const noexcept {
+ if (__mode_ & consume_header)
+ return 7;
+ return 4;
}
_LIBCPP_SUPPRESS_DEPRECATED_POP
// __narrow_to_utf8<16>
-__narrow_to_utf8<16>::~__narrow_to_utf8()
-{
-}
+__narrow_to_utf8<16>::~__narrow_to_utf8() {}
// __narrow_to_utf8<32>
-__narrow_to_utf8<32>::~__narrow_to_utf8()
-{
-}
+__narrow_to_utf8<32>::~__narrow_to_utf8() {}
// __widen_from_utf8<16>
-__widen_from_utf8<16>::~__widen_from_utf8()
-{
-}
+__widen_from_utf8<16>::~__widen_from_utf8() {}
// __widen_from_utf8<32>
-__widen_from_utf8<32>::~__widen_from_utf8()
-{
-}
+__widen_from_utf8<32>::~__widen_from_utf8() {}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-static bool checked_string_to_wchar_convert(wchar_t& dest,
- const char* ptr,
- locale_t loc) {
+static bool checked_string_to_wchar_convert(wchar_t& dest, const char* ptr, locale_t loc) {
if (*ptr == '\0')
return false;
mbstate_t mb = {};
@@ -4603,9 +3991,7 @@ static bool is_non_breaking_space(const char* ptr) {
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-static bool checked_string_to_char_convert(char& dest,
- const char* ptr,
- locale_t __loc) {
+static bool checked_string_to_char_convert(char& dest, const char* ptr, locale_t __loc) {
if (*ptr == '\0')
return false;
if (!ptr[1]) {
@@ -4634,7 +4020,7 @@ static bool checked_string_to_char_convert(char& dest,
default:
return false;
}
-#else // _LIBCPP_HAS_NO_WIDE_CHARACTERS
+#else // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// FIXME: Work around specific multibyte sequences that we can reasonably
// translate into a different single byte.
if (is_narrow_non_breaking_space(ptr) || is_non_breaking_space(ptr)) {
@@ -4647,7 +4033,6 @@ static bool checked_string_to_char_convert(char& dest,
__libcpp_unreachable();
}
-
// numpunct<char> && numpunct<wchar_t>
constinit locale::id numpunct<char>::id;
@@ -4655,1941 +4040,1707 @@ constinit locale::id numpunct<char>::id;
constinit locale::id numpunct<wchar_t>::id;
#endif
-numpunct<char>::numpunct(size_t refs)
- : locale::facet(refs),
- __decimal_point_('.'),
- __thousands_sep_(',')
-{
-}
+numpunct<char>::numpunct(size_t refs) : locale::facet(refs), __decimal_point_('.'), __thousands_sep_(',') {}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-numpunct<wchar_t>::numpunct(size_t refs)
- : locale::facet(refs),
- __decimal_point_(L'.'),
- __thousands_sep_(L',')
-{
-}
+numpunct<wchar_t>::numpunct(size_t refs) : locale::facet(refs), __decimal_point_(L'.'), __thousands_sep_(L',') {}
#endif
-numpunct<char>::~numpunct()
-{
-}
+numpunct<char>::~numpunct() {}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-numpunct<wchar_t>::~numpunct()
-{
-}
+numpunct<wchar_t>::~numpunct() {}
#endif
- char numpunct< char >::do_decimal_point() const {return __decimal_point_;}
+char numpunct< char >::do_decimal_point() const { return __decimal_point_; }
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-wchar_t numpunct<wchar_t>::do_decimal_point() const {return __decimal_point_;}
+wchar_t numpunct<wchar_t>::do_decimal_point() const { return __decimal_point_; }
#endif
- char numpunct< char >::do_thousands_sep() const {return __thousands_sep_;}
+char numpunct< char >::do_thousands_sep() const { return __thousands_sep_; }
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-wchar_t numpunct<wchar_t>::do_thousands_sep() const {return __thousands_sep_;}
+wchar_t numpunct<wchar_t>::do_thousands_sep() const { return __thousands_sep_; }
#endif
-string numpunct< char >::do_grouping() const {return __grouping_;}
+string numpunct< char >::do_grouping() const { return __grouping_; }
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-string numpunct<wchar_t>::do_grouping() const {return __grouping_;}
+string numpunct<wchar_t>::do_grouping() const { return __grouping_; }
#endif
- string numpunct< char >::do_truename() const {return "true";}
+string numpunct< char >::do_truename() const { return "true"; }
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-wstring numpunct<wchar_t>::do_truename() const {return L"true";}
+wstring numpunct<wchar_t>::do_truename() const { return L"true"; }
#endif
- string numpunct< char >::do_falsename() const {return "false";}
+string numpunct< char >::do_falsename() const { return "false"; }
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-wstring numpunct<wchar_t>::do_falsename() const {return L"false";}
+wstring numpunct<wchar_t>::do_falsename() const { return L"false"; }
#endif
// numpunct_byname<char>
-numpunct_byname<char>::numpunct_byname(const char* nm, size_t refs)
- : numpunct<char>(refs)
-{
- __init(nm);
-}
+numpunct_byname<char>::numpunct_byname(const char* nm, size_t refs) : numpunct<char>(refs) { __init(nm); }
-numpunct_byname<char>::numpunct_byname(const string& nm, size_t refs)
- : numpunct<char>(refs)
-{
- __init(nm.c_str());
-}
+numpunct_byname<char>::numpunct_byname(const string& nm, size_t refs) : numpunct<char>(refs) { __init(nm.c_str()); }
-numpunct_byname<char>::~numpunct_byname()
-{
-}
+numpunct_byname<char>::~numpunct_byname() {}
-void
-numpunct_byname<char>::__init(const char* nm)
-{
- typedef numpunct<char> base;
- if (strcmp(nm, "C") != 0)
- {
- __libcpp_unique_locale loc(nm);
- if (!loc)
- __throw_runtime_error(("numpunct_byname<char>::numpunct_byname"
- " failed to construct for " + string(nm)).c_str());
-
- lconv* lc = __libcpp_localeconv_l(loc.get());
- if (!checked_string_to_char_convert(__decimal_point_, lc->decimal_point,
- loc.get()))
- __decimal_point_ = base::do_decimal_point();
- if (!checked_string_to_char_convert(__thousands_sep_, lc->thousands_sep,
- loc.get()))
- __thousands_sep_ = base::do_thousands_sep();
- __grouping_ = lc->grouping;
- // localization for truename and falsename is not available
- }
+void numpunct_byname<char>::__init(const char* nm) {
+ typedef numpunct<char> base;
+ if (strcmp(nm, "C") != 0) {
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error(
+ ("numpunct_byname<char>::numpunct_byname"
+ " failed to construct for " +
+ string(nm))
+ .c_str());
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_char_convert(__decimal_point_, lc->decimal_point, loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_char_convert(__thousands_sep_, lc->thousands_sep, loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+ __grouping_ = lc->grouping;
+ // localization for truename and falsename is not available
+ }
}
// numpunct_byname<wchar_t>
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs)
- : numpunct<wchar_t>(refs)
-{
- __init(nm);
-}
+numpunct_byname<wchar_t>::numpunct_byname(const char* nm, size_t refs) : numpunct<wchar_t>(refs) { __init(nm); }
-numpunct_byname<wchar_t>::numpunct_byname(const string& nm, size_t refs)
- : numpunct<wchar_t>(refs)
-{
- __init(nm.c_str());
+numpunct_byname<wchar_t>::numpunct_byname(const string& nm, size_t refs) : numpunct<wchar_t>(refs) {
+ __init(nm.c_str());
}
-numpunct_byname<wchar_t>::~numpunct_byname()
-{
-}
+numpunct_byname<wchar_t>::~numpunct_byname() {}
-void
-numpunct_byname<wchar_t>::__init(const char* nm)
-{
- if (strcmp(nm, "C") != 0)
- {
- __libcpp_unique_locale loc(nm);
- if (!loc)
- __throw_runtime_error(("numpunct_byname<wchar_t>::numpunct_byname"
- " failed to construct for " + string(nm)).c_str());
-
- lconv* lc = __libcpp_localeconv_l(loc.get());
- checked_string_to_wchar_convert(__decimal_point_, lc->decimal_point,
- loc.get());
- checked_string_to_wchar_convert(__thousands_sep_, lc->thousands_sep,
- loc.get());
- __grouping_ = lc->grouping;
- // localization for truename and falsename is not available
- }
+void numpunct_byname<wchar_t>::__init(const char* nm) {
+ if (strcmp(nm, "C") != 0) {
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error(
+ ("numpunct_byname<wchar_t>::numpunct_byname"
+ " failed to construct for " +
+ string(nm))
+ .c_str());
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ checked_string_to_wchar_convert(__decimal_point_, lc->decimal_point, loc.get());
+ checked_string_to_wchar_convert(__thousands_sep_, lc->thousands_sep, loc.get());
+ __grouping_ = lc->grouping;
+ // localization for truename and falsename is not available
+ }
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// num_get helpers
-int
-__num_get_base::__get_base(ios_base& iob)
-{
- ios_base::fmtflags __basefield = iob.flags() & ios_base::basefield;
- if (__basefield == ios_base::oct)
- return 8;
- else if (__basefield == ios_base::hex)
- return 16;
- else if (__basefield == 0)
- return 0;
- return 10;
+int __num_get_base::__get_base(ios_base& iob) {
+ ios_base::fmtflags __basefield = iob.flags() & ios_base::basefield;
+ if (__basefield == ios_base::oct)
+ return 8;
+ else if (__basefield == ios_base::hex)
+ return 16;
+ else if (__basefield == 0)
+ return 0;
+ return 10;
}
const char __num_get_base::__src[33] = "0123456789abcdefABCDEFxX+-pPiInN";
-void
-__check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end,
- ios_base::iostate& __err)
-{
-// if the grouping pattern is empty _or_ there are no grouping bits, then do nothing
-// we always have at least a single entry in [__g, __g_end); the end of the input sequence
- if (__grouping.size() != 0 && __g_end - __g > 1)
- {
- reverse(__g, __g_end);
- const char* __ig = __grouping.data();
- const char* __eg = __ig + __grouping.size();
- for (unsigned* __r = __g; __r < __g_end-1; ++__r)
- {
- if (0 < *__ig && *__ig < numeric_limits<char>::max())
- {
- if (static_cast<unsigned>(*__ig) != *__r)
- {
- __err = ios_base::failbit;
- return;
- }
- }
- if (__eg - __ig > 1)
- ++__ig;
- }
- if (0 < *__ig && *__ig < numeric_limits<char>::max())
- {
- if (static_cast<unsigned>(*__ig) < __g_end[-1] || __g_end[-1] == 0)
- __err = ios_base::failbit;
+void __check_grouping(const string& __grouping, unsigned* __g, unsigned* __g_end, ios_base::iostate& __err) {
+ // if the grouping pattern is empty _or_ there are no grouping bits, then do nothing
+ // we always have at least a single entry in [__g, __g_end); the end of the input sequence
+ if (__grouping.size() != 0 && __g_end - __g > 1) {
+ reverse(__g, __g_end);
+ const char* __ig = __grouping.data();
+ const char* __eg = __ig + __grouping.size();
+ for (unsigned* __r = __g; __r < __g_end - 1; ++__r) {
+ if (0 < *__ig && *__ig < numeric_limits<char>::max()) {
+ if (static_cast<unsigned>(*__ig) != *__r) {
+ __err = ios_base::failbit;
+ return;
}
+ }
+ if (__eg - __ig > 1)
+ ++__ig;
}
+ if (0 < *__ig && *__ig < numeric_limits<char>::max()) {
+ if (static_cast<unsigned>(*__ig) < __g_end[-1] || __g_end[-1] == 0)
+ __err = ios_base::failbit;
+ }
+ }
}
-void
-__num_put_base::__format_int(char* __fmtp, const char* __len, bool __signd,
- ios_base::fmtflags __flags)
-{
- if ((__flags & ios_base::showpos) &&
- (__flags & ios_base::basefield) != ios_base::oct &&
- (__flags & ios_base::basefield) != ios_base::hex &&
- __signd)
- *__fmtp++ = '+';
- if (__flags & ios_base::showbase)
- *__fmtp++ = '#';
- while(*__len)
- *__fmtp++ = *__len++;
- if ((__flags & ios_base::basefield) == ios_base::oct)
- *__fmtp = 'o';
- else if ((__flags & ios_base::basefield) == ios_base::hex)
- {
- if (__flags & ios_base::uppercase)
- *__fmtp = 'X';
- else
- *__fmtp = 'x';
- }
- else if (__signd)
- *__fmtp = 'd';
+void __num_put_base::__format_int(char* __fmtp, const char* __len, bool __signd, ios_base::fmtflags __flags) {
+ if ((__flags & ios_base::showpos) && (__flags & ios_base::basefield) != ios_base::oct &&
+ (__flags & ios_base::basefield) != ios_base::hex && __signd)
+ *__fmtp++ = '+';
+ if (__flags & ios_base::showbase)
+ *__fmtp++ = '#';
+ while (*__len)
+ *__fmtp++ = *__len++;
+ if ((__flags & ios_base::basefield) == ios_base::oct)
+ *__fmtp = 'o';
+ else if ((__flags & ios_base::basefield) == ios_base::hex) {
+ if (__flags & ios_base::uppercase)
+ *__fmtp = 'X';
else
- *__fmtp = 'u';
-}
-
-bool
-__num_put_base::__format_float(char* __fmtp, const char* __len,
- ios_base::fmtflags __flags)
-{
- bool specify_precision = true;
- if (__flags & ios_base::showpos)
- *__fmtp++ = '+';
- if (__flags & ios_base::showpoint)
- *__fmtp++ = '#';
- ios_base::fmtflags floatfield = __flags & ios_base::floatfield;
- bool uppercase = (__flags & ios_base::uppercase) != 0;
- if (floatfield == (ios_base::fixed | ios_base::scientific))
- specify_precision = false;
+ *__fmtp = 'x';
+ } else if (__signd)
+ *__fmtp = 'd';
+ else
+ *__fmtp = 'u';
+}
+
+bool __num_put_base::__format_float(char* __fmtp, const char* __len, ios_base::fmtflags __flags) {
+ bool specify_precision = true;
+ if (__flags & ios_base::showpos)
+ *__fmtp++ = '+';
+ if (__flags & ios_base::showpoint)
+ *__fmtp++ = '#';
+ ios_base::fmtflags floatfield = __flags & ios_base::floatfield;
+ bool uppercase = (__flags & ios_base::uppercase) != 0;
+ if (floatfield == (ios_base::fixed | ios_base::scientific))
+ specify_precision = false;
+ else {
+ *__fmtp++ = '.';
+ *__fmtp++ = '*';
+ }
+ while (*__len)
+ *__fmtp++ = *__len++;
+ if (floatfield == ios_base::fixed) {
+ if (uppercase)
+ *__fmtp = 'F';
else
- {
- *__fmtp++ = '.';
- *__fmtp++ = '*';
- }
- while(*__len)
- *__fmtp++ = *__len++;
- if (floatfield == ios_base::fixed)
- {
- if (uppercase)
- *__fmtp = 'F';
- else
- *__fmtp = 'f';
- }
- else if (floatfield == ios_base::scientific)
- {
- if (uppercase)
- *__fmtp = 'E';
- else
- *__fmtp = 'e';
- }
- else if (floatfield == (ios_base::fixed | ios_base::scientific))
- {
- if (uppercase)
- *__fmtp = 'A';
- else
- *__fmtp = 'a';
- }
+ *__fmtp = 'f';
+ } else if (floatfield == ios_base::scientific) {
+ if (uppercase)
+ *__fmtp = 'E';
else
- {
- if (uppercase)
- *__fmtp = 'G';
- else
- *__fmtp = 'g';
- }
- return specify_precision;
-}
-
-char*
-__num_put_base::__identify_padding(char* __nb, char* __ne,
- const ios_base& __iob)
-{
- switch (__iob.flags() & ios_base::adjustfield)
- {
- case ios_base::internal:
- if (__nb[0] == '-' || __nb[0] == '+')
- return __nb+1;
- if (__ne - __nb >= 2 && __nb[0] == '0'
- && (__nb[1] == 'x' || __nb[1] == 'X'))
- return __nb+2;
- break;
- case ios_base::left:
- return __ne;
- case ios_base::right:
- default:
- break;
- }
- return __nb;
+ *__fmtp = 'e';
+ } else if (floatfield == (ios_base::fixed | ios_base::scientific)) {
+ if (uppercase)
+ *__fmtp = 'A';
+ else
+ *__fmtp = 'a';
+ } else {
+ if (uppercase)
+ *__fmtp = 'G';
+ else
+ *__fmtp = 'g';
+ }
+ return specify_precision;
+}
+
+char* __num_put_base::__identify_padding(char* __nb, char* __ne, const ios_base& __iob) {
+ switch (__iob.flags() & ios_base::adjustfield) {
+ case ios_base::internal:
+ if (__nb[0] == '-' || __nb[0] == '+')
+ return __nb + 1;
+ if (__ne - __nb >= 2 && __nb[0] == '0' && (__nb[1] == 'x' || __nb[1] == 'X'))
+ return __nb + 2;
+ break;
+ case ios_base::left:
+ return __ne;
+ case ios_base::right:
+ default:
+ break;
+ }
+ return __nb;
}
// time_get
-static
-string*
-init_weeks()
-{
- static string weeks[14];
- weeks[0] = "Sunday";
- weeks[1] = "Monday";
- weeks[2] = "Tuesday";
- weeks[3] = "Wednesday";
- weeks[4] = "Thursday";
- weeks[5] = "Friday";
- weeks[6] = "Saturday";
- weeks[7] = "Sun";
- weeks[8] = "Mon";
- weeks[9] = "Tue";
- weeks[10] = "Wed";
- weeks[11] = "Thu";
- weeks[12] = "Fri";
- weeks[13] = "Sat";
- return weeks;
+static string* init_weeks() {
+ static string weeks[14];
+ weeks[0] = "Sunday";
+ weeks[1] = "Monday";
+ weeks[2] = "Tuesday";
+ weeks[3] = "Wednesday";
+ weeks[4] = "Thursday";
+ weeks[5] = "Friday";
+ weeks[6] = "Saturday";
+ weeks[7] = "Sun";
+ weeks[8] = "Mon";
+ weeks[9] = "Tue";
+ weeks[10] = "Wed";
+ weeks[11] = "Thu";
+ weeks[12] = "Fri";
+ weeks[13] = "Sat";
+ return weeks;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-static
-wstring*
-init_wweeks()
-{
- static wstring weeks[14];
- weeks[0] = L"Sunday";
- weeks[1] = L"Monday";
- weeks[2] = L"Tuesday";
- weeks[3] = L"Wednesday";
- weeks[4] = L"Thursday";
- weeks[5] = L"Friday";
- weeks[6] = L"Saturday";
- weeks[7] = L"Sun";
- weeks[8] = L"Mon";
- weeks[9] = L"Tue";
- weeks[10] = L"Wed";
- weeks[11] = L"Thu";
- weeks[12] = L"Fri";
- weeks[13] = L"Sat";
- return weeks;
+static wstring* init_wweeks() {
+ static wstring weeks[14];
+ weeks[0] = L"Sunday";
+ weeks[1] = L"Monday";
+ weeks[2] = L"Tuesday";
+ weeks[3] = L"Wednesday";
+ weeks[4] = L"Thursday";
+ weeks[5] = L"Friday";
+ weeks[6] = L"Saturday";
+ weeks[7] = L"Sun";
+ weeks[8] = L"Mon";
+ weeks[9] = L"Tue";
+ weeks[10] = L"Wed";
+ weeks[11] = L"Thu";
+ weeks[12] = L"Fri";
+ weeks[13] = L"Sat";
+ return weeks;
}
#endif
template <>
-const string*
-__time_get_c_storage<char>::__weeks() const
-{
- static const string* weeks = init_weeks();
- return weeks;
+const string* __time_get_c_storage<char>::__weeks() const {
+ static const string* weeks = init_weeks();
+ return weeks;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-const wstring*
-__time_get_c_storage<wchar_t>::__weeks() const
-{
- static const wstring* weeks = init_wweeks();
- return weeks;
+const wstring* __time_get_c_storage<wchar_t>::__weeks() const {
+ static const wstring* weeks = init_wweeks();
+ return weeks;
}
#endif
-static
-string*
-init_months()
-{
- static string months[24];
- months[0] = "January";
- months[1] = "February";
- months[2] = "March";
- months[3] = "April";
- months[4] = "May";
- months[5] = "June";
- months[6] = "July";
- months[7] = "August";
- months[8] = "September";
- months[9] = "October";
- months[10] = "November";
- months[11] = "December";
- months[12] = "Jan";
- months[13] = "Feb";
- months[14] = "Mar";
- months[15] = "Apr";
- months[16] = "May";
- months[17] = "Jun";
- months[18] = "Jul";
- months[19] = "Aug";
- months[20] = "Sep";
- months[21] = "Oct";
- months[22] = "Nov";
- months[23] = "Dec";
- return months;
+static string* init_months() {
+ static string months[24];
+ months[0] = "January";
+ months[1] = "February";
+ months[2] = "March";
+ months[3] = "April";
+ months[4] = "May";
+ months[5] = "June";
+ months[6] = "July";
+ months[7] = "August";
+ months[8] = "September";
+ months[9] = "October";
+ months[10] = "November";
+ months[11] = "December";
+ months[12] = "Jan";
+ months[13] = "Feb";
+ months[14] = "Mar";
+ months[15] = "Apr";
+ months[16] = "May";
+ months[17] = "Jun";
+ months[18] = "Jul";
+ months[19] = "Aug";
+ months[20] = "Sep";
+ months[21] = "Oct";
+ months[22] = "Nov";
+ months[23] = "Dec";
+ return months;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-static
-wstring*
-init_wmonths()
-{
- static wstring months[24];
- months[0] = L"January";
- months[1] = L"February";
- months[2] = L"March";
- months[3] = L"April";
- months[4] = L"May";
- months[5] = L"June";
- months[6] = L"July";
- months[7] = L"August";
- months[8] = L"September";
- months[9] = L"October";
- months[10] = L"November";
- months[11] = L"December";
- months[12] = L"Jan";
- months[13] = L"Feb";
- months[14] = L"Mar";
- months[15] = L"Apr";
- months[16] = L"May";
- months[17] = L"Jun";
- months[18] = L"Jul";
- months[19] = L"Aug";
- months[20] = L"Sep";
- months[21] = L"Oct";
- months[22] = L"Nov";
- months[23] = L"Dec";
- return months;
+static wstring* init_wmonths() {
+ static wstring months[24];
+ months[0] = L"January";
+ months[1] = L"February";
+ months[2] = L"March";
+ months[3] = L"April";
+ months[4] = L"May";
+ months[5] = L"June";
+ months[6] = L"July";
+ months[7] = L"August";
+ months[8] = L"September";
+ months[9] = L"October";
+ months[10] = L"November";
+ months[11] = L"December";
+ months[12] = L"Jan";
+ months[13] = L"Feb";
+ months[14] = L"Mar";
+ months[15] = L"Apr";
+ months[16] = L"May";
+ months[17] = L"Jun";
+ months[18] = L"Jul";
+ months[19] = L"Aug";
+ months[20] = L"Sep";
+ months[21] = L"Oct";
+ months[22] = L"Nov";
+ months[23] = L"Dec";
+ return months;
}
#endif
template <>
-const string*
-__time_get_c_storage<char>::__months() const
-{
- static const string* months = init_months();
- return months;
+const string* __time_get_c_storage<char>::__months() const {
+ static const string* months = init_months();
+ return months;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-const wstring*
-__time_get_c_storage<wchar_t>::__months() const
-{
- static const wstring* months = init_wmonths();
- return months;
+const wstring* __time_get_c_storage<wchar_t>::__months() const {
+ static const wstring* months = init_wmonths();
+ return months;
}
#endif
-static
-string*
-init_am_pm()
-{
- static string am_pm[2];
- am_pm[0] = "AM";
- am_pm[1] = "PM";
- return am_pm;
+static string* init_am_pm() {
+ static string am_pm[2];
+ am_pm[0] = "AM";
+ am_pm[1] = "PM";
+ return am_pm;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-static
-wstring*
-init_wam_pm()
-{
- static wstring am_pm[2];
- am_pm[0] = L"AM";
- am_pm[1] = L"PM";
- return am_pm;
+static wstring* init_wam_pm() {
+ static wstring am_pm[2];
+ am_pm[0] = L"AM";
+ am_pm[1] = L"PM";
+ return am_pm;
}
#endif
template <>
-const string*
-__time_get_c_storage<char>::__am_pm() const
-{
- static const string* am_pm = init_am_pm();
- return am_pm;
+const string* __time_get_c_storage<char>::__am_pm() const {
+ static const string* am_pm = init_am_pm();
+ return am_pm;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-const wstring*
-__time_get_c_storage<wchar_t>::__am_pm() const
-{
- static const wstring* am_pm = init_wam_pm();
- return am_pm;
+const wstring* __time_get_c_storage<wchar_t>::__am_pm() const {
+ static const wstring* am_pm = init_wam_pm();
+ return am_pm;
}
#endif
template <>
-const string&
-__time_get_c_storage<char>::__x() const
-{
- static string s("%m/%d/%y");
- return s;
+const string& __time_get_c_storage<char>::__x() const {
+ static string s("%m/%d/%y");
+ return s;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-const wstring&
-__time_get_c_storage<wchar_t>::__x() const
-{
- static wstring s(L"%m/%d/%y");
- return s;
+const wstring& __time_get_c_storage<wchar_t>::__x() const {
+ static wstring s(L"%m/%d/%y");
+ return s;
}
#endif
template <>
-const string&
-__time_get_c_storage<char>::__X() const
-{
- static string s("%H:%M:%S");
- return s;
+const string& __time_get_c_storage<char>::__X() const {
+ static string s("%H:%M:%S");
+ return s;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-const wstring&
-__time_get_c_storage<wchar_t>::__X() const
-{
- static wstring s(L"%H:%M:%S");
- return s;
+const wstring& __time_get_c_storage<wchar_t>::__X() const {
+ static wstring s(L"%H:%M:%S");
+ return s;
}
#endif
template <>
-const string&
-__time_get_c_storage<char>::__c() const
-{
- static string s("%a %b %d %H:%M:%S %Y");
- return s;
+const string& __time_get_c_storage<char>::__c() const {
+ static string s("%a %b %d %H:%M:%S %Y");
+ return s;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-const wstring&
-__time_get_c_storage<wchar_t>::__c() const
-{
- static wstring s(L"%a %b %d %H:%M:%S %Y");
- return s;
+const wstring& __time_get_c_storage<wchar_t>::__c() const {
+ static wstring s(L"%a %b %d %H:%M:%S %Y");
+ return s;
}
#endif
template <>
-const string&
-__time_get_c_storage<char>::__r() const
-{
- static string s("%I:%M:%S %p");
- return s;
+const string& __time_get_c_storage<char>::__r() const {
+ static string s("%I:%M:%S %p");
+ return s;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-const wstring&
-__time_get_c_storage<wchar_t>::__r() const
-{
- static wstring s(L"%I:%M:%S %p");
- return s;
+const wstring& __time_get_c_storage<wchar_t>::__r() const {
+ static wstring s(L"%I:%M:%S %p");
+ return s;
}
#endif
// time_get_byname
-__time_get::__time_get(const char* nm)
- : __loc_(newlocale(LC_ALL_MASK, nm, 0))
-{
- if (__loc_ == 0)
- __throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str());
+__time_get::__time_get(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {
+ if (__loc_ == 0)
+ __throw_runtime_error(("time_get_byname failed to construct for " + string(nm)).c_str());
}
-__time_get::__time_get(const string& nm)
- : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
-{
- if (__loc_ == 0)
- __throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str());
+__time_get::__time_get(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) {
+ if (__loc_ == 0)
+ __throw_runtime_error(("time_get_byname failed to construct for " + nm).c_str());
}
-__time_get::~__time_get()
-{
- freelocale(__loc_);
-}
+__time_get::~__time_get() { freelocale(__loc_); }
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-field-initializers")
template <>
-string
-__time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct)
-{
- tm t = {0};
- t.tm_sec = 59;
- t.tm_min = 55;
- t.tm_hour = 23;
- t.tm_mday = 31;
- t.tm_mon = 11;
- t.tm_year = 161;
- t.tm_wday = 6;
- t.tm_yday = 364;
- t.tm_isdst = -1;
- char buf[100];
- char f[3] = {0};
- f[0] = '%';
- f[1] = fmt;
- size_t n = strftime_l(buf, countof(buf), f, &t, __loc_);
- char* bb = buf;
- char* be = buf + n;
- string result;
- while (bb != be)
- {
- if (ct.is(ctype_base::space, *bb))
- {
- result.push_back(' ');
- for (++bb; bb != be && ct.is(ctype_base::space, *bb); ++bb)
- ;
- continue;
- }
- char* w = bb;
- ios_base::iostate err = ios_base::goodbit;
- ptrdiff_t i = __scan_keyword(w, be, this->__weeks_, this->__weeks_+14,
- ct, err, false)
- - this->__weeks_;
- if (i < 14)
- {
- result.push_back('%');
- if (i < 7)
- result.push_back('A');
- else
- result.push_back('a');
- bb = w;
- continue;
- }
- w = bb;
- i = __scan_keyword(w, be, this->__months_, this->__months_+24,
- ct, err, false)
- - this->__months_;
- if (i < 24)
- {
- result.push_back('%');
- if (i < 12)
- result.push_back('B');
- else
- result.push_back('b');
- if (fmt == 'x' && ct.is(ctype_base::digit, this->__months_[i][0]))
- result.back() = 'm';
- bb = w;
- continue;
- }
- if (this->__am_pm_[0].size() + this->__am_pm_[1].size() > 0)
- {
- w = bb;
- i = __scan_keyword(w, be, this->__am_pm_, this->__am_pm_+2,
- ct, err, false) - this->__am_pm_;
- if (i < 2)
- {
- result.push_back('%');
- result.push_back('p');
- bb = w;
- continue;
- }
- }
- w = bb;
- if (ct.is(ctype_base::digit, *bb))
- {
- switch(__get_up_to_n_digits(bb, be, err, ct, 4))
- {
- case 6:
- result.push_back('%');
- result.push_back('w');
- break;
- case 7:
- result.push_back('%');
- result.push_back('u');
- break;
- case 11:
- result.push_back('%');
- result.push_back('I');
- break;
- case 12:
- result.push_back('%');
- result.push_back('m');
- break;
- case 23:
- result.push_back('%');
- result.push_back('H');
- break;
- case 31:
- result.push_back('%');
- result.push_back('d');
- break;
- case 55:
- result.push_back('%');
- result.push_back('M');
- break;
- case 59:
- result.push_back('%');
- result.push_back('S');
- break;
- case 61:
- result.push_back('%');
- result.push_back('y');
- break;
- case 364:
- result.push_back('%');
- result.push_back('j');
- break;
- case 2061:
- result.push_back('%');
- result.push_back('Y');
- break;
- default:
- for (; w != bb; ++w)
- result.push_back(*w);
- break;
- }
- continue;
- }
- if (*bb == '%')
- {
- result.push_back('%');
- result.push_back('%');
- ++bb;
- continue;
- }
- result.push_back(*bb);
- ++bb;
+string __time_get_storage<char>::__analyze(char fmt, const ctype<char>& ct) {
+ tm t = {0};
+ t.tm_sec = 59;
+ t.tm_min = 55;
+ t.tm_hour = 23;
+ t.tm_mday = 31;
+ t.tm_mon = 11;
+ t.tm_year = 161;
+ t.tm_wday = 6;
+ t.tm_yday = 364;
+ t.tm_isdst = -1;
+ char buf[100];
+ char f[3] = {0};
+ f[0] = '%';
+ f[1] = fmt;
+ size_t n = strftime_l(buf, countof(buf), f, &t, __loc_);
+ char* bb = buf;
+ char* be = buf + n;
+ string result;
+ while (bb != be) {
+ if (ct.is(ctype_base::space, *bb)) {
+ result.push_back(' ');
+ for (++bb; bb != be && ct.is(ctype_base::space, *bb); ++bb)
+ ;
+ continue;
+ }
+ char* w = bb;
+ ios_base::iostate err = ios_base::goodbit;
+ ptrdiff_t i = __scan_keyword(w, be, this->__weeks_, this->__weeks_ + 14, ct, err, false) - this->__weeks_;
+ if (i < 14) {
+ result.push_back('%');
+ if (i < 7)
+ result.push_back('A');
+ else
+ result.push_back('a');
+ bb = w;
+ continue;
+ }
+ w = bb;
+ i = __scan_keyword(w, be, this->__months_, this->__months_ + 24, ct, err, false) - this->__months_;
+ if (i < 24) {
+ result.push_back('%');
+ if (i < 12)
+ result.push_back('B');
+ else
+ result.push_back('b');
+ if (fmt == 'x' && ct.is(ctype_base::digit, this->__months_[i][0]))
+ result.back() = 'm';
+ bb = w;
+ continue;
}
- return result;
+ if (this->__am_pm_[0].size() + this->__am_pm_[1].size() > 0) {
+ w = bb;
+ i = __scan_keyword(w, be, this->__am_pm_, this->__am_pm_ + 2, ct, err, false) - this->__am_pm_;
+ if (i < 2) {
+ result.push_back('%');
+ result.push_back('p');
+ bb = w;
+ continue;
+ }
+ }
+ w = bb;
+ if (ct.is(ctype_base::digit, *bb)) {
+ switch (__get_up_to_n_digits(bb, be, err, ct, 4)) {
+ case 6:
+ result.push_back('%');
+ result.push_back('w');
+ break;
+ case 7:
+ result.push_back('%');
+ result.push_back('u');
+ break;
+ case 11:
+ result.push_back('%');
+ result.push_back('I');
+ break;
+ case 12:
+ result.push_back('%');
+ result.push_back('m');
+ break;
+ case 23:
+ result.push_back('%');
+ result.push_back('H');
+ break;
+ case 31:
+ result.push_back('%');
+ result.push_back('d');
+ break;
+ case 55:
+ result.push_back('%');
+ result.push_back('M');
+ break;
+ case 59:
+ result.push_back('%');
+ result.push_back('S');
+ break;
+ case 61:
+ result.push_back('%');
+ result.push_back('y');
+ break;
+ case 364:
+ result.push_back('%');
+ result.push_back('j');
+ break;
+ case 2061:
+ result.push_back('%');
+ result.push_back('Y');
+ break;
+ default:
+ for (; w != bb; ++w)
+ result.push_back(*w);
+ break;
+ }
+ continue;
+ }
+ if (*bb == '%') {
+ result.push_back('%');
+ result.push_back('%');
+ ++bb;
+ continue;
+ }
+ result.push_back(*bb);
+ ++bb;
+ }
+ return result;
}
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wmissing-braces")
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-wstring
-__time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct)
-{
- tm t = {0};
- t.tm_sec = 59;
- t.tm_min = 55;
- t.tm_hour = 23;
- t.tm_mday = 31;
- t.tm_mon = 11;
- t.tm_year = 161;
- t.tm_wday = 6;
- t.tm_yday = 364;
- t.tm_isdst = -1;
- char buf[100];
- char f[3] = {0};
- f[0] = '%';
- f[1] = fmt;
- strftime_l(buf, countof(buf), f, &t, __loc_);
- wchar_t wbuf[100];
- wchar_t* wbb = wbuf;
- mbstate_t mb = {0};
- const char* bb = buf;
- size_t j = __libcpp_mbsrtowcs_l( wbb, &bb, countof(wbuf), &mb, __loc_);
- if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
- wchar_t* wbe = wbb + j;
- wstring result;
- while (wbb != wbe)
- {
- if (ct.is(ctype_base::space, *wbb))
- {
- result.push_back(L' ');
- for (++wbb; wbb != wbe && ct.is(ctype_base::space, *wbb); ++wbb)
- ;
- continue;
- }
- wchar_t* w = wbb;
- ios_base::iostate err = ios_base::goodbit;
- ptrdiff_t i = __scan_keyword(w, wbe, this->__weeks_, this->__weeks_+14,
- ct, err, false)
- - this->__weeks_;
- if (i < 14)
- {
- result.push_back(L'%');
- if (i < 7)
- result.push_back(L'A');
- else
- result.push_back(L'a');
- wbb = w;
- continue;
- }
- w = wbb;
- i = __scan_keyword(w, wbe, this->__months_, this->__months_+24,
- ct, err, false)
- - this->__months_;
- if (i < 24)
- {
- result.push_back(L'%');
- if (i < 12)
- result.push_back(L'B');
- else
- result.push_back(L'b');
- if (fmt == 'x' && ct.is(ctype_base::digit, this->__months_[i][0]))
- result.back() = L'm';
- wbb = w;
- continue;
- }
- if (this->__am_pm_[0].size() + this->__am_pm_[1].size() > 0)
- {
- w = wbb;
- i = __scan_keyword(w, wbe, this->__am_pm_, this->__am_pm_+2,
- ct, err, false) - this->__am_pm_;
- if (i < 2)
- {
- result.push_back(L'%');
- result.push_back(L'p');
- wbb = w;
- continue;
- }
- }
- w = wbb;
- if (ct.is(ctype_base::digit, *wbb))
- {
- switch(__get_up_to_n_digits(wbb, wbe, err, ct, 4))
- {
- case 6:
- result.push_back(L'%');
- result.push_back(L'w');
- break;
- case 7:
- result.push_back(L'%');
- result.push_back(L'u');
- break;
- case 11:
- result.push_back(L'%');
- result.push_back(L'I');
- break;
- case 12:
- result.push_back(L'%');
- result.push_back(L'm');
- break;
- case 23:
- result.push_back(L'%');
- result.push_back(L'H');
- break;
- case 31:
- result.push_back(L'%');
- result.push_back(L'd');
- break;
- case 55:
- result.push_back(L'%');
- result.push_back(L'M');
- break;
- case 59:
- result.push_back(L'%');
- result.push_back(L'S');
- break;
- case 61:
- result.push_back(L'%');
- result.push_back(L'y');
- break;
- case 364:
- result.push_back(L'%');
- result.push_back(L'j');
- break;
- case 2061:
- result.push_back(L'%');
- result.push_back(L'Y');
- break;
- default:
- for (; w != wbb; ++w)
- result.push_back(*w);
- break;
- }
- continue;
- }
- if (ct.narrow(*wbb, 0) == '%')
- {
- result.push_back(L'%');
- result.push_back(L'%');
- ++wbb;
- continue;
- }
- result.push_back(*wbb);
- ++wbb;
+wstring __time_get_storage<wchar_t>::__analyze(char fmt, const ctype<wchar_t>& ct) {
+ tm t = {0};
+ t.tm_sec = 59;
+ t.tm_min = 55;
+ t.tm_hour = 23;
+ t.tm_mday = 31;
+ t.tm_mon = 11;
+ t.tm_year = 161;
+ t.tm_wday = 6;
+ t.tm_yday = 364;
+ t.tm_isdst = -1;
+ char buf[100];
+ char f[3] = {0};
+ f[0] = '%';
+ f[1] = fmt;
+ strftime_l(buf, countof(buf), f, &t, __loc_);
+ wchar_t wbuf[100];
+ wchar_t* wbb = wbuf;
+ mbstate_t mb = {0};
+ const char* bb = buf;
+ size_t j = __libcpp_mbsrtowcs_l(wbb, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wchar_t* wbe = wbb + j;
+ wstring result;
+ while (wbb != wbe) {
+ if (ct.is(ctype_base::space, *wbb)) {
+ result.push_back(L' ');
+ for (++wbb; wbb != wbe && ct.is(ctype_base::space, *wbb); ++wbb)
+ ;
+ continue;
+ }
+ wchar_t* w = wbb;
+ ios_base::iostate err = ios_base::goodbit;
+ ptrdiff_t i = __scan_keyword(w, wbe, this->__weeks_, this->__weeks_ + 14, ct, err, false) - this->__weeks_;
+ if (i < 14) {
+ result.push_back(L'%');
+ if (i < 7)
+ result.push_back(L'A');
+ else
+ result.push_back(L'a');
+ wbb = w;
+ continue;
}
- return result;
+ w = wbb;
+ i = __scan_keyword(w, wbe, this->__months_, this->__months_ + 24, ct, err, false) - this->__months_;
+ if (i < 24) {
+ result.push_back(L'%');
+ if (i < 12)
+ result.push_back(L'B');
+ else
+ result.push_back(L'b');
+ if (fmt == 'x' && ct.is(ctype_base::digit, this->__months_[i][0]))
+ result.back() = L'm';
+ wbb = w;
+ continue;
+ }
+ if (this->__am_pm_[0].size() + this->__am_pm_[1].size() > 0) {
+ w = wbb;
+ i = __scan_keyword(w, wbe, this->__am_pm_, this->__am_pm_ + 2, ct, err, false) - this->__am_pm_;
+ if (i < 2) {
+ result.push_back(L'%');
+ result.push_back(L'p');
+ wbb = w;
+ continue;
+ }
+ }
+ w = wbb;
+ if (ct.is(ctype_base::digit, *wbb)) {
+ switch (__get_up_to_n_digits(wbb, wbe, err, ct, 4)) {
+ case 6:
+ result.push_back(L'%');
+ result.push_back(L'w');
+ break;
+ case 7:
+ result.push_back(L'%');
+ result.push_back(L'u');
+ break;
+ case 11:
+ result.push_back(L'%');
+ result.push_back(L'I');
+ break;
+ case 12:
+ result.push_back(L'%');
+ result.push_back(L'm');
+ break;
+ case 23:
+ result.push_back(L'%');
+ result.push_back(L'H');
+ break;
+ case 31:
+ result.push_back(L'%');
+ result.push_back(L'd');
+ break;
+ case 55:
+ result.push_back(L'%');
+ result.push_back(L'M');
+ break;
+ case 59:
+ result.push_back(L'%');
+ result.push_back(L'S');
+ break;
+ case 61:
+ result.push_back(L'%');
+ result.push_back(L'y');
+ break;
+ case 364:
+ result.push_back(L'%');
+ result.push_back(L'j');
+ break;
+ case 2061:
+ result.push_back(L'%');
+ result.push_back(L'Y');
+ break;
+ default:
+ for (; w != wbb; ++w)
+ result.push_back(*w);
+ break;
+ }
+ continue;
+ }
+ if (ct.narrow(*wbb, 0) == '%') {
+ result.push_back(L'%');
+ result.push_back(L'%');
+ ++wbb;
+ continue;
+ }
+ result.push_back(*wbb);
+ ++wbb;
+ }
+ return result;
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-void
-__time_get_storage<char>::init(const ctype<char>& ct)
-{
- tm t = {0};
- char buf[100];
- // __weeks_
- for (int i = 0; i < 7; ++i)
- {
- t.tm_wday = i;
- strftime_l(buf, countof(buf), "%A", &t, __loc_);
- __weeks_[i] = buf;
- strftime_l(buf, countof(buf), "%a", &t, __loc_);
- __weeks_[i+7] = buf;
- }
- // __months_
- for (int i = 0; i < 12; ++i)
- {
- t.tm_mon = i;
- strftime_l(buf, countof(buf), "%B", &t, __loc_);
- __months_[i] = buf;
- strftime_l(buf, countof(buf), "%b", &t, __loc_);
- __months_[i+12] = buf;
- }
- // __am_pm_
- t.tm_hour = 1;
- strftime_l(buf, countof(buf), "%p", &t, __loc_);
- __am_pm_[0] = buf;
- t.tm_hour = 13;
- strftime_l(buf, countof(buf), "%p", &t, __loc_);
- __am_pm_[1] = buf;
- __c_ = __analyze('c', ct);
- __r_ = __analyze('r', ct);
- __x_ = __analyze('x', ct);
- __X_ = __analyze('X', ct);
+void __time_get_storage<char>::init(const ctype<char>& ct) {
+ tm t = {0};
+ char buf[100];
+ // __weeks_
+ for (int i = 0; i < 7; ++i) {
+ t.tm_wday = i;
+ strftime_l(buf, countof(buf), "%A", &t, __loc_);
+ __weeks_[i] = buf;
+ strftime_l(buf, countof(buf), "%a", &t, __loc_);
+ __weeks_[i + 7] = buf;
+ }
+ // __months_
+ for (int i = 0; i < 12; ++i) {
+ t.tm_mon = i;
+ strftime_l(buf, countof(buf), "%B", &t, __loc_);
+ __months_[i] = buf;
+ strftime_l(buf, countof(buf), "%b", &t, __loc_);
+ __months_[i + 12] = buf;
+ }
+ // __am_pm_
+ t.tm_hour = 1;
+ strftime_l(buf, countof(buf), "%p", &t, __loc_);
+ __am_pm_[0] = buf;
+ t.tm_hour = 13;
+ strftime_l(buf, countof(buf), "%p", &t, __loc_);
+ __am_pm_[1] = buf;
+ __c_ = __analyze('c', ct);
+ __r_ = __analyze('r', ct);
+ __x_ = __analyze('x', ct);
+ __X_ = __analyze('X', ct);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-void
-__time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct)
-{
- tm t = {0};
- char buf[100];
- wchar_t wbuf[100];
- wchar_t* wbe;
- mbstate_t mb = {0};
- // __weeks_
- for (int i = 0; i < 7; ++i)
- {
- t.tm_wday = i;
- strftime_l(buf, countof(buf), "%A", &t, __loc_);
- mb = mbstate_t();
- const char* bb = buf;
- size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
- if (j == size_t(-1) || j == 0)
- __throw_runtime_error("locale not supported");
- wbe = wbuf + j;
- __weeks_[i].assign(wbuf, wbe);
- strftime_l(buf, countof(buf), "%a", &t, __loc_);
- mb = mbstate_t();
- bb = buf;
- j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
- if (j == size_t(-1) || j == 0)
- __throw_runtime_error("locale not supported");
- wbe = wbuf + j;
- __weeks_[i+7].assign(wbuf, wbe);
- }
- // __months_
- for (int i = 0; i < 12; ++i)
- {
- t.tm_mon = i;
- strftime_l(buf, countof(buf), "%B", &t, __loc_);
- mb = mbstate_t();
- const char* bb = buf;
- size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
- if (j == size_t(-1) || j == 0)
- __throw_runtime_error("locale not supported");
- wbe = wbuf + j;
- __months_[i].assign(wbuf, wbe);
- strftime_l(buf, countof(buf), "%b", &t, __loc_);
- mb = mbstate_t();
- bb = buf;
- j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
- if (j == size_t(-1) || j == 0)
- __throw_runtime_error("locale not supported");
- wbe = wbuf + j;
- __months_[i+12].assign(wbuf, wbe);
- }
- // __am_pm_
- t.tm_hour = 1;
- strftime_l(buf, countof(buf), "%p", &t, __loc_);
+void __time_get_storage<wchar_t>::init(const ctype<wchar_t>& ct) {
+ tm t = {0};
+ char buf[100];
+ wchar_t wbuf[100];
+ wchar_t* wbe;
+ mbstate_t mb = {0};
+ // __weeks_
+ for (int i = 0; i < 7; ++i) {
+ t.tm_wday = i;
+ strftime_l(buf, countof(buf), "%A", &t, __loc_);
+ mb = mbstate_t();
+ const char* bb = buf;
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1) || j == 0)
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __weeks_[i].assign(wbuf, wbe);
+ strftime_l(buf, countof(buf), "%a", &t, __loc_);
mb = mbstate_t();
+ bb = buf;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1) || j == 0)
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __weeks_[i + 7].assign(wbuf, wbe);
+ }
+ // __months_
+ for (int i = 0; i < 12; ++i) {
+ t.tm_mon = i;
+ strftime_l(buf, countof(buf), "%B", &t, __loc_);
+ mb = mbstate_t();
const char* bb = buf;
- size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
- if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1) || j == 0)
+ __throw_runtime_error("locale not supported");
wbe = wbuf + j;
- __am_pm_[0].assign(wbuf, wbe);
- t.tm_hour = 13;
- strftime_l(buf, countof(buf), "%p", &t, __loc_);
+ __months_[i].assign(wbuf, wbe);
+ strftime_l(buf, countof(buf), "%b", &t, __loc_);
mb = mbstate_t();
bb = buf;
- j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
- if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1) || j == 0)
+ __throw_runtime_error("locale not supported");
wbe = wbuf + j;
- __am_pm_[1].assign(wbuf, wbe);
- __c_ = __analyze('c', ct);
- __r_ = __analyze('r', ct);
- __x_ = __analyze('x', ct);
- __X_ = __analyze('X', ct);
+ __months_[i + 12].assign(wbuf, wbe);
+ }
+ // __am_pm_
+ t.tm_hour = 1;
+ strftime_l(buf, countof(buf), "%p", &t, __loc_);
+ mb = mbstate_t();
+ const char* bb = buf;
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __am_pm_[0].assign(wbuf, wbe);
+ t.tm_hour = 13;
+ strftime_l(buf, countof(buf), "%p", &t, __loc_);
+ mb = mbstate_t();
+ bb = buf;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, __loc_);
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __am_pm_[1].assign(wbuf, wbe);
+ __c_ = __analyze('c', ct);
+ __r_ = __analyze('r', ct);
+ __x_ = __analyze('x', ct);
+ __X_ = __analyze('X', ct);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <class CharT>
-struct _LIBCPP_HIDDEN __time_get_temp
- : public ctype_byname<CharT>
-{
- explicit __time_get_temp(const char* nm)
- : ctype_byname<CharT>(nm, 1) {}
- explicit __time_get_temp(const string& nm)
- : ctype_byname<CharT>(nm, 1) {}
+struct _LIBCPP_HIDDEN __time_get_temp : public ctype_byname<CharT> {
+ explicit __time_get_temp(const char* nm) : ctype_byname<CharT>(nm, 1) {}
+ explicit __time_get_temp(const string& nm) : ctype_byname<CharT>(nm, 1) {}
};
template <>
-__time_get_storage<char>::__time_get_storage(const char* __nm)
- : __time_get(__nm)
-{
- const __time_get_temp<char> ct(__nm);
- init(ct);
+__time_get_storage<char>::__time_get_storage(const char* __nm) : __time_get(__nm) {
+ const __time_get_temp<char> ct(__nm);
+ init(ct);
}
template <>
-__time_get_storage<char>::__time_get_storage(const string& __nm)
- : __time_get(__nm)
-{
- const __time_get_temp<char> ct(__nm);
- init(ct);
+__time_get_storage<char>::__time_get_storage(const string& __nm) : __time_get(__nm) {
+ const __time_get_temp<char> ct(__nm);
+ init(ct);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-__time_get_storage<wchar_t>::__time_get_storage(const char* __nm)
- : __time_get(__nm)
-{
- const __time_get_temp<wchar_t> ct(__nm);
- init(ct);
+__time_get_storage<wchar_t>::__time_get_storage(const char* __nm) : __time_get(__nm) {
+ const __time_get_temp<wchar_t> ct(__nm);
+ init(ct);
}
template <>
-__time_get_storage<wchar_t>::__time_get_storage(const string& __nm)
- : __time_get(__nm)
-{
- const __time_get_temp<wchar_t> ct(__nm);
- init(ct);
+__time_get_storage<wchar_t>::__time_get_storage(const string& __nm) : __time_get(__nm) {
+ const __time_get_temp<wchar_t> ct(__nm);
+ init(ct);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-time_base::dateorder
-__time_get_storage<char>::__do_date_order() const
-{
- unsigned i;
- for (i = 0; i < __x_.size(); ++i)
- if (__x_[i] == '%')
- break;
- ++i;
- switch (__x_[i])
- {
- case 'y':
- case 'Y':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == '%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- switch (__x_[i])
- {
- case 'm':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == '%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == 'd')
- return time_base::ymd;
- break;
- case 'd':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == '%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == 'm')
- return time_base::ydm;
- break;
- }
+time_base::dateorder __time_get_storage<char>::__do_date_order() const {
+ unsigned i;
+ for (i = 0; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ ++i;
+ switch (__x_[i]) {
+ case 'y':
+ case 'Y':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ switch (__x_[i]) {
case 'm':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == '%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == 'd')
- {
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == '%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == 'y' || __x_[i] == 'Y')
- return time_base::mdy;
- break;
- }
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
break;
+ ++i;
+ if (__x_[i] == 'd')
+ return time_base::ymd;
+ break;
case 'd':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == '%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == 'm')
- {
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == '%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == 'y' || __x_[i] == 'Y')
- return time_base::dmy;
- break;
- }
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'm')
+ return time_base::ydm;
+ break;
+ }
+ break;
+ case 'm':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'd') {
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'y' || __x_[i] == 'Y')
+ return time_base::mdy;
+ break;
+ }
+ break;
+ case 'd':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'm') {
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == '%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == 'y' || __x_[i] == 'Y')
+ return time_base::dmy;
+ break;
}
- return time_base::no_order;
+ break;
+ }
+ return time_base::no_order;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
-time_base::dateorder
-__time_get_storage<wchar_t>::__do_date_order() const
-{
- unsigned i;
- for (i = 0; i < __x_.size(); ++i)
- if (__x_[i] == L'%')
- break;
- ++i;
- switch (__x_[i])
- {
- case L'y':
- case L'Y':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == L'%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- switch (__x_[i])
- {
- case L'm':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == L'%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == L'd')
- return time_base::ymd;
- break;
- case L'd':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == L'%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == L'm')
- return time_base::ydm;
- break;
- }
+time_base::dateorder __time_get_storage<wchar_t>::__do_date_order() const {
+ unsigned i;
+ for (i = 0; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ ++i;
+ switch (__x_[i]) {
+ case L'y':
+ case L'Y':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ switch (__x_[i]) {
case L'm':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == L'%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == L'd')
- {
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == L'%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == L'y' || __x_[i] == L'Y')
- return time_base::mdy;
- break;
- }
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
break;
+ ++i;
+ if (__x_[i] == L'd')
+ return time_base::ymd;
+ break;
case L'd':
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == L'%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == L'm')
- {
- for (++i; i < __x_.size(); ++i)
- if (__x_[i] == L'%')
- break;
- if (i == __x_.size())
- break;
- ++i;
- if (__x_[i] == L'y' || __x_[i] == L'Y')
- return time_base::dmy;
- break;
- }
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'm')
+ return time_base::ydm;
+ break;
+ }
+ break;
+ case L'm':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'd') {
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'y' || __x_[i] == L'Y')
+ return time_base::mdy;
+ break;
}
- return time_base::no_order;
+ break;
+ case L'd':
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'm') {
+ for (++i; i < __x_.size(); ++i)
+ if (__x_[i] == L'%')
+ break;
+ if (i == __x_.size())
+ break;
+ ++i;
+ if (__x_[i] == L'y' || __x_[i] == L'Y')
+ return time_base::dmy;
+ break;
+ }
+ break;
+ }
+ return time_base::no_order;
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// time_put
-__time_put::__time_put(const char* nm)
- : __loc_(newlocale(LC_ALL_MASK, nm, 0))
-{
- if (__loc_ == 0)
- __throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str());
+__time_put::__time_put(const char* nm) : __loc_(newlocale(LC_ALL_MASK, nm, 0)) {
+ if (__loc_ == 0)
+ __throw_runtime_error(("time_put_byname failed to construct for " + string(nm)).c_str());
}
-__time_put::__time_put(const string& nm)
- : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0))
-{
- if (__loc_ == 0)
- __throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str());
+__time_put::__time_put(const string& nm) : __loc_(newlocale(LC_ALL_MASK, nm.c_str(), 0)) {
+ if (__loc_ == 0)
+ __throw_runtime_error(("time_put_byname failed to construct for " + nm).c_str());
}
-__time_put::~__time_put()
-{
- if (__loc_ != _LIBCPP_GET_C_LOCALE)
- freelocale(__loc_);
+__time_put::~__time_put() {
+ if (__loc_ != _LIBCPP_GET_C_LOCALE)
+ freelocale(__loc_);
}
-void
-__time_put::__do_put(char* __nb, char*& __ne, const tm* __tm,
- char __fmt, char __mod) const
-{
- char fmt[] = {'%', __fmt, __mod, 0};
- if (__mod != 0)
- swap(fmt[1], fmt[2]);
- size_t n = strftime_l(__nb, countof(__nb, __ne), fmt, __tm, __loc_);
- __ne = __nb + n;
+void __time_put::__do_put(char* __nb, char*& __ne, const tm* __tm, char __fmt, char __mod) const {
+ char fmt[] = {'%', __fmt, __mod, 0};
+ if (__mod != 0)
+ swap(fmt[1], fmt[2]);
+ size_t n = strftime_l(__nb, countof(__nb, __ne), fmt, __tm, __loc_);
+ __ne = __nb + n;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-void
-__time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm,
- char __fmt, char __mod) const
-{
- char __nar[100];
- char* __ne = __nar + 100;
- __do_put(__nar, __ne, __tm, __fmt, __mod);
- mbstate_t mb = {0};
- const char* __nb = __nar;
- size_t j = __libcpp_mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
- if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
- __we = __wb + j;
+void __time_put::__do_put(wchar_t* __wb, wchar_t*& __we, const tm* __tm, char __fmt, char __mod) const {
+ char __nar[100];
+ char* __ne = __nar + 100;
+ __do_put(__nar, __ne, __tm, __fmt, __mod);
+ mbstate_t mb = {0};
+ const char* __nb = __nar;
+ size_t j = __libcpp_mbsrtowcs_l(__wb, &__nb, countof(__wb, __we), &mb, __loc_);
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ __we = __wb + j;
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// moneypunct_byname
template <class charT>
-static
-void
-__init_pat(money_base::pattern& pat, basic_string<charT>& __curr_symbol_,
- bool intl, char cs_precedes, char sep_by_space, char sign_posn,
- charT space_char)
-{
- const char sign = static_cast<char>(money_base::sign);
- const char space = static_cast<char>(money_base::space);
- const char none = static_cast<char>(money_base::none);
- const char symbol = static_cast<char>(money_base::symbol);
- const char value = static_cast<char>(money_base::value);
- const bool symbol_contains_sep = intl && __curr_symbol_.size() == 4;
-
- // Comments on case branches reflect 'C11 7.11.2.1 The localeconv
- // function'. "Space between sign and symbol or value" means that
- // if the sign is adjacent to the symbol, there's a space between
- // them, and otherwise there's a space between the sign and value.
- //
- // C11's localeconv specifies that the fourth character of an
- // international curr_symbol is used to separate the sign and
- // value when sep_by_space says to do so. C++ can't represent
- // that, so we just use a space. When sep_by_space says to
- // separate the symbol and value-or-sign with a space, we rearrange the
- // curr_symbol to put its spacing character on the correct side of
- // the symbol.
- //
- // We also need to avoid adding an extra space between the sign
- // and value when the currency symbol is suppressed (by not
- // setting showbase). We match glibc's strfmon by interpreting
- // sep_by_space==1 as "omit the space when the currency symbol is
- // absent".
- //
- // Users who want to get this right should use ICU instead.
-
- switch (cs_precedes)
- {
- case 0: // value before curr_symbol
+static void __init_pat(
+ money_base::pattern& pat,
+ basic_string<charT>& __curr_symbol_,
+ bool intl,
+ char cs_precedes,
+ char sep_by_space,
+ char sign_posn,
+ charT space_char) {
+ const char sign = static_cast<char>(money_base::sign);
+ const char space = static_cast<char>(money_base::space);
+ const char none = static_cast<char>(money_base::none);
+ const char symbol = static_cast<char>(money_base::symbol);
+ const char value = static_cast<char>(money_base::value);
+ const bool symbol_contains_sep = intl && __curr_symbol_.size() == 4;
+
+ // Comments on case branches reflect 'C11 7.11.2.1 The localeconv
+ // function'. "Space between sign and symbol or value" means that
+ // if the sign is adjacent to the symbol, there's a space between
+ // them, and otherwise there's a space between the sign and value.
+ //
+ // C11's localeconv specifies that the fourth character of an
+ // international curr_symbol is used to separate the sign and
+ // value when sep_by_space says to do so. C++ can't represent
+ // that, so we just use a space. When sep_by_space says to
+ // separate the symbol and value-or-sign with a space, we rearrange the
+ // curr_symbol to put its spacing character on the correct side of
+ // the symbol.
+ //
+ // We also need to avoid adding an extra space between the sign
+ // and value when the currency symbol is suppressed (by not
+ // setting showbase). We match glibc's strfmon by interpreting
+ // sep_by_space==1 as "omit the space when the currency symbol is
+ // absent".
+ //
+ // Users who want to get this right should use ICU instead.
+
+ switch (cs_precedes) {
+ case 0: // value before curr_symbol
+ if (symbol_contains_sep) {
+ // Move the separator to before the symbol, to place it
+ // between the value and symbol.
+ rotate(__curr_symbol_.begin(), __curr_symbol_.begin() + 3, __curr_symbol_.end());
+ }
+ switch (sign_posn) {
+ case 0: // Parentheses surround the quantity and currency symbol.
+ pat.field[0] = sign;
+ pat.field[1] = value;
+ pat.field[2] = none; // Any space appears in the symbol.
+ pat.field[3] = symbol;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ // This case may have changed between C99 and C11;
+ // assume the currency symbol matches the intention.
+ case 2: // Space between sign and currency or value.
+ // The "sign" is two parentheses, so no space here either.
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 1: // The sign string precedes the quantity and currency symbol.
+ pat.field[0] = sign;
+ pat.field[3] = symbol;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = value;
+ pat.field[2] = none;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = value;
+ pat.field[2] = none;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = space;
+ pat.field[2] = value;
if (symbol_contains_sep) {
- // Move the separator to before the symbol, to place it
- // between the value and symbol.
- rotate(__curr_symbol_.begin(), __curr_symbol_.begin() + 3,
- __curr_symbol_.end());
+ // Remove the separator from the symbol, since it
+ // has already appeared after the sign.
+ __curr_symbol_.erase(__curr_symbol_.begin());
}
- switch (sign_posn)
- {
- case 0: // Parentheses surround the quantity and currency symbol.
- pat.field[0] = sign;
- pat.field[1] = value;
- pat.field[2] = none; // Any space appears in the symbol.
- pat.field[3] = symbol;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- // This case may have changed between C99 and C11;
- // assume the currency symbol matches the intention.
- case 2: // Space between sign and currency or value.
- // The "sign" is two parentheses, so no space here either.
- return;
- case 1: // Space between currency-and-sign or currency and value.
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[2]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.insert((size_t)0, 1, space_char);
- }
- return;
- default:
- break;
- }
- break;
- case 1: // The sign string precedes the quantity and currency symbol.
- pat.field[0] = sign;
- pat.field[3] = symbol;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- pat.field[1] = value;
- pat.field[2] = none;
- return;
- case 1: // Space between currency-and-sign or currency and value.
- pat.field[1] = value;
- pat.field[2] = none;
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[2]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.insert((size_t)0, 1, space_char);
- }
- return;
- case 2: // Space between sign and currency or value.
- pat.field[1] = space;
- pat.field[2] = value;
- if (symbol_contains_sep) {
- // Remove the separator from the symbol, since it
- // has already appeared after the sign.
- __curr_symbol_.erase(__curr_symbol_.begin());
- }
- return;
- default:
- break;
- }
- break;
- case 2: // The sign string succeeds the quantity and currency symbol.
- pat.field[0] = value;
- pat.field[3] = sign;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- pat.field[1] = none;
- pat.field[2] = symbol;
- return;
- case 1: // Space between currency-and-sign or currency and value.
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[1]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.insert((size_t)0, 1, space_char);
- }
- pat.field[1] = none;
- pat.field[2] = symbol;
- return;
- case 2: // Space between sign and currency or value.
- pat.field[1] = symbol;
- pat.field[2] = space;
- if (symbol_contains_sep) {
- // Remove the separator from the symbol, since it
- // should not be removed if showbase is absent.
- __curr_symbol_.erase(__curr_symbol_.begin());
- }
- return;
- default:
- break;
- }
- break;
- case 3: // The sign string immediately precedes the currency symbol.
- pat.field[0] = value;
- pat.field[3] = symbol;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- pat.field[1] = none;
- pat.field[2] = sign;
- return;
- case 1: // Space between currency-and-sign or currency and value.
- pat.field[1] = space;
- pat.field[2] = sign;
- if (symbol_contains_sep) {
- // Remove the separator from the symbol, since it
- // has already appeared before the sign.
- __curr_symbol_.erase(__curr_symbol_.begin());
- }
- return;
- case 2: // Space between sign and currency or value.
- pat.field[1] = sign;
- pat.field[2] = none;
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[2]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.insert((size_t)0, 1, space_char);
- }
- return;
- default:
- break;
- }
- break;
- case 4: // The sign string immediately succeeds the currency symbol.
- pat.field[0] = value;
- pat.field[3] = sign;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- pat.field[1] = none;
- pat.field[2] = symbol;
- return;
- case 1: // Space between currency-and-sign or currency and value.
- pat.field[1] = none;
- pat.field[2] = symbol;
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[1]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.insert((size_t)0, 1, space_char);
- }
- return;
- case 2: // Space between sign and currency or value.
- pat.field[1] = symbol;
- pat.field[2] = space;
- if (symbol_contains_sep) {
- // Remove the separator from the symbol, since it
- // should not disappear when showbase is absent.
- __curr_symbol_.erase(__curr_symbol_.begin());
- }
- return;
- default:
- break;
- }
- break;
- default:
- break;
+ return;
+ default:
+ break;
+ }
+ break;
+ case 2: // The sign string succeeds the quantity and currency symbol.
+ pat.field[0] = value;
+ pat.field[3] = sign;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = none;
+ pat.field[2] = symbol;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[1]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
}
+ pat.field[1] = none;
+ pat.field[2] = symbol;
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = symbol;
+ pat.field[2] = space;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // should not be removed if showbase is absent.
+ __curr_symbol_.erase(__curr_symbol_.begin());
+ }
+ return;
+ default:
break;
- case 1: // curr_symbol before value
- switch (sign_posn)
- {
- case 0: // Parentheses surround the quantity and currency symbol.
- pat.field[0] = sign;
- pat.field[1] = symbol;
- pat.field[2] = none; // Any space appears in the symbol.
- pat.field[3] = value;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- // This case may have changed between C99 and C11;
- // assume the currency symbol matches the intention.
- case 2: // Space between sign and currency or value.
- // The "sign" is two parentheses, so no space here either.
- return;
- case 1: // Space between currency-and-sign or currency and value.
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[2]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.insert((size_t)0, 1, space_char);
- }
- return;
- default:
- break;
- }
- break;
- case 1: // The sign string precedes the quantity and currency symbol.
- pat.field[0] = sign;
- pat.field[3] = value;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- pat.field[1] = symbol;
- pat.field[2] = none;
- return;
- case 1: // Space between currency-and-sign or currency and value.
- pat.field[1] = symbol;
- pat.field[2] = none;
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[2]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.push_back(space_char);
- }
- return;
- case 2: // Space between sign and currency or value.
- pat.field[1] = space;
- pat.field[2] = symbol;
- if (symbol_contains_sep) {
- // Remove the separator from the symbol, since it
- // has already appeared after the sign.
- __curr_symbol_.pop_back();
- }
- return;
- default:
- break;
- }
- break;
- case 2: // The sign string succeeds the quantity and currency symbol.
- pat.field[0] = symbol;
- pat.field[3] = sign;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- pat.field[1] = none;
- pat.field[2] = value;
- return;
- case 1: // Space between currency-and-sign or currency and value.
- pat.field[1] = none;
- pat.field[2] = value;
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[1]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.push_back(space_char);
- }
- return;
- case 2: // Space between sign and currency or value.
- pat.field[1] = value;
- pat.field[2] = space;
- if (symbol_contains_sep) {
- // Remove the separator from the symbol, since it
- // will appear before the sign.
- __curr_symbol_.pop_back();
- }
- return;
- default:
- break;
- }
- break;
- case 3: // The sign string immediately precedes the currency symbol.
- pat.field[0] = sign;
- pat.field[3] = value;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- pat.field[1] = symbol;
- pat.field[2] = none;
- return;
- case 1: // Space between currency-and-sign or currency and value.
- pat.field[1] = symbol;
- pat.field[2] = none;
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[2]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.push_back(space_char);
- }
- return;
- case 2: // Space between sign and currency or value.
- pat.field[1] = space;
- pat.field[2] = symbol;
- if (symbol_contains_sep) {
- // Remove the separator from the symbol, since it
- // has already appeared after the sign.
- __curr_symbol_.pop_back();
- }
- return;
- default:
- break;
- }
- break;
- case 4: // The sign string immediately succeeds the currency symbol.
- pat.field[0] = symbol;
- pat.field[3] = value;
- switch (sep_by_space)
- {
- case 0: // No space separates the currency symbol and value.
- pat.field[1] = sign;
- pat.field[2] = none;
- return;
- case 1: // Space between currency-and-sign or currency and value.
- pat.field[1] = sign;
- pat.field[2] = space;
- if (symbol_contains_sep) {
- // Remove the separator from the symbol, since it
- // should not disappear when showbase is absent.
- __curr_symbol_.pop_back();
- }
- return;
- case 2: // Space between sign and currency or value.
- pat.field[1] = none;
- pat.field[2] = sign;
- if (!symbol_contains_sep) {
- // We insert the space into the symbol instead of
- // setting pat.field[1]=space so that when
- // showbase is not set, the space goes away too.
- __curr_symbol_.push_back(space_char);
- }
- return;
- default:
- break;
- }
- break;
- default:
- break;
+ }
+ break;
+ case 3: // The sign string immediately precedes the currency symbol.
+ pat.field[0] = value;
+ pat.field[3] = symbol;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = none;
+ pat.field[2] = sign;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = space;
+ pat.field[2] = sign;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // has already appeared before the sign.
+ __curr_symbol_.erase(__curr_symbol_.begin());
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = sign;
+ pat.field[2] = none;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 4: // The sign string immediately succeeds the currency symbol.
+ pat.field[0] = value;
+ pat.field[3] = sign;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = none;
+ pat.field[2] = symbol;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = none;
+ pat.field[2] = symbol;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[1]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = symbol;
+ pat.field[2] = space;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // should not disappear when showbase is absent.
+ __curr_symbol_.erase(__curr_symbol_.begin());
}
+ return;
+ default:
break;
+ }
+ break;
default:
+ break;
+ }
+ break;
+ case 1: // curr_symbol before value
+ switch (sign_posn) {
+ case 0: // Parentheses surround the quantity and currency symbol.
+ pat.field[0] = sign;
+ pat.field[1] = symbol;
+ pat.field[2] = none; // Any space appears in the symbol.
+ pat.field[3] = value;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ // This case may have changed between C99 and C11;
+ // assume the currency symbol matches the intention.
+ case 2: // Space between sign and currency or value.
+ // The "sign" is two parentheses, so no space here either.
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.insert((size_t)0, 1, space_char);
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 1: // The sign string precedes the quantity and currency symbol.
+ pat.field[0] = sign;
+ pat.field[3] = value;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = symbol;
+ pat.field[2] = none;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = symbol;
+ pat.field[2] = none;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.push_back(space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = space;
+ pat.field[2] = symbol;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // has already appeared after the sign.
+ __curr_symbol_.pop_back();
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 2: // The sign string succeeds the quantity and currency symbol.
+ pat.field[0] = symbol;
+ pat.field[3] = sign;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = none;
+ pat.field[2] = value;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = none;
+ pat.field[2] = value;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[1]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.push_back(space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = value;
+ pat.field[2] = space;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // will appear before the sign.
+ __curr_symbol_.pop_back();
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ case 3: // The sign string immediately precedes the currency symbol.
+ pat.field[0] = sign;
+ pat.field[3] = value;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = symbol;
+ pat.field[2] = none;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = symbol;
+ pat.field[2] = none;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[2]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.push_back(space_char);
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = space;
+ pat.field[2] = symbol;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // has already appeared after the sign.
+ __curr_symbol_.pop_back();
+ }
+ return;
+ default:
break;
+ }
+ break;
+ case 4: // The sign string immediately succeeds the currency symbol.
+ pat.field[0] = symbol;
+ pat.field[3] = value;
+ switch (sep_by_space) {
+ case 0: // No space separates the currency symbol and value.
+ pat.field[1] = sign;
+ pat.field[2] = none;
+ return;
+ case 1: // Space between currency-and-sign or currency and value.
+ pat.field[1] = sign;
+ pat.field[2] = space;
+ if (symbol_contains_sep) {
+ // Remove the separator from the symbol, since it
+ // should not disappear when showbase is absent.
+ __curr_symbol_.pop_back();
+ }
+ return;
+ case 2: // Space between sign and currency or value.
+ pat.field[1] = none;
+ pat.field[2] = sign;
+ if (!symbol_contains_sep) {
+ // We insert the space into the symbol instead of
+ // setting pat.field[1]=space so that when
+ // showbase is not set, the space goes away too.
+ __curr_symbol_.push_back(space_char);
+ }
+ return;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
}
- pat.field[0] = symbol;
- pat.field[1] = sign;
- pat.field[2] = none;
- pat.field[3] = value;
+ break;
+ default:
+ break;
+ }
+ pat.field[0] = symbol;
+ pat.field[1] = sign;
+ pat.field[2] = none;
+ pat.field[3] = value;
}
-template<>
-void
-moneypunct_byname<char, false>::init(const char* nm)
-{
- typedef moneypunct<char, false> base;
- __libcpp_unique_locale loc(nm);
- if (!loc)
- __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
-
- lconv* lc = __libcpp_localeconv_l(loc.get());
- if (!checked_string_to_char_convert(__decimal_point_,
- lc->mon_decimal_point,
- loc.get()))
- __decimal_point_ = base::do_decimal_point();
- if (!checked_string_to_char_convert(__thousands_sep_,
- lc->mon_thousands_sep,
- loc.get()))
- __thousands_sep_ = base::do_thousands_sep();
-
- __grouping_ = lc->mon_grouping;
- __curr_symbol_ = lc->currency_symbol;
- if (lc->frac_digits != CHAR_MAX)
- __frac_digits_ = lc->frac_digits;
- else
- __frac_digits_ = base::do_frac_digits();
- if (lc->p_sign_posn == 0)
- __positive_sign_ = "()";
- else
- __positive_sign_ = lc->positive_sign;
- if (lc->n_sign_posn == 0)
- __negative_sign_ = "()";
- else
- __negative_sign_ = lc->negative_sign;
- // Assume the positive and negative formats will want spaces in
- // the same places in curr_symbol since there's no way to
- // represent anything else.
- string_type __dummy_curr_symbol = __curr_symbol_;
- __init_pat(__pos_format_, __dummy_curr_symbol, false,
- lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
- __init_pat(__neg_format_, __curr_symbol_, false,
- lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
-}
-
-template<>
-void
-moneypunct_byname<char, true>::init(const char* nm)
-{
- typedef moneypunct<char, true> base;
- __libcpp_unique_locale loc(nm);
- if (!loc)
- __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
+template <>
+void moneypunct_byname<char, false>::init(const char* nm) {
+ typedef moneypunct<char, false> base;
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_char_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+
+ __grouping_ = lc->mon_grouping;
+ __curr_symbol_ = lc->currency_symbol;
+ if (lc->frac_digits != CHAR_MAX)
+ __frac_digits_ = lc->frac_digits;
+ else
+ __frac_digits_ = base::do_frac_digits();
+ if (lc->p_sign_posn == 0)
+ __positive_sign_ = "()";
+ else
+ __positive_sign_ = lc->positive_sign;
+ if (lc->n_sign_posn == 0)
+ __negative_sign_ = "()";
+ else
+ __negative_sign_ = lc->negative_sign;
+ // Assume the positive and negative formats will want spaces in
+ // the same places in curr_symbol since there's no way to
+ // represent anything else.
+ string_type __dummy_curr_symbol = __curr_symbol_;
+ __init_pat(__pos_format_, __dummy_curr_symbol, false, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
+ __init_pat(__neg_format_, __curr_symbol_, false, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
+}
- lconv* lc = __libcpp_localeconv_l(loc.get());
- if (!checked_string_to_char_convert(__decimal_point_,
- lc->mon_decimal_point,
- loc.get()))
- __decimal_point_ = base::do_decimal_point();
- if (!checked_string_to_char_convert(__thousands_sep_,
- lc->mon_thousands_sep,
- loc.get()))
- __thousands_sep_ = base::do_thousands_sep();
- __grouping_ = lc->mon_grouping;
- __curr_symbol_ = lc->int_curr_symbol;
- if (lc->int_frac_digits != CHAR_MAX)
- __frac_digits_ = lc->int_frac_digits;
- else
- __frac_digits_ = base::do_frac_digits();
+template <>
+void moneypunct_byname<char, true>::init(const char* nm) {
+ typedef moneypunct<char, true> base;
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_char_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_char_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+ __grouping_ = lc->mon_grouping;
+ __curr_symbol_ = lc->int_curr_symbol;
+ if (lc->int_frac_digits != CHAR_MAX)
+ __frac_digits_ = lc->int_frac_digits;
+ else
+ __frac_digits_ = base::do_frac_digits();
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
- if (lc->p_sign_posn == 0)
-#else // _LIBCPP_MSVCRT
- if (lc->int_p_sign_posn == 0)
+ if (lc->p_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+ if (lc->int_p_sign_posn == 0)
#endif // !_LIBCPP_MSVCRT
- __positive_sign_ = "()";
- else
- __positive_sign_ = lc->positive_sign;
+ __positive_sign_ = "()";
+ else
+ __positive_sign_ = lc->positive_sign;
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
- if(lc->n_sign_posn == 0)
-#else // _LIBCPP_MSVCRT
- if (lc->int_n_sign_posn == 0)
+ if (lc->n_sign_posn == 0)
+#else // _LIBCPP_MSVCRT
+ if (lc->int_n_sign_posn == 0)
#endif // !_LIBCPP_MSVCRT
- __negative_sign_ = "()";
- else
- __negative_sign_ = lc->negative_sign;
- // Assume the positive and negative formats will want spaces in
- // the same places in curr_symbol since there's no way to
- // represent anything else.
- string_type __dummy_curr_symbol = __curr_symbol_;
+ __negative_sign_ = "()";
+ else
+ __negative_sign_ = lc->negative_sign;
+ // Assume the positive and negative formats will want spaces in
+ // the same places in curr_symbol since there's no way to
+ // represent anything else.
+ string_type __dummy_curr_symbol = __curr_symbol_;
#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
- __init_pat(__pos_format_, __dummy_curr_symbol, true,
- lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
- __init_pat(__neg_format_, __curr_symbol_, true,
- lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
-#else // _LIBCPP_MSVCRT
- __init_pat(__pos_format_, __dummy_curr_symbol, true,
- lc->int_p_cs_precedes, lc->int_p_sep_by_space,
- lc->int_p_sign_posn, ' ');
- __init_pat(__neg_format_, __curr_symbol_, true,
- lc->int_n_cs_precedes, lc->int_n_sep_by_space,
- lc->int_n_sign_posn, ' ');
+ __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, ' ');
+ __init_pat(__neg_format_, __curr_symbol_, true, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, ' ');
+#else // _LIBCPP_MSVCRT
+ __init_pat(
+ __pos_format_,
+ __dummy_curr_symbol,
+ true,
+ lc->int_p_cs_precedes,
+ lc->int_p_sep_by_space,
+ lc->int_p_sign_posn,
+ ' ');
+ __init_pat(
+ __neg_format_, __curr_symbol_, true, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn, ' ');
#endif // !_LIBCPP_MSVCRT
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template<>
-void
-moneypunct_byname<wchar_t, false>::init(const char* nm)
-{
- typedef moneypunct<wchar_t, false> base;
- __libcpp_unique_locale loc(nm);
- if (!loc)
- __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
- lconv* lc = __libcpp_localeconv_l(loc.get());
- if (!checked_string_to_wchar_convert(__decimal_point_,
- lc->mon_decimal_point,
- loc.get()))
- __decimal_point_ = base::do_decimal_point();
- if (!checked_string_to_wchar_convert(__thousands_sep_,
- lc->mon_thousands_sep,
- loc.get()))
- __thousands_sep_ = base::do_thousands_sep();
- __grouping_ = lc->mon_grouping;
- wchar_t wbuf[100];
- mbstate_t mb = {0};
- const char* bb = lc->currency_symbol;
- size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+template <>
+void moneypunct_byname<wchar_t, false>::init(const char* nm) {
+ typedef moneypunct<wchar_t, false> base;
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_wchar_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+ __grouping_ = lc->mon_grouping;
+ wchar_t wbuf[100];
+ mbstate_t mb = {0};
+ const char* bb = lc->currency_symbol;
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wchar_t* wbe = wbuf + j;
+ __curr_symbol_.assign(wbuf, wbe);
+ if (lc->frac_digits != CHAR_MAX)
+ __frac_digits_ = lc->frac_digits;
+ else
+ __frac_digits_ = base::do_frac_digits();
+ if (lc->p_sign_posn == 0)
+ __positive_sign_ = L"()";
+ else {
+ mb = mbstate_t();
+ bb = lc->positive_sign;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
- wchar_t* wbe = wbuf + j;
- __curr_symbol_.assign(wbuf, wbe);
- if (lc->frac_digits != CHAR_MAX)
- __frac_digits_ = lc->frac_digits;
- else
- __frac_digits_ = base::do_frac_digits();
- if (lc->p_sign_posn == 0)
- __positive_sign_ = L"()";
- else
- {
- mb = mbstate_t();
- bb = lc->positive_sign;
- j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
- if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
- wbe = wbuf + j;
- __positive_sign_.assign(wbuf, wbe);
- }
- if (lc->n_sign_posn == 0)
- __negative_sign_ = L"()";
- else
- {
- mb = mbstate_t();
- bb = lc->negative_sign;
- j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
- if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
- wbe = wbuf + j;
- __negative_sign_.assign(wbuf, wbe);
- }
- // Assume the positive and negative formats will want spaces in
- // the same places in curr_symbol since there's no way to
- // represent anything else.
- string_type __dummy_curr_symbol = __curr_symbol_;
- __init_pat(__pos_format_, __dummy_curr_symbol, false,
- lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
- __init_pat(__neg_format_, __curr_symbol_, false,
- lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
-}
-
-template<>
-void
-moneypunct_byname<wchar_t, true>::init(const char* nm)
-{
- typedef moneypunct<wchar_t, true> base;
- __libcpp_unique_locale loc(nm);
- if (!loc)
- __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __positive_sign_.assign(wbuf, wbe);
+ }
+ if (lc->n_sign_posn == 0)
+ __negative_sign_ = L"()";
+ else {
+ mb = mbstate_t();
+ bb = lc->negative_sign;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __negative_sign_.assign(wbuf, wbe);
+ }
+ // Assume the positive and negative formats will want spaces in
+ // the same places in curr_symbol since there's no way to
+ // represent anything else.
+ string_type __dummy_curr_symbol = __curr_symbol_;
+ __init_pat(__pos_format_, __dummy_curr_symbol, false, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
+ __init_pat(__neg_format_, __curr_symbol_, false, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
+}
- lconv* lc = __libcpp_localeconv_l(loc.get());
- if (!checked_string_to_wchar_convert(__decimal_point_,
- lc->mon_decimal_point,
- loc.get()))
- __decimal_point_ = base::do_decimal_point();
- if (!checked_string_to_wchar_convert(__thousands_sep_,
- lc->mon_thousands_sep,
- loc.get()))
- __thousands_sep_ = base::do_thousands_sep();
- __grouping_ = lc->mon_grouping;
- wchar_t wbuf[100];
- mbstate_t mb = {0};
- const char* bb = lc->int_curr_symbol;
- size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+template <>
+void moneypunct_byname<wchar_t, true>::init(const char* nm) {
+ typedef moneypunct<wchar_t, true> base;
+ __libcpp_unique_locale loc(nm);
+ if (!loc)
+ __throw_runtime_error(("moneypunct_byname failed to construct for " + string(nm)).c_str());
+
+ lconv* lc = __libcpp_localeconv_l(loc.get());
+ if (!checked_string_to_wchar_convert(__decimal_point_, lc->mon_decimal_point, loc.get()))
+ __decimal_point_ = base::do_decimal_point();
+ if (!checked_string_to_wchar_convert(__thousands_sep_, lc->mon_thousands_sep, loc.get()))
+ __thousands_sep_ = base::do_thousands_sep();
+ __grouping_ = lc->mon_grouping;
+ wchar_t wbuf[100];
+ mbstate_t mb = {0};
+ const char* bb = lc->int_curr_symbol;
+ size_t j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wchar_t* wbe = wbuf + j;
+ __curr_symbol_.assign(wbuf, wbe);
+ if (lc->int_frac_digits != CHAR_MAX)
+ __frac_digits_ = lc->int_frac_digits;
+ else
+ __frac_digits_ = base::do_frac_digits();
+# if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ if (lc->p_sign_posn == 0)
+# else // _LIBCPP_MSVCRT
+ if (lc->int_p_sign_posn == 0)
+# endif // !_LIBCPP_MSVCRT
+ __positive_sign_ = L"()";
+ else {
+ mb = mbstate_t();
+ bb = lc->positive_sign;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
- wchar_t* wbe = wbuf + j;
- __curr_symbol_.assign(wbuf, wbe);
- if (lc->int_frac_digits != CHAR_MAX)
- __frac_digits_ = lc->int_frac_digits;
- else
- __frac_digits_ = base::do_frac_digits();
-#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
- if (lc->p_sign_posn == 0)
-#else // _LIBCPP_MSVCRT
- if (lc->int_p_sign_posn == 0)
-#endif // !_LIBCPP_MSVCRT
- __positive_sign_ = L"()";
- else
- {
- mb = mbstate_t();
- bb = lc->positive_sign;
- j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
- if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
- wbe = wbuf + j;
- __positive_sign_.assign(wbuf, wbe);
- }
-#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
- if (lc->n_sign_posn == 0)
-#else // _LIBCPP_MSVCRT
- if (lc->int_n_sign_posn == 0)
-#endif // !_LIBCPP_MSVCRT
- __negative_sign_ = L"()";
- else
- {
- mb = mbstate_t();
- bb = lc->negative_sign;
- j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
- if (j == size_t(-1))
- __throw_runtime_error("locale not supported");
- wbe = wbuf + j;
- __negative_sign_.assign(wbuf, wbe);
- }
- // Assume the positive and negative formats will want spaces in
- // the same places in curr_symbol since there's no way to
- // represent anything else.
- string_type __dummy_curr_symbol = __curr_symbol_;
-#if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
- __init_pat(__pos_format_, __dummy_curr_symbol, true,
- lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
- __init_pat(__neg_format_, __curr_symbol_, true,
- lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
-#else // _LIBCPP_MSVCRT
- __init_pat(__pos_format_, __dummy_curr_symbol, true,
- lc->int_p_cs_precedes, lc->int_p_sep_by_space,
- lc->int_p_sign_posn, L' ');
- __init_pat(__neg_format_, __curr_symbol_, true,
- lc->int_n_cs_precedes, lc->int_n_sep_by_space,
- lc->int_n_sign_posn, L' ');
-#endif // !_LIBCPP_MSVCRT
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __positive_sign_.assign(wbuf, wbe);
+ }
+# if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ if (lc->n_sign_posn == 0)
+# else // _LIBCPP_MSVCRT
+ if (lc->int_n_sign_posn == 0)
+# endif // !_LIBCPP_MSVCRT
+ __negative_sign_ = L"()";
+ else {
+ mb = mbstate_t();
+ bb = lc->negative_sign;
+ j = __libcpp_mbsrtowcs_l(wbuf, &bb, countof(wbuf), &mb, loc.get());
+ if (j == size_t(-1))
+ __throw_runtime_error("locale not supported");
+ wbe = wbuf + j;
+ __negative_sign_.assign(wbuf, wbe);
+ }
+ // Assume the positive and negative formats will want spaces in
+ // the same places in curr_symbol since there's no way to
+ // represent anything else.
+ string_type __dummy_curr_symbol = __curr_symbol_;
+# if defined(_LIBCPP_MSVCRT) || defined(__MINGW32__)
+ __init_pat(__pos_format_, __dummy_curr_symbol, true, lc->p_cs_precedes, lc->p_sep_by_space, lc->p_sign_posn, L' ');
+ __init_pat(__neg_format_, __curr_symbol_, true, lc->n_cs_precedes, lc->n_sep_by_space, lc->n_sign_posn, L' ');
+# else // _LIBCPP_MSVCRT
+ __init_pat(
+ __pos_format_,
+ __dummy_curr_symbol,
+ true,
+ lc->int_p_cs_precedes,
+ lc->int_p_sep_by_space,
+ lc->int_p_sign_posn,
+ L' ');
+ __init_pat(
+ __neg_format_, __curr_symbol_, true, lc->int_n_cs_precedes, lc->int_n_sep_by_space, lc->int_n_sign_posn, L' ');
+# endif // !_LIBCPP_MSVCRT
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
void __do_nothing(void*) {}
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS collate<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_get<wchar_t>;)
- template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get<char>;
+template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_get<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS num_put<wchar_t>;)
- template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put<char>;
+template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template struct _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __num_put<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_get_byname<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS time_put_byname<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, false>;
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, true>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, false>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<char, true>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, false>;)
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct<wchar_t, true>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, false>;
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, true>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, false>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<char, true>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, false>;)
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS moneypunct_byname<wchar_t, true>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_get<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_get<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS money_put<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS __money_put<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<char>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<char>;
_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS messages_byname<wchar_t>;)
- template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char, char, mbstate_t>;
-_LIBCPP_IF_WIDE_CHARACTERS(template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<wchar_t, char, mbstate_t>;)
-template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char, mbstate_t>;
-template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char, mbstate_t>;
+template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char, char, mbstate_t>;
+_LIBCPP_IF_WIDE_CHARACTERS(
+ template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<wchar_t, char, mbstate_t>;)
+template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+ codecvt_byname<char16_t, char, mbstate_t>;
+template class _LIBCPP_DEPRECATED_IN_CXX20 _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS
+ codecvt_byname<char32_t, char, mbstate_t>;
#ifndef _LIBCPP_HAS_NO_CHAR8_T
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char16_t, char8_t, mbstate_t>;
template class _LIBCPP_CLASS_TEMPLATE_INSTANTIATION_VIS codecvt_byname<char32_t, char8_t, mbstate_t>;
diff --git a/contrib/libs/cxxsupp/libcxx/src/memory.cpp b/contrib/libs/cxxsupp/libcxx/src/memory.cpp
index e318eee327..b1e91e8400 100644
--- a/contrib/libs/cxxsupp/libcxx/src/memory.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/memory.cpp
@@ -8,7 +8,7 @@
#include <__config>
#ifdef _LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS
-# define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
+# define _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
#endif
#include <memory>
@@ -22,155 +22,123 @@
#endif
#if !defined(_LIBCPP_HAS_NO_THREADS)
-#include <atomic>
+# include <atomic>
#else
-#include "include/atomic_support.h"
+# include "include/atomic_support.h"
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
bad_weak_ptr::~bad_weak_ptr() noexcept {}
-const char*
-bad_weak_ptr::what() const noexcept
-{
- return "bad_weak_ptr";
-}
+const char* bad_weak_ptr::what() const noexcept { return "bad_weak_ptr"; }
-__shared_count::~__shared_count()
-{
-}
+__shared_count::~__shared_count() {}
-__shared_weak_count::~__shared_weak_count()
-{
-}
+__shared_weak_count::~__shared_weak_count() {}
#if defined(_LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS)
-void
-__shared_count::__add_shared() noexcept
-{
-#ifdef _LIBCPP_HAS_NO_THREADS
- __libcpp_atomic_refcount_increment(__shared_owners_);
-#else
- ++__shared_owners_;
-#endif
+void __shared_count::__add_shared() noexcept {
+# ifdef _LIBCPP_HAS_NO_THREADS
+ __libcpp_atomic_refcount_increment(__shared_owners_);
+# else
+ ++__shared_owners_;
+# endif
}
-bool
-__shared_count::__release_shared() noexcept
-{
-#ifdef _LIBCPP_HAS_NO_THREADS
- if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1)
-#else
- if (--__shared_owners_ == -1)
-#endif
- {
- __on_zero_shared();
- return true;
- }
- return false;
+bool __shared_count::__release_shared() noexcept {
+# ifdef _LIBCPP_HAS_NO_THREADS
+ if (__libcpp_atomic_refcount_decrement(__shared_owners_) == -1)
+# else
+ if (--__shared_owners_ == -1)
+# endif
+ {
+ __on_zero_shared();
+ return true;
+ }
+ return false;
}
-void
-__shared_weak_count::__add_shared() noexcept
-{
- __shared_count::__add_shared();
-}
+void __shared_weak_count::__add_shared() noexcept { __shared_count::__add_shared(); }
-void
-__shared_weak_count::__add_weak() noexcept
-{
-#ifdef _LIBCPP_HAS_NO_THREADS
- __libcpp_atomic_refcount_increment(__shared_weak_owners_);
-#else
- ++__shared_weak_owners_;
-#endif
+void __shared_weak_count::__add_weak() noexcept {
+# ifdef _LIBCPP_HAS_NO_THREADS
+ __libcpp_atomic_refcount_increment(__shared_weak_owners_);
+# else
+ ++__shared_weak_owners_;
+# endif
}
-void
-__shared_weak_count::__release_shared() noexcept
-{
- if (__shared_count::__release_shared())
- __release_weak();
+void __shared_weak_count::__release_shared() noexcept {
+ if (__shared_count::__release_shared())
+ __release_weak();
}
#endif // _LIBCPP_SHARED_PTR_DEFINE_LEGACY_INLINE_FUNCTIONS
-void
-__shared_weak_count::__release_weak() noexcept
-{
- // NOTE: The acquire load here is an optimization of the very
- // common case where a shared pointer is being destructed while
- // having no other contended references.
- //
- // BENEFIT: We avoid expensive atomic stores like XADD and STREX
- // in a common case. Those instructions are slow and do nasty
- // things to caches.
- //
- // IS THIS SAFE? Yes. During weak destruction, if we see that we
- // are the last reference, we know that no-one else is accessing
- // us. If someone were accessing us, then they would be doing so
- // while the last shared / weak_ptr was being destructed, and
- // that's undefined anyway.
- //
- // If we see anything other than a 0, then we have possible
- // contention, and need to use an atomicrmw primitive.
- // The same arguments don't apply for increment, where it is legal
- // (though inadvisable) to share shared_ptr references between
- // threads, and have them all get copied at once. The argument
- // also doesn't apply for __release_shared, because an outstanding
- // weak_ptr::lock() could read / modify the shared count.
+void __shared_weak_count::__release_weak() noexcept {
+ // NOTE: The acquire load here is an optimization of the very
+ // common case where a shared pointer is being destructed while
+ // having no other contended references.
+ //
+ // BENEFIT: We avoid expensive atomic stores like XADD and STREX
+ // in a common case. Those instructions are slow and do nasty
+ // things to caches.
+ //
+ // IS THIS SAFE? Yes. During weak destruction, if we see that we
+ // are the last reference, we know that no-one else is accessing
+ // us. If someone were accessing us, then they would be doing so
+ // while the last shared / weak_ptr was being destructed, and
+ // that's undefined anyway.
+ //
+ // If we see anything other than a 0, then we have possible
+ // contention, and need to use an atomicrmw primitive.
+ // The same arguments don't apply for increment, where it is legal
+ // (though inadvisable) to share shared_ptr references between
+ // threads, and have them all get copied at once. The argument
+ // also doesn't apply for __release_shared, because an outstanding
+ // weak_ptr::lock() could read / modify the shared count.
#ifdef _LIBCPP_HAS_NO_THREADS
- if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Acquire) == 0)
+ if (__libcpp_atomic_load(&__shared_weak_owners_, _AO_Acquire) == 0)
#else
- if (__shared_weak_owners_.load(memory_order_acquire) == 0)
+ if (__shared_weak_owners_.load(memory_order_acquire) == 0)
#endif
- {
- // no need to do this store, because we are about
- // to destroy everything.
- //__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release);
- __on_zero_shared_weak();
- }
+ {
+ // no need to do this store, because we are about
+ // to destroy everything.
+ //__libcpp_atomic_store(&__shared_weak_owners_, -1, _AO_Release);
+ __on_zero_shared_weak();
+ }
#ifdef _LIBCPP_HAS_NO_THREADS
- else if (__libcpp_atomic_refcount_decrement(__shared_weak_owners_) == -1)
+ else if (__libcpp_atomic_refcount_decrement(__shared_weak_owners_) == -1)
#else
- else if (--__shared_weak_owners_ == -1)
+ else if (--__shared_weak_owners_ == -1)
#endif
- __on_zero_shared_weak();
+ __on_zero_shared_weak();
}
-__shared_weak_count*
-__shared_weak_count::lock() noexcept
-{
+__shared_weak_count* __shared_weak_count::lock() noexcept {
#ifdef _LIBCPP_HAS_NO_THREADS
- long object_owners = __libcpp_atomic_load(&__shared_owners_);
+ long object_owners = __libcpp_atomic_load(&__shared_owners_);
#else
- long object_owners = __shared_owners_.load();
+ long object_owners = __shared_owners_.load();
#endif
- while (object_owners != -1)
- {
+ while (object_owners != -1) {
#ifdef _LIBCPP_HAS_NO_THREADS
- if (__libcpp_atomic_compare_exchange(&__shared_owners_,
- &object_owners,
- object_owners+1))
+ if (__libcpp_atomic_compare_exchange(&__shared_owners_, &object_owners, object_owners + 1))
#else
- if (__shared_owners_.compare_exchange_weak(object_owners, object_owners+1))
+ if (__shared_owners_.compare_exchange_weak(object_owners, object_owners + 1))
#endif
- return this;
- }
- return nullptr;
+ return this;
+ }
+ return nullptr;
}
-const void*
-__shared_weak_count::__get_deleter(const type_info&) const noexcept
-{
- return nullptr;
-}
+const void* __shared_weak_count::__get_deleter(const type_info&) const noexcept { return nullptr; }
#if !defined(_LIBCPP_HAS_NO_THREADS)
-static constexpr std::size_t __sp_mut_count = 32;
-static constinit __libcpp_mutex_t mut_back[__sp_mut_count] =
-{
+static constexpr std::size_t __sp_mut_count = 32;
+static constinit __libcpp_mutex_t mut_back[__sp_mut_count] = {
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
@@ -178,62 +146,42 @@ static constinit __libcpp_mutex_t mut_back[__sp_mut_count] =
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
_LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
- _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER
-};
+ _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER};
-constexpr __sp_mut::__sp_mut(void* p) noexcept
- : __lx_(p)
-{
-}
+constexpr __sp_mut::__sp_mut(void* p) noexcept : __lx_(p) {}
-void
-__sp_mut::lock() noexcept
-{
- auto m = static_cast<__libcpp_mutex_t*>(__lx_);
- __libcpp_mutex_lock(m);
+void __sp_mut::lock() noexcept {
+ auto m = static_cast<__libcpp_mutex_t*>(__lx_);
+ __libcpp_mutex_lock(m);
}
-void
-__sp_mut::unlock() noexcept
-{
- __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx_));
-}
+void __sp_mut::unlock() noexcept { __libcpp_mutex_unlock(static_cast<__libcpp_mutex_t*>(__lx_)); }
-__sp_mut&
-__get_sp_mut(const void* p)
-{
- static constinit __sp_mut muts[__sp_mut_count] = {
- &mut_back[ 0], &mut_back[ 1], &mut_back[ 2], &mut_back[ 3],
- &mut_back[ 4], &mut_back[ 5], &mut_back[ 6], &mut_back[ 7],
- &mut_back[ 8], &mut_back[ 9], &mut_back[10], &mut_back[11],
- &mut_back[12], &mut_back[13], &mut_back[14], &mut_back[15],
- &mut_back[16], &mut_back[17], &mut_back[18], &mut_back[19],
- &mut_back[20], &mut_back[21], &mut_back[22], &mut_back[23],
- &mut_back[24], &mut_back[25], &mut_back[26], &mut_back[27],
- &mut_back[28], &mut_back[29], &mut_back[30], &mut_back[31]
- };
- return muts[hash<const void*>()(p) & (__sp_mut_count-1)];
+__sp_mut& __get_sp_mut(const void* p) {
+ static constinit __sp_mut muts[__sp_mut_count] = {
+ &mut_back[0], &mut_back[1], &mut_back[2], &mut_back[3], &mut_back[4], &mut_back[5], &mut_back[6],
+ &mut_back[7], &mut_back[8], &mut_back[9], &mut_back[10], &mut_back[11], &mut_back[12], &mut_back[13],
+ &mut_back[14], &mut_back[15], &mut_back[16], &mut_back[17], &mut_back[18], &mut_back[19], &mut_back[20],
+ &mut_back[21], &mut_back[22], &mut_back[23], &mut_back[24], &mut_back[25], &mut_back[26], &mut_back[27],
+ &mut_back[28], &mut_back[29], &mut_back[30], &mut_back[31]};
+ return muts[hash<const void*>()(p) & (__sp_mut_count - 1)];
}
#endif // !defined(_LIBCPP_HAS_NO_THREADS)
-void*
-align(size_t alignment, size_t size, void*& ptr, size_t& space)
-{
- void* r = nullptr;
- if (size <= space)
- {
- char* p1 = static_cast<char*>(ptr);
- char* p2 = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(p1 + (alignment - 1)) & -alignment);
- size_t d = static_cast<size_t>(p2 - p1);
- if (d <= space - size)
- {
- r = p2;
- ptr = r;
- space -= d;
- }
+void* align(size_t alignment, size_t size, void*& ptr, size_t& space) {
+ void* r = nullptr;
+ if (size <= space) {
+ char* p1 = static_cast<char*>(ptr);
+ char* p2 = reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(p1 + (alignment - 1)) & -alignment);
+ size_t d = static_cast<size_t>(p2 - p1);
+ if (d <= space - size) {
+ r = p2;
+ ptr = r;
+ space -= d;
}
- return r;
+ }
+ return r;
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/mutex.cpp b/contrib/libs/cxxsupp/libcxx/src/mutex.cpp
index 11f7be38e2..13c63247f1 100644
--- a/contrib/libs/cxxsupp/libcxx/src/mutex.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/mutex.cpp
@@ -13,7 +13,7 @@
#include <mutex>
#if !defined(_LIBCPP_ABI_MICROSOFT)
-#include "include/atomic_support.h"
+# include "include/atomic_support.h"
#endif
#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
@@ -27,164 +27,117 @@ _LIBCPP_BEGIN_NAMESPACE_STD
// ~mutex is defined elsewhere
-void
-mutex::lock()
-{
- int ec = __libcpp_mutex_lock(&__m_);
- if (ec)
- __throw_system_error(ec, "mutex lock failed");
+void mutex::lock() {
+ int ec = __libcpp_mutex_lock(&__m_);
+ if (ec)
+ __throw_system_error(ec, "mutex lock failed");
}
-bool
-mutex::try_lock() noexcept
-{
- return __libcpp_mutex_trylock(&__m_);
-}
+bool mutex::try_lock() noexcept { return __libcpp_mutex_trylock(&__m_); }
-void
-mutex::unlock() noexcept
-{
- int ec = __libcpp_mutex_unlock(&__m_);
- (void)ec;
- _LIBCPP_ASSERT_UNCATEGORIZED(ec == 0, "call to mutex::unlock failed");
+void mutex::unlock() noexcept {
+ int ec = __libcpp_mutex_unlock(&__m_);
+ (void)ec;
+ _LIBCPP_ASSERT_UNCATEGORIZED(ec == 0, "call to mutex::unlock failed");
}
// recursive_mutex
-recursive_mutex::recursive_mutex()
-{
- int ec = __libcpp_recursive_mutex_init(&__m_);
- if (ec)
- __throw_system_error(ec, "recursive_mutex constructor failed");
+recursive_mutex::recursive_mutex() {
+ int ec = __libcpp_recursive_mutex_init(&__m_);
+ if (ec)
+ __throw_system_error(ec, "recursive_mutex constructor failed");
}
-recursive_mutex::~recursive_mutex()
-{
- int e = __libcpp_recursive_mutex_destroy(&__m_);
- (void)e;
- _LIBCPP_ASSERT_UNCATEGORIZED(e == 0, "call to ~recursive_mutex() failed");
+recursive_mutex::~recursive_mutex() {
+ int e = __libcpp_recursive_mutex_destroy(&__m_);
+ (void)e;
+ _LIBCPP_ASSERT_UNCATEGORIZED(e == 0, "call to ~recursive_mutex() failed");
}
-void
-recursive_mutex::lock()
-{
- int ec = __libcpp_recursive_mutex_lock(&__m_);
- if (ec)
- __throw_system_error(ec, "recursive_mutex lock failed");
+void recursive_mutex::lock() {
+ int ec = __libcpp_recursive_mutex_lock(&__m_);
+ if (ec)
+ __throw_system_error(ec, "recursive_mutex lock failed");
}
-void
-recursive_mutex::unlock() noexcept
-{
- int e = __libcpp_recursive_mutex_unlock(&__m_);
- (void)e;
- _LIBCPP_ASSERT_UNCATEGORIZED(e == 0, "call to recursive_mutex::unlock() failed");
+void recursive_mutex::unlock() noexcept {
+ int e = __libcpp_recursive_mutex_unlock(&__m_);
+ (void)e;
+ _LIBCPP_ASSERT_UNCATEGORIZED(e == 0, "call to recursive_mutex::unlock() failed");
}
-bool
-recursive_mutex::try_lock() noexcept
-{
- return __libcpp_recursive_mutex_trylock(&__m_);
-}
+bool recursive_mutex::try_lock() noexcept { return __libcpp_recursive_mutex_trylock(&__m_); }
// timed_mutex
-timed_mutex::timed_mutex()
- : __locked_(false)
-{
-}
+timed_mutex::timed_mutex() : __locked_(false) {}
-timed_mutex::~timed_mutex()
-{
- lock_guard<mutex> _(__m_);
-}
+timed_mutex::~timed_mutex() { lock_guard<mutex> _(__m_); }
-void
-timed_mutex::lock()
-{
- unique_lock<mutex> lk(__m_);
- while (__locked_)
- __cv_.wait(lk);
- __locked_ = true;
+void timed_mutex::lock() {
+ unique_lock<mutex> lk(__m_);
+ while (__locked_)
+ __cv_.wait(lk);
+ __locked_ = true;
}
-bool
-timed_mutex::try_lock() noexcept
-{
- unique_lock<mutex> lk(__m_, try_to_lock);
- if (lk.owns_lock() && !__locked_)
- {
- __locked_ = true;
- return true;
- }
- return false;
+bool timed_mutex::try_lock() noexcept {
+ unique_lock<mutex> lk(__m_, try_to_lock);
+ if (lk.owns_lock() && !__locked_) {
+ __locked_ = true;
+ return true;
+ }
+ return false;
}
-void
-timed_mutex::unlock() noexcept
-{
- lock_guard<mutex> _(__m_);
- __locked_ = false;
- __cv_.notify_one();
+void timed_mutex::unlock() noexcept {
+ lock_guard<mutex> _(__m_);
+ __locked_ = false;
+ __cv_.notify_one();
}
// recursive_timed_mutex
-recursive_timed_mutex::recursive_timed_mutex()
- : __count_(0),
- __id_{}
-{
-}
-
-recursive_timed_mutex::~recursive_timed_mutex()
-{
- lock_guard<mutex> _(__m_);
-}
-
-void
-recursive_timed_mutex::lock()
-{
- __thread_id id = this_thread::get_id();
- unique_lock<mutex> lk(__m_);
- if (id ==__id_)
- {
- if (__count_ == numeric_limits<size_t>::max())
- __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
- ++__count_;
- return;
- }
- while (__count_ != 0)
- __cv_.wait(lk);
- __count_ = 1;
+recursive_timed_mutex::recursive_timed_mutex() : __count_(0), __id_{} {}
+
+recursive_timed_mutex::~recursive_timed_mutex() { lock_guard<mutex> _(__m_); }
+
+void recursive_timed_mutex::lock() {
+ __thread_id id = this_thread::get_id();
+ unique_lock<mutex> lk(__m_);
+ if (id == __id_) {
+ if (__count_ == numeric_limits<size_t>::max())
+ __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
+ ++__count_;
+ return;
+ }
+ while (__count_ != 0)
+ __cv_.wait(lk);
+ __count_ = 1;
+ __id_ = id;
+}
+
+bool recursive_timed_mutex::try_lock() noexcept {
+ __thread_id id = this_thread::get_id();
+ unique_lock<mutex> lk(__m_, try_to_lock);
+ if (lk.owns_lock() && (__count_ == 0 || id == __id_)) {
+ if (__count_ == numeric_limits<size_t>::max())
+ return false;
+ ++__count_;
__id_ = id;
+ return true;
+ }
+ return false;
}
-bool
-recursive_timed_mutex::try_lock() noexcept
-{
- __thread_id id = this_thread::get_id();
- unique_lock<mutex> lk(__m_, try_to_lock);
- if (lk.owns_lock() && (__count_ == 0 || id == __id_))
- {
- if (__count_ == numeric_limits<size_t>::max())
- return false;
- ++__count_;
- __id_ = id;
- return true;
- }
- return false;
-}
-
-void
-recursive_timed_mutex::unlock() noexcept
-{
- unique_lock<mutex> lk(__m_);
- if (--__count_ == 0)
- {
- __id_.__reset();
- lk.unlock();
- __cv_.notify_one();
- }
+void recursive_timed_mutex::unlock() noexcept {
+ unique_lock<mutex> lk(__m_);
+ if (--__count_ == 0) {
+ __id_.__reset();
+ lk.unlock();
+ __cv_.notify_one();
+ }
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/mutex_destructor.cpp b/contrib/libs/cxxsupp/libcxx/src/mutex_destructor.cpp
index 5f06370332..d5ac257f94 100644
--- a/contrib/libs/cxxsupp/libcxx/src/mutex_destructor.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/mutex_destructor.cpp
@@ -26,23 +26,17 @@
_LIBCPP_BEGIN_NAMESPACE_STD
#ifdef NEEDS_MUTEX_DESTRUCTOR
-class _LIBCPP_EXPORTED_FROM_ABI mutex
-{
- __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
+class _LIBCPP_EXPORTED_FROM_ABI mutex {
+ __libcpp_mutex_t __m_ = _LIBCPP_MUTEX_INITIALIZER;
public:
- _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI
- constexpr mutex() = default;
- mutex(const mutex&) = delete;
- mutex& operator=(const mutex&) = delete;
- ~mutex() noexcept;
+ _LIBCPP_ALWAYS_INLINE _LIBCPP_HIDE_FROM_ABI constexpr mutex() = default;
+ mutex(const mutex&) = delete;
+ mutex& operator=(const mutex&) = delete;
+ ~mutex() noexcept;
};
-
-mutex::~mutex() noexcept
-{
- __libcpp_mutex_destroy(&__m_);
-}
+mutex::~mutex() noexcept { __libcpp_mutex_destroy(&__m_); }
#endif // !NEEDS_MUTEX_DESTRUCTOR
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/new.cpp b/contrib/libs/cxxsupp/libcxx/src/new.cpp
index 318b062bb0..e9a4adcfdf 100644
--- a/contrib/libs/cxxsupp/libcxx/src/new.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/new.cpp
@@ -44,12 +44,12 @@ _LIBCPP_WEAK void* operator new(std::size_t size) _THROW_BAD_ALLOC {
# else
# ifdef __EMSCRIPTEN__
if (p == nullptr)
- // Abort here so that when exceptions are disabled, we do not just
- // return 0 when malloc returns 0.
- // We could also do this with set_new_handler, but that adds a
- // global constructor and a table entry, overhead that we can avoid
- // by doing it this way.
- abort();
+ // Abort here so that when exceptions are disabled, we do not just
+ // return 0 when malloc returns 0.
+ // We could also do this with set_new_handler, but that adds a
+ // global constructor and a table entry, overhead that we can avoid
+ // by doing it this way.
+ abort();
# endif
# endif
return p;
diff --git a/contrib/libs/cxxsupp/libcxx/src/optional.cpp b/contrib/libs/cxxsupp/libcxx/src/optional.cpp
index fc91152f01..6ba63f2d89 100644
--- a/contrib/libs/cxxsupp/libcxx/src/optional.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/optional.cpp
@@ -10,17 +10,13 @@
#include <optional>
#include <stdexcept>
-namespace std
-{
+namespace std {
bad_optional_access::~bad_optional_access() noexcept = default;
-const char* bad_optional_access::what() const noexcept {
- return "bad_optional_access";
-}
-
-} // std
+const char* bad_optional_access::what() const noexcept { return "bad_optional_access"; }
+} // namespace std
#include <experimental/__config>
@@ -28,9 +24,7 @@ const char* bad_optional_access::what() const noexcept {
// Even though it no longer exists in a header file
_LIBCPP_BEGIN_NAMESPACE_EXPERIMENTAL
-class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access
- : public std::logic_error
-{
+class _LIBCPP_EXPORTED_FROM_ABI _LIBCPP_AVAILABILITY_BAD_OPTIONAL_ACCESS bad_optional_access : public std::logic_error {
public:
bad_optional_access() : std::logic_error("Bad optional Access") {}
diff --git a/contrib/libs/cxxsupp/libcxx/src/random.cpp b/contrib/libs/cxxsupp/libcxx/src/random.cpp
index dfac89f75b..c7073c54da 100644
--- a/contrib/libs/cxxsupp/libcxx/src/random.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/random.cpp
@@ -9,8 +9,8 @@
#include <__config>
#if defined(_LIBCPP_USING_WIN32_RANDOM)
- // Must be defined before including stdlib.h to enable rand_s().
-# define _CRT_RAND_S
+// Must be defined before including stdlib.h to enable rand_s().
+# define _CRT_RAND_S
#endif // defined(_LIBCPP_USING_WIN32_RANDOM)
#include <__system_error/system_error.h>
@@ -22,148 +22,115 @@
#include <stdlib.h>
#if defined(_LIBCPP_USING_GETENTROPY)
-# include <sys/random.h>
+# include <sys/random.h>
#elif defined(_LIBCPP_USING_DEV_RANDOM)
-# include <fcntl.h>
-# include <unistd.h>
-# if __has_include(<sys/ioctl.h>) && __has_include(<linux/random.h>)
-# include <sys/ioctl.h>
-# include <linux/random.h>
-# endif
+# include <fcntl.h>
+# include <unistd.h>
+# if __has_include(<sys/ioctl.h>) && __has_include(<linux/random.h>)
+# include <linux/random.h>
+# include <sys/ioctl.h>
+# endif
#elif defined(_LIBCPP_USING_NACL_RANDOM)
-# include <nacl/nacl_random.h>
+# include <nacl/nacl_random.h>
#elif defined(_LIBCPP_USING_FUCHSIA_CPRNG)
# include <zircon/syscalls.h>
#endif
-
_LIBCPP_BEGIN_NAMESPACE_STD
#if defined(_LIBCPP_USING_GETENTROPY)
-random_device::random_device(const string& __token)
-{
- if (__token != "/dev/urandom")
- __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+random_device::random_device(const string& __token) {
+ if (__token != "/dev/urandom")
+ __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
}
-random_device::~random_device()
-{
-}
+random_device::~random_device() {}
-unsigned
-random_device::operator()()
-{
- unsigned r;
- size_t n = sizeof(r);
- int err = getentropy(&r, n);
- if (err)
- __throw_system_error(errno, "random_device getentropy failed");
- return r;
+unsigned random_device::operator()() {
+ unsigned r;
+ size_t n = sizeof(r);
+ int err = getentropy(&r, n);
+ if (err)
+ __throw_system_error(errno, "random_device getentropy failed");
+ return r;
}
#elif defined(_LIBCPP_USING_ARC4_RANDOM)
-random_device::random_device(const string&)
-{
-}
+random_device::random_device(const string&) {}
-random_device::~random_device()
-{
-}
+random_device::~random_device() {}
-unsigned
-random_device::operator()()
-{
- return arc4random();
-}
+unsigned random_device::operator()() { return arc4random(); }
#elif defined(_LIBCPP_USING_DEV_RANDOM)
-random_device::random_device(const string& __token)
- : __f_(open(__token.c_str(), O_RDONLY))
-{
- if (__f_ < 0)
- __throw_system_error(errno, ("random_device failed to open " + __token).c_str());
+random_device::random_device(const string& __token) : __f_(open(__token.c_str(), O_RDONLY)) {
+ if (__f_ < 0)
+ __throw_system_error(errno, ("random_device failed to open " + __token).c_str());
}
-random_device::~random_device()
-{
- close(__f_);
-}
+random_device::~random_device() { close(__f_); }
-unsigned
-random_device::operator()()
-{
- unsigned r;
- size_t n = sizeof(r);
- char* p = reinterpret_cast<char*>(&r);
- while (n > 0)
- {
- ssize_t s = read(__f_, p, n);
- if (s == 0)
- __throw_system_error(ENODATA, "random_device got EOF");
- if (s == -1)
- {
- if (errno != EINTR)
- __throw_system_error(errno, "random_device got an unexpected error");
- continue;
- }
- n -= static_cast<size_t>(s);
- p += static_cast<size_t>(s);
+unsigned random_device::operator()() {
+ unsigned r;
+ size_t n = sizeof(r);
+ char* p = reinterpret_cast<char*>(&r);
+ while (n > 0) {
+ ssize_t s = read(__f_, p, n);
+ if (s == 0)
+ __throw_system_error(ENODATA, "random_device got EOF");
+ if (s == -1) {
+ if (errno != EINTR)
+ __throw_system_error(errno, "random_device got an unexpected error");
+ continue;
}
- return r;
+ n -= static_cast<size_t>(s);
+ p += static_cast<size_t>(s);
+ }
+ return r;
}
#elif defined(_LIBCPP_USING_NACL_RANDOM)
-random_device::random_device(const string& __token)
-{
- if (__token != "/dev/urandom")
- __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
- int error = nacl_secure_random_init();
- if (error)
- __throw_system_error(error, ("random device failed to open " + __token).c_str());
+random_device::random_device(const string& __token) {
+ if (__token != "/dev/urandom")
+ __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+ int error = nacl_secure_random_init();
+ if (error)
+ __throw_system_error(error, ("random device failed to open " + __token).c_str());
}
-random_device::~random_device()
-{
-}
+random_device::~random_device() {}
-unsigned
-random_device::operator()()
-{
- unsigned r;
- size_t n = sizeof(r);
- size_t bytes_written;
- int error = nacl_secure_random(&r, n, &bytes_written);
- if (error != 0)
- __throw_system_error(error, "random_device failed getting bytes");
- else if (bytes_written != n)
- __throw_runtime_error("random_device failed to obtain enough bytes");
- return r;
+unsigned random_device::operator()() {
+ unsigned r;
+ size_t n = sizeof(r);
+ size_t bytes_written;
+ int error = nacl_secure_random(&r, n, &bytes_written);
+ if (error != 0)
+ __throw_system_error(error, "random_device failed getting bytes");
+ else if (bytes_written != n)
+ __throw_runtime_error("random_device failed to obtain enough bytes");
+ return r;
}
#elif defined(_LIBCPP_USING_WIN32_RANDOM)
-random_device::random_device(const string& __token)
-{
- if (__token != "/dev/urandom")
- __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
+random_device::random_device(const string& __token) {
+ if (__token != "/dev/urandom")
+ __throw_system_error(ENOENT, ("random device not supported " + __token).c_str());
}
-random_device::~random_device()
-{
-}
+random_device::~random_device() {}
-unsigned
-random_device::operator()()
-{
- unsigned r;
- errno_t err = rand_s(&r);
- if (err)
- __throw_system_error(err, "random_device rand_s failed.");
- return r;
+unsigned random_device::operator()() {
+ unsigned r;
+ errno_t err = rand_s(&r);
+ if (err)
+ __throw_system_error(err, "random_device rand_s failed.");
+ return r;
}
#elif defined(_LIBCPP_USING_FUCHSIA_CPRNG)
@@ -188,12 +155,10 @@ unsigned random_device::operator()() {
}
#else
-#error "Random device not implemented for this architecture"
+# error "Random device not implemented for this architecture"
#endif
-double
-random_device::entropy() const noexcept
-{
+double random_device::entropy() const noexcept {
#if defined(_LIBCPP_USING_DEV_RANDOM) && defined(RNDGETENTCNT)
int ent;
if (::ioctl(__f_, RNDGETENTCNT, &ent) < 0)
diff --git a/contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp b/contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp
index e9087a9701..3aaf71d846 100644
--- a/contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/random_shuffle.cpp
@@ -23,40 +23,29 @@ static constinit __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
#endif
unsigned __rs_default::__c_ = 0;
-__rs_default::__rs_default()
-{
+__rs_default::__rs_default() {
#ifndef _LIBCPP_HAS_NO_THREADS
- __libcpp_mutex_lock(&__rs_mut);
+ __libcpp_mutex_lock(&__rs_mut);
#endif
- __c_ = 1;
+ __c_ = 1;
}
-__rs_default::__rs_default(const __rs_default&)
-{
- ++__c_;
-}
+__rs_default::__rs_default(const __rs_default&) { ++__c_; }
-__rs_default::~__rs_default()
-{
+__rs_default::~__rs_default() {
#ifndef _LIBCPP_HAS_NO_THREADS
- if (--__c_ == 0)
- __libcpp_mutex_unlock(&__rs_mut);
+ if (--__c_ == 0)
+ __libcpp_mutex_unlock(&__rs_mut);
#else
- --__c_;
+ --__c_;
#endif
}
-__rs_default::result_type
-__rs_default::operator()()
-{
- static mt19937 __rs_g;
- return __rs_g();
+__rs_default::result_type __rs_default::operator()() {
+ static mt19937 __rs_g;
+ return __rs_g();
}
-__rs_default
-__rs_get()
-{
- return __rs_default();
-}
+__rs_default __rs_get() { return __rs_default(); }
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/regex.cpp b/contrib/libs/cxxsupp/libcxx/src/regex.cpp
index 0825c758bf..9dc0c69854 100644
--- a/contrib/libs/cxxsupp/libcxx/src/regex.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/regex.cpp
@@ -12,75 +12,67 @@
_LIBCPP_BEGIN_NAMESPACE_STD
-static
-const char*
-make_error_type_string(regex_constants::error_type ecode)
-{
- switch (ecode)
- {
- case regex_constants::error_collate:
- return "The expression contained an invalid collating element name.";
- case regex_constants::error_ctype:
- return "The expression contained an invalid character class name.";
- case regex_constants::error_escape:
- return "The expression contained an invalid escaped character, or a "
- "trailing escape.";
- case regex_constants::error_backref:
- return "The expression contained an invalid back reference.";
- case regex_constants::error_brack:
- return "The expression contained mismatched [ and ].";
- case regex_constants::error_paren:
- return "The expression contained mismatched ( and ).";
- case regex_constants::error_brace:
- return "The expression contained mismatched { and }.";
- case regex_constants::error_badbrace:
- return "The expression contained an invalid range in a {} expression.";
- case regex_constants::error_range:
- return "The expression contained an invalid character range, "
- "such as [b-a] in most encodings.";
- case regex_constants::error_space:
- return "There was insufficient memory to convert the expression into "
- "a finite state machine.";
- case regex_constants::error_badrepeat:
- return "One of *?+{ was not preceded by a valid regular expression.";
- case regex_constants::error_complexity:
- return "The complexity of an attempted match against a regular "
- "expression exceeded a pre-set level.";
- case regex_constants::error_stack:
- return "There was insufficient memory to determine whether the regular "
- "expression could match the specified character sequence.";
- case regex_constants::__re_err_grammar:
- return "An invalid regex grammar has been requested.";
- case regex_constants::__re_err_empty:
- return "An empty regex is not allowed in the POSIX grammar.";
- case regex_constants::__re_err_parse:
- return "The parser did not consume the entire regular expression.";
- default:
- break;
- }
- return "Unknown error type";
+static const char* make_error_type_string(regex_constants::error_type ecode) {
+ switch (ecode) {
+ case regex_constants::error_collate:
+ return "The expression contained an invalid collating element name.";
+ case regex_constants::error_ctype:
+ return "The expression contained an invalid character class name.";
+ case regex_constants::error_escape:
+ return "The expression contained an invalid escaped character, or a "
+ "trailing escape.";
+ case regex_constants::error_backref:
+ return "The expression contained an invalid back reference.";
+ case regex_constants::error_brack:
+ return "The expression contained mismatched [ and ].";
+ case regex_constants::error_paren:
+ return "The expression contained mismatched ( and ).";
+ case regex_constants::error_brace:
+ return "The expression contained mismatched { and }.";
+ case regex_constants::error_badbrace:
+ return "The expression contained an invalid range in a {} expression.";
+ case regex_constants::error_range:
+ return "The expression contained an invalid character range, "
+ "such as [b-a] in most encodings.";
+ case regex_constants::error_space:
+ return "There was insufficient memory to convert the expression into "
+ "a finite state machine.";
+ case regex_constants::error_badrepeat:
+ return "One of *?+{ was not preceded by a valid regular expression.";
+ case regex_constants::error_complexity:
+ return "The complexity of an attempted match against a regular "
+ "expression exceeded a pre-set level.";
+ case regex_constants::error_stack:
+ return "There was insufficient memory to determine whether the regular "
+ "expression could match the specified character sequence.";
+ case regex_constants::__re_err_grammar:
+ return "An invalid regex grammar has been requested.";
+ case regex_constants::__re_err_empty:
+ return "An empty regex is not allowed in the POSIX grammar.";
+ case regex_constants::__re_err_parse:
+ return "The parser did not consume the entire regular expression.";
+ default:
+ break;
+ }
+ return "Unknown error type";
}
regex_error::regex_error(regex_constants::error_type ecode)
- : runtime_error(make_error_type_string(ecode)),
- __code_(ecode)
-{}
+ : runtime_error(make_error_type_string(ecode)), __code_(ecode) {}
regex_error::~regex_error() throw() {}
namespace {
-struct collationnames
-{
- const char* elem_;
- char char_;
+struct collationnames {
+ const char* elem_;
+ char char_;
};
#if defined(__MVS__) && !defined(__NATIVE_ASCII_F)
// EBCDIC IBM-1047
// Sorted via the EBCDIC collating sequence
-const collationnames collatenames[] =
-{
+const collationnames collatenames[] = {
{"a", 0x81},
{"alert", 0x2f},
{"ampersand", 0x50},
@@ -191,12 +183,10 @@ const collationnames collatenames[] =
{"W", 0xe6},
{"X", 0xe7},
{"Y", 0xe8},
- {"Z", 0xe9}
-};
+ {"Z", 0xe9}};
#else
// ASCII
-const collationnames collatenames[] =
-{
+const collationnames collatenames[] = {
{"A", 0x41},
{"B", 0x42},
{"C", 0x43},
@@ -307,130 +297,103 @@ const collationnames collatenames[] =
{"x", 0x78},
{"y", 0x79},
{"z", 0x7a},
- {"zero", 0x30}
-};
+ {"zero", 0x30}};
#endif
-struct classnames
-{
- const char* elem_;
- regex_traits<char>::char_class_type mask_;
+struct classnames {
+ const char* elem_;
+ regex_traits<char>::char_class_type mask_;
};
-const classnames ClassNames[] =
-{
- {"alnum", ctype_base::alnum},
- {"alpha", ctype_base::alpha},
- {"blank", ctype_base::blank},
- {"cntrl", ctype_base::cntrl},
- {"d", ctype_base::digit},
- {"digit", ctype_base::digit},
- {"graph", ctype_base::graph},
- {"lower", ctype_base::lower},
- {"print", ctype_base::print},
- {"punct", ctype_base::punct},
- {"s", ctype_base::space},
- {"space", ctype_base::space},
- {"upper", ctype_base::upper},
- {"w", regex_traits<char>::__regex_word},
- {"xdigit", ctype_base::xdigit}
-};
+const classnames ClassNames[] = {
+ {"alnum", ctype_base::alnum},
+ {"alpha", ctype_base::alpha},
+ {"blank", ctype_base::blank},
+ {"cntrl", ctype_base::cntrl},
+ {"d", ctype_base::digit},
+ {"digit", ctype_base::digit},
+ {"graph", ctype_base::graph},
+ {"lower", ctype_base::lower},
+ {"print", ctype_base::print},
+ {"punct", ctype_base::punct},
+ {"s", ctype_base::space},
+ {"space", ctype_base::space},
+ {"upper", ctype_base::upper},
+ {"w", regex_traits<char>::__regex_word},
+ {"xdigit", ctype_base::xdigit}};
-struct use_strcmp
-{
- bool operator()(const collationnames& x, const char* y)
- {return strcmp(x.elem_, y) < 0;}
- bool operator()(const classnames& x, const char* y)
- {return strcmp(x.elem_, y) < 0;}
+struct use_strcmp {
+ bool operator()(const collationnames& x, const char* y) { return strcmp(x.elem_, y) < 0; }
+ bool operator()(const classnames& x, const char* y) { return strcmp(x.elem_, y) < 0; }
};
-}
+} // namespace
-string
-__get_collation_name(const char* s)
-{
- const collationnames* i =
- std::lower_bound(begin(collatenames), end(collatenames), s, use_strcmp());
- string r;
- if (i != end(collatenames) && strcmp(s, i->elem_) == 0)
- r = char(i->char_);
- return r;
+string __get_collation_name(const char* s) {
+ const collationnames* i = std::lower_bound(begin(collatenames), end(collatenames), s, use_strcmp());
+ string r;
+ if (i != end(collatenames) && strcmp(s, i->elem_) == 0)
+ r = char(i->char_);
+ return r;
}
-regex_traits<char>::char_class_type
-__get_classname(const char* s, bool __icase)
-{
- const classnames* i =
- std::lower_bound(begin(ClassNames), end(ClassNames), s, use_strcmp());
- regex_traits<char>::char_class_type r = 0;
- if (i != end(ClassNames) && strcmp(s, i->elem_) == 0)
- {
- r = i->mask_;
- if (r == regex_traits<char>::__regex_word)
- r |= ctype_base::alnum | ctype_base::upper | ctype_base::lower;
- else if (__icase)
- {
- if (r & (ctype_base::lower | ctype_base::upper))
- r |= ctype_base::alpha;
- }
+regex_traits<char>::char_class_type __get_classname(const char* s, bool __icase) {
+ const classnames* i = std::lower_bound(begin(ClassNames), end(ClassNames), s, use_strcmp());
+ regex_traits<char>::char_class_type r = 0;
+ if (i != end(ClassNames) && strcmp(s, i->elem_) == 0) {
+ r = i->mask_;
+ if (r == regex_traits<char>::__regex_word)
+ r |= ctype_base::alnum | ctype_base::upper | ctype_base::lower;
+ else if (__icase) {
+ if (r & (ctype_base::lower | ctype_base::upper))
+ r |= ctype_base::alpha;
}
- return r;
+ }
+ return r;
}
template <>
-void
-__match_any_but_newline<char>::__exec(__state& __s) const
-{
- if (__s.__current_ != __s.__last_)
- {
- switch (*__s.__current_)
- {
- case '\r':
- case '\n':
- __s.__do_ = __state::__reject;
- __s.__node_ = nullptr;
- break;
- default:
- __s.__do_ = __state::__accept_and_consume;
- ++__s.__current_;
- __s.__node_ = this->first();
- break;
- }
- }
- else
- {
- __s.__do_ = __state::__reject;
- __s.__node_ = nullptr;
+void __match_any_but_newline<char>::__exec(__state& __s) const {
+ if (__s.__current_ != __s.__last_) {
+ switch (*__s.__current_) {
+ case '\r':
+ case '\n':
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ break;
+ default:
+ __s.__do_ = __state::__accept_and_consume;
+ ++__s.__current_;
+ __s.__node_ = this->first();
+ break;
}
+ } else {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
}
template <>
-void
-__match_any_but_newline<wchar_t>::__exec(__state& __s) const
-{
- if (__s.__current_ != __s.__last_)
- {
- switch (*__s.__current_)
- {
- case '\r':
- case '\n':
- case 0x2028:
- case 0x2029:
- __s.__do_ = __state::__reject;
- __s.__node_ = nullptr;
- break;
- default:
- __s.__do_ = __state::__accept_and_consume;
- ++__s.__current_;
- __s.__node_ = this->first();
- break;
- }
- }
- else
- {
- __s.__do_ = __state::__reject;
- __s.__node_ = nullptr;
+void __match_any_but_newline<wchar_t>::__exec(__state& __s) const {
+ if (__s.__current_ != __s.__last_) {
+ switch (*__s.__current_) {
+ case '\r':
+ case '\n':
+ case 0x2028:
+ case 0x2029:
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ break;
+ default:
+ __s.__do_ = __state::__accept_and_consume;
+ ++__s.__current_;
+ __s.__node_ = this->first();
+ break;
}
+ } else {
+ __s.__do_ = __state::__reject;
+ __s.__node_ = nullptr;
+ }
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/std_stream.h b/contrib/libs/cxxsupp/libcxx/src/std_stream.h
index 39a2b70b4f..c4e9733601 100644
--- a/contrib/libs/cxxsupp/libcxx/src/std_stream.h
+++ b/contrib/libs/cxxsupp/libcxx/src/std_stream.h
@@ -23,7 +23,6 @@
_LIBCPP_PUSH_MACROS
#include <__undef_macros>
-
_LIBCPP_BEGIN_NAMESPACE_STD
static const int __limit = 8;
@@ -31,281 +30,245 @@ static const int __limit = 8;
// __stdinbuf
template <class _CharT>
-class _LIBCPP_HIDDEN __stdinbuf
- : public basic_streambuf<_CharT, char_traits<_CharT> >
-{
+class _LIBCPP_HIDDEN __stdinbuf : public basic_streambuf<_CharT, char_traits<_CharT> > {
public:
- typedef _CharT char_type;
- typedef char_traits<char_type> traits_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef typename traits_type::state_type state_type;
+ typedef _CharT char_type;
+ typedef char_traits<char_type> traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef typename traits_type::state_type state_type;
- __stdinbuf(FILE* __fp, state_type* __st);
+ __stdinbuf(FILE* __fp, state_type* __st);
protected:
- virtual int_type underflow();
- virtual int_type uflow();
- virtual int_type pbackfail(int_type __c = traits_type::eof());
- virtual void imbue(const locale& __loc);
+ virtual int_type underflow();
+ virtual int_type uflow();
+ virtual int_type pbackfail(int_type __c = traits_type::eof());
+ virtual void imbue(const locale& __loc);
private:
-
- FILE* __file_;
- const codecvt<char_type, char, state_type>* __cv_;
- state_type* __st_;
- int __encoding_;
- int_type __last_consumed_;
- bool __last_consumed_is_next_;
- bool __always_noconv_;
+ FILE* __file_;
+ const codecvt<char_type, char, state_type>* __cv_;
+ state_type* __st_;
+ int __encoding_;
+ int_type __last_consumed_;
+ bool __last_consumed_is_next_;
+ bool __always_noconv_;
#if defined(_LIBCPP_WIN32API)
- static constexpr bool __is_win32api_wide_char = !is_same_v<_CharT, char>;
+ static constexpr bool __is_win32api_wide_char = !is_same_v<_CharT, char>;
#else
- static constexpr bool __is_win32api_wide_char = false;
+ static constexpr bool __is_win32api_wide_char = false;
#endif
- __stdinbuf(const __stdinbuf&);
- __stdinbuf& operator=(const __stdinbuf&);
+ __stdinbuf(const __stdinbuf&);
+ __stdinbuf& operator=(const __stdinbuf&);
- int_type __getchar(bool __consume);
+ int_type __getchar(bool __consume);
};
template <class _CharT>
__stdinbuf<_CharT>::__stdinbuf(FILE* __fp, state_type* __st)
- : __file_(__fp),
- __st_(__st),
- __last_consumed_(traits_type::eof()),
- __last_consumed_is_next_(false)
-{
- imbue(this->getloc());
- // On Windows, in wchar_t mode, ignore the codecvt from the locale by
- // default and assume noconv; this passes wchar_t through unmodified from
- // getwc. If the user sets a custom locale with imbue(), that gets honored,
- // the IO is done with getc() and converted with the provided codecvt.
- if constexpr (__is_win32api_wide_char)
- __always_noconv_ = true;
+ : __file_(__fp), __st_(__st), __last_consumed_(traits_type::eof()), __last_consumed_is_next_(false) {
+ imbue(this->getloc());
+ // On Windows, in wchar_t mode, ignore the codecvt from the locale by
+ // default and assume noconv; this passes wchar_t through unmodified from
+ // getwc. If the user sets a custom locale with imbue(), that gets honored,
+ // the IO is done with getc() and converted with the provided codecvt.
+ if constexpr (__is_win32api_wide_char)
+ __always_noconv_ = true;
}
template <class _CharT>
-void
-__stdinbuf<_CharT>::imbue(const locale& __loc)
-{
- __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
- __encoding_ = __cv_->encoding();
- __always_noconv_ = __cv_->always_noconv();
- if (__encoding_ > __limit)
- __throw_runtime_error("unsupported locale for standard input");
+void __stdinbuf<_CharT>::imbue(const locale& __loc) {
+ __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+ __encoding_ = __cv_->encoding();
+ __always_noconv_ = __cv_->always_noconv();
+ if (__encoding_ > __limit)
+ __throw_runtime_error("unsupported locale for standard input");
}
template <class _CharT>
-typename __stdinbuf<_CharT>::int_type
-__stdinbuf<_CharT>::underflow()
-{
- return __getchar(false);
+typename __stdinbuf<_CharT>::int_type __stdinbuf<_CharT>::underflow() {
+ return __getchar(false);
}
template <class _CharT>
-typename __stdinbuf<_CharT>::int_type
-__stdinbuf<_CharT>::uflow()
-{
- return __getchar(true);
+typename __stdinbuf<_CharT>::int_type __stdinbuf<_CharT>::uflow() {
+ return __getchar(true);
}
-inline bool __do_getc(FILE *__fp, char *__pbuf) {
- int __c = getc(__fp);
- if (__c == EOF)
- return false;
- *__pbuf = static_cast<char>(__c);
- return true;
+inline bool __do_getc(FILE* __fp, char* __pbuf) {
+ int __c = getc(__fp);
+ if (__c == EOF)
+ return false;
+ *__pbuf = static_cast<char>(__c);
+ return true;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-inline bool __do_getc(FILE *__fp, wchar_t *__pbuf) {
- wint_t __c = getwc(__fp);
- if (__c == WEOF)
- return false;
- *__pbuf = static_cast<wchar_t>(__c);
- return true;
+inline bool __do_getc(FILE* __fp, wchar_t* __pbuf) {
+ wint_t __c = getwc(__fp);
+ if (__c == WEOF)
+ return false;
+ *__pbuf = static_cast<wchar_t>(__c);
+ return true;
}
#endif
-inline bool __do_ungetc(int __c, FILE *__fp, char __dummy) {
- if (ungetc(__c, __fp) == EOF)
- return false;
- return true;
+inline bool __do_ungetc(int __c, FILE* __fp, char __dummy) {
+ if (ungetc(__c, __fp) == EOF)
+ return false;
+ return true;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-inline bool __do_ungetc(std::wint_t __c, FILE *__fp, wchar_t __dummy) {
- if (ungetwc(__c, __fp) == WEOF)
- return false;
- return true;
+inline bool __do_ungetc(std::wint_t __c, FILE* __fp, wchar_t __dummy) {
+ if (ungetwc(__c, __fp) == WEOF)
+ return false;
+ return true;
}
#endif
template <class _CharT>
-typename __stdinbuf<_CharT>::int_type
-__stdinbuf<_CharT>::__getchar(bool __consume)
-{
- if (__last_consumed_is_next_)
- {
- int_type __result = __last_consumed_;
- if (__consume)
- {
- __last_consumed_ = traits_type::eof();
- __last_consumed_is_next_ = false;
- }
- return __result;
- }
- if (__always_noconv_) {
- char_type __1buf;
- if (!__do_getc(__file_, &__1buf))
- return traits_type::eof();
- if (!__consume)
- {
- if (!__do_ungetc(traits_type::to_int_type(__1buf), __file_, __1buf))
- return traits_type::eof();
- }
- else
- __last_consumed_ = traits_type::to_int_type(__1buf);
- return traits_type::to_int_type(__1buf);
+typename __stdinbuf<_CharT>::int_type __stdinbuf<_CharT>::__getchar(bool __consume) {
+ if (__last_consumed_is_next_) {
+ int_type __result = __last_consumed_;
+ if (__consume) {
+ __last_consumed_ = traits_type::eof();
+ __last_consumed_is_next_ = false;
}
+ return __result;
+ }
+ if (__always_noconv_) {
+ char_type __1buf;
+ if (!__do_getc(__file_, &__1buf))
+ return traits_type::eof();
+ if (!__consume) {
+ if (!__do_ungetc(traits_type::to_int_type(__1buf), __file_, __1buf))
+ return traits_type::eof();
+ } else
+ __last_consumed_ = traits_type::to_int_type(__1buf);
+ return traits_type::to_int_type(__1buf);
+ }
- char __extbuf[__limit];
- int __nread = std::max(1, __encoding_);
- for (int __i = 0; __i < __nread; ++__i)
- {
+ char __extbuf[__limit];
+ int __nread = std::max(1, __encoding_);
+ for (int __i = 0; __i < __nread; ++__i) {
+ int __c = getc(__file_);
+ if (__c == EOF)
+ return traits_type::eof();
+ __extbuf[__i] = static_cast<char>(__c);
+ }
+ char_type __1buf;
+ const char* __enxt;
+ char_type* __inxt;
+ codecvt_base::result __r;
+ do {
+ state_type __sv_st = *__st_;
+ __r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt, &__1buf, &__1buf + 1, __inxt);
+ switch (__r) {
+ case std::codecvt_base::ok:
+ break;
+ case codecvt_base::partial:
+ *__st_ = __sv_st;
+ if (__nread == sizeof(__extbuf))
+ return traits_type::eof();
+ {
int __c = getc(__file_);
if (__c == EOF)
- return traits_type::eof();
- __extbuf[__i] = static_cast<char>(__c);
+ return traits_type::eof();
+ __extbuf[__nread] = static_cast<char>(__c);
+ }
+ ++__nread;
+ break;
+ case codecvt_base::error:
+ return traits_type::eof();
+ case std::codecvt_base::noconv:
+ __1buf = static_cast<char_type>(__extbuf[0]);
+ break;
}
- char_type __1buf;
- const char* __enxt;
- char_type* __inxt;
- codecvt_base::result __r;
- do
- {
- state_type __sv_st = *__st_;
- __r = __cv_->in(*__st_, __extbuf, __extbuf + __nread, __enxt,
- &__1buf, &__1buf + 1, __inxt);
- switch (__r)
- {
- case std::codecvt_base::ok:
- break;
- case codecvt_base::partial:
- *__st_ = __sv_st;
- if (__nread == sizeof(__extbuf))
- return traits_type::eof();
- {
- int __c = getc(__file_);
- if (__c == EOF)
- return traits_type::eof();
- __extbuf[__nread] = static_cast<char>(__c);
- }
- ++__nread;
- break;
- case codecvt_base::error:
- return traits_type::eof();
- case std::codecvt_base::noconv:
- __1buf = static_cast<char_type>(__extbuf[0]);
- break;
- }
- } while (__r == std::codecvt_base::partial);
- if (!__consume)
- {
- for (int __i = __nread; __i > 0;)
- {
- if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF)
- return traits_type::eof();
- }
+ } while (__r == std::codecvt_base::partial);
+ if (!__consume) {
+ for (int __i = __nread; __i > 0;) {
+ if (ungetc(traits_type::to_int_type(__extbuf[--__i]), __file_) == EOF)
+ return traits_type::eof();
}
- else
- __last_consumed_ = traits_type::to_int_type(__1buf);
- return traits_type::to_int_type(__1buf);
+ } else
+ __last_consumed_ = traits_type::to_int_type(__1buf);
+ return traits_type::to_int_type(__1buf);
}
template <class _CharT>
-typename __stdinbuf<_CharT>::int_type
-__stdinbuf<_CharT>::pbackfail(int_type __c)
-{
- if (traits_type::eq_int_type(__c, traits_type::eof()))
- {
- if (!__last_consumed_is_next_)
- {
- __c = __last_consumed_;
- __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_,
- traits_type::eof());
- }
- return __c;
+typename __stdinbuf<_CharT>::int_type __stdinbuf<_CharT>::pbackfail(int_type __c) {
+ if (traits_type::eq_int_type(__c, traits_type::eof())) {
+ if (!__last_consumed_is_next_) {
+ __c = __last_consumed_;
+ __last_consumed_is_next_ = !traits_type::eq_int_type(__last_consumed_, traits_type::eof());
}
- if (__always_noconv_ && __last_consumed_is_next_) {
- if (!__do_ungetc(__last_consumed_, __file_,
- traits_type::to_char_type(__last_consumed_)))
- return traits_type::eof();
- } else if (__last_consumed_is_next_) {
- char __extbuf[__limit];
- char* __enxt;
- const char_type __ci = traits_type::to_char_type(__last_consumed_);
- const char_type* __inxt;
- switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt,
- __extbuf, __extbuf + sizeof(__extbuf), __enxt))
- {
- case std::codecvt_base::ok:
- break;
- case std::codecvt_base::noconv:
- __extbuf[0] = static_cast<char>(__last_consumed_);
- __enxt = __extbuf + 1;
- break;
- case codecvt_base::partial:
- case codecvt_base::error:
- return traits_type::eof();
- }
- while (__enxt > __extbuf)
- if (ungetc(*--__enxt, __file_) == EOF)
- return traits_type::eof();
- }
- __last_consumed_ = __c;
- __last_consumed_is_next_ = true;
return __c;
+ }
+ if (__always_noconv_ && __last_consumed_is_next_) {
+ if (!__do_ungetc(__last_consumed_, __file_, traits_type::to_char_type(__last_consumed_)))
+ return traits_type::eof();
+ } else if (__last_consumed_is_next_) {
+ char __extbuf[__limit];
+ char* __enxt;
+ const char_type __ci = traits_type::to_char_type(__last_consumed_);
+ const char_type* __inxt;
+ switch (__cv_->out(*__st_, &__ci, &__ci + 1, __inxt, __extbuf, __extbuf + sizeof(__extbuf), __enxt)) {
+ case std::codecvt_base::ok:
+ break;
+ case std::codecvt_base::noconv:
+ __extbuf[0] = static_cast<char>(__last_consumed_);
+ __enxt = __extbuf + 1;
+ break;
+ case codecvt_base::partial:
+ case codecvt_base::error:
+ return traits_type::eof();
+ }
+ while (__enxt > __extbuf)
+ if (ungetc(*--__enxt, __file_) == EOF)
+ return traits_type::eof();
+ }
+ __last_consumed_ = __c;
+ __last_consumed_is_next_ = true;
+ return __c;
}
// __stdoutbuf
template <class _CharT>
-class _LIBCPP_HIDDEN __stdoutbuf
- : public basic_streambuf<_CharT, char_traits<_CharT> >
-{
+class _LIBCPP_HIDDEN __stdoutbuf : public basic_streambuf<_CharT, char_traits<_CharT> > {
public:
- typedef _CharT char_type;
- typedef char_traits<char_type> traits_type;
- typedef typename traits_type::int_type int_type;
- typedef typename traits_type::pos_type pos_type;
- typedef typename traits_type::off_type off_type;
- typedef typename traits_type::state_type state_type;
+ typedef _CharT char_type;
+ typedef char_traits<char_type> traits_type;
+ typedef typename traits_type::int_type int_type;
+ typedef typename traits_type::pos_type pos_type;
+ typedef typename traits_type::off_type off_type;
+ typedef typename traits_type::state_type state_type;
- __stdoutbuf(FILE* __fp, state_type* __st);
+ __stdoutbuf(FILE* __fp, state_type* __st);
protected:
- virtual int_type overflow (int_type __c = traits_type::eof());
- virtual streamsize xsputn(const char_type* __s, streamsize __n);
- virtual int sync();
- virtual void imbue(const locale& __loc);
+ virtual int_type overflow(int_type __c = traits_type::eof());
+ virtual streamsize xsputn(const char_type* __s, streamsize __n);
+ virtual int sync();
+ virtual void imbue(const locale& __loc);
private:
- FILE* __file_;
- const codecvt<char_type, char, state_type>* __cv_;
- state_type* __st_;
- bool __always_noconv_;
+ FILE* __file_;
+ const codecvt<char_type, char, state_type>* __cv_;
+ state_type* __st_;
+ bool __always_noconv_;
#if defined(_LIBCPP_WIN32API)
- static constexpr bool __is_win32api_wide_char = !is_same_v<_CharT, char>;
+ static constexpr bool __is_win32api_wide_char = !is_same_v<_CharT, char>;
#else
- static constexpr bool __is_win32api_wide_char = false;
+ static constexpr bool __is_win32api_wide_char = false;
#endif
- __stdoutbuf(const __stdoutbuf&);
- __stdoutbuf& operator=(const __stdoutbuf&);
+ __stdoutbuf(const __stdoutbuf&);
+ __stdoutbuf& operator=(const __stdoutbuf&);
};
template <class _CharT>
@@ -313,131 +276,106 @@ __stdoutbuf<_CharT>::__stdoutbuf(FILE* __fp, state_type* __st)
: __file_(__fp),
__cv_(&use_facet<codecvt<char_type, char, state_type> >(this->getloc())),
__st_(__st),
- __always_noconv_(__cv_->always_noconv())
-{
- // On Windows, in wchar_t mode, ignore the codecvt from the locale by
- // default and assume noconv; this passes wchar_t through unmodified to
- // fputwc, which handles it correctly depending on the actual mode of the
- // output stream. If the user sets a custom locale with imbue(), that
- // gets honored.
- if constexpr (__is_win32api_wide_char)
- __always_noconv_ = true;
+ __always_noconv_(__cv_->always_noconv()) {
+ // On Windows, in wchar_t mode, ignore the codecvt from the locale by
+ // default and assume noconv; this passes wchar_t through unmodified to
+ // fputwc, which handles it correctly depending on the actual mode of the
+ // output stream. If the user sets a custom locale with imbue(), that
+ // gets honored.
+ if constexpr (__is_win32api_wide_char)
+ __always_noconv_ = true;
}
inline bool __do_fputc(char __c, FILE* __fp) {
- if (fwrite(&__c, sizeof(__c), 1, __fp) != 1)
- return false;
- return true;
+ if (fwrite(&__c, sizeof(__c), 1, __fp) != 1)
+ return false;
+ return true;
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
inline bool __do_fputc(wchar_t __c, FILE* __fp) {
- // fputwc works regardless of wide/narrow mode of stdout, while
- // fwrite of wchar_t only works if the stream actually has been set
- // into wide mode.
- if (fputwc(__c, __fp) == WEOF)
- return false;
- return true;
+ // fputwc works regardless of wide/narrow mode of stdout, while
+ // fwrite of wchar_t only works if the stream actually has been set
+ // into wide mode.
+ if (fputwc(__c, __fp) == WEOF)
+ return false;
+ return true;
}
#endif
template <class _CharT>
-typename __stdoutbuf<_CharT>::int_type
-__stdoutbuf<_CharT>::overflow(int_type __c)
-{
- char __extbuf[__limit];
- char_type __1buf;
- if (!traits_type::eq_int_type(__c, traits_type::eof()))
- {
- __1buf = traits_type::to_char_type(__c);
- if (__always_noconv_)
- {
- if (!__do_fputc(__1buf, __file_))
- return traits_type::eof();
- }
- else
- {
- char* __extbe = __extbuf;
- codecvt_base::result __r;
- char_type* pbase = &__1buf;
- char_type* pptr = pbase + 1;
- do
- {
- const char_type* __e;
- __r = __cv_->out(*__st_, pbase, pptr, __e,
- __extbuf,
- __extbuf + sizeof(__extbuf),
- __extbe);
- if (__e == pbase)
- return traits_type::eof();
- if (__r == codecvt_base::noconv)
- {
- if (fwrite(pbase, 1, 1, __file_) != 1)
- return traits_type::eof();
- }
- else if (__r == codecvt_base::ok || __r == codecvt_base::partial)
- {
- size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
- if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
- return traits_type::eof();
- if (__r == codecvt_base::partial)
- {
- pbase = const_cast<char_type*>(__e);
- }
- }
- else
- return traits_type::eof();
- } while (__r == codecvt_base::partial);
- }
+typename __stdoutbuf<_CharT>::int_type __stdoutbuf<_CharT>::overflow(int_type __c) {
+ char __extbuf[__limit];
+ char_type __1buf;
+ if (!traits_type::eq_int_type(__c, traits_type::eof())) {
+ __1buf = traits_type::to_char_type(__c);
+ if (__always_noconv_) {
+ if (!__do_fputc(__1buf, __file_))
+ return traits_type::eof();
+ } else {
+ char* __extbe = __extbuf;
+ codecvt_base::result __r;
+ char_type* pbase = &__1buf;
+ char_type* pptr = pbase + 1;
+ do {
+ const char_type* __e;
+ __r = __cv_->out(*__st_, pbase, pptr, __e, __extbuf, __extbuf + sizeof(__extbuf), __extbe);
+ if (__e == pbase)
+ return traits_type::eof();
+ if (__r == codecvt_base::noconv) {
+ if (fwrite(pbase, 1, 1, __file_) != 1)
+ return traits_type::eof();
+ } else if (__r == codecvt_base::ok || __r == codecvt_base::partial) {
+ size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
+ if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
+ return traits_type::eof();
+ if (__r == codecvt_base::partial) {
+ pbase = const_cast<char_type*>(__e);
+ }
+ } else
+ return traits_type::eof();
+ } while (__r == codecvt_base::partial);
}
- return traits_type::not_eof(__c);
+ }
+ return traits_type::not_eof(__c);
}
template <class _CharT>
-streamsize
-__stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n)
-{
- // For wchar_t on Windows, don't call fwrite(), but write characters one
- // at a time with fputwc(); that works both when stdout is in the default
- // mode and when it is set to Unicode mode.
- if (__always_noconv_ && !__is_win32api_wide_char)
- return fwrite(__s, sizeof(char_type), __n, __file_);
- streamsize __i = 0;
- for (; __i < __n; ++__i, ++__s)
- if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof())
- break;
- return __i;
+streamsize __stdoutbuf<_CharT>::xsputn(const char_type* __s, streamsize __n) {
+ // For wchar_t on Windows, don't call fwrite(), but write characters one
+ // at a time with fputwc(); that works both when stdout is in the default
+ // mode and when it is set to Unicode mode.
+ if (__always_noconv_ && !__is_win32api_wide_char)
+ return fwrite(__s, sizeof(char_type), __n, __file_);
+ streamsize __i = 0;
+ for (; __i < __n; ++__i, ++__s)
+ if (overflow(traits_type::to_int_type(*__s)) == traits_type::eof())
+ break;
+ return __i;
}
template <class _CharT>
-int
-__stdoutbuf<_CharT>::sync()
-{
- char __extbuf[__limit];
- codecvt_base::result __r;
- do
- {
- char* __extbe;
- __r = __cv_->unshift(*__st_, __extbuf,
- __extbuf + sizeof(__extbuf),
- __extbe);
- size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
- if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
- return -1;
- } while (__r == codecvt_base::partial);
- if (__r == codecvt_base::error)
- return -1;
- if (fflush(__file_))
- return -1;
- return 0;
+int __stdoutbuf<_CharT>::sync() {
+ char __extbuf[__limit];
+ codecvt_base::result __r;
+ do {
+ char* __extbe;
+ __r = __cv_->unshift(*__st_, __extbuf, __extbuf + sizeof(__extbuf), __extbe);
+ size_t __nmemb = static_cast<size_t>(__extbe - __extbuf);
+ if (fwrite(__extbuf, 1, __nmemb, __file_) != __nmemb)
+ return -1;
+ } while (__r == codecvt_base::partial);
+ if (__r == codecvt_base::error)
+ return -1;
+ if (fflush(__file_))
+ return -1;
+ return 0;
}
template <class _CharT>
-void
-__stdoutbuf<_CharT>::imbue(const locale& __loc)
-{
- sync();
- __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
- __always_noconv_ = __cv_->always_noconv();
+void __stdoutbuf<_CharT>::imbue(const locale& __loc) {
+ sync();
+ __cv_ = &use_facet<codecvt<char_type, char, state_type> >(__loc);
+ __always_noconv_ = __cv_->always_noconv();
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/string.cpp b/contrib/libs/cxxsupp/libcxx/src/string.cpp
index 4f3de555e3..cf07b3ef1e 100644
--- a/contrib/libs/cxxsupp/libcxx/src/string.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/string.cpp
@@ -28,281 +28,247 @@ struct __basic_string_common;
// The struct isn't declared anymore in the headers. It's only here for ABI compatibility.
template <>
struct __basic_string_common<true> {
- _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;
- _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;
+ _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_length_error() const;
+ _LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;
};
-void __basic_string_common<true>::__throw_length_error() const {
- std::__throw_length_error("basic_string");
-}
-void __basic_string_common<true>::__throw_out_of_range() const {
- std::__throw_out_of_range("basic_string");
-}
+void __basic_string_common<true>::__throw_length_error() const { std::__throw_length_error("basic_string"); }
+void __basic_string_common<true>::__throw_out_of_range() const { std::__throw_out_of_range("basic_string"); }
#endif // _LIBCPP_ABI_DO_NOT_EXPORT_BASIC_STRING_COMMON
#define _LIBCPP_EXTERN_TEMPLATE_DEFINE(...) template __VA_ARGS__;
#ifdef _LIBCPP_ABI_STRING_OPTIMIZED_EXTERNAL_INSTANTIATION
- _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- _LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
-# endif
+_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_STRING_UNSTABLE_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
+# endif
#else
- _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
-# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
- _LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
-# endif
+_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, char)
+# ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
+_LIBCPP_STRING_V1_EXTERN_TEMPLATE_LIST(_LIBCPP_EXTERN_TEMPLATE_DEFINE, wchar_t)
+# endif
#endif
#undef _LIBCPP_EXTERN_TEMPLATE_DEFINE
-template string operator+<char, char_traits<char>, allocator<char>>(char const*, string const&);
+template string operator+ <char, char_traits<char>, allocator<char>>(char const*, string const&);
-namespace
-{
+namespace {
inline void throw_from_string_out_of_range(const string& func) {
- std::__throw_out_of_range((func + ": out of range").c_str());
+ std::__throw_out_of_range((func + ": out of range").c_str());
}
inline void throw_from_string_invalid_arg(const string& func) {
- std::__throw_invalid_argument((func + ": no conversion").c_str());
+ std::__throw_invalid_argument((func + ": no conversion").c_str());
}
// as_integer
-template<typename V, typename S, typename F>
+template <typename V, typename S, typename F>
inline V as_integer_helper(const string& func, const S& str, size_t* idx, int base, F f) {
- typename S::value_type* ptr = nullptr;
- const typename S::value_type* const p = str.c_str();
- __libcpp_remove_reference_t<decltype(errno)> errno_save = errno;
- errno = 0;
- V r = f(p, &ptr, base);
- swap(errno, errno_save);
- if (errno_save == ERANGE)
- throw_from_string_out_of_range(func);
- if (ptr == p)
- throw_from_string_invalid_arg(func);
- if (idx)
- *idx = static_cast<size_t>(ptr - p);
- return r;
-}
-
-template<typename V, typename S>
+ typename S::value_type* ptr = nullptr;
+ const typename S::value_type* const p = str.c_str();
+ __libcpp_remove_reference_t<decltype(errno)> errno_save = errno;
+ errno = 0;
+ V r = f(p, &ptr, base);
+ swap(errno, errno_save);
+ if (errno_save == ERANGE)
+ throw_from_string_out_of_range(func);
+ if (ptr == p)
+ throw_from_string_invalid_arg(func);
+ if (idx)
+ *idx = static_cast<size_t>(ptr - p);
+ return r;
+}
+
+template <typename V, typename S>
inline V as_integer(const string& func, const S& s, size_t* idx, int base);
// string
-template<>
+template <>
inline int as_integer(const string& func, const string& s, size_t* idx, int base) {
- // Use long as no Standard string to integer exists.
- long r = as_integer_helper<long>(func, s, idx, base, strtol);
- if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
- throw_from_string_out_of_range(func);
- return static_cast<int>(r);
+ // Use long as no Standard string to integer exists.
+ long r = as_integer_helper<long>(func, s, idx, base, strtol);
+ if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
+ throw_from_string_out_of_range(func);
+ return static_cast<int>(r);
}
-template<>
+template <>
inline long as_integer(const string& func, const string& s, size_t* idx, int base) {
- return as_integer_helper<long>(func, s, idx, base, strtol);
+ return as_integer_helper<long>(func, s, idx, base, strtol);
}
-template<>
+template <>
inline unsigned long as_integer(const string& func, const string& s, size_t* idx, int base) {
- return as_integer_helper<unsigned long>(func, s, idx, base, strtoul);
+ return as_integer_helper<unsigned long>(func, s, idx, base, strtoul);
}
-template<>
+template <>
inline long long as_integer(const string& func, const string& s, size_t* idx, int base) {
- return as_integer_helper<long long>(func, s, idx, base, strtoll);
+ return as_integer_helper<long long>(func, s, idx, base, strtoll);
}
-template<>
+template <>
inline unsigned long long as_integer(const string& func, const string& s, size_t* idx, int base) {
- return as_integer_helper<unsigned long long>(func, s, idx, base, strtoull);
+ return as_integer_helper<unsigned long long>(func, s, idx, base, strtoull);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
// wstring
-template<>
+template <>
inline int as_integer(const string& func, const wstring& s, size_t* idx, int base) {
- // Use long as no Stantard string to integer exists.
- long r = as_integer_helper<long>(func, s, idx, base, wcstol);
- if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
- throw_from_string_out_of_range(func);
- return static_cast<int>(r);
+ // Use long as no Stantard string to integer exists.
+ long r = as_integer_helper<long>(func, s, idx, base, wcstol);
+ if (r < numeric_limits<int>::min() || numeric_limits<int>::max() < r)
+ throw_from_string_out_of_range(func);
+ return static_cast<int>(r);
}
-template<>
+template <>
inline long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
- return as_integer_helper<long>(func, s, idx, base, wcstol);
+ return as_integer_helper<long>(func, s, idx, base, wcstol);
}
-template<>
-inline
-unsigned long
-as_integer(const string& func, const wstring& s, size_t* idx, int base)
-{
- return as_integer_helper<unsigned long>(func, s, idx, base, wcstoul);
+template <>
+inline unsigned long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
+ return as_integer_helper<unsigned long>(func, s, idx, base, wcstoul);
}
-template<>
+template <>
inline long long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
- return as_integer_helper<long long>(func, s, idx, base, wcstoll);
+ return as_integer_helper<long long>(func, s, idx, base, wcstoll);
}
-template<>
+template <>
inline unsigned long long as_integer(const string& func, const wstring& s, size_t* idx, int base) {
- return as_integer_helper<unsigned long long>(func, s, idx, base, wcstoull);
+ return as_integer_helper<unsigned long long>(func, s, idx, base, wcstoull);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
// as_float
-template<typename V, typename S, typename F>
+template <typename V, typename S, typename F>
inline V as_float_helper(const string& func, const S& str, size_t* idx, F f) {
- typename S::value_type* ptr = nullptr;
- const typename S::value_type* const p = str.c_str();
- __libcpp_remove_reference_t<decltype(errno)> errno_save = errno;
- errno = 0;
- V r = f(p, &ptr);
- swap(errno, errno_save);
- if (errno_save == ERANGE)
- throw_from_string_out_of_range(func);
- if (ptr == p)
- throw_from_string_invalid_arg(func);
- if (idx)
- *idx = static_cast<size_t>(ptr - p);
- return r;
-}
-
-template<typename V, typename S>
+ typename S::value_type* ptr = nullptr;
+ const typename S::value_type* const p = str.c_str();
+ __libcpp_remove_reference_t<decltype(errno)> errno_save = errno;
+ errno = 0;
+ V r = f(p, &ptr);
+ swap(errno, errno_save);
+ if (errno_save == ERANGE)
+ throw_from_string_out_of_range(func);
+ if (ptr == p)
+ throw_from_string_invalid_arg(func);
+ if (idx)
+ *idx = static_cast<size_t>(ptr - p);
+ return r;
+}
+
+template <typename V, typename S>
inline V as_float(const string& func, const S& s, size_t* idx = nullptr);
-template<>
+template <>
inline float as_float(const string& func, const string& s, size_t* idx) {
- return as_float_helper<float>(func, s, idx, strtof);
+ return as_float_helper<float>(func, s, idx, strtof);
}
-template<>
+template <>
inline double as_float(const string& func, const string& s, size_t* idx) {
- return as_float_helper<double>(func, s, idx, strtod);
+ return as_float_helper<double>(func, s, idx, strtod);
}
-template<>
+template <>
inline long double as_float(const string& func, const string& s, size_t* idx) {
- return as_float_helper<long double>(func, s, idx, strtold);
+ return as_float_helper<long double>(func, s, idx, strtold);
}
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-template<>
+template <>
inline float as_float(const string& func, const wstring& s, size_t* idx) {
- return as_float_helper<float>(func, s, idx, wcstof);
+ return as_float_helper<float>(func, s, idx, wcstof);
}
-template<>
+template <>
inline double as_float(const string& func, const wstring& s, size_t* idx) {
- return as_float_helper<double>(func, s, idx, wcstod);
+ return as_float_helper<double>(func, s, idx, wcstod);
}
-template<>
+template <>
inline long double as_float(const string& func, const wstring& s, size_t* idx) {
- return as_float_helper<long double>(func, s, idx, wcstold);
+ return as_float_helper<long double>(func, s, idx, wcstold);
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
-} // unnamed namespace
+} // unnamed namespace
-int stoi(const string& str, size_t* idx, int base) {
- return as_integer<int>("stoi", str, idx, base);
-}
+int stoi(const string& str, size_t* idx, int base) { return as_integer<int>("stoi", str, idx, base); }
-long stol(const string& str, size_t* idx, int base) {
- return as_integer<long>("stol", str, idx, base);
-}
+long stol(const string& str, size_t* idx, int base) { return as_integer<long>("stol", str, idx, base); }
unsigned long stoul(const string& str, size_t* idx, int base) {
- return as_integer<unsigned long>("stoul", str, idx, base);
+ return as_integer<unsigned long>("stoul", str, idx, base);
}
-long long stoll(const string& str, size_t* idx, int base) {
- return as_integer<long long>("stoll", str, idx, base);
-}
+long long stoll(const string& str, size_t* idx, int base) { return as_integer<long long>("stoll", str, idx, base); }
unsigned long long stoull(const string& str, size_t* idx, int base) {
- return as_integer<unsigned long long>("stoull", str, idx, base);
+ return as_integer<unsigned long long>("stoull", str, idx, base);
}
-float stof(const string& str, size_t* idx) {
- return as_float<float>("stof", str, idx);
-}
+float stof(const string& str, size_t* idx) { return as_float<float>("stof", str, idx); }
-double stod(const string& str, size_t* idx) {
- return as_float<double>("stod", str, idx);
-}
+double stod(const string& str, size_t* idx) { return as_float<double>("stod", str, idx); }
-long double stold(const string& str, size_t* idx) {
- return as_float<long double>("stold", str, idx);
-}
+long double stold(const string& str, size_t* idx) { return as_float<long double>("stold", str, idx); }
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-int stoi(const wstring& str, size_t* idx, int base) {
- return as_integer<int>("stoi", str, idx, base);
-}
+int stoi(const wstring& str, size_t* idx, int base) { return as_integer<int>("stoi", str, idx, base); }
-long stol(const wstring& str, size_t* idx, int base) {
- return as_integer<long>("stol", str, idx, base);
-}
+long stol(const wstring& str, size_t* idx, int base) { return as_integer<long>("stol", str, idx, base); }
unsigned long stoul(const wstring& str, size_t* idx, int base) {
- return as_integer<unsigned long>("stoul", str, idx, base);
+ return as_integer<unsigned long>("stoul", str, idx, base);
}
-long long stoll(const wstring& str, size_t* idx, int base) {
- return as_integer<long long>("stoll", str, idx, base);
-}
+long long stoll(const wstring& str, size_t* idx, int base) { return as_integer<long long>("stoll", str, idx, base); }
unsigned long long stoull(const wstring& str, size_t* idx, int base) {
- return as_integer<unsigned long long>("stoull", str, idx, base);
+ return as_integer<unsigned long long>("stoull", str, idx, base);
}
-float stof(const wstring& str, size_t* idx) {
- return as_float<float>("stof", str, idx);
-}
+float stof(const wstring& str, size_t* idx) { return as_float<float>("stof", str, idx); }
-double stod(const wstring& str, size_t* idx) {
- return as_float<double>("stod", str, idx);
-}
+double stod(const wstring& str, size_t* idx) { return as_float<double>("stod", str, idx); }
-long double stold(const wstring& str, size_t* idx) {
- return as_float<long double>("stold", str, idx);
-}
+long double stold(const wstring& str, size_t* idx) { return as_float<long double>("stold", str, idx); }
#endif // !_LIBCPP_HAS_NO_WIDE_CHARACTERS
// to_string
-namespace
-{
+namespace {
// as_string
-template<typename S, typename P, typename V >
+template <typename S, typename P, typename V >
inline S as_string(P sprintf_like, S s, const typename S::value_type* fmt, V a) {
- typedef typename S::size_type size_type;
- size_type available = s.size();
- while (true) {
- int status = sprintf_like(&s[0], available + 1, fmt, a);
- if (status >= 0) {
- size_type used = static_cast<size_type>(status);
- if (used <= available) {
- s.resize(used);
- break;
- }
- available = used; // Assume this is advice of how much space we need.
- }
- else
- available = available * 2 + 1;
- s.resize(available);
- }
- return s;
+ typedef typename S::size_type size_type;
+ size_type available = s.size();
+ while (true) {
+ int status = sprintf_like(&s[0], available + 1, fmt, a);
+ if (status >= 0) {
+ size_type used = static_cast<size_type>(status);
+ if (used <= available) {
+ s.resize(used);
+ break;
+ }
+ available = used; // Assume this is advice of how much space we need.
+ } else
+ available = available * 2 + 1;
+ s.resize(available);
+ }
+ return s;
}
template <class S>
@@ -310,71 +276,71 @@ struct initial_string;
template <>
struct initial_string<string> {
- string operator()() const {
- string s;
- s.resize(s.capacity());
- return s;
- }
+ string operator()() const {
+ string s;
+ s.resize(s.capacity());
+ return s;
+ }
};
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
struct initial_string<wstring> {
- wstring operator()() const {
- wstring s(20, wchar_t());
- s.resize(s.capacity());
- return s;
- }
+ wstring operator()() const {
+ wstring s(20, wchar_t());
+ s.resize(s.capacity());
+ return s;
+ }
};
-typedef int (*wide_printf)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...);
+typedef int (*wide_printf)(wchar_t* __restrict, size_t, const wchar_t* __restrict, ...);
inline wide_printf get_swprintf() {
-#ifndef _LIBCPP_MSVCRT
- return swprintf;
-#else
- return static_cast<int (__cdecl*)(wchar_t* __restrict, size_t, const wchar_t*__restrict, ...)>(_snwprintf);
-#endif
+# ifndef _LIBCPP_MSVCRT
+ return swprintf;
+# else
+ return static_cast<int(__cdecl*)(wchar_t* __restrict, size_t, const wchar_t* __restrict, ...)>(_snwprintf);
+# endif
}
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <typename S, typename V>
S i_to_string(V v) {
-// numeric_limits::digits10 returns value less on 1 than desired for unsigned numbers.
-// For example, for 1-byte unsigned value digits10 is 2 (999 can not be represented),
-// so we need +1 here.
- constexpr size_t bufsize = numeric_limits<V>::digits10 + 2; // +1 for minus, +1 for digits10
- char buf[bufsize];
- const auto res = to_chars(buf, buf + bufsize, v);
- _LIBCPP_ASSERT_INTERNAL(res.ec == errc(), "bufsize must be large enough to accomodate the value");
- return S(buf, res.ptr);
+ // numeric_limits::digits10 returns value less on 1 than desired for unsigned numbers.
+ // For example, for 1-byte unsigned value digits10 is 2 (999 can not be represented),
+ // so we need +1 here.
+ constexpr size_t bufsize = numeric_limits<V>::digits10 + 2; // +1 for minus, +1 for digits10
+ char buf[bufsize];
+ const auto res = to_chars(buf, buf + bufsize, v);
+ _LIBCPP_ASSERT_INTERNAL(res.ec == errc(), "bufsize must be large enough to accomodate the value");
+ return S(buf, res.ptr);
}
-} // unnamed namespace
+} // unnamed namespace
-string to_string (int val) { return i_to_string< string>(val); }
-string to_string (long val) { return i_to_string< string>(val); }
-string to_string (long long val) { return i_to_string< string>(val); }
-string to_string (unsigned val) { return i_to_string< string>(val); }
-string to_string (unsigned long val) { return i_to_string< string>(val); }
-string to_string (unsigned long long val) { return i_to_string< string>(val); }
+string to_string(int val) { return i_to_string< string>(val); }
+string to_string(long val) { return i_to_string< string>(val); }
+string to_string(long long val) { return i_to_string< string>(val); }
+string to_string(unsigned val) { return i_to_string< string>(val); }
+string to_string(unsigned long val) { return i_to_string< string>(val); }
+string to_string(unsigned long long val) { return i_to_string< string>(val); }
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-wstring to_wstring(int val) { return i_to_string<wstring>(val); }
-wstring to_wstring(long val) { return i_to_string<wstring>(val); }
-wstring to_wstring(long long val) { return i_to_string<wstring>(val); }
-wstring to_wstring(unsigned val) { return i_to_string<wstring>(val); }
-wstring to_wstring(unsigned long val) { return i_to_string<wstring>(val); }
+wstring to_wstring(int val) { return i_to_string<wstring>(val); }
+wstring to_wstring(long val) { return i_to_string<wstring>(val); }
+wstring to_wstring(long long val) { return i_to_string<wstring>(val); }
+wstring to_wstring(unsigned val) { return i_to_string<wstring>(val); }
+wstring to_wstring(unsigned long val) { return i_to_string<wstring>(val); }
wstring to_wstring(unsigned long long val) { return i_to_string<wstring>(val); }
#endif
-string to_string (float val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
-string to_string (double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
-string to_string (long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); }
+string to_string(float val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
+string to_string(double val) { return as_string(snprintf, initial_string< string>()(), "%f", val); }
+string to_string(long double val) { return as_string(snprintf, initial_string< string>()(), "%Lf", val); }
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
-wstring to_wstring(float val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
-wstring to_wstring(double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
+wstring to_wstring(float val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
+wstring to_wstring(double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%f", val); }
wstring to_wstring(long double val) { return as_string(get_swprintf(), initial_string<wstring>()(), L"%Lf", val); }
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp
index 6edc3c254d..122dc5ed89 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#include <cstddef> // size_t
-#include <cwchar> // mbstate_t
+#include <cstddef> // size_t
+#include <cwchar> // mbstate_t
#include <limits.h> // MB_LEN_MAX
#include <string.h> // wmemcpy
@@ -18,12 +18,14 @@
// Returns (size_t) -1 when an invalid sequence is encountered.
// Leaves *`src` pointing to the next character to convert or NULL
// if a null character was converted from *`src`.
-_LIBCPP_EXPORTED_FROM_ABI
-size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
- size_t src_size_bytes, size_t max_dest_chars,
- mbstate_t *__restrict ps) {
+_LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs(
+ wchar_t* __restrict dst,
+ const char** __restrict src,
+ size_t src_size_bytes,
+ size_t max_dest_chars,
+ mbstate_t* __restrict ps) {
const size_t terminated_sequence = static_cast<size_t>(0);
- const size_t invalid_sequence = static_cast<size_t>(-1);
+ const size_t invalid_sequence = static_cast<size_t>(-1);
const size_t incomplete_sequence = static_cast<size_t>(-2);
size_t source_converted;
@@ -43,7 +45,7 @@ size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
// If result (char_size) is zero, it indicates that the null character has been found.
// Otherwise, it's an error and errno may be set.
size_t source_remaining = src_size_bytes - source_converted;
- size_t dest_remaining = max_dest_chars - dest_converted;
+ size_t dest_remaining = max_dest_chars - dest_converted;
if (dst == nullptr) {
result = mbrtowc(NULL, *src + source_converted, source_remaining, ps);
@@ -52,12 +54,12 @@ size_t mbsnrtowcs(wchar_t *__restrict dst, const char **__restrict src,
result = mbrtowc(dst + dest_converted, *src + source_converted, source_remaining, ps);
} else {
/*
- * dst may not have enough space, so use a temporary buffer.
- *
- * We need to save a copy of the conversion state
- * here so we can restore it if the multibyte
- * character is too long for the buffer.
- */
+ * dst may not have enough space, so use a temporary buffer.
+ *
+ * We need to save a copy of the conversion state
+ * here so we can restore it if the multibyte
+ * character is too long for the buffer.
+ */
wchar_t buff[MB_LEN_MAX];
mbstate_t mbstate_tmp;
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp
index d6333fe5f1..f037215233 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp
@@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
-#include <cwchar> // mbstate_t
+#include <cwchar> // mbstate_t
#include <limits.h> // MB_LEN_MAX
#include <stdlib.h> // MB_CUR_MAX, size_t
#include <string.h> // memcpy
@@ -17,11 +17,12 @@
// converted from *src, excluding the null terminator.
// Returns (size_t) -1 if an error occurs and sets errno.
// If `dst` is NULL, `dst_size_bytes` is ignored and no bytes are copied to `dst`.
-_LIBCPP_EXPORTED_FROM_ABI
-size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
- size_t max_source_chars, size_t dst_size_bytes,
- mbstate_t *__restrict ps) {
-
+_LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs(
+ char* __restrict dst,
+ const wchar_t** __restrict src,
+ size_t max_source_chars,
+ size_t dst_size_bytes,
+ mbstate_t* __restrict ps) {
const size_t invalid_wchar = static_cast<size_t>(-1);
size_t source_converted;
@@ -36,7 +37,7 @@ size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
for (dest_converted = source_converted = 0;
source_converted < max_source_chars && (!dst || dest_converted < dst_size_bytes);
++source_converted, dest_converted += result) {
- wchar_t c = (*src)[source_converted];
+ wchar_t c = (*src)[source_converted];
size_t dest_remaining = dst_size_bytes - dest_converted;
if (dst == nullptr) {
@@ -46,12 +47,12 @@ size_t wcsnrtombs(char *__restrict dst, const wchar_t **__restrict src,
result = wcrtomb(dst + dest_converted, c, ps);
} else {
/*
- * dst may not have enough space, so use a temporary buffer.
- *
- * We need to save a copy of the conversion state
- * here so we can restore it if the multibyte
- * character is too long for the buffer.
- */
+ * dst may not have enough space, so use a temporary buffer.
+ *
+ * We need to save a copy of the conversion state
+ * here so we can restore it if the multibyte
+ * character is too long for the buffer.
+ */
char buff[MB_LEN_MAX];
mbstate_t mbstate_tmp;
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp
index 034a5b9660..4c20997b4e 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp
@@ -39,7 +39,7 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {
if (base) {
if (category_mask != LC_ALL_MASK) {
// Copy base when it will not be overwritten.
- memcpy(newloc, base, sizeof (locale_struct));
+ memcpy(newloc, base, sizeof(locale_struct));
newloc->category_mask = category_mask | base->category_mask;
}
delete base;
@@ -65,9 +65,7 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {
return (locale_t)newloc;
}
-void freelocale(locale_t locobj) {
- delete locobj;
-}
+void freelocale(locale_t locobj) { delete locobj; }
locale_t uselocale(locale_t newloc) {
// Maintain current locale name(s).
@@ -76,18 +74,12 @@ locale_t uselocale(locale_t newloc) {
if (newloc) {
// Set locales and check for errors.
bool is_error =
- (newloc->category_mask & LC_COLLATE_MASK &&
- setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) ||
- (newloc->category_mask & LC_CTYPE_MASK &&
- setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) ||
- (newloc->category_mask & LC_MONETARY_MASK &&
- setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) ||
- (newloc->category_mask & LC_NUMERIC_MASK &&
- setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) ||
- (newloc->category_mask & LC_TIME_MASK &&
- setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) ||
- (newloc->category_mask & LC_MESSAGES_MASK &&
- setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL);
+ (newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) ||
+ (newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) ||
+ (newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) ||
+ (newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) ||
+ (newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) ||
+ (newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL);
if (is_error) {
setlocale(LC_ALL, current_loc_name.c_str());
@@ -108,24 +100,24 @@ locale_t uselocale(locale_t newloc) {
std::string s;
while (std::getline(ss, s, delimiter)) {
- tokenized.push_back(s);
+ tokenized.push_back(s);
}
_LIBCPP_ASSERT_UNCATEGORIZED(tokenized.size() >= _NCAT, "locale-name list is too short");
- previous_loc->lc_collate = tokenized[LC_COLLATE];
- previous_loc->lc_ctype = tokenized[LC_CTYPE];
+ previous_loc->lc_collate = tokenized[LC_COLLATE];
+ previous_loc->lc_ctype = tokenized[LC_CTYPE];
previous_loc->lc_monetary = tokenized[LC_MONETARY];
- previous_loc->lc_numeric = tokenized[LC_NUMERIC];
- previous_loc->lc_time = tokenized[LC_TIME];
+ previous_loc->lc_numeric = tokenized[LC_NUMERIC];
+ previous_loc->lc_time = tokenized[LC_TIME];
// Skip LC_TOD.
previous_loc->lc_messages = tokenized[LC_MESSAGES];
} else {
- previous_loc->lc_collate = current_loc_name;
- previous_loc->lc_ctype = current_loc_name;
+ previous_loc->lc_collate = current_loc_name;
+ previous_loc->lc_ctype = current_loc_name;
previous_loc->lc_monetary = current_loc_name;
- previous_loc->lc_numeric = current_loc_name;
- previous_loc->lc_time = current_loc_name;
+ previous_loc->lc_numeric = current_loc_name;
+ previous_loc->lc_time = current_loc_name;
previous_loc->lc_messages = current_loc_name;
}
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp
index c14c375338..d54a9a5846 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_fallback.ipp
@@ -11,63 +11,43 @@
namespace std {
-static constinit std::terminate_handler __terminate_handler = nullptr;
+static constinit std::terminate_handler __terminate_handler = nullptr;
static constinit std::unexpected_handler __unexpected_handler = nullptr;
// libcxxrt provides implementations of these functions itself.
-unexpected_handler
-set_unexpected(unexpected_handler func) noexcept
-{
+unexpected_handler set_unexpected(unexpected_handler func) noexcept {
return __libcpp_atomic_exchange(&__unexpected_handler, func);
}
-unexpected_handler
-get_unexpected() noexcept
-{
- return __libcpp_atomic_load(&__unexpected_handler);
-}
+unexpected_handler get_unexpected() noexcept { return __libcpp_atomic_load(&__unexpected_handler); }
-_LIBCPP_NORETURN
-void unexpected()
-{
- (*get_unexpected())();
- // unexpected handler should not return
- terminate();
+_LIBCPP_NORETURN void unexpected() {
+ (*get_unexpected())();
+ // unexpected handler should not return
+ terminate();
}
-terminate_handler
-set_terminate(terminate_handler func) noexcept
-{
+terminate_handler set_terminate(terminate_handler func) noexcept {
return __libcpp_atomic_exchange(&__terminate_handler, func);
}
-terminate_handler
-get_terminate() noexcept
-{
- return __libcpp_atomic_load(&__terminate_handler);
-}
+terminate_handler get_terminate() noexcept { return __libcpp_atomic_load(&__terminate_handler); }
#ifndef __EMSCRIPTEN__ // We provide this in JS
-_LIBCPP_NORETURN
-void
-terminate() noexcept
-{
+_LIBCPP_NORETURN void terminate() noexcept {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- try
- {
+ try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
- (*get_terminate())();
- // handler should not return
- fprintf(stderr, "terminate_handler unexpectedly returned\n");
- ::abort();
+ (*get_terminate())();
+ // handler should not return
+ fprintf(stderr, "terminate_handler unexpectedly returned\n");
+ ::abort();
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- }
- catch (...)
- {
- // handler should not throw exception
- fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
- ::abort();
- }
+ } catch (...) {
+ // handler should not throw exception
+ fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
+ ::abort();
+ }
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
#endif // !__EMSCRIPTEN__
@@ -75,88 +55,43 @@ terminate() noexcept
#if !defined(__EMSCRIPTEN__)
bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
-int uncaught_exceptions() noexcept
-{
+int uncaught_exceptions() noexcept {
#warning uncaught_exception not yet implemented
fprintf(stderr, "uncaught_exceptions not yet implemented\n");
::abort();
}
#endif // !__EMSCRIPTEN__
+exception::~exception() noexcept {}
-exception::~exception() noexcept
-{
-}
-
-const char* exception::what() const noexcept
-{
- return "std::exception";
-}
-
-bad_exception::~bad_exception() noexcept
-{
-}
+const char* exception::what() const noexcept { return "std::exception"; }
-const char* bad_exception::what() const noexcept
-{
- return "std::bad_exception";
-}
+bad_exception::~bad_exception() noexcept {}
+const char* bad_exception::what() const noexcept { return "std::bad_exception"; }
-bad_alloc::bad_alloc() noexcept
-{
-}
+bad_alloc::bad_alloc() noexcept {}
-bad_alloc::~bad_alloc() noexcept
-{
-}
+bad_alloc::~bad_alloc() noexcept {}
-const char*
-bad_alloc::what() const noexcept
-{
- return "std::bad_alloc";
-}
+const char* bad_alloc::what() const noexcept { return "std::bad_alloc"; }
-bad_array_new_length::bad_array_new_length() noexcept
-{
-}
+bad_array_new_length::bad_array_new_length() noexcept {}
-bad_array_new_length::~bad_array_new_length() noexcept
-{
-}
+bad_array_new_length::~bad_array_new_length() noexcept {}
-const char*
-bad_array_new_length::what() const noexcept
-{
- return "bad_array_new_length";
-}
+const char* bad_array_new_length::what() const noexcept { return "bad_array_new_length"; }
-bad_cast::bad_cast() noexcept
-{
-}
+bad_cast::bad_cast() noexcept {}
-bad_typeid::bad_typeid() noexcept
-{
-}
+bad_typeid::bad_typeid() noexcept {}
-bad_cast::~bad_cast() noexcept
-{
-}
+bad_cast::~bad_cast() noexcept {}
-const char*
-bad_cast::what() const noexcept
-{
- return "std::bad_cast";
-}
+const char* bad_cast::what() const noexcept { return "std::bad_cast"; }
-bad_typeid::~bad_typeid() noexcept
-{
-}
+bad_typeid::~bad_typeid() noexcept {}
-const char*
-bad_typeid::what() const noexcept
-{
- return "std::bad_typeid";
-}
+const char* bad_typeid::what() const noexcept { return "std::bad_typeid"; }
} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_glibcxx.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_glibcxx.ipp
index e478ccbb6e..aa67cab6bc 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_glibcxx.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_glibcxx.ipp
@@ -8,25 +8,17 @@
//===----------------------------------------------------------------------===//
#ifndef __GLIBCXX__
-#error header can only be used when targeting libstdc++ or libsupc++
+# error header can only be used when targeting libstdc++ or libsupc++
#endif
namespace std {
-bad_alloc::bad_alloc() noexcept
-{
-}
+bad_alloc::bad_alloc() noexcept {}
-bad_array_new_length::bad_array_new_length() noexcept
-{
-}
+bad_array_new_length::bad_array_new_length() noexcept {}
-bad_cast::bad_cast() noexcept
-{
-}
+bad_cast::bad_cast() noexcept {}
-bad_typeid::bad_typeid() noexcept
-{
-}
+bad_typeid::bad_typeid() noexcept {}
} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxabi.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxabi.ipp
index ee15e437e6..df6bd6574b 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxabi.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxabi.ipp
@@ -8,20 +8,19 @@
//===----------------------------------------------------------------------===//
#ifndef _LIBCPPABI_VERSION
-#error this header can only be used with libc++abi
+# error this header can only be used with libc++abi
#endif
namespace std {
bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
-int uncaught_exceptions() noexcept
-{
-# if _LIBCPPABI_VERSION > 1001
- return __cxa_uncaught_exceptions();
-# else
- return __cxa_uncaught_exception() ? 1 : 0;
-# endif
+int uncaught_exceptions() noexcept {
+#if _LIBCPPABI_VERSION > 1001
+ return __cxa_uncaught_exceptions();
+#else
+ return __cxa_uncaught_exception() ? 1 : 0;
+#endif
}
} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxrt.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxrt.ipp
index 4e428d216c..82f60f5048 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxrt.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_libcxxrt.ipp
@@ -8,18 +8,13 @@
//===----------------------------------------------------------------------===//
#ifndef LIBCXX_BUILDING_LIBCXXRT
-#error this header may only be used when targeting libcxxrt
+# error this header may only be used when targeting libcxxrt
#endif
namespace std {
-bad_exception::~bad_exception() noexcept
-{
-}
+bad_exception::~bad_exception() noexcept {}
-const char* bad_exception::what() const noexcept
-{
- return "std::bad_exception";
-}
+const char* bad_exception::what() const noexcept { return "std::bad_exception"; }
} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_msvc.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_msvc.ipp
index 0114d5adee..323cd9d180 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_msvc.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_msvc.ipp
@@ -8,21 +8,19 @@
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_ABI_MICROSOFT
-#error this header can only be used when targeting the MSVC ABI
+# error this header can only be used when targeting the MSVC ABI
#endif
#include <stdio.h>
#include <stdlib.h>
extern "C" {
-typedef void (__cdecl* terminate_handler)();
-_LIBCPP_CRT_FUNC terminate_handler __cdecl set_terminate(
- terminate_handler _NewTerminateHandler) throw();
+typedef void(__cdecl* terminate_handler)();
+_LIBCPP_CRT_FUNC terminate_handler __cdecl set_terminate(terminate_handler _NewTerminateHandler) throw();
_LIBCPP_CRT_FUNC terminate_handler __cdecl _get_terminate();
-typedef void (__cdecl* unexpected_handler)();
-unexpected_handler __cdecl set_unexpected(
- unexpected_handler _NewUnexpectedHandler) throw();
+typedef void(__cdecl* unexpected_handler)();
+unexpected_handler __cdecl set_unexpected(unexpected_handler _NewUnexpectedHandler) throw();
unexpected_handler __cdecl _get_unexpected();
int __cdecl __uncaught_exceptions();
@@ -30,134 +28,73 @@ int __cdecl __uncaught_exceptions();
namespace std {
-unexpected_handler
-set_unexpected(unexpected_handler func) noexcept {
- return ::set_unexpected(func);
-}
+unexpected_handler set_unexpected(unexpected_handler func) noexcept { return ::set_unexpected(func); }
-unexpected_handler get_unexpected() noexcept {
- return ::_get_unexpected();
-}
+unexpected_handler get_unexpected() noexcept { return ::_get_unexpected(); }
-_LIBCPP_NORETURN
-void unexpected() {
- (*get_unexpected())();
- // unexpected handler should not return
- terminate();
+_LIBCPP_NORETURN void unexpected() {
+ (*get_unexpected())();
+ // unexpected handler should not return
+ terminate();
}
-terminate_handler set_terminate(terminate_handler func) noexcept {
- return ::set_terminate(func);
-}
+terminate_handler set_terminate(terminate_handler func) noexcept { return ::set_terminate(func); }
-terminate_handler get_terminate() noexcept {
- return ::_get_terminate();
-}
+terminate_handler get_terminate() noexcept { return ::_get_terminate(); }
-_LIBCPP_NORETURN
-void terminate() noexcept
-{
+_LIBCPP_NORETURN void terminate() noexcept {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- try
- {
+ try {
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
- (*get_terminate())();
- // handler should not return
- fprintf(stderr, "terminate_handler unexpectedly returned\n");
- ::abort();
+ (*get_terminate())();
+ // handler should not return
+ fprintf(stderr, "terminate_handler unexpectedly returned\n");
+ ::abort();
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- }
- catch (...)
- {
- // handler should not throw exception
- fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
- ::abort();
- }
+ } catch (...) {
+ // handler should not throw exception
+ fprintf(stderr, "terminate_handler unexpectedly threw an exception\n");
+ ::abort();
+ }
#endif // _LIBCPP_HAS_NO_EXCEPTIONS
}
bool uncaught_exception() noexcept { return uncaught_exceptions() > 0; }
-int uncaught_exceptions() noexcept {
- return __uncaught_exceptions();
-}
+int uncaught_exceptions() noexcept { return __uncaught_exceptions(); }
#if !defined(_LIBCPP_ABI_VCRUNTIME)
-bad_cast::bad_cast() noexcept
-{
-}
+bad_cast::bad_cast() noexcept {}
-bad_cast::~bad_cast() noexcept
-{
-}
+bad_cast::~bad_cast() noexcept {}
-const char *
-bad_cast::what() const noexcept
-{
- return "std::bad_cast";
-}
+const char* bad_cast::what() const noexcept { return "std::bad_cast"; }
-bad_typeid::bad_typeid() noexcept
-{
-}
+bad_typeid::bad_typeid() noexcept {}
-bad_typeid::~bad_typeid() noexcept
-{
-}
+bad_typeid::~bad_typeid() noexcept {}
-const char *
-bad_typeid::what() const noexcept
-{
- return "std::bad_typeid";
-}
+const char* bad_typeid::what() const noexcept { return "std::bad_typeid"; }
-exception::~exception() noexcept
-{
-}
+exception::~exception() noexcept {}
-const char* exception::what() const noexcept
-{
- return "std::exception";
-}
+const char* exception::what() const noexcept { return "std::exception"; }
+bad_exception::~bad_exception() noexcept {}
-bad_exception::~bad_exception() noexcept
-{
-}
+const char* bad_exception::what() const noexcept { return "std::bad_exception"; }
-const char* bad_exception::what() const noexcept
-{
- return "std::bad_exception";
-}
+bad_alloc::bad_alloc() noexcept {}
+bad_alloc::~bad_alloc() noexcept {}
-bad_alloc::bad_alloc() noexcept
-{
-}
+const char* bad_alloc::what() const noexcept { return "std::bad_alloc"; }
-bad_alloc::~bad_alloc() noexcept
-{
-}
+bad_array_new_length::bad_array_new_length() noexcept {}
-const char*
-bad_alloc::what() const noexcept
-{
- return "std::bad_alloc";
-}
+bad_array_new_length::~bad_array_new_length() noexcept {}
-bad_array_new_length::bad_array_new_length() noexcept
-{
-}
-
-bad_array_new_length::~bad_array_new_length() noexcept
-{
-}
-
-const char*
-bad_array_new_length::what() const noexcept
-{
- return "bad_array_new_length";
-}
+const char* bad_array_new_length::what() const noexcept { return "bad_array_new_length"; }
#endif // !_LIBCPP_ABI_VCRUNTIME
} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
index 33aa94502b..c07de5838b 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_cxxabi.ipp
@@ -8,66 +8,49 @@
//===----------------------------------------------------------------------===//
#ifndef HAVE_DEPENDENT_EH_ABI
-#error this header may only be used with libc++abi or libcxxrt
+# error this header may only be used with libc++abi or libcxxrt
#endif
namespace std {
-exception_ptr::~exception_ptr() noexcept {
- __cxa_decrement_exception_refcount(__ptr_);
-}
+exception_ptr::~exception_ptr() noexcept { __cxa_decrement_exception_refcount(__ptr_); }
-exception_ptr::exception_ptr(const exception_ptr& other) noexcept
- : __ptr_(other.__ptr_)
-{
- __cxa_increment_exception_refcount(__ptr_);
+exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) {
+ __cxa_increment_exception_refcount(__ptr_);
}
-exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
-{
- if (__ptr_ != other.__ptr_)
- {
- __cxa_increment_exception_refcount(other.__ptr_);
- __cxa_decrement_exception_refcount(__ptr_);
- __ptr_ = other.__ptr_;
- }
- return *this;
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept {
+ if (__ptr_ != other.__ptr_) {
+ __cxa_increment_exception_refcount(other.__ptr_);
+ __cxa_decrement_exception_refcount(__ptr_);
+ __ptr_ = other.__ptr_;
+ }
+ return *this;
}
-nested_exception::nested_exception() noexcept
- : __ptr_(current_exception())
-{
-}
+nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
-nested_exception::~nested_exception() noexcept
-{
-}
+nested_exception::~nested_exception() noexcept {}
-_LIBCPP_NORETURN
-void
-nested_exception::rethrow_nested() const
-{
- if (__ptr_ == nullptr)
- terminate();
- rethrow_exception(__ptr_);
+_LIBCPP_NORETURN void nested_exception::rethrow_nested() const {
+ if (__ptr_ == nullptr)
+ terminate();
+ rethrow_exception(__ptr_);
}
-exception_ptr current_exception() noexcept
-{
- // be nicer if there was a constructor that took a ptr, then
- // this whole function would be just:
- // return exception_ptr(__cxa_current_primary_exception());
- exception_ptr ptr;
- ptr.__ptr_ = __cxa_current_primary_exception();
- return ptr;
+exception_ptr current_exception() noexcept {
+ // be nicer if there was a constructor that took a ptr, then
+ // this whole function would be just:
+ // return exception_ptr(__cxa_current_primary_exception());
+ exception_ptr ptr;
+ ptr.__ptr_ = __cxa_current_primary_exception();
+ return ptr;
}
-_LIBCPP_NORETURN
-void rethrow_exception(exception_ptr p)
-{
- __cxa_rethrow_primary_exception(p.__ptr_);
- // if p.__ptr_ is NULL, above returns so we terminate
- terminate();
+_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) {
+ __cxa_rethrow_primary_exception(p.__ptr_);
+ // if p.__ptr_ is NULL, above returns so we terminate
+ terminate();
}
} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
index 983a08808d..8e0e63cd4d 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_glibcxx.ipp
@@ -18,60 +18,43 @@
namespace std {
-namespace __exception_ptr
-{
+namespace __exception_ptr {
-struct exception_ptr
-{
- void* __ptr_;
+struct exception_ptr {
+ void* __ptr_;
- exception_ptr(const exception_ptr&) noexcept;
- exception_ptr& operator=(const exception_ptr&) noexcept;
- ~exception_ptr() noexcept;
+ exception_ptr(const exception_ptr&) noexcept;
+ exception_ptr& operator=(const exception_ptr&) noexcept;
+ ~exception_ptr() noexcept;
};
-}
+} // namespace __exception_ptr
_LIBCPP_NORETURN void rethrow_exception(__exception_ptr::exception_ptr);
-exception_ptr::~exception_ptr() noexcept
-{
- reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr();
-}
-
-exception_ptr::exception_ptr(const exception_ptr& other) noexcept
- : __ptr_(other.__ptr_)
-{
- new (reinterpret_cast<void*>(this)) __exception_ptr::exception_ptr(
- reinterpret_cast<const __exception_ptr::exception_ptr&>(other));
-}
+exception_ptr::~exception_ptr() noexcept { reinterpret_cast<__exception_ptr::exception_ptr*>(this)->~exception_ptr(); }
-exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
-{
- *reinterpret_cast<__exception_ptr::exception_ptr*>(this) =
- reinterpret_cast<const __exception_ptr::exception_ptr&>(other);
- return *this;
+exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) {
+ new (reinterpret_cast<void*>(this))
+ __exception_ptr::exception_ptr(reinterpret_cast<const __exception_ptr::exception_ptr&>(other));
}
-nested_exception::nested_exception() noexcept
- : __ptr_(current_exception())
-{
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept {
+ *reinterpret_cast<__exception_ptr::exception_ptr*>(this) =
+ reinterpret_cast<const __exception_ptr::exception_ptr&>(other);
+ return *this;
}
+nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
-_LIBCPP_NORETURN
-void
-nested_exception::rethrow_nested() const
-{
- if (__ptr_ == nullptr)
- terminate();
- rethrow_exception(__ptr_);
+_LIBCPP_NORETURN void nested_exception::rethrow_nested() const {
+ if (__ptr_ == nullptr)
+ terminate();
+ rethrow_exception(__ptr_);
}
-_LIBCPP_NORETURN
-void rethrow_exception(exception_ptr p)
-{
- rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p));
+_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) {
+ rethrow_exception(reinterpret_cast<__exception_ptr::exception_ptr&>(p));
}
} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp
index c88c68cca5..43ac8ca7e1 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_msvc.ipp
@@ -63,8 +63,7 @@ extern "C" EHExceptionRecord** __current_exception();
#ifdef __clang__
struct _ThrowInfo;
// defined in vcruntime<ver>.dll
-extern "C" _LIBCPP_NORETURN void __stdcall _CxxThrowException(
- void* __exc, _ThrowInfo* __throw_info);
+extern "C" _LIBCPP_NORETURN void __stdcall _CxxThrowException(void* __exc, _ThrowInfo* __throw_info);
#endif
namespace {
@@ -78,15 +77,12 @@ struct ExceptionPtr {
template <class T>
T convert(int32_t offset) {
#ifdef _M_AMD64
- uintptr_t value = reinterpret_cast<uintptr_t>(image_base) +
- static_cast<uintptr_t>(offset);
+ uintptr_t value = reinterpret_cast<uintptr_t>(image_base) + static_cast<uintptr_t>(offset);
#else
uintptr_t value = static_cast<uintptr_t>(offset);
#endif
T res;
- static_assert(
- sizeof(value) == sizeof(res),
- "Can only convert to pointers or pointers to member functions");
+ static_assert(sizeof(value) == sizeof(res), "Can only convert to pointers or pointers to member functions");
memcpy(&res, &value, sizeof(value));
return res;
}
@@ -97,31 +93,26 @@ struct ExceptionPtr {
if (exc_type->copy_function == 0) {
memcpy(dst, src, exc_type->size);
} else if (exc_type->properties & virtual_base) {
- auto copy_constructor =
- convert<void (Temp::*)(const void*, int)>(exc_type->copy_function);
+ auto copy_constructor = convert<void (Temp::*)(const void*, int)>(exc_type->copy_function);
((Temp*)dst->*copy_constructor)(src, 1);
} else {
- auto copy_constructor =
- convert<void (Temp::*)(const void*)>(exc_type->copy_function);
+ auto copy_constructor = convert<void (Temp::*)(const void*)>(exc_type->copy_function);
((Temp*)dst->*copy_constructor)(src);
}
}
EHCatchableType* exception_type() {
return convert<EHCatchableType*>(
- convert<EHCatchableTypeArray*>(throw_info->catchable_type_array)
- ->array_of_catchable_types[0]);
+ convert<EHCatchableTypeArray*>(throw_info->catchable_type_array)->array_of_catchable_types[0]);
}
ExceptionPtr(const void* exception_object_, const EHThrowInfo* throw_info_)
: exception_object(nullptr), throw_info(throw_info_), counter(1) {
#ifdef _M_AMD64
- RtlPcToFileHeader(
- reinterpret_cast<PVOID>(const_cast<EHThrowInfo*>(throw_info)),
- &image_base);
+ RtlPcToFileHeader(reinterpret_cast<PVOID>(const_cast<EHThrowInfo*>(throw_info)), &image_base);
#endif
EHCatchableType* exc_type = exception_type();
- this->exception_object = malloc(exc_type->size);
+ this->exception_object = malloc(exc_type->size);
if (this->exception_object == nullptr) {
throw std::bad_alloc();
}
@@ -140,19 +131,19 @@ struct ExceptionPtr {
// _bad_alloc_storage must be initialized before bad_alloc, so we declare and define it first.
static std::bad_alloc _bad_alloc_storage;
static ExceptionPtr bad_alloc;
- //static ExceptionPtr bad_exception;
+ // static ExceptionPtr bad_exception;
};
#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Waddress-of-temporary"
+# pragma clang diagnostic push
+# pragma clang diagnostic ignored "-Waddress-of-temporary"
#endif
std::bad_alloc ExceptionPtr::_bad_alloc_storage;
-ExceptionPtr ExceptionPtr::bad_alloc(
- &ExceptionPtr::_bad_alloc_storage,
- reinterpret_cast<const EHThrowInfo*>(__GetExceptionInfo(ExceptionPtr::_bad_alloc_storage)));
+ExceptionPtr
+ ExceptionPtr::bad_alloc(&ExceptionPtr::_bad_alloc_storage,
+ reinterpret_cast<const EHThrowInfo*>(__GetExceptionInfo(ExceptionPtr::_bad_alloc_storage)));
/* ExceptionPtr
ExceptionPtr::bad_exception(&std::bad_exception(),
@@ -160,24 +151,22 @@ ExceptionPtr::bad_exception(&std::bad_exception(),
__GetExceptionInfo(std::bad_exception()))); */
#ifdef __clang__
-#pragma clang diagnostic pop
+# pragma clang diagnostic pop
#endif
} // namespace
namespace std {
-exception_ptr::exception_ptr(const exception_ptr& __other) noexcept
- : __ptr_(__other.__ptr_) {
+exception_ptr::exception_ptr(const exception_ptr& __other) noexcept : __ptr_(__other.__ptr_) {
if (__ptr_) {
reinterpret_cast<ExceptionPtr*>(__ptr_)->counter.fetch_add(1);
}
}
-exception_ptr& exception_ptr::
-operator=(const exception_ptr& __other) noexcept {
+exception_ptr& exception_ptr::operator=(const exception_ptr& __other) noexcept {
auto before = __ptr_;
- __ptr_ = __other.__ptr_;
+ __ptr_ = __other.__ptr_;
if (__ptr_) {
reinterpret_cast<ExceptionPtr*>(__ptr_)->counter.fetch_add(1);
}
@@ -197,18 +186,16 @@ exception_ptr::~exception_ptr() noexcept {
}
}
-exception_ptr __copy_exception_ptr(void* exception_object,
- const void* throw_info) {
+exception_ptr __copy_exception_ptr(void* exception_object, const void* throw_info) {
ExceptionPtr* ptr;
try {
- ptr = new ExceptionPtr(exception_object,
- reinterpret_cast<const EHThrowInfo*>(throw_info));
+ ptr = new ExceptionPtr(exception_object, reinterpret_cast<const EHThrowInfo*>(throw_info));
} catch (const std::bad_alloc&) {
ptr = &ExceptionPtr::bad_alloc;
ptr->counter.fetch_add(1);
} catch (...) {
- //ptr = &ExceptionPtr::bad_exception;
- //ptr->counter.fetch_add(1);
+ // ptr = &ExceptionPtr::bad_exception;
+ // ptr->counter.fetch_add(1);
std::terminate();
}
exception_ptr res;
@@ -219,25 +206,22 @@ exception_ptr __copy_exception_ptr(void* exception_object,
exception_ptr current_exception() noexcept {
EHExceptionRecord** record = __current_exception();
if (*record && !std::uncaught_exception()) {
- return __copy_exception_ptr((*record)->parameters.exception_object,
- (*record)->parameters.throw_info);
+ return __copy_exception_ptr((*record)->parameters.exception_object, (*record)->parameters.throw_info);
}
return exception_ptr();
}
-_LIBCPP_NORETURN
-void rethrow_exception(exception_ptr p) {
+_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) {
if (!p) {
throw std::bad_exception();
}
- ExceptionPtr* exc_ptr = reinterpret_cast<ExceptionPtr*>(p.__ptr_);
+ ExceptionPtr* exc_ptr = reinterpret_cast<ExceptionPtr*>(p.__ptr_);
EHCatchableType* exc_type = exc_ptr->exception_type();
// _CxxThrowException doesn't call free on exception object so we must
// allocate it on the stack.
void* dst = _alloca(exc_type->size);
exc_ptr->copy(dst, exc_ptr->exception_object, exc_type);
- auto throw_info = reinterpret_cast<_ThrowInfo*>(
- const_cast<EHThrowInfo*>(exc_ptr->throw_info));
+ auto throw_info = reinterpret_cast<_ThrowInfo*>(const_cast<EHThrowInfo*>(exc_ptr->throw_info));
// For some reason clang doesn't call p destructor during unwinding.
// So we must clear it ourselves.
p = nullptr;
@@ -248,8 +232,7 @@ nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
nested_exception::~nested_exception() noexcept {}
-_LIBCPP_NORETURN
-void nested_exception::rethrow_nested() const {
+_LIBCPP_NORETURN void nested_exception::rethrow_nested() const {
if (__ptr_ == nullptr)
terminate();
rethrow_exception(__ptr_);
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp
index 9e8ec04e11..de0605d777 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/exception_pointer_unimplemented.ipp
@@ -12,46 +12,34 @@
namespace std {
-exception_ptr::~exception_ptr() noexcept
-{
-# warning exception_ptr not yet implemented
+exception_ptr::~exception_ptr() noexcept {
+#warning exception_ptr not yet implemented
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
}
-exception_ptr::exception_ptr(const exception_ptr& other) noexcept
- : __ptr_(other.__ptr_)
-{
-# warning exception_ptr not yet implemented
+exception_ptr::exception_ptr(const exception_ptr& other) noexcept : __ptr_(other.__ptr_) {
+#warning exception_ptr not yet implemented
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
}
-exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept
-{
-# warning exception_ptr not yet implemented
+exception_ptr& exception_ptr::operator=(const exception_ptr& other) noexcept {
+#warning exception_ptr not yet implemented
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
}
-nested_exception::nested_exception() noexcept
- : __ptr_(current_exception())
-{
-}
+nested_exception::nested_exception() noexcept : __ptr_(current_exception()) {}
#if !defined(__GLIBCXX__)
-nested_exception::~nested_exception() noexcept
-{
-}
+nested_exception::~nested_exception() noexcept {}
#endif
-_LIBCPP_NORETURN
-void
-nested_exception::rethrow_nested() const
-{
-# warning exception_ptr not yet implemented
+_LIBCPP_NORETURN void nested_exception::rethrow_nested() const {
+#warning exception_ptr not yet implemented
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
#if 0
@@ -61,17 +49,14 @@ nested_exception::rethrow_nested() const
#endif // FIXME
}
-exception_ptr current_exception() noexcept
-{
-# warning exception_ptr not yet implemented
+exception_ptr current_exception() noexcept {
+#warning exception_ptr not yet implemented
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
}
-_LIBCPP_NORETURN
-void rethrow_exception(exception_ptr p)
-{
-# warning exception_ptr not yet implemented
+_LIBCPP_NORETURN void rethrow_exception(exception_ptr p) {
+#warning exception_ptr not yet implemented
fprintf(stderr, "exception_ptr not yet implemented\n");
::abort();
}
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_default.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_default.ipp
index d0218bfbc6..f2bb2ea3e7 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_default.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_default.ipp
@@ -9,9 +9,9 @@
#include "../../include/refstring.h"
/* For _LIBCPPABI_VERSION */
-#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
+#if !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) && \
(defined(LIBCXX_BUILDING_LIBCXXABI) || defined(LIBCXX_BUILDING_LIBCXXRT))
-#include <cxxabi.h>
+# include <cxxabi.h>
#endif
static_assert(sizeof(std::__libcpp_refstring) == sizeof(const char*), "");
@@ -34,8 +34,7 @@ runtime_error::runtime_error(const string& msg) : __imp_(msg.c_str()) {}
runtime_error::runtime_error(const char* msg) : __imp_(msg) {}
-runtime_error::runtime_error(const runtime_error& re) noexcept
- : __imp_(re.__imp_) {}
+runtime_error::runtime_error(const runtime_error& re) noexcept : __imp_(re.__imp_) {}
runtime_error& runtime_error::operator=(const runtime_error& re) noexcept {
__imp_ = re.__imp_;
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_vcruntime.ipp b/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_vcruntime.ipp
index db9097d097..e6ecbf782f 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_vcruntime.ipp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/runtime/stdexcept_vcruntime.ipp
@@ -7,7 +7,7 @@
//===----------------------------------------------------------------------===//
#ifndef _LIBCPP_ABI_VCRUNTIME
-#error This file may only be used when deferring to vcruntime
+# error This file may only be used when deferring to vcruntime
#endif
namespace std {
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp
index c9d1d63b25..57ef94932b 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/locale_win32.cpp
@@ -6,25 +6,23 @@
//
//===----------------------------------------------------------------------===//
-#include <locale>
#include <cstdarg> // va_start, va_end
+#include <locale>
#include <memory>
#include <type_traits>
#include <__locale_dir/locale_base_api/locale_guard.h>
-int __libcpp_vasprintf(char **sptr, const char *__restrict fmt, va_list ap);
+int __libcpp_vasprintf(char** sptr, const char* __restrict fmt, va_list ap);
using std::__libcpp_locale_guard;
// FIXME: base and mask currently unused. Needs manual work to construct the new locale
-locale_t newlocale(int /*mask*/, const char * locale, locale_t /*base*/)
-{
- return {_create_locale( LC_ALL, locale ), locale};
+locale_t newlocale(int /*mask*/, const char* locale, locale_t /*base*/) {
+ return {_create_locale(LC_ALL, locale), locale};
}
-decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
-{
+decltype(MB_CUR_MAX) MB_CUR_MAX_L(locale_t __l) {
#if defined(_LIBCPP_MSVCRT)
return ___mb_cur_max_l_func(__l);
#else
@@ -33,93 +31,85 @@ decltype(MB_CUR_MAX) MB_CUR_MAX_L( locale_t __l )
#endif
}
-lconv *localeconv_l( locale_t &loc )
-{
- __libcpp_locale_guard __current(loc);
- lconv *lc = localeconv();
- if (!lc)
- return lc;
- return loc.__store_lconv(lc);
-}
-size_t mbrlen_l( const char *__restrict s, size_t n,
- mbstate_t *__restrict ps, locale_t loc )
-{
- __libcpp_locale_guard __current(loc);
- return mbrlen( s, n, ps );
-}
-size_t mbsrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
- size_t len, mbstate_t *__restrict ps, locale_t loc )
-{
- __libcpp_locale_guard __current(loc);
- return mbsrtowcs( dst, src, len, ps );
-}
-size_t wcrtomb_l( char *__restrict s, wchar_t wc, mbstate_t *__restrict ps,
- locale_t loc )
-{
- __libcpp_locale_guard __current(loc);
- return wcrtomb( s, wc, ps );
-}
-size_t mbrtowc_l( wchar_t *__restrict pwc, const char *__restrict s,
- size_t n, mbstate_t *__restrict ps, locale_t loc )
-{
- __libcpp_locale_guard __current(loc);
- return mbrtowc( pwc, s, n, ps );
-}
-size_t mbsnrtowcs_l( wchar_t *__restrict dst, const char **__restrict src,
- size_t nms, size_t len, mbstate_t *__restrict ps, locale_t loc )
-{
- __libcpp_locale_guard __current(loc);
- return mbsnrtowcs( dst, src, nms, len, ps );
-}
-size_t wcsnrtombs_l( char *__restrict dst, const wchar_t **__restrict src,
- size_t nwc, size_t len, mbstate_t *__restrict ps, locale_t loc )
-{
- __libcpp_locale_guard __current(loc);
- return wcsnrtombs( dst, src, nwc, len, ps );
-}
-wint_t btowc_l( int c, locale_t loc )
-{
- __libcpp_locale_guard __current(loc);
- return btowc( c );
-}
-int wctob_l( wint_t c, locale_t loc )
-{
- __libcpp_locale_guard __current(loc);
- return wctob( c );
+lconv* localeconv_l(locale_t& loc) {
+ __libcpp_locale_guard __current(loc);
+ lconv* lc = localeconv();
+ if (!lc)
+ return lc;
+ return loc.__store_lconv(lc);
+}
+size_t mbrlen_l(const char* __restrict s, size_t n, mbstate_t* __restrict ps, locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return mbrlen(s, n, ps);
+}
+size_t
+mbsrtowcs_l(wchar_t* __restrict dst, const char** __restrict src, size_t len, mbstate_t* __restrict ps, locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return mbsrtowcs(dst, src, len, ps);
+}
+size_t wcrtomb_l(char* __restrict s, wchar_t wc, mbstate_t* __restrict ps, locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return wcrtomb(s, wc, ps);
+}
+size_t mbrtowc_l(wchar_t* __restrict pwc, const char* __restrict s, size_t n, mbstate_t* __restrict ps, locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return mbrtowc(pwc, s, n, ps);
+}
+size_t mbsnrtowcs_l(wchar_t* __restrict dst,
+ const char** __restrict src,
+ size_t nms,
+ size_t len,
+ mbstate_t* __restrict ps,
+ locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return mbsnrtowcs(dst, src, nms, len, ps);
+}
+size_t wcsnrtombs_l(char* __restrict dst,
+ const wchar_t** __restrict src,
+ size_t nwc,
+ size_t len,
+ mbstate_t* __restrict ps,
+ locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return wcsnrtombs(dst, src, nwc, len, ps);
+}
+wint_t btowc_l(int c, locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return btowc(c);
+}
+int wctob_l(wint_t c, locale_t loc) {
+ __libcpp_locale_guard __current(loc);
+ return wctob(c);
}
-int snprintf_l(char *ret, size_t n, locale_t loc, const char *format, ...)
-{
- va_list ap;
- va_start( ap, format );
+int snprintf_l(char* ret, size_t n, locale_t loc, const char* format, ...) {
+ va_list ap;
+ va_start(ap, format);
#if defined(_LIBCPP_MSVCRT)
- // FIXME: Remove usage of internal CRT function and globals.
- int result = __stdio_common_vsprintf(
- _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR,
- ret, n, format, loc, ap);
+ // FIXME: Remove usage of internal CRT function and globals.
+ int result = __stdio_common_vsprintf(
+ _CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, ret, n, format, loc, ap);
#else
- __libcpp_locale_guard __current(loc);
- _LIBCPP_DIAGNOSTIC_PUSH
- _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
- int result = vsnprintf( ret, n, format, ap );
- _LIBCPP_DIAGNOSTIC_POP
+ __libcpp_locale_guard __current(loc);
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ int result = vsnprintf(ret, n, format, ap);
+ _LIBCPP_DIAGNOSTIC_POP
#endif
- va_end(ap);
- return result;
+ va_end(ap);
+ return result;
}
-int asprintf_l( char **ret, locale_t loc, const char *format, ... )
-{
- va_list ap;
- va_start( ap, format );
- int result = vasprintf_l( ret, loc, format, ap );
- va_end(ap);
- return result;
-}
-int vasprintf_l( char **ret, locale_t loc, const char *format, va_list ap )
-{
- __libcpp_locale_guard __current(loc);
- return __libcpp_vasprintf( ret, format, ap );
+int asprintf_l(char** ret, locale_t loc, const char* format, ...) {
+ va_list ap;
+ va_start(ap, format);
+ int result = vasprintf_l(ret, loc, format, ap);
+ va_end(ap);
+ return result;
+}
+int vasprintf_l(char** ret, locale_t loc, const char* format, va_list ap) {
+ __libcpp_locale_guard __current(loc);
+ return __libcpp_vasprintf(ret, format, ap);
}
#if !defined(_LIBCPP_MSVCRT)
@@ -135,8 +125,7 @@ long double strtold_l(const char* nptr, char** endptr, locale_t loc) {
#endif
#if defined(__MINGW32__) && __MSVCRT_VERSION__ < 0x0800
-size_t strftime_l(char *ret, size_t n, const char *format, const struct tm *tm,
- locale_t loc) {
+size_t strftime_l(char* ret, size_t n, const char* format, const struct tm* tm, locale_t loc) {
__libcpp_locale_guard __current(loc);
return strftime(ret, n, format, tm);
}
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp
index dbec4083cb..fed51d8b0b 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/support.cpp
@@ -8,44 +8,42 @@
#include <cstdarg> // va_start, va_end
#include <cstddef> // size_t
-#include <cstdlib> // malloc
#include <cstdio> // vsprintf, vsnprintf
+#include <cstdlib> // malloc
#include <cstring> // strcpy, wcsncpy
#include <cwchar> // mbstate_t
-
// Like sprintf, but when return value >= 0 it returns
// a pointer to a malloc'd string in *sptr.
// If return >= 0, use free to delete *sptr.
-int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
-{
- *sptr = NULL;
- // Query the count required.
- va_list ap_copy;
- va_copy(ap_copy, ap);
- _LIBCPP_DIAGNOSTIC_PUSH
- _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
- int count = vsnprintf( NULL, 0, format, ap_copy );
- _LIBCPP_DIAGNOSTIC_POP
- va_end(ap_copy);
- if (count < 0)
- return count;
- size_t buffer_size = static_cast<size_t>(count) + 1;
- char* p = static_cast<char*>(malloc(buffer_size));
- if ( ! p )
- return -1;
- // If we haven't used exactly what was required, something is wrong.
- // Maybe bug in vsnprintf. Report the error and return.
- _LIBCPP_DIAGNOSTIC_PUSH
- _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
- if (vsnprintf(p, buffer_size, format, ap) != count) {
- _LIBCPP_DIAGNOSTIC_POP
- free(p);
- return -1;
- }
- // All good. This is returning memory to the caller not freeing it.
- *sptr = p;
+int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) {
+ *sptr = NULL;
+ // Query the count required.
+ va_list ap_copy;
+ va_copy(ap_copy, ap);
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ int count = vsnprintf(NULL, 0, format, ap_copy);
+ _LIBCPP_DIAGNOSTIC_POP
+ va_end(ap_copy);
+ if (count < 0)
return count;
+ size_t buffer_size = static_cast<size_t>(count) + 1;
+ char* p = static_cast<char*>(malloc(buffer_size));
+ if (!p)
+ return -1;
+ // If we haven't used exactly what was required, something is wrong.
+ // Maybe bug in vsnprintf. Report the error and return.
+ _LIBCPP_DIAGNOSTIC_PUSH
+ _LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
+ if (vsnprintf(p, buffer_size, format, ap) != count) {
+ _LIBCPP_DIAGNOSTIC_POP
+ free(p);
+ return -1;
+ }
+ // All good. This is returning memory to the caller not freeing it.
+ *sptr = p;
+ return count;
}
// Returns >= 0: the number of wide characters found in the
@@ -56,53 +54,55 @@ int __libcpp_vasprintf( char **sptr, const char *__restrict format, va_list ap )
// Returns (size_t) -1: an incomplete sequence encountered.
// Leaves *src pointing the next character to convert or NULL
// if a null character was converted from *src.
-size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
- size_t src_size_bytes, size_t max_dest_chars, mbstate_t *__restrict ps )
-{
- const size_t terminated_sequence = static_cast<size_t>(0);
- //const size_t invalid_sequence = static_cast<size_t>(-1);
- const size_t incomplete_sequence = static_cast< size_t>(-2);
+size_t mbsnrtowcs(wchar_t* __restrict dst,
+ const char** __restrict src,
+ size_t src_size_bytes,
+ size_t max_dest_chars,
+ mbstate_t* __restrict ps) {
+ const size_t terminated_sequence = static_cast<size_t>(0);
+ // const size_t invalid_sequence = static_cast<size_t>(-1);
+ const size_t incomplete_sequence = static_cast< size_t>(-2);
- size_t dest_converted = 0;
- size_t source_converted = 0;
- size_t source_remaining = src_size_bytes;
- size_t result = 0;
- bool have_result = false;
+ size_t dest_converted = 0;
+ size_t source_converted = 0;
+ size_t source_remaining = src_size_bytes;
+ size_t result = 0;
+ bool have_result = false;
- // If dst is null then max_dest_chars should be ignored according to the
- // standard. Setting max_dest_chars to a large value has this effect.
- if (!dst)
- max_dest_chars = static_cast<size_t>(-1);
+ // If dst is null then max_dest_chars should be ignored according to the
+ // standard. Setting max_dest_chars to a large value has this effect.
+ if (!dst)
+ max_dest_chars = static_cast<size_t>(-1);
- while ( source_remaining ) {
- if ( dst && dest_converted >= max_dest_chars )
- break;
- // Converts one multi byte character.
- // if result > 0, it's the size in bytes of that character.
- // othewise if result is zero it indicates the null character has been found.
- // otherwise it's an error and errno may be set.
- size_t char_size = mbrtowc( dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps );
- // Don't do anything to change errno from here on.
- if ( char_size > 0 ) {
- source_remaining -= char_size;
- source_converted += char_size;
- ++dest_converted;
- continue;
- }
- result = char_size;
- have_result = true;
- break;
- }
- if ( dst ) {
- if ( have_result && result == terminated_sequence )
- *src = NULL;
- else
- *src += source_converted;
+ while (source_remaining) {
+ if (dst && dest_converted >= max_dest_chars)
+ break;
+ // Converts one multi byte character.
+ // if result > 0, it's the size in bytes of that character.
+ // othewise if result is zero it indicates the null character has been found.
+ // otherwise it's an error and errno may be set.
+ size_t char_size = mbrtowc(dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps);
+ // Don't do anything to change errno from here on.
+ if (char_size > 0) {
+ source_remaining -= char_size;
+ source_converted += char_size;
+ ++dest_converted;
+ continue;
}
- if ( have_result && result != terminated_sequence && result != incomplete_sequence )
- return static_cast<size_t>(-1);
+ result = char_size;
+ have_result = true;
+ break;
+ }
+ if (dst) {
+ if (have_result && result == terminated_sequence)
+ *src = NULL;
+ else
+ *src += source_converted;
+ }
+ if (have_result && result != terminated_sequence && result != incomplete_sequence)
+ return static_cast<size_t>(-1);
- return dest_converted;
+ return dest_converted;
}
// Converts max_source_chars from the wide character buffer pointer to by *src,
@@ -113,60 +113,62 @@ size_t mbsnrtowcs( wchar_t *__restrict dst, const char **__restrict src,
// Returns size_t(-1) if an error occurs, also sets errno.
// If dst is NULL dst_size_bytes is ignored and no bytes are copied to dst
// and no "out" parameters are updated.
-size_t wcsnrtombs( char *__restrict dst, const wchar_t **__restrict src,
- size_t max_source_chars, size_t dst_size_bytes, mbstate_t *__restrict ps )
-{
- //const size_t invalid_sequence = static_cast<size_t>(-1);
+size_t wcsnrtombs(char* __restrict dst,
+ const wchar_t** __restrict src,
+ size_t max_source_chars,
+ size_t dst_size_bytes,
+ mbstate_t* __restrict ps) {
+ // const size_t invalid_sequence = static_cast<size_t>(-1);
- size_t source_converted = 0;
- size_t dest_converted = 0;
- size_t dest_remaining = dst_size_bytes;
- size_t char_size = 0;
- const errno_t no_error = ( errno_t) 0;
- errno_t result = ( errno_t ) 0;
- bool have_result = false;
- bool terminator_found = false;
+ size_t source_converted = 0;
+ size_t dest_converted = 0;
+ size_t dest_remaining = dst_size_bytes;
+ size_t char_size = 0;
+ const errno_t no_error = (errno_t)0;
+ errno_t result = (errno_t)0;
+ bool have_result = false;
+ bool terminator_found = false;
- // If dst is null then dst_size_bytes should be ignored according to the
- // standard. Setting dest_remaining to a large value has this effect.
- if (!dst)
- dest_remaining = static_cast<size_t>(-1);
+ // If dst is null then dst_size_bytes should be ignored according to the
+ // standard. Setting dest_remaining to a large value has this effect.
+ if (!dst)
+ dest_remaining = static_cast<size_t>(-1);
- while ( source_converted != max_source_chars ) {
- if ( ! dest_remaining )
- break;
- wchar_t c = (*src)[source_converted];
- if ( dst )
- result = wcrtomb_s( &char_size, dst + dest_converted, dest_remaining, c, ps);
- else
- result = wcrtomb_s( &char_size, NULL, 0, c, ps);
- // If result is zero there is no error and char_size contains the
- // size of the multi-byte-sequence converted.
- // Otherwise result indicates an errno type error.
- if ( result == no_error ) {
- if ( c == L'\0' ) {
- terminator_found = true;
- break;
- }
- ++source_converted;
- if ( dst )
- dest_remaining -= char_size;
- dest_converted += char_size;
- continue;
- }
- have_result = true;
+ while (source_converted != max_source_chars) {
+ if (!dest_remaining)
+ break;
+ wchar_t c = (*src)[source_converted];
+ if (dst)
+ result = wcrtomb_s(&char_size, dst + dest_converted, dest_remaining, c, ps);
+ else
+ result = wcrtomb_s(&char_size, NULL, 0, c, ps);
+ // If result is zero there is no error and char_size contains the
+ // size of the multi-byte-sequence converted.
+ // Otherwise result indicates an errno type error.
+ if (result == no_error) {
+ if (c == L'\0') {
+ terminator_found = true;
break;
+ }
+ ++source_converted;
+ if (dst)
+ dest_remaining -= char_size;
+ dest_converted += char_size;
+ continue;
}
- if ( dst ) {
- if ( terminator_found )
- *src = NULL;
- else
- *src = *src + source_converted;
- }
- if ( have_result && result != no_error ) {
- errno = result;
- return static_cast<size_t>(-1);
- }
+ have_result = true;
+ break;
+ }
+ if (dst) {
+ if (terminator_found)
+ *src = NULL;
+ else
+ *src = *src + source_converted;
+ }
+ if (have_result && result != no_error) {
+ errno = result;
+ return static_cast<size_t>(-1);
+ }
- return dest_converted;
+ return dest_converted;
}
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp b/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp
index 848ed99cf0..8736a53207 100644
--- a/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/support/win32/thread_win32.cpp
@@ -20,10 +20,8 @@ _LIBCPP_BEGIN_NAMESPACE_STD
static_assert(sizeof(__libcpp_mutex_t) == sizeof(SRWLOCK), "");
static_assert(alignof(__libcpp_mutex_t) == alignof(SRWLOCK), "");
-static_assert(sizeof(__libcpp_recursive_mutex_t) == sizeof(CRITICAL_SECTION),
- "");
-static_assert(alignof(__libcpp_recursive_mutex_t) == alignof(CRITICAL_SECTION),
- "");
+static_assert(sizeof(__libcpp_recursive_mutex_t) == sizeof(CRITICAL_SECTION), "");
+static_assert(alignof(__libcpp_recursive_mutex_t) == alignof(CRITICAL_SECTION), "");
static_assert(sizeof(__libcpp_condvar_t) == sizeof(CONDITION_VARIABLE), "");
static_assert(alignof(__libcpp_condvar_t) == alignof(CONDITION_VARIABLE), "");
@@ -41,109 +39,86 @@ static_assert(sizeof(__libcpp_tls_key) == sizeof(DWORD), "");
static_assert(alignof(__libcpp_tls_key) == alignof(DWORD), "");
// Mutex
-int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t *__m)
-{
+int __libcpp_recursive_mutex_init(__libcpp_recursive_mutex_t* __m) {
InitializeCriticalSection((LPCRITICAL_SECTION)__m);
return 0;
}
-int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t *__m)
-{
+int __libcpp_recursive_mutex_lock(__libcpp_recursive_mutex_t* __m) {
EnterCriticalSection((LPCRITICAL_SECTION)__m);
return 0;
}
-bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t *__m)
-{
+bool __libcpp_recursive_mutex_trylock(__libcpp_recursive_mutex_t* __m) {
return TryEnterCriticalSection((LPCRITICAL_SECTION)__m) != 0;
}
-int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t *__m)
-{
+int __libcpp_recursive_mutex_unlock(__libcpp_recursive_mutex_t* __m) {
LeaveCriticalSection((LPCRITICAL_SECTION)__m);
return 0;
}
-int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t *__m)
-{
+int __libcpp_recursive_mutex_destroy(__libcpp_recursive_mutex_t* __m) {
DeleteCriticalSection((LPCRITICAL_SECTION)__m);
return 0;
}
-int __libcpp_mutex_lock(__libcpp_mutex_t *__m)
-{
+int __libcpp_mutex_lock(__libcpp_mutex_t* __m) {
AcquireSRWLockExclusive((PSRWLOCK)__m);
return 0;
}
-bool __libcpp_mutex_trylock(__libcpp_mutex_t *__m)
-{
- return TryAcquireSRWLockExclusive((PSRWLOCK)__m) != 0;
-}
+bool __libcpp_mutex_trylock(__libcpp_mutex_t* __m) { return TryAcquireSRWLockExclusive((PSRWLOCK)__m) != 0; }
-int __libcpp_mutex_unlock(__libcpp_mutex_t *__m)
-{
+int __libcpp_mutex_unlock(__libcpp_mutex_t* __m) {
ReleaseSRWLockExclusive((PSRWLOCK)__m);
return 0;
}
-int __libcpp_mutex_destroy(__libcpp_mutex_t *__m)
-{
+int __libcpp_mutex_destroy(__libcpp_mutex_t* __m) {
static_cast<void>(__m);
return 0;
}
// Condition Variable
-int __libcpp_condvar_signal(__libcpp_condvar_t *__cv)
-{
+int __libcpp_condvar_signal(__libcpp_condvar_t* __cv) {
WakeConditionVariable((PCONDITION_VARIABLE)__cv);
return 0;
}
-int __libcpp_condvar_broadcast(__libcpp_condvar_t *__cv)
-{
+int __libcpp_condvar_broadcast(__libcpp_condvar_t* __cv) {
WakeAllConditionVariable((PCONDITION_VARIABLE)__cv);
return 0;
}
-int __libcpp_condvar_wait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m)
-{
+int __libcpp_condvar_wait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m) {
SleepConditionVariableSRW((PCONDITION_VARIABLE)__cv, (PSRWLOCK)__m, INFINITE, 0);
return 0;
}
-int __libcpp_condvar_timedwait(__libcpp_condvar_t *__cv, __libcpp_mutex_t *__m,
- __libcpp_timespec_t *__ts)
-{
+int __libcpp_condvar_timedwait(__libcpp_condvar_t* __cv, __libcpp_mutex_t* __m, __libcpp_timespec_t* __ts) {
using namespace std::chrono;
- auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
- auto abstime =
- system_clock::time_point(duration_cast<system_clock::duration>(duration));
+ auto duration = seconds(__ts->tv_sec) + nanoseconds(__ts->tv_nsec);
+ auto abstime = system_clock::time_point(duration_cast<system_clock::duration>(duration));
auto timeout_ms = duration_cast<milliseconds>(abstime - system_clock::now());
- if (!SleepConditionVariableSRW((PCONDITION_VARIABLE)__cv, (PSRWLOCK)__m,
- timeout_ms.count() > 0 ? timeout_ms.count()
- : 0,
- 0))
- {
- auto __ec = GetLastError();
- return __ec == ERROR_TIMEOUT ? ETIMEDOUT : __ec;
- }
+ if (!SleepConditionVariableSRW(
+ (PCONDITION_VARIABLE)__cv, (PSRWLOCK)__m, timeout_ms.count() > 0 ? timeout_ms.count() : 0, 0)) {
+ auto __ec = GetLastError();
+ return __ec == ERROR_TIMEOUT ? ETIMEDOUT : __ec;
+ }
return 0;
}
-int __libcpp_condvar_destroy(__libcpp_condvar_t *__cv)
-{
+int __libcpp_condvar_destroy(__libcpp_condvar_t* __cv) {
static_cast<void>(__cv);
return 0;
}
// Execute Once
static inline _LIBCPP_HIDE_FROM_ABI BOOL CALLBACK
-__libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,
- PVOID *__context)
-{
+__libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter, PVOID* __context) {
static_cast<void>(__init_once);
static_cast<void>(__context);
@@ -152,77 +127,51 @@ __libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,
return TRUE;
}
-int __libcpp_execute_once(__libcpp_exec_once_flag *__flag,
- void (*__init_routine)(void))
-{
- if (!InitOnceExecuteOnce((PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk,
- reinterpret_cast<void *>(__init_routine), NULL))
+int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)(void)) {
+ if (!InitOnceExecuteOnce(
+ (PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), NULL))
return GetLastError();
return 0;
}
// Thread ID
-bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs,
- __libcpp_thread_id __rhs)
-{
- return __lhs == __rhs;
-}
+bool __libcpp_thread_id_equal(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs) { return __lhs == __rhs; }
-bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs)
-{
- return __lhs < __rhs;
-}
+bool __libcpp_thread_id_less(__libcpp_thread_id __lhs, __libcpp_thread_id __rhs) { return __lhs < __rhs; }
// Thread
-struct __libcpp_beginthreadex_thunk_data
-{
- void *(*__func)(void *);
- void *__arg;
+struct __libcpp_beginthreadex_thunk_data {
+ void* (*__func)(void*);
+ void* __arg;
};
-static inline _LIBCPP_HIDE_FROM_ABI unsigned WINAPI
-__libcpp_beginthreadex_thunk(void *__raw_data)
-{
- auto *__data =
- static_cast<__libcpp_beginthreadex_thunk_data *>(__raw_data);
- auto *__func = __data->__func;
- void *__arg = __data->__arg;
+static inline _LIBCPP_HIDE_FROM_ABI unsigned WINAPI __libcpp_beginthreadex_thunk(void* __raw_data) {
+ auto* __data = static_cast<__libcpp_beginthreadex_thunk_data*>(__raw_data);
+ auto* __func = __data->__func;
+ void* __arg = __data->__arg;
delete __data;
return static_cast<unsigned>(reinterpret_cast<uintptr_t>(__func(__arg)));
}
-bool __libcpp_thread_isnull(const __libcpp_thread_t *__t) {
- return *__t == 0;
-}
+bool __libcpp_thread_isnull(const __libcpp_thread_t* __t) { return *__t == 0; }
-int __libcpp_thread_create(__libcpp_thread_t *__t, void *(*__func)(void *),
- void *__arg)
-{
- auto *__data = new __libcpp_beginthreadex_thunk_data;
+int __libcpp_thread_create(__libcpp_thread_t* __t, void* (*__func)(void*), void* __arg) {
+ auto* __data = new __libcpp_beginthreadex_thunk_data;
__data->__func = __func;
- __data->__arg = __arg;
+ __data->__arg = __arg;
- *__t = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0,
- __libcpp_beginthreadex_thunk,
- __data, 0, nullptr));
+ *__t = reinterpret_cast<HANDLE>(_beginthreadex(nullptr, 0, __libcpp_beginthreadex_thunk, __data, 0, nullptr));
if (*__t)
return 0;
return GetLastError();
}
-__libcpp_thread_id __libcpp_thread_get_current_id()
-{
- return GetCurrentThreadId();
-}
+__libcpp_thread_id __libcpp_thread_get_current_id() { return GetCurrentThreadId(); }
-__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t *__t)
-{
- return GetThreadId(*__t);
-}
+__libcpp_thread_id __libcpp_thread_get_id(const __libcpp_thread_t* __t) { return GetThreadId(*__t); }
-int __libcpp_thread_join(__libcpp_thread_t *__t)
-{
+int __libcpp_thread_join(__libcpp_thread_t* __t) {
if (WaitForSingleObjectEx(*__t, INFINITE, FALSE) == WAIT_FAILED)
return GetLastError();
if (!CloseHandle(*__t))
@@ -230,20 +179,15 @@ int __libcpp_thread_join(__libcpp_thread_t *__t)
return 0;
}
-int __libcpp_thread_detach(__libcpp_thread_t *__t)
-{
+int __libcpp_thread_detach(__libcpp_thread_t* __t) {
if (!CloseHandle(*__t))
return GetLastError();
return 0;
}
-void __libcpp_thread_yield()
-{
- SwitchToThread();
-}
+void __libcpp_thread_yield() { SwitchToThread(); }
-void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
-{
+void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns) {
// round-up to the nearest millisecond
chrono::milliseconds __ms = chrono::ceil<chrono::milliseconds>(__ns);
// FIXME(compnerd) this should be an alertable sleep (WFSO or SleepEx)
@@ -251,9 +195,7 @@ void __libcpp_thread_sleep_for(const chrono::nanoseconds& __ns)
}
// Thread Local Storage
-int __libcpp_tls_create(__libcpp_tls_key* __key,
- void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*))
-{
+int __libcpp_tls_create(__libcpp_tls_key* __key, void(_LIBCPP_TLS_DESTRUCTOR_CC* __at_exit)(void*)) {
DWORD index = FlsAlloc(__at_exit);
if (index == FLS_OUT_OF_INDEXES)
return GetLastError();
@@ -261,13 +203,9 @@ int __libcpp_tls_create(__libcpp_tls_key* __key,
return 0;
}
-void *__libcpp_tls_get(__libcpp_tls_key __key)
-{
- return FlsGetValue(__key);
-}
+void* __libcpp_tls_get(__libcpp_tls_key __key) { return FlsGetValue(__key); }
-int __libcpp_tls_set(__libcpp_tls_key __key, void *__p)
-{
+int __libcpp_tls_set(__libcpp_tls_key __key, void* __p) {
if (!FlsSetValue(__key, __p))
return GetLastError();
return 0;
diff --git a/contrib/libs/cxxsupp/libcxx/src/system_error.cpp b/contrib/libs/cxxsupp/libcxx/src/system_error.cpp
index 1cc6b7d7e1..034b73c548 100644
--- a/contrib/libs/cxxsupp/libcxx/src/system_error.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/system_error.cpp
@@ -13,14 +13,14 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
-#include <string>
#include <string.h>
+#include <string>
#include <system_error>
#include "include/config_elast.h"
#if defined(__ANDROID__)
-#include <android/api-level.h>
+# include <android/api-level.h>
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
@@ -33,7 +33,7 @@ constexpr size_t strerror_buff_size = 1024;
string do_strerror_r(int ev);
-#if defined(_LIBCPP_MSVCRT_LIKE)
+# if defined(_LIBCPP_MSVCRT_LIKE)
string do_strerror_r(int ev) {
char buffer[strerror_buff_size];
if (::strerror_s(buffer, strerror_buff_size, ev) == 0)
@@ -41,14 +41,13 @@ string do_strerror_r(int ev) {
std::snprintf(buffer, strerror_buff_size, "unknown error %d", ev);
return string(buffer);
}
-#else
+# else
// Only one of the two following functions will be used, depending on
// the return type of strerror_r:
// For the GNU variant, a char* return value:
-__attribute__((unused)) const char *
-handle_strerror_r_return(char *strerror_return, char *buffer) {
+__attribute__((unused)) const char* handle_strerror_r_return(char* strerror_return, char* buffer) {
// GNU always returns a string pointer in its return value. The
// string might point to either the input buffer, or a static
// buffer, but we don't care which.
@@ -56,8 +55,7 @@ handle_strerror_r_return(char *strerror_return, char *buffer) {
}
// For the POSIX variant: an int return value.
-__attribute__((unused)) const char *
-handle_strerror_r_return(int strerror_return, char *buffer) {
+__attribute__((unused)) const char* handle_strerror_r_return(int strerror_return, char* buffer) {
// The POSIX variant either:
// - fills in the provided buffer and returns 0
// - returns a positive error value, or
@@ -79,201 +77,146 @@ handle_strerror_r_return(int strerror_return, char *buffer) {
// This function handles both GNU and POSIX variants, dispatching to
// one of the two above functions.
string do_strerror_r(int ev) {
- char buffer[strerror_buff_size];
- // Preserve errno around the call. (The C++ standard requires that
- // system_error functions not modify errno).
- const int old_errno = errno;
- const char *error_message = handle_strerror_r_return(
- ::strerror_r(ev, buffer, strerror_buff_size), buffer);
- // If we didn't get any message, print one now.
- if (!error_message[0]) {
- std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
- error_message = buffer;
- }
- errno = old_errno;
- return string(error_message);
-}
-#endif
+ char buffer[strerror_buff_size];
+ // Preserve errno around the call. (The C++ standard requires that
+ // system_error functions not modify errno).
+ const int old_errno = errno;
+ const char* error_message = handle_strerror_r_return(::strerror_r(ev, buffer, strerror_buff_size), buffer);
+ // If we didn't get any message, print one now.
+ if (!error_message[0]) {
+ std::snprintf(buffer, strerror_buff_size, "Unknown error %d", ev);
+ error_message = buffer;
+ }
+ errno = old_errno;
+ return string(error_message);
+}
+# endif
#endif // !defined(_LIBCPP_HAS_NO_THREADS)
string make_error_str(const error_code& ec, string what_arg) {
- if (ec) {
- if (!what_arg.empty()) {
- what_arg += ": ";
- }
- what_arg += ec.message();
+ if (ec) {
+ if (!what_arg.empty()) {
+ what_arg += ": ";
}
- return what_arg;
+ what_arg += ec.message();
+ }
+ return what_arg;
}
string make_error_str(const error_code& ec) {
- if (ec) {
- return ec.message();
- }
- return string();
+ if (ec) {
+ return ec.message();
+ }
+ return string();
}
} // end namespace
-string
-__do_message::message(int ev) const
-{
+string __do_message::message(int ev) const {
#if defined(_LIBCPP_HAS_NO_THREADS)
- return string(::strerror(ev));
+ return string(::strerror(ev));
#else
- return do_strerror_r(ev);
+ return do_strerror_r(ev);
#endif
}
-class _LIBCPP_HIDDEN __generic_error_category
- : public __do_message
-{
+class _LIBCPP_HIDDEN __generic_error_category : public __do_message {
public:
- virtual const char* name() const noexcept;
- virtual string message(int ev) const;
+ virtual const char* name() const noexcept;
+ virtual string message(int ev) const;
};
-const char*
-__generic_error_category::name() const noexcept
-{
- return "generic";
-}
+const char* __generic_error_category::name() const noexcept { return "generic"; }
-string
-__generic_error_category::message(int ev) const
-{
+string __generic_error_category::message(int ev) const {
#ifdef _LIBCPP_ELAST
- if (ev > _LIBCPP_ELAST)
- return string("unspecified generic_category error");
+ if (ev > _LIBCPP_ELAST)
+ return string("unspecified generic_category error");
#endif // _LIBCPP_ELAST
- return __do_message::message(ev);
+ return __do_message::message(ev);
}
-const error_category&
-generic_category() noexcept
-{
- union AvoidDestroyingGenericCategory {
- __generic_error_category generic_error_category;
- constexpr explicit AvoidDestroyingGenericCategory() : generic_error_category() {}
- ~AvoidDestroyingGenericCategory() {}
- };
- constinit static AvoidDestroyingGenericCategory helper;
- return helper.generic_error_category;
+const error_category& generic_category() noexcept {
+ union AvoidDestroyingGenericCategory {
+ __generic_error_category generic_error_category;
+ constexpr explicit AvoidDestroyingGenericCategory() : generic_error_category() {}
+ ~AvoidDestroyingGenericCategory() {}
+ };
+ constinit static AvoidDestroyingGenericCategory helper;
+ return helper.generic_error_category;
}
-class _LIBCPP_HIDDEN __system_error_category
- : public __do_message
-{
+class _LIBCPP_HIDDEN __system_error_category : public __do_message {
public:
- virtual const char* name() const noexcept;
- virtual string message(int ev) const;
- virtual error_condition default_error_condition(int ev) const noexcept;
+ virtual const char* name() const noexcept;
+ virtual string message(int ev) const;
+ virtual error_condition default_error_condition(int ev) const noexcept;
};
-const char*
-__system_error_category::name() const noexcept
-{
- return "system";
-}
+const char* __system_error_category::name() const noexcept { return "system"; }
-string
-__system_error_category::message(int ev) const
-{
+string __system_error_category::message(int ev) const {
#ifdef _LIBCPP_ELAST
- if (ev > _LIBCPP_ELAST)
- return string("unspecified system_category error");
+ if (ev > _LIBCPP_ELAST)
+ return string("unspecified system_category error");
#endif // _LIBCPP_ELAST
- return __do_message::message(ev);
+ return __do_message::message(ev);
}
-error_condition
-__system_error_category::default_error_condition(int ev) const noexcept
-{
+error_condition __system_error_category::default_error_condition(int ev) const noexcept {
#ifdef _LIBCPP_ELAST
- if (ev > _LIBCPP_ELAST)
- return error_condition(ev, system_category());
+ if (ev > _LIBCPP_ELAST)
+ return error_condition(ev, system_category());
#endif // _LIBCPP_ELAST
- return error_condition(ev, generic_category());
+ return error_condition(ev, generic_category());
}
-const error_category&
-system_category() noexcept
-{
- union AvoidDestroyingSystemCategory {
- __system_error_category system_error_category;
- constexpr explicit AvoidDestroyingSystemCategory() : system_error_category() {}
- ~AvoidDestroyingSystemCategory() {}
- };
- constinit static AvoidDestroyingSystemCategory helper;
- return helper.system_error_category;
+const error_category& system_category() noexcept {
+ union AvoidDestroyingSystemCategory {
+ __system_error_category system_error_category;
+ constexpr explicit AvoidDestroyingSystemCategory() : system_error_category() {}
+ ~AvoidDestroyingSystemCategory() {}
+ };
+ constinit static AvoidDestroyingSystemCategory helper;
+ return helper.system_error_category;
}
// error_condition
-string
-error_condition::message() const
-{
- return __cat_->message(__val_);
-}
+string error_condition::message() const { return __cat_->message(__val_); }
// error_code
-string
-error_code::message() const
-{
- return __cat_->message(__val_);
-}
+string error_code::message() const { return __cat_->message(__val_); }
// system_error
system_error::system_error(error_code ec, const string& what_arg)
- : runtime_error(make_error_str(ec, what_arg)),
- __ec_(ec)
-{
-}
+ : runtime_error(make_error_str(ec, what_arg)), __ec_(ec) {}
system_error::system_error(error_code ec, const char* what_arg)
- : runtime_error(make_error_str(ec, what_arg)),
- __ec_(ec)
-{
-}
+ : runtime_error(make_error_str(ec, what_arg)), __ec_(ec) {}
-system_error::system_error(error_code ec)
- : runtime_error(make_error_str(ec)),
- __ec_(ec)
-{
-}
+system_error::system_error(error_code ec) : runtime_error(make_error_str(ec)), __ec_(ec) {}
system_error::system_error(int ev, const error_category& ecat, const string& what_arg)
- : runtime_error(make_error_str(error_code(ev, ecat), what_arg)),
- __ec_(error_code(ev, ecat))
-{
-}
+ : runtime_error(make_error_str(error_code(ev, ecat), what_arg)), __ec_(error_code(ev, ecat)) {}
system_error::system_error(int ev, const error_category& ecat, const char* what_arg)
- : runtime_error(make_error_str(error_code(ev, ecat), what_arg)),
- __ec_(error_code(ev, ecat))
-{
-}
+ : runtime_error(make_error_str(error_code(ev, ecat), what_arg)), __ec_(error_code(ev, ecat)) {}
system_error::system_error(int ev, const error_category& ecat)
- : runtime_error(make_error_str(error_code(ev, ecat))),
- __ec_(error_code(ev, ecat))
-{
-}
+ : runtime_error(make_error_str(error_code(ev, ecat))), __ec_(error_code(ev, ecat)) {}
-system_error::~system_error() noexcept
-{
-}
+system_error::~system_error() noexcept {}
-void
-__throw_system_error(int ev, const char* what_arg)
-{
+void __throw_system_error(int ev, const char* what_arg) {
#ifndef _LIBCPP_HAS_NO_EXCEPTIONS
- std::__throw_system_error(error_code(ev, system_category()), what_arg);
+ std::__throw_system_error(error_code(ev, system_category()), what_arg);
#else
- // The above could also handle the no-exception case, but for size, avoid referencing system_category() unnecessarily.
- _LIBCPP_VERBOSE_ABORT("system_error was thrown in -fno-exceptions mode with error %i and message \"%s\"", ev, what_arg);
+ // The above could also handle the no-exception case, but for size, avoid referencing system_category() unnecessarily.
+ _LIBCPP_VERBOSE_ABORT(
+ "system_error was thrown in -fno-exceptions mode with error %i and message \"%s\"", ev, what_arg);
#endif
}
diff --git a/contrib/libs/cxxsupp/libcxx/src/thread.cpp b/contrib/libs/cxxsupp/libcxx/src/thread.cpp
index 289c457cd5..73f22f12d8 100644
--- a/contrib/libs/cxxsupp/libcxx/src/thread.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/thread.cpp
@@ -15,104 +15,89 @@
#include <vector>
#if __has_include(<unistd.h>)
-# include <unistd.h> // for sysconf
+# include <unistd.h> // for sysconf
#endif
#if defined(__NetBSD__)
-#pragma weak pthread_create // Do not create libpthread dependency
+# pragma weak pthread_create // Do not create libpthread dependency
#endif
#if defined(_LIBCPP_WIN32API)
-#include <windows.h>
+# include <windows.h>
#endif
#if defined(__ELF__) && defined(_LIBCPP_LINK_PTHREAD_LIB)
-#pragma comment(lib, "pthread")
+# pragma comment(lib, "pthread")
#endif
_LIBCPP_BEGIN_NAMESPACE_STD
-thread::~thread()
-{
- if (!__libcpp_thread_isnull(&__t_))
- terminate();
+thread::~thread() {
+ if (!__libcpp_thread_isnull(&__t_))
+ terminate();
}
-void
-thread::join()
-{
- int ec = EINVAL;
- if (!__libcpp_thread_isnull(&__t_))
- {
- ec = __libcpp_thread_join(&__t_);
- if (ec == 0)
- __t_ = _LIBCPP_NULL_THREAD;
- }
-
- if (ec)
- __throw_system_error(ec, "thread::join failed");
+void thread::join() {
+ int ec = EINVAL;
+ if (!__libcpp_thread_isnull(&__t_)) {
+ ec = __libcpp_thread_join(&__t_);
+ if (ec == 0)
+ __t_ = _LIBCPP_NULL_THREAD;
+ }
+
+ if (ec)
+ __throw_system_error(ec, "thread::join failed");
}
-void
-thread::detach()
-{
- int ec = EINVAL;
- if (!__libcpp_thread_isnull(&__t_))
- {
- ec = __libcpp_thread_detach(&__t_);
- if (ec == 0)
- __t_ = _LIBCPP_NULL_THREAD;
- }
-
- if (ec)
- __throw_system_error(ec, "thread::detach failed");
+void thread::detach() {
+ int ec = EINVAL;
+ if (!__libcpp_thread_isnull(&__t_)) {
+ ec = __libcpp_thread_detach(&__t_);
+ if (ec == 0)
+ __t_ = _LIBCPP_NULL_THREAD;
+ }
+
+ if (ec)
+ __throw_system_error(ec, "thread::detach failed");
}
-unsigned
-thread::hardware_concurrency() noexcept
-{
+unsigned thread::hardware_concurrency() noexcept {
#if defined(_SC_NPROCESSORS_ONLN)
- long result = sysconf(_SC_NPROCESSORS_ONLN);
- // sysconf returns -1 if the name is invalid, the option does not exist or
- // does not have a definite limit.
- // if sysconf returns some other negative number, we have no idea
- // what is going on. Default to something safe.
- if (result < 0)
- return 0;
- return static_cast<unsigned>(result);
+ long result = sysconf(_SC_NPROCESSORS_ONLN);
+ // sysconf returns -1 if the name is invalid, the option does not exist or
+ // does not have a definite limit.
+ // if sysconf returns some other negative number, we have no idea
+ // what is going on. Default to something safe.
+ if (result < 0)
+ return 0;
+ return static_cast<unsigned>(result);
#elif defined(_LIBCPP_WIN32API)
- SYSTEM_INFO info;
- GetSystemInfo(&info);
- return info.dwNumberOfProcessors;
-#else // defined(CTL_HW) && defined(HW_NCPU)
- // TODO: grovel through /proc or check cpuid on x86 and similar
- // instructions on other architectures.
-# if defined(_LIBCPP_WARNING)
- _LIBCPP_WARNING("hardware_concurrency not yet implemented")
-# else
-# warning hardware_concurrency not yet implemented
-# endif
- return 0; // Means not computable [thread.thread.static]
+ SYSTEM_INFO info;
+ GetSystemInfo(&info);
+ return info.dwNumberOfProcessors;
+#else // defined(CTL_HW) && defined(HW_NCPU)
+ // TODO: grovel through /proc or check cpuid on x86 and similar
+ // instructions on other architectures.
+# if defined(_LIBCPP_WARNING)
+ _LIBCPP_WARNING("hardware_concurrency not yet implemented")
+# else
+# warning hardware_concurrency not yet implemented
+# endif
+ return 0; // Means not computable [thread.thread.static]
#endif // defined(CTL_HW) && defined(HW_NCPU)
}
-namespace this_thread
-{
+namespace this_thread {
-void
-sleep_for(const chrono::nanoseconds& ns)
-{
- if (ns > chrono::nanoseconds::zero())
- {
- __libcpp_thread_sleep_for(ns);
- }
+void sleep_for(const chrono::nanoseconds& ns) {
+ if (ns > chrono::nanoseconds::zero()) {
+ __libcpp_thread_sleep_for(ns);
+ }
}
-} // this_thread
+} // namespace this_thread
-__thread_specific_ptr<__thread_struct>&
-__thread_local_data()
-{
+__thread_specific_ptr<__thread_struct>& __thread_local_data() {
// Even though __thread_specific_ptr's destructor doesn't actually destroy
// anything (see comments there), we can't call it at all because threads may
// outlive the static variable and calling its destructor means accessing an
@@ -125,89 +110,64 @@ __thread_local_data()
// __thread_struct_imp
template <class T>
-class _LIBCPP_HIDDEN __hidden_allocator
-{
+class _LIBCPP_HIDDEN __hidden_allocator {
public:
- typedef T value_type;
+ typedef T value_type;
- T* allocate(size_t __n)
- {return static_cast<T*>(::operator new(__n * sizeof(T)));}
- void deallocate(T* __p, size_t) {::operator delete(static_cast<void*>(__p));}
+ T* allocate(size_t __n) { return static_cast<T*>(::operator new(__n * sizeof(T))); }
+ void deallocate(T* __p, size_t) { ::operator delete(static_cast<void*>(__p)); }
- size_t max_size() const {return size_t(~0) / sizeof(T);}
+ size_t max_size() const { return size_t(~0) / sizeof(T); }
};
-class _LIBCPP_HIDDEN __thread_struct_imp
-{
- typedef vector<__assoc_sub_state*,
- __hidden_allocator<__assoc_sub_state*> > _AsyncStates;
- typedef vector<pair<condition_variable*, mutex*>,
- __hidden_allocator<pair<condition_variable*, mutex*> > > _Notify;
+class _LIBCPP_HIDDEN __thread_struct_imp {
+ typedef vector<__assoc_sub_state*, __hidden_allocator<__assoc_sub_state*> > _AsyncStates;
+ typedef vector<pair<condition_variable*, mutex*>, __hidden_allocator<pair<condition_variable*, mutex*> > > _Notify;
+
+ _AsyncStates async_states_;
+ _Notify notify_;
- _AsyncStates async_states_;
- _Notify notify_;
+ __thread_struct_imp(const __thread_struct_imp&);
+ __thread_struct_imp& operator=(const __thread_struct_imp&);
- __thread_struct_imp(const __thread_struct_imp&);
- __thread_struct_imp& operator=(const __thread_struct_imp&);
public:
- __thread_struct_imp() {}
- ~__thread_struct_imp();
+ __thread_struct_imp() {}
+ ~__thread_struct_imp();
- void notify_all_at_thread_exit(condition_variable* cv, mutex* m);
- void __make_ready_at_thread_exit(__assoc_sub_state* __s);
+ void notify_all_at_thread_exit(condition_variable* cv, mutex* m);
+ void __make_ready_at_thread_exit(__assoc_sub_state* __s);
};
-__thread_struct_imp::~__thread_struct_imp()
-{
- for (_Notify::iterator i = notify_.begin(), e = notify_.end();
- i != e; ++i)
- {
- i->first->notify_all();
- i->second->unlock();
- }
- for (_AsyncStates::iterator i = async_states_.begin(), e = async_states_.end();
- i != e; ++i)
- {
- (*i)->__make_ready();
- (*i)->__release_shared();
- }
+__thread_struct_imp::~__thread_struct_imp() {
+ for (_Notify::iterator i = notify_.begin(), e = notify_.end(); i != e; ++i) {
+ i->first->notify_all();
+ i->second->unlock();
+ }
+ for (_AsyncStates::iterator i = async_states_.begin(), e = async_states_.end(); i != e; ++i) {
+ (*i)->__make_ready();
+ (*i)->__release_shared();
+ }
}
-void
-__thread_struct_imp::notify_all_at_thread_exit(condition_variable* cv, mutex* m)
-{
- notify_.push_back(pair<condition_variable*, mutex*>(cv, m));
+void __thread_struct_imp::notify_all_at_thread_exit(condition_variable* cv, mutex* m) {
+ notify_.push_back(pair<condition_variable*, mutex*>(cv, m));
}
-void
-__thread_struct_imp::__make_ready_at_thread_exit(__assoc_sub_state* __s)
-{
- async_states_.push_back(__s);
- __s->__add_shared();
+void __thread_struct_imp::__make_ready_at_thread_exit(__assoc_sub_state* __s) {
+ async_states_.push_back(__s);
+ __s->__add_shared();
}
// __thread_struct
-__thread_struct::__thread_struct()
- : __p_(new __thread_struct_imp)
-{
-}
+__thread_struct::__thread_struct() : __p_(new __thread_struct_imp) {}
-__thread_struct::~__thread_struct()
-{
- delete __p_;
-}
+__thread_struct::~__thread_struct() { delete __p_; }
-void
-__thread_struct::notify_all_at_thread_exit(condition_variable* cv, mutex* m)
-{
- __p_->notify_all_at_thread_exit(cv, m);
+void __thread_struct::notify_all_at_thread_exit(condition_variable* cv, mutex* m) {
+ __p_->notify_all_at_thread_exit(cv, m);
}
-void
-__thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s)
-{
- __p_->__make_ready_at_thread_exit(__s);
-}
+void __thread_struct::__make_ready_at_thread_exit(__assoc_sub_state* __s) { __p_->__make_ready_at_thread_exit(__s); }
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp b/contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp
index a98ceb0034..60230a6c38 100644
--- a/contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/typeinfo.cpp
@@ -10,27 +10,27 @@
#if defined(_LIBCPP_ABI_MICROSOFT) && !defined(_LIBCPP_ABI_VCRUNTIME)
-#include <string.h>
+# include <string.h>
-int std::type_info::__compare(const type_info &__rhs) const noexcept {
+int std::type_info::__compare(const type_info& __rhs) const noexcept {
if (&__data == &__rhs.__data)
return 0;
return strcmp(&__data.__decorated_name[1], &__rhs.__data.__decorated_name[1]);
}
-const char *std::type_info::name() const noexcept {
+const char* std::type_info::name() const noexcept {
// TODO(compnerd) cache demangled &__data.__decorated_name[1]
return &__data.__decorated_name[1];
}
size_t std::type_info::hash_code() const noexcept {
-#if defined(_WIN64)
+# if defined(_WIN64)
constexpr size_t fnv_offset_basis = 14695981039346656037ull;
- constexpr size_t fnv_prime = 10995116282110ull;
-#else
+ constexpr size_t fnv_prime = 10995116282110ull;
+# else
constexpr size_t fnv_offset_basis = 2166136261ull;
- constexpr size_t fnv_prime = 16777619ull;
-#endif
+ constexpr size_t fnv_prime = 16777619ull;
+# endif
size_t value = fnv_offset_basis;
for (const char* c = &__data.__decorated_name[1]; *c; ++c) {
@@ -38,21 +38,17 @@ size_t std::type_info::hash_code() const noexcept {
value *= fnv_prime;
}
-#if defined(_WIN64)
+# if defined(_WIN64)
value ^= value >> 32;
-#endif
+# endif
return value;
}
#endif // _LIBCPP_ABI_MICROSOFT
// FIXME: Remove the _LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY configuration.
-#if (!defined(LIBCXX_BUILDING_LIBCXXABI) && \
- !defined(LIBCXX_BUILDING_LIBCXXRT) && \
- !defined(__GLIBCXX__) && \
- !defined(_LIBCPP_ABI_VCRUNTIME)) || \
+#if (!defined(LIBCXX_BUILDING_LIBCXXABI) && !defined(LIBCXX_BUILDING_LIBCXXRT) && !defined(__GLIBCXX__) && \
+ !defined(_LIBCPP_ABI_VCRUNTIME)) || \
defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
-std::type_info::~type_info()
-{
-}
+std::type_info::~type_info() {}
#endif
diff --git a/contrib/libs/cxxsupp/libcxx/src/valarray.cpp b/contrib/libs/cxxsupp/libcxx/src/valarray.cpp
index f377e0f4e8..6ef1f1cafc 100644
--- a/contrib/libs/cxxsupp/libcxx/src/valarray.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/valarray.cpp
@@ -18,40 +18,32 @@ template _LIBCPP_EXPORTED_FROM_ABI valarray<size_t>::~valarray();
template void valarray<size_t>::resize(size_t, size_t);
-void
-gslice::__init(size_t __start)
-{
- valarray<size_t> __indices(__size_.size());
- size_t __k = __size_.size() != 0;
- for (size_t __i = 0; __i < __size_.size(); ++__i)
- __k *= __size_[__i];
- __1d_.resize(__k);
- if (__1d_.size())
- {
- __k = 0;
- __1d_[__k] = __start;
- while (true)
- {
- size_t __i = __indices.size() - 1;
- while (true)
- {
- if (++__indices[__i] < __size_[__i])
- {
- ++__k;
- __1d_[__k] = __1d_[__k-1] + __stride_[__i];
- for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
- __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
- break;
- }
- else
- {
- if (__i == 0)
- return;
- __indices[__i--] = 0;
- }
- }
+void gslice::__init(size_t __start) {
+ valarray<size_t> __indices(__size_.size());
+ size_t __k = __size_.size() != 0;
+ for (size_t __i = 0; __i < __size_.size(); ++__i)
+ __k *= __size_[__i];
+ __1d_.resize(__k);
+ if (__1d_.size()) {
+ __k = 0;
+ __1d_[__k] = __start;
+ while (true) {
+ size_t __i = __indices.size() - 1;
+ while (true) {
+ if (++__indices[__i] < __size_[__i]) {
+ ++__k;
+ __1d_[__k] = __1d_[__k - 1] + __stride_[__i];
+ for (size_t __j = __i + 1; __j != __indices.size(); ++__j)
+ __1d_[__k] -= __stride_[__j] * (__size_[__j] - 1);
+ break;
+ } else {
+ if (__i == 0)
+ return;
+ __indices[__i--] = 0;
}
+ }
}
+ }
}
_LIBCPP_END_NAMESPACE_STD
diff --git a/contrib/libs/cxxsupp/libcxx/src/variant.cpp b/contrib/libs/cxxsupp/libcxx/src/variant.cpp
index b6ec448081..b5462d64fe 100644
--- a/contrib/libs/cxxsupp/libcxx/src/variant.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/variant.cpp
@@ -10,8 +10,6 @@
namespace std {
-const char* bad_variant_access::what() const noexcept {
- return "bad_variant_access";
-}
+const char* bad_variant_access::what() const noexcept { return "bad_variant_access"; }
-} // namespace std
+} // namespace std
diff --git a/contrib/libs/cxxsupp/libcxx/src/vector.cpp b/contrib/libs/cxxsupp/libcxx/src/vector.cpp
index b09db92cf8..b6153b0e9b 100644
--- a/contrib/libs/cxxsupp/libcxx/src/vector.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/vector.cpp
@@ -21,13 +21,9 @@ struct __vector_base_common<true> {
_LIBCPP_NORETURN _LIBCPP_EXPORTED_FROM_ABI void __throw_out_of_range() const;
};
-void __vector_base_common<true>::__throw_length_error() const {
- std::__throw_length_error("vector");
-}
+void __vector_base_common<true>::__throw_length_error() const { std::__throw_length_error("vector"); }
-void __vector_base_common<true>::__throw_out_of_range() const {
- std::__throw_out_of_range("vector");
-}
+void __vector_base_common<true>::__throw_out_of_range() const { std::__throw_out_of_range("vector"); }
#endif // _LIBCPP_ABI_DO_NOT_EXPORT_VECTOR_BASE_COMMON
diff --git a/contrib/libs/cxxsupp/libcxx/src/verbose_abort.cpp b/contrib/libs/cxxsupp/libcxx/src/verbose_abort.cpp
index a9fba5e3c0..719134e2ae 100644
--- a/contrib/libs/cxxsupp/libcxx/src/verbose_abort.cpp
+++ b/contrib/libs/cxxsupp/libcxx/src/verbose_abort.cpp
@@ -28,8 +28,7 @@ extern "C" void android_set_abort_message(const char* msg);
_LIBCPP_BEGIN_NAMESPACE_STD
-_LIBCPP_WEAK
-void __libcpp_verbose_abort(char const* format, ...) {
+_LIBCPP_WEAK void __libcpp_verbose_abort(char const* format, ...) {
// Write message to stderr. We do this before formatting into a
// buffer so that we still get some information out if that fails.
{
@@ -41,7 +40,8 @@ void __libcpp_verbose_abort(char const* format, ...) {
// Format the arguments into an allocated buffer for CrashReport & friends.
// We leak the buffer on purpose, since we're about to abort() anyway.
- char* buffer; (void)buffer;
+ char* buffer;
+ (void)buffer;
va_list list;
va_start(list, format);