summaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/src/support/ibm
diff options
context:
space:
mode:
authormonster <[email protected]>2022-07-07 14:41:37 +0300
committermonster <[email protected]>2022-07-07 14:41:37 +0300
commit06e5c21a835c0e923506c4ff27929f34e00761c2 (patch)
tree75efcbc6854ef9bd476eb8bf00cc5c900da436a2 /contrib/libs/cxxsupp/libcxx/src/support/ibm
parent03f024c4412e3aa613bb543cf1660176320ba8f4 (diff)
fix ya.make
Diffstat (limited to 'contrib/libs/cxxsupp/libcxx/src/support/ibm')
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp95
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp93
-rw-r--r--contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp137
3 files changed, 0 insertions, 325 deletions
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp
deleted file mode 100644
index d7220fb46d8..00000000000
--- a/contrib/libs/cxxsupp/libcxx/src/support/ibm/mbsnrtowcs.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include <cstddef> // size_t
-#include <cwchar> // mbstate_t
-#include <limits.h> // MB_LEN_MAX
-#include <string.h> // wmemcpy
-
-// Returns the number of wide characters found in the multi byte sequence `src`
-// (of `src_size_bytes`), that fit in the buffer `dst` (of `max_dest_chars`
-// elements size). The count returned excludes the null terminator.
-// When `dst` is NULL, no characters are copied to `dst`.
-// 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_FUNC_VIS
-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 source_converted;
- size_t dest_converted;
- size_t result = 0;
-
- // 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 == nullptr)
- max_dest_chars = static_cast<size_t>(-1);
-
- for (dest_converted = source_converted = 0;
- source_converted < src_size_bytes && (!dst || dest_converted < max_dest_chars);
- ++dest_converted, source_converted += result) {
- // Converts one multi byte character.
- // If result (char_size) is greater than 0, it's the size in bytes of that character.
- // 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;
-
- if (dst == nullptr) {
- result = mbrtowc(NULL, *src + source_converted, source_remaining, ps);
- } else if (dest_remaining >= source_remaining) {
- // dst has enough space to translate in-place.
- 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.
- */
- wchar_t buff[MB_LEN_MAX];
- mbstate_t mbstate_tmp;
-
- if (ps != nullptr)
- mbstate_tmp = *ps;
- result = mbrtowc(buff, *src + source_converted, source_remaining, ps);
-
- if (result > dest_remaining) {
- // Multi-byte sequence for character won't fit.
- if (ps != nullptr)
- *ps = mbstate_tmp;
- break;
- } else {
- // The buffer was used, so we need copy the translation to dst.
- wmemcpy(dst, buff, result);
- }
- }
-
- // Don't do anything to change errno from here on.
- if (result == invalid_sequence || result == terminated_sequence || result == incomplete_sequence) {
- break;
- }
- }
-
- if (dst) {
- if (result == terminated_sequence)
- *src = NULL;
- else
- *src += source_converted;
- }
- if (result == invalid_sequence)
- return invalid_sequence;
-
- return dest_converted;
-}
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp
deleted file mode 100644
index 66395bfdcb2..00000000000
--- a/contrib/libs/cxxsupp/libcxx/src/support/ibm/wcsnrtombs.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include <cwchar> // mbstate_t
-#include <limits.h> // MB_LEN_MAX
-#include <stdlib.h> // MB_CUR_MAX, size_t
-#include <string.h> // memcpy
-
-// Converts `max_source_chars` from the wide character buffer pointer to by *`src`,
-// into the multi byte character sequence buffer stored at `dst`, which must be
-// `dst_size_bytes` bytes in size. Returns the number of bytes in the sequence
-// 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_FUNC_VIS
-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;
- size_t dest_converted;
- size_t result = 0;
-
- // If `dst` is null then `dst_size_bytes` should be ignored according to the
- // standard. Setting dst_size_bytes to a large value has this effect.
- if (dst == nullptr)
- dst_size_bytes = static_cast<size_t>(-1);
-
- 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];
- size_t dest_remaining = dst_size_bytes - dest_converted;
-
- if (dst == nullptr) {
- result = wcrtomb(NULL, c, ps);
- } else if (dest_remaining >= static_cast<size_t>(MB_CUR_MAX)) {
- // dst has enough space to translate in-place.
- 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.
- */
- char buff[MB_LEN_MAX];
- mbstate_t mbstate_tmp;
-
- if (ps != nullptr)
- mbstate_tmp = *ps;
- result = wcrtomb(buff, c, ps);
-
- if (result > dest_remaining) {
- // Multi-byte sequence for character won't fit.
- if (ps != nullptr)
- *ps = mbstate_tmp;
- if (result != invalid_wchar)
- break;
- } else {
- // The buffer was used, so we need copy the translation to dst.
- memcpy(dst, buff, result);
- }
- }
-
- // result (char_size) contains the size of the multi-byte-sequence converted.
- // Otherwise, result (char_size) is (size_t) -1 and wcrtomb() sets the errno.
- if (result == invalid_wchar) {
- if (dst)
- *src = *src + source_converted;
- return invalid_wchar;
- }
-
- if (c == L'\0') {
- if (dst)
- *src = NULL;
- return dest_converted;
- }
- }
-
- if (dst)
- *src = *src + source_converted;
-
- return dest_converted;
-}
diff --git a/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp b/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp
deleted file mode 100644
index 90c1ba95a31..00000000000
--- a/contrib/libs/cxxsupp/libcxx/src/support/ibm/xlocale_zos.cpp
+++ /dev/null
@@ -1,137 +0,0 @@
-//===----------------------------------------------------------------------===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===----------------------------------------------------------------------===//
-
-#include <__support/ibm/xlocale.h>
-#include <sstream>
-#include <vector>
-
-#ifdef __cplusplus
-extern "C" {
-#endif // __cplusplus
-
-locale_t newlocale(int category_mask, const char* locale, locale_t base) {
- // Maintain current locale name(s) to restore later.
- std::string current_loc_name(setlocale(LC_ALL, 0));
-
- // Check for errors.
- if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == NULL) {
- errno = EINVAL;
- return (locale_t)0;
- } else {
- for (int _Cat = 0; _Cat <= _LC_MAX; ++_Cat) {
- if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == NULL) {
- setlocale(LC_ALL, current_loc_name.c_str());
- errno = EINVAL;
- return (locale_t)0;
- }
- }
- }
-
- // Create new locale.
- locale_t newloc = new locale_struct();
-
- if (base) {
- if (category_mask != LC_ALL_MASK) {
- // Copy base when it will not be overwritten.
- memcpy(newloc, base, sizeof (locale_struct));
- newloc->category_mask = category_mask | base->category_mask;
- }
- delete base;
- } else {
- newloc->category_mask = category_mask;
- }
-
- if (category_mask & LC_COLLATE_MASK)
- newloc->lc_collate = locale;
- if (category_mask & LC_CTYPE_MASK)
- newloc->lc_ctype = locale;
- if (category_mask & LC_MONETARY_MASK)
- newloc->lc_monetary = locale;
- if (category_mask & LC_NUMERIC_MASK)
- newloc->lc_numeric = locale;
- if (category_mask & LC_TIME_MASK)
- newloc->lc_time = locale;
- if (category_mask & LC_MESSAGES_MASK)
- newloc->lc_messages = locale;
-
- // Restore current locale.
- setlocale(LC_ALL, current_loc_name.c_str());
- return (locale_t)newloc;
-}
-
-void freelocale(locale_t locobj) {
- delete locobj;
-}
-
-locale_t uselocale(locale_t newloc) {
- // Maintain current locale name(s).
- std::string current_loc_name(setlocale(LC_ALL, 0));
-
- 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);
-
- if (is_error) {
- setlocale(LC_ALL, current_loc_name.c_str());
- errno = EINVAL;
- return (locale_t)0;
- }
- }
-
- // Construct and return previous locale.
- locale_t previous_loc = new locale_struct();
-
- // current_loc_name might be a comma-separated locale name list.
- if (current_loc_name.find(',') != std::string::npos) {
- // Tokenize locale name list.
- const char delimiter = ',';
- std::vector<std::string> tokenized;
- std::stringstream ss(current_loc_name);
- std::string s;
-
- while (std::getline(ss, s, delimiter)) {
- tokenized.push_back(s);
- }
-
- _LIBCPP_ASSERT(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_monetary = tokenized[LC_MONETARY];
- 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_monetary = current_loc_name;
- previous_loc->lc_numeric = current_loc_name;
- previous_loc->lc_time = current_loc_name;
- previous_loc->lc_messages = current_loc_name;
- }
-
- previous_loc->category_mask = LC_ALL_MASK;
- return previous_loc;
-}
-
-#ifdef __cplusplus
-}
-#endif // __cplusplus