summaryrefslogtreecommitdiffstats
path: root/contrib/restricted/boost/locale/src
diff options
context:
space:
mode:
authorthegeorg <[email protected]>2025-05-07 11:09:12 +0300
committerthegeorg <[email protected]>2025-05-07 11:25:22 +0300
commit4c98f14a2491da2bc1a9d40fed1d1682c7ec5dd6 (patch)
tree8142081775c27c8780fa0282a0273ee268e13b98 /contrib/restricted/boost/locale/src
parent40b86c68b431bb65d67bba51ef9159066a833b68 (diff)
Update contrib/restricted/boost/locale to 1.88.0
commit_hash:87b595328ea79c6ba38cb973580804486ca4a3ff
Diffstat (limited to 'contrib/restricted/boost/locale/src')
-rw-r--r--contrib/restricted/boost/locale/src/boost/locale/icu/time_zone.cpp212
-rw-r--r--contrib/restricted/boost/locale/src/encoding/codepage.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/encoding/codepage.cpp)12
-rw-r--r--contrib/restricted/boost/locale/src/encoding/iconv_converter.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/encoding/iconv_converter.hpp)4
-rw-r--r--contrib/restricted/boost/locale/src/encoding/uconv_converter.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/encoding/uconv_converter.hpp)4
-rw-r--r--contrib/restricted/boost/locale/src/encoding/wconv_converter.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/encoding/wconv_converter.hpp)2
-rw-r--r--contrib/restricted/boost/locale/src/icu/all_generator.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/all_generator.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/icu/boundary.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/boundary.cpp)12
-rw-r--r--contrib/restricted/boost/locale/src/icu/cdata.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/cdata.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/icu/codecvt.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/codecvt.cpp)14
-rw-r--r--contrib/restricted/boost/locale/src/icu/codecvt.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/codecvt.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/icu/collator.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/collator.cpp)25
-rw-r--r--contrib/restricted/boost/locale/src/icu/conversion.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/conversion.cpp)29
-rw-r--r--contrib/restricted/boost/locale/src/icu/date_time.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/date_time.cpp)31
-rw-r--r--contrib/restricted/boost/locale/src/icu/formatter.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/formatter.cpp)85
-rw-r--r--contrib/restricted/boost/locale/src/icu/formatter.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/formatter.hpp)6
-rw-r--r--contrib/restricted/boost/locale/src/icu/formatters_cache.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/formatters_cache.cpp)16
-rw-r--r--contrib/restricted/boost/locale/src/icu/formatters_cache.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/formatters_cache.hpp)2
-rw-r--r--contrib/restricted/boost/locale/src/icu/icu_backend.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/icu_backend.cpp)10
-rw-r--r--contrib/restricted/boost/locale/src/icu/icu_backend.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/icu_backend.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/icu/icu_util.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/icu_util.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/icu/numeric.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/numeric.cpp)64
-rw-r--r--contrib/restricted/boost/locale/src/icu/time_zone.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/time_zone.hpp)14
-rw-r--r--contrib/restricted/boost/locale/src/icu/uconv.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/icu/uconv.hpp)2
-rw-r--r--contrib/restricted/boost/locale/src/posix/all_generator.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/posix/all_generator.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/posix/codecvt.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/posix/codecvt.cpp)6
-rw-r--r--contrib/restricted/boost/locale/src/posix/collate.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/posix/collate.cpp)5
-rw-r--r--contrib/restricted/boost/locale/src/posix/converter.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/posix/converter.cpp)6
-rw-r--r--contrib/restricted/boost/locale/src/posix/numeric.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/posix/numeric.cpp)4
-rw-r--r--contrib/restricted/boost/locale/src/posix/posix_backend.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/posix/posix_backend.cpp)10
-rw-r--r--contrib/restricted/boost/locale/src/posix/posix_backend.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/posix/posix_backend.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/shared/date_time.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/date_time.cpp)0
-rw-r--r--contrib/restricted/boost/locale/src/shared/format.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/format.cpp)10
-rw-r--r--contrib/restricted/boost/locale/src/shared/formatting.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/formatting.cpp)4
-rw-r--r--contrib/restricted/boost/locale/src/shared/generator.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/generator.cpp)9
-rw-r--r--contrib/restricted/boost/locale/src/shared/iconv_codecvt.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/iconv_codecvt.cpp)6
-rw-r--r--contrib/restricted/boost/locale/src/shared/iconv_codecvt.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/iconv_codecvt.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/shared/ids.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/ids.cpp)2
-rw-r--r--contrib/restricted/boost/locale/src/shared/ios_prop.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/ios_prop.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/shared/localization_backend.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/localization_backend.cpp)8
-rw-r--r--contrib/restricted/boost/locale/src/shared/message.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/message.cpp)36
-rw-r--r--contrib/restricted/boost/locale/src/shared/message.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/message.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/shared/mo_hash.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/mo_hash.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/shared/mo_lambda.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/mo_lambda.cpp)2
-rw-r--r--contrib/restricted/boost/locale/src/shared/mo_lambda.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/mo_lambda.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/shared/std_collate_adapter.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/shared/std_collate_adapter.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/std/all_generator.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/std/all_generator.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/std/codecvt.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/std/codecvt.cpp)2
-rw-r--r--contrib/restricted/boost/locale/src/std/collate.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/std/collate.cpp)2
-rw-r--r--contrib/restricted/boost/locale/src/std/converter.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/std/converter.cpp)4
-rw-r--r--contrib/restricted/boost/locale/src/std/numeric.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/std/numeric.cpp)4
-rw-r--r--contrib/restricted/boost/locale/src/std/std_backend.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/std/std_backend.cpp)16
-rw-r--r--contrib/restricted/boost/locale/src/std/std_backend.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/std/std_backend.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/util/codecvt_converter.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/codecvt_converter.cpp)4
-rw-r--r--contrib/restricted/boost/locale/src/util/default_locale.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/default_locale.cpp)0
-rw-r--r--contrib/restricted/boost/locale/src/util/encoding.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/encoding.cpp)12
-rw-r--r--contrib/restricted/boost/locale/src/util/encoding.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/encoding.hpp)10
-rw-r--r--contrib/restricted/boost/locale/src/util/foreach_char.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/foreach_char.hpp)2
-rw-r--r--contrib/restricted/boost/locale/src/util/gregorian.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/gregorian.cpp)4
-rw-r--r--contrib/restricted/boost/locale/src/util/gregorian.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/gregorian.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/util/iconv.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/iconv.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/util/info.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/info.cpp)0
-rw-r--r--contrib/restricted/boost/locale/src/util/locale_data.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/locale_data.cpp)79
-rw-r--r--contrib/restricted/boost/locale/src/util/make_std_unique.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/make_std_unique.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/util/numeric.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/numeric.hpp)34
-rw-r--r--contrib/restricted/boost/locale/src/util/numeric_conversion.hpp147
-rw-r--r--contrib/restricted/boost/locale/src/util/timezone.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/timezone.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/util/win_codepages.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/util/win_codepages.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/win32/all_generator.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/win32/all_generator.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/win32/api.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/win32/api.hpp)2
-rw-r--r--contrib/restricted/boost/locale/src/win32/collate.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/win32/collate.cpp)6
-rw-r--r--contrib/restricted/boost/locale/src/win32/converter.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/win32/converter.cpp)6
-rw-r--r--contrib/restricted/boost/locale/src/win32/lcid.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/win32/lcid.cpp)2
-rw-r--r--contrib/restricted/boost/locale/src/win32/lcid.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/win32/lcid.hpp)0
-rw-r--r--contrib/restricted/boost/locale/src/win32/numeric.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/win32/numeric.cpp)6
-rw-r--r--contrib/restricted/boost/locale/src/win32/win_backend.cpp (renamed from contrib/restricted/boost/locale/src/boost/locale/win32/win_backend.cpp)12
-rw-r--r--contrib/restricted/boost/locale/src/win32/win_backend.hpp (renamed from contrib/restricted/boost/locale/src/boost/locale/win32/win_backend.hpp)0
76 files changed, 481 insertions, 525 deletions
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/time_zone.cpp b/contrib/restricted/boost/locale/src/boost/locale/icu/time_zone.cpp
deleted file mode 100644
index 2f11862a59a..00000000000
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/time_zone.cpp
+++ /dev/null
@@ -1,212 +0,0 @@
-//
-// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-//
-// Distributed under the Boost Software License, Version 1.0.
-// https://www.boost.org/LICENSE_1_0.txt
-
-#include "boost/locale/icu/time_zone.hpp"
-#include <boost/locale/hold_ptr.hpp>
-#include "boost/locale/icu/icu_util.hpp"
-#include <boost/predef/os.h>
-
-//
-// Bug - when ICU tries to find a file that is equivalent to /etc/localtime it finds /usr/share/zoneinfo/localtime
-// that is just a symbolic link to /etc/localtime.
-//
-// It started in 4.0 and was fixed in version 4.6, also the fix was backported to the 4.4 branch so it should be
-// available from 4.4.3... So we test if the workaround is required
-//
-// It is also relevant only for Linux, BSD and Apple (as I see in ICU code)
-//
-
-#if BOOST_LOCALE_ICU_VERSION >= 400 && BOOST_LOCALE_ICU_VERSION <= 406 \
- && (BOOST_LOCALE_ICU_VERSION != 404 || U_ICU_VERSION_PATCHLEVEL_NUM >= 3)
-# if BOOST_OS_LINUX || BOOST_OS_BSD_FREE || defined(__APPLE__)
-# define BOOST_LOCALE_WORKAROUND_ICU_BUG
-# endif
-#endif
-
-#ifdef BOOST_LOCALE_WORKAROUND_ICU_BUG
-# include <cstring>
-# include <dirent.h>
-# include <fstream>
-# include <memory>
-# include <pthread.h>
-# include <sys/stat.h>
-# include <sys/types.h>
-# include <unistd.h>
-#endif
-
-namespace boost { namespace locale { namespace impl_icu {
-
-#ifndef BOOST_LOCALE_WORKAROUND_ICU_BUG
-
- // This is normal behavior
-
- icu::TimeZone* get_time_zone(const std::string& time_zone)
- {
- if(time_zone.empty())
- return icu::TimeZone::createDefault();
- else
- return icu::TimeZone::createTimeZone(time_zone.c_str());
- }
-
-#else
-
- // This is a workaround for an ICU timezone detection bug.
- // It is \b very ICU specific and should not be used
- // in general. It is also designed to work only on
- // specific patforms: Linux, BSD and Apple, where this bug may actually
- // occur
- namespace {
-
- // Under BSD, Linux and Mac OS X dirent has normal size
- // so no issues with readdir_r
-
- class directory {
- public:
- directory(const char* name) : d(0), read_result(0)
- {
- d = opendir(name);
- if(!d)
- return;
- }
- ~directory()
- {
- if(d)
- closedir(d);
- }
- bool is_open() { return d; }
- const char* next()
- {
- if(d && readdir_r(d, &de, &read_result) == 0 && read_result != 0)
- return de.d_name;
- return nullptr;
- }
-
- private:
- DIR* d;
- struct dirent de;
- struct dirent* read_result;
- };
-
- bool files_equal(const std::string& left, const std::string& right)
- {
- char l[256], r[256];
- std::ifstream ls(left);
- if(!ls)
- return false;
- std::ifstream rs(right);
- if(!rs)
- return false;
- do {
- ls.read(l, sizeof(l));
- rs.read(r, sizeof(r));
- size_t n;
- if((n = ls.gcount()) != size_t(rs.gcount()))
- return false;
- if(memcmp(l, r, n) != 0)
- return false;
- } while(!ls.eof() || !rs.eof());
- if(bool(ls.eof()) != bool(rs.eof()))
- return false;
- return true;
- }
-
- std::string find_file_in(const std::string& ref, size_t size, const std::string& dir)
- {
- directory d(dir.c_str());
- if(!d.is_open())
- return std::string();
-
- const char* name = nullptr;
- while((name = d.next()) != 0) {
- std::string file_name = name;
- if(file_name == "." || file_name == ".." || file_name == "posixrules" || file_name == "localtime")
- continue;
- struct stat st;
- std::string path = dir + "/" + file_name;
- if(stat(path.c_str(), &st) == 0) {
- if(S_ISDIR(st.st_mode)) {
- std::string res = find_file_in(ref, size, path);
- if(!res.empty())
- return file_name + "/" + res;
- } else {
- if(size_t(st.st_size) == size && files_equal(path, ref))
- return file_name;
- }
- }
- }
- return std::string();
- }
-
- // This actually emulates ICU's search
- // algorithm... just it ignores localtime
- std::string detect_correct_time_zone()
- {
- const char* tz_dir = "/usr/share/zoneinfo";
- const char* tz_file = "/etc/localtime";
-
- struct stat st;
- if(::stat(tz_file, &st) != 0)
- return std::string();
- size_t size = st.st_size;
- std::string r = find_file_in(tz_file, size, tz_dir);
- if(r.empty())
- return r;
- if(r.compare(0, 6, "posix/") == 0 || r.compare(0, 6, "right/", 6) == 0)
- return r.substr(6);
- return r;
- }
-
- // Using pthread as:
- // - This bug is relevant for only Linux, BSD, Mac OS X and
- // pthreads are native threading API
- // - The dependency on boost.thread may be removed when using
- // more recent ICU versions (so TLS would not be needed)
- //
- // This the dependency on Boost.Thread is eliminated
-
- pthread_once_t init_tz = PTHREAD_ONCE_INIT;
- std::string default_time_zone_name;
-
- extern "C" {
- static void init_tz_proc()
- {
- try {
- default_time_zone_name = detect_correct_time_zone();
- } catch(...) {
- }
- }
- }
-
- std::string get_time_zone_name()
- {
- pthread_once(&init_tz, init_tz_proc);
- return default_time_zone_name;
- }
-
- } // namespace
-
- icu::TimeZone* get_time_zone(const std::string& time_zone)
- {
- if(!time_zone.empty())
- return icu::TimeZone::createTimeZone(time_zone.c_str());
- hold_ptr<icu::TimeZone> tz(icu::TimeZone::createDefault());
- icu::UnicodeString id;
- tz->getID(id);
- // Check if there is a bug?
- if(id != icu::UnicodeString("localtime"))
- return tz.release();
- // Now let's deal with the bug and run the fixed
- // search loop as that of ICU
- std::string real_id = get_time_zone_name();
- if(real_id.empty()) {
- // if we failed fallback to ICU's time zone
- return tz.release();
- }
- return icu::TimeZone::createTimeZone(real_id.c_str());
- }
-#endif // bug workaround
-
-}}} // namespace boost::locale::impl_icu
diff --git a/contrib/restricted/boost/locale/src/boost/locale/encoding/codepage.cpp b/contrib/restricted/boost/locale/src/encoding/codepage.cpp
index 0ac9659ab56..814a8035df2 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/encoding/codepage.cpp
+++ b/contrib/restricted/boost/locale/src/encoding/codepage.cpp
@@ -1,24 +1,24 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2022-2023 Alexander Grund
+// Copyright (c) 2022-2025 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/locale/encoding.hpp>
-#include "boost/locale/util/make_std_unique.hpp"
+#include "../util/make_std_unique.hpp"
#if BOOST_LOCALE_USE_WIN32_API
# define BOOST_LOCALE_WITH_WCONV
#endif
#ifdef BOOST_LOCALE_WITH_ICONV
-# include "boost/locale/encoding/iconv_converter.hpp"
+# include "iconv_converter.hpp"
#endif
#ifdef BOOST_LOCALE_WITH_ICU
-# include "boost/locale/encoding/uconv_converter.hpp"
+# include "uconv_converter.hpp"
#endif
#ifdef BOOST_LOCALE_WITH_WCONV
-# include "boost/locale/encoding/wconv_converter.hpp"
+# include "wconv_converter.hpp"
#endif
namespace boost { namespace locale { namespace conv {
@@ -224,7 +224,7 @@ namespace boost { namespace locale { namespace conv {
BOOST_LOCALE_INSTANTIATE(char);
BOOST_LOCALE_INSTANTIATE_NO_CHAR(wchar_t);
-#ifndef BOOST_LOCALE_NO_CXX20_STRING8
+#ifdef __cpp_lib_char8_t
BOOST_LOCALE_INSTANTIATE_NO_CHAR(char8_t);
#endif
diff --git a/contrib/restricted/boost/locale/src/boost/locale/encoding/iconv_converter.hpp b/contrib/restricted/boost/locale/src/encoding/iconv_converter.hpp
index 2877dbca5e5..8d26287b564 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/encoding/iconv_converter.hpp
+++ b/contrib/restricted/boost/locale/src/encoding/iconv_converter.hpp
@@ -8,8 +8,8 @@
#define BOOST_LOCALE_IMPL_ICONV_CODEPAGE_HPP
#include <boost/locale/encoding.hpp>
-#include "boost/locale/util/encoding.hpp"
-#include "boost/locale/util/iconv.hpp"
+#include "../util/encoding.hpp"
+#include "../util/iconv.hpp"
#include <boost/assert.hpp>
#include <cerrno>
#include <string>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/encoding/uconv_converter.hpp b/contrib/restricted/boost/locale/src/encoding/uconv_converter.hpp
index 53a14055322..ae8913764ae 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/encoding/uconv_converter.hpp
+++ b/contrib/restricted/boost/locale/src/encoding/uconv_converter.hpp
@@ -8,8 +8,8 @@
#define BOOST_LOCALE_IMPL_UCONV_CODEPAGE_HPP
#include <boost/locale/encoding.hpp>
#include <boost/locale/hold_ptr.hpp>
-#include "boost/locale/icu/icu_util.hpp"
-#include "boost/locale/icu/uconv.hpp"
+#include "../icu/icu_util.hpp"
+#include "../icu/uconv.hpp"
#include <unicode/ucnv.h>
#include <unicode/ucnv_err.h>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/encoding/wconv_converter.hpp b/contrib/restricted/boost/locale/src/encoding/wconv_converter.hpp
index 32cd78e21a9..e29b562edfa 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/encoding/wconv_converter.hpp
+++ b/contrib/restricted/boost/locale/src/encoding/wconv_converter.hpp
@@ -11,7 +11,7 @@
# define NOMINMAX
#endif
#include <boost/locale/encoding.hpp>
-#include "boost/locale/util/encoding.hpp"
+#include "../util/encoding.hpp"
#include <algorithm>
#include <cstddef>
#include <cstring>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/all_generator.hpp b/contrib/restricted/boost/locale/src/icu/all_generator.hpp
index b2f8c34a33b..b2f8c34a33b 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/all_generator.hpp
+++ b/contrib/restricted/boost/locale/src/icu/all_generator.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/boundary.cpp b/contrib/restricted/boost/locale/src/icu/boundary.cpp
index 4adada4f428..339cab50914 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/boundary.cpp
+++ b/contrib/restricted/boost/locale/src/icu/boundary.cpp
@@ -1,17 +1,17 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2021-2022 Alexander Grund
+// Copyright (c) 2021-2025 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/locale/boundary.hpp>
#include <boost/locale/generator.hpp>
-#include "boost/locale/icu/all_generator.hpp"
-#include "boost/locale/icu/cdata.hpp"
-#include "boost/locale/icu/icu_util.hpp"
-#include "boost/locale/icu/uconv.hpp"
-#include "boost/locale/util/encoding.hpp"
+#include "../util/encoding.hpp"
+#include "all_generator.hpp"
+#include "cdata.hpp"
+#include "icu_util.hpp"
+#include "uconv.hpp"
#if BOOST_LOCALE_ICU_VERSION >= 5502
# include <unicode/utext.h>
#endif
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/cdata.hpp b/contrib/restricted/boost/locale/src/icu/cdata.hpp
index 37ce36888e6..37ce36888e6 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/cdata.hpp
+++ b/contrib/restricted/boost/locale/src/icu/cdata.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/codecvt.cpp b/contrib/restricted/boost/locale/src/icu/codecvt.cpp
index cdf958ab58f..3e6e24f7743 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/codecvt.cpp
+++ b/contrib/restricted/boost/locale/src/icu/codecvt.cpp
@@ -1,20 +1,20 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2022-2023 Alexander Grund
+// Copyright (c) 2022-2025 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/icu/codecvt.hpp"
+#include "codecvt.hpp"
#include <boost/locale/encoding.hpp>
#include <boost/locale/encoding_errors.hpp>
#include <boost/locale/hold_ptr.hpp>
#include <boost/locale/util.hpp>
-#include "boost/locale/icu/all_generator.hpp"
-#include "boost/locale/icu/icu_util.hpp"
-#include "boost/locale/icu/uconv.hpp"
-#include "boost/locale/util/encoding.hpp"
-#include "boost/locale/util/make_std_unique.hpp"
+#include "../util/encoding.hpp"
+#include "../util/make_std_unique.hpp"
+#include "all_generator.hpp"
+#include "icu_util.hpp"
+#include "uconv.hpp"
#include <unicode/ucnv.h>
#include <unicode/ucnv_err.h>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/codecvt.hpp b/contrib/restricted/boost/locale/src/icu/codecvt.hpp
index f406f7f5335..f406f7f5335 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/codecvt.hpp
+++ b/contrib/restricted/boost/locale/src/icu/codecvt.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/collator.cpp b/contrib/restricted/boost/locale/src/icu/collator.cpp
index 72ade74fbb7..43d921d5941 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/collator.cpp
+++ b/contrib/restricted/boost/locale/src/icu/collator.cpp
@@ -1,28 +1,24 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
+// Copyright (c) 2022-2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/locale/collator.hpp>
#include <boost/locale/generator.hpp>
-#include "boost/locale/icu/all_generator.hpp"
-#include "boost/locale/icu/cdata.hpp"
-#include "boost/locale/icu/icu_util.hpp"
-#include "boost/locale/icu/uconv.hpp"
-#include "boost/locale/shared/mo_hash.hpp"
-#include "boost/locale/shared/std_collate_adapter.hpp"
+#include "../shared/mo_hash.hpp"
+#include "../shared/std_collate_adapter.hpp"
+#include "all_generator.hpp"
+#include "cdata.hpp"
+#include "icu_util.hpp"
+#include "uconv.hpp"
#include <boost/thread.hpp>
#include <limits>
#include <memory>
#include <unicode/coll.h>
+#include <unicode/stringpiece.h>
#include <vector>
-#if BOOST_LOCALE_ICU_VERSION >= 402
-# define BOOST_LOCALE_WITH_STRINGPIECE 1
-# include <unicode/stringpiece.h>
-#else
-# define BOOST_LOCALE_WITH_STRINGPIECE 0
-#endif
#ifdef BOOST_MSVC
# pragma warning(disable : 4244) // 'argument' : conversion from 'int'
@@ -43,7 +39,6 @@ namespace boost { namespace locale { namespace impl_icu {
return res;
}
-#if BOOST_LOCALE_WITH_STRINGPIECE
int do_utf8_compare(collate_level level,
const char* b1,
const char* e1,
@@ -55,7 +50,6 @@ namespace boost { namespace locale { namespace impl_icu {
icu::StringPiece right(b2, e2 - b2);
return get_collator(level).compareUTF8(left, right, status);
}
-#endif
int do_ustring_compare(collate_level level,
const CharType* b1,
@@ -159,7 +153,6 @@ namespace boost { namespace locale { namespace impl_icu {
bool is_utf8_;
};
-#if BOOST_LOCALE_WITH_STRINGPIECE
template<>
int collate_impl<char>::do_real_compare(collate_level level,
const char* b1,
@@ -173,7 +166,7 @@ namespace boost { namespace locale { namespace impl_icu {
else
return do_ustring_compare(level, b1, e1, b2, e2, status);
}
-#endif
+
std::locale create_collate(const std::locale& in, const cdata& cd, char_facet_t type)
{
switch(type) {
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/conversion.cpp b/contrib/restricted/boost/locale/src/icu/conversion.cpp
index c619dd94a1e..a7fddb473ab 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/conversion.cpp
+++ b/contrib/restricted/boost/locale/src/icu/conversion.cpp
@@ -1,23 +1,20 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2022-2023 Alexander Grund
+// Copyright (c) 2022-2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/locale/conversion.hpp>
-#include "boost/locale/icu/all_generator.hpp"
-#include "boost/locale/icu/cdata.hpp"
-#include "boost/locale/icu/icu_util.hpp"
-#include "boost/locale/icu/uconv.hpp"
+#include "all_generator.hpp"
+#include "cdata.hpp"
+#include "icu_util.hpp"
+#include "uconv.hpp"
#include <limits>
#include <unicode/locid.h>
#include <unicode/normlzr.h>
+#include <unicode/ucasemap.h>
#include <unicode/ustring.h>
-#if BOOST_LOCALE_ICU_VERSION >= 308
-# include <unicode/ucasemap.h>
-# define BOOST_LOCALE_WITH_CASEMAP
-#endif
#include <vector>
namespace boost { namespace locale { namespace impl_icu {
@@ -72,7 +69,6 @@ namespace boost { namespace locale { namespace impl_icu {
std::string encoding_;
}; // converter_impl
-#ifdef BOOST_LOCALE_WITH_CASEMAP
template<typename T>
struct get_casemap_size_type;
@@ -193,26 +189,17 @@ namespace boost { namespace locale { namespace impl_icu {
raii_casemap<U8Char> map_;
}; // converter_impl
-#endif // BOOST_LOCALE_WITH_CASEMAP
-
std::locale create_convert(const std::locale& in, const cdata& cd, char_facet_t type)
{
switch(type) {
case char_facet_t::nochar: break;
case char_facet_t::char_f:
-#ifdef BOOST_LOCALE_WITH_CASEMAP
if(cd.is_utf8())
return std::locale(in, new utf8_converter_impl<char>(cd));
-#endif
return std::locale(in, new converter_impl<char>(cd));
case char_facet_t::wchar_f: return std::locale(in, new converter_impl<wchar_t>(cd));
-#ifndef BOOST_LOCALE_NO_CXX20_STRING8
- case char_facet_t::char8_f:
-# if defined(BOOST_LOCALE_WITH_CASEMAP)
- return std::locale(in, new utf8_converter_impl<char8_t>(cd));
-# else
- return std::locale(in, new converter_impl<char8_t>(cd));
-# endif
+#ifdef __cpp_lib_char8_t
+ case char_facet_t::char8_f: return std::locale(in, new utf8_converter_impl<char8_t>(cd));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;
#endif
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/date_time.cpp b/contrib/restricted/boost/locale/src/icu/date_time.cpp
index 14e21d9f155..76785ec6ce7 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/date_time.cpp
+++ b/contrib/restricted/boost/locale/src/icu/date_time.cpp
@@ -1,6 +1,6 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2021-2022 Alexander Grund
+// Copyright (c) 2021-2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
@@ -9,11 +9,11 @@
#include <boost/locale/date_time_facet.hpp>
#include <boost/locale/formatting.hpp>
#include <boost/locale/hold_ptr.hpp>
-#include "boost/locale/icu/all_generator.hpp"
-#include "boost/locale/icu/cdata.hpp"
-#include "boost/locale/icu/icu_util.hpp"
-#include "boost/locale/icu/time_zone.hpp"
-#include "boost/locale/icu/uconv.hpp"
+#include "all_generator.hpp"
+#include "cdata.hpp"
+#include "icu_util.hpp"
+#include "time_zone.hpp"
+#include "uconv.hpp"
#include <boost/thread.hpp>
#include <cmath>
#include <memory>
@@ -67,10 +67,6 @@ namespace boost { namespace locale { namespace impl_icu {
const double rounded_time = std::floor(calendar_->getTime(err) / U_MILLIS_PER_SECOND) * U_MILLIS_PER_SECOND;
calendar_->setTime(rounded_time, err);
check_and_throw_dt(err);
-#if BOOST_LOCALE_ICU_VERSION < 402
- // workaround old/invalid data, it should be 4 in general
- calendar_->setMinimalDaysInFirstWeek(4);
-#endif
encoding_ = dat.encoding();
}
calendar_impl(const calendar_impl& other)
@@ -79,15 +75,9 @@ namespace boost { namespace locale { namespace impl_icu {
encoding_ = other.encoding_;
}
- calendar_impl* clone() const override
- {
- return new calendar_impl(*this);
- }
+ calendar_impl* clone() const override { return new calendar_impl(*this); }
- void set_value(period::marks::period_mark p, int value) override
- {
- calendar_->set(to_icu(p), int32_t(value));
- }
+ void set_value(period::marks::period_mark p, int value) override { calendar_->set(to_icu(p), int32_t(value)); }
int get_value(period::marks::period_mark p, value_type type) const override
{
@@ -202,10 +192,7 @@ namespace boost { namespace locale { namespace impl_icu {
check_and_throw_dt(err);
return diff;
}
- void set_timezone(const std::string& tz) override
- {
- calendar_->adoptTimeZone(get_time_zone(tz));
- }
+ void set_timezone(const std::string& tz) override { calendar_->adoptTimeZone(get_time_zone(tz)); }
std::string get_timezone() const override
{
icu::UnicodeString tz;
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/formatter.cpp b/contrib/restricted/boost/locale/src/icu/formatter.cpp
index 12cb73632e1..64f8e1e46da 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/formatter.cpp
+++ b/contrib/restricted/boost/locale/src/icu/formatter.cpp
@@ -1,18 +1,22 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2021-2023 Alexander Grund
+// Copyright (c) 2021-2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/icu/formatter.hpp"
+#include "formatter.hpp"
#include <boost/locale/formatting.hpp>
#include <boost/locale/info.hpp>
-#include "boost/locale/icu/formatters_cache.hpp"
-#include "boost/locale/icu/icu_util.hpp"
-#include "boost/locale/icu/time_zone.hpp"
-#include "boost/locale/icu/uconv.hpp"
-#include "boost/locale/util/foreach_char.hpp"
+#include "../util/foreach_char.hpp"
+#include "../util/numeric_conversion.hpp"
+#include "formatters_cache.hpp"
+#include "icu_util.hpp"
+#include "time_zone.hpp"
+#include "uconv.hpp"
+#include <boost/assert.hpp>
+#include <boost/charconv/limits.hpp>
+#include <boost/charconv/to_chars.hpp>
#include <limits>
#include <memory>
#ifdef BOOST_MSVC
@@ -20,7 +24,6 @@
# pragma warning(disable : 4251) // "identifier" : class "type" needs to have dll-interface...
#endif
#include <unicode/datefmt.h>
-#include <unicode/decimfmt.h>
#include <unicode/numfmt.h>
#include <unicode/rbnf.h>
#include <unicode/smpdtfmt.h>
@@ -54,41 +57,72 @@ namespace boost { namespace locale { namespace impl_icu {
public:
typedef std::basic_string<CharType> string_type;
- number_format(icu::NumberFormat& fmt, std::string codepage) : cvt_(codepage), icu_fmt_(fmt) {}
+ number_format(icu::NumberFormat& fmt, const std::string& codepage, bool isNumberOnly = false) :
+ cvt_(codepage), icu_fmt_(fmt), isNumberOnly_(isNumberOnly)
+ {}
string_type format(double value, size_t& code_points) const override { return do_format(value, code_points); }
string_type format(int64_t value, size_t& code_points) const override { return do_format(value, code_points); }
string_type format(int32_t value, size_t& code_points) const override { return do_format(value, code_points); }
size_t parse(const string_type& str, double& value) const override { return do_parse(str, value); }
+ size_t parse(const string_type& str, uint64_t& value) const override { return do_parse(str, value); }
size_t parse(const string_type& str, int64_t& value) const override { return do_parse(str, value); }
size_t parse(const string_type& str, int32_t& value) const override { return do_parse(str, value); }
+ string_type format(const uint64_t value, size_t& code_points) const override
+ {
+ // ICU only supports int64_t as the largest integer type
+ if(value <= static_cast<uint64_t>(std::numeric_limits<int64_t>::max()))
+ return format(static_cast<int64_t>(value), code_points);
+
+ // Fallback to using a StringPiece (decimal number) as input
+ char buffer[boost::charconv::limits<uint64_t>::max_chars10 + 1];
+ auto res = boost::charconv::to_chars(buffer, std::end(buffer), value);
+ BOOST_ASSERT(res);
+ BOOST_ASSERT(res.ptr < std::end(buffer));
+ *res.ptr = '\0'; // ICU expects a NULL-terminated string even for the StringPiece
+ icu::UnicodeString tmp;
+ UErrorCode err = U_ZERO_ERROR;
+ icu_fmt_.format(icu::StringPiece(buffer, res.ptr - buffer), tmp, nullptr, err);
+ check_and_throw_icu_error(err);
+ code_points = tmp.countChar32();
+ return cvt_.std(tmp);
+ }
+
private:
bool get_value(double& v, icu::Formattable& fmt) const
{
UErrorCode err = U_ZERO_ERROR;
v = fmt.getDouble(err);
- if(U_FAILURE(err))
- return false;
- return true;
+ return U_SUCCESS(err);
}
bool get_value(int64_t& v, icu::Formattable& fmt) const
{
UErrorCode err = U_ZERO_ERROR;
v = fmt.getInt64(err);
- if(U_FAILURE(err))
- return false;
- return true;
+ return U_SUCCESS(err);
+ }
+
+ bool get_value(uint64_t& v, icu::Formattable& fmt) const
+ {
+ UErrorCode err = U_ZERO_ERROR;
+ // ICU only supports int64_t as the largest integer type
+ const int64_t tmp = fmt.getInt64(err);
+ if(U_SUCCESS(err)) {
+ if(tmp < 0)
+ return false;
+ v = static_cast<uint64_t>(tmp);
+ return true;
+ }
+ return util::try_parse_icu(fmt, v);
}
bool get_value(int32_t& v, icu::Formattable& fmt) const
{
UErrorCode err = U_ZERO_ERROR;
v = fmt.getLong(err);
- if(U_FAILURE(err))
- return false;
- return true;
+ return U_SUCCESS(err);
}
template<typename ValueType>
@@ -107,21 +141,22 @@ namespace boost { namespace locale { namespace impl_icu {
icu::ParsePosition pp;
icu::UnicodeString tmp = cvt_.icu(str.data(), str.data() + str.size());
+ // For the plain number parsing (no currency etc) parse "123.456" as 2 ints
+ // not a float later converted to int
+ icu_fmt_.setParseIntegerOnly(std::is_integral<ValueType>::value && isNumberOnly_);
icu_fmt_.parse(tmp, val, pp);
- ValueType tmp_v;
-
- if(pp.getIndex() == 0 || !get_value(tmp_v, val))
+ if(pp.getIndex() == 0 || !get_value(v, val))
return 0;
size_t cut = cvt_.cut(tmp, str.data(), str.data() + str.size(), pp.getIndex());
if(cut == 0)
return 0;
- v = tmp_v;
return cut;
}
icu_std_converter<CharType> cvt_;
icu::NumberFormat& icu_fmt_;
+ const bool isNumberOnly_;
};
template<typename CharType>
@@ -130,11 +165,11 @@ namespace boost { namespace locale { namespace impl_icu {
typedef std::basic_string<CharType> string_type;
string_type format(double value, size_t& code_points) const override { return do_format(value, code_points); }
+ string_type format(uint64_t value, size_t& code_points) const override { return do_format(value, code_points); }
string_type format(int64_t value, size_t& code_points) const override { return do_format(value, code_points); }
-
string_type format(int32_t value, size_t& code_points) const override { return do_format(value, code_points); }
-
size_t parse(const string_type& str, double& value) const override { return do_parse(str, value); }
+ size_t parse(const string_type& str, uint64_t& value) const override { return do_parse(str, value); }
size_t parse(const string_type& str, int64_t& value) const override { return do_parse(str, value); }
size_t parse(const string_type& str, int32_t& value) const override { return do_parse(str, value); }
@@ -355,7 +390,7 @@ namespace boost { namespace locale { namespace impl_icu {
icu::NumberFormat& nf =
cache.number_format((how == std::ios_base::scientific) ? num_fmt_type::sci : num_fmt_type::number);
set_fraction_digits(nf, how, ios.precision());
- return ptr_type(new number_format<CharType>(nf, encoding));
+ return ptr_type(new number_format<CharType>(nf, encoding, true));
}
case currency: {
icu::NumberFormat& nf = cache.number_format(
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/formatter.hpp b/contrib/restricted/boost/locale/src/icu/formatter.hpp
index 110a031551c..bcda2788ef8 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/formatter.hpp
+++ b/contrib/restricted/boost/locale/src/icu/formatter.hpp
@@ -1,5 +1,6 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
+// Copyright (c) 2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
@@ -31,6 +32,8 @@ namespace boost { namespace locale { namespace impl_icu {
/// Format the value and return the number of Unicode code points
virtual string_type format(double value, size_t& code_points) const = 0;
/// Format the value and return the number of Unicode code points
+ virtual string_type format(uint64_t value, size_t& code_points) const = 0;
+ /// Format the value and return the number of Unicode code points
virtual string_type format(int64_t value, size_t& code_points) const = 0;
/// Format the value and return the number of Unicode code points
virtual string_type format(int32_t value, size_t& code_points) const = 0;
@@ -40,6 +43,9 @@ namespace boost { namespace locale { namespace impl_icu {
virtual size_t parse(const string_type& str, double& value) const = 0;
/// Parse the string and return the number of used characters. If it returns 0
/// then parsing failed.
+ virtual size_t parse(const string_type& str, uint64_t& value) const = 0;
+ /// Parse the string and return the number of used characters. If it returns 0
+ /// then parsing failed.
virtual size_t parse(const string_type& str, int64_t& value) const = 0;
/// Parse the string and return the number of used characters. If it returns 0
/// then parsing failed.
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/formatters_cache.cpp b/contrib/restricted/boost/locale/src/icu/formatters_cache.cpp
index c9a8c46347a..101ffcc6504 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/formatters_cache.cpp
+++ b/contrib/restricted/boost/locale/src/icu/formatters_cache.cpp
@@ -1,11 +1,11 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2021-2022 Alexander Grund
+// Copyright (c) 2021-2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/icu/formatters_cache.hpp"
+#include "formatters_cache.hpp"
#include <boost/assert.hpp>
#include <boost/core/ignore_unused.hpp>
#include <memory>
@@ -87,22 +87,10 @@ namespace boost { namespace locale { namespace impl_icu {
switch(type) {
case num_fmt_type::number: return icu::NumberFormat::createInstance(locale_, err); break;
case num_fmt_type::sci: return icu::NumberFormat::createScientificInstance(locale_, err); break;
-#if BOOST_LOCALE_ICU_VERSION >= 408
case num_fmt_type::curr_nat: return icu::NumberFormat::createInstance(locale_, UNUM_CURRENCY, err); break;
case num_fmt_type::curr_iso:
return icu::NumberFormat::createInstance(locale_, UNUM_CURRENCY_ISO, err);
break;
-#elif BOOST_LOCALE_ICU_VERSION >= 402
- case num_fmt_type::curr_nat:
- return icu::NumberFormat::createInstance(locale_, icu::NumberFormat::kCurrencyStyle, err);
- break;
- case num_fmt_type::curr_iso:
- return icu::NumberFormat::createInstance(locale_, icu::NumberFormat::kIsoCurrencyStyle, err);
- break;
-#else
- case num_fmt_type::curr_nat:
- case num_fmt_type::curr_iso: return icu::NumberFormat::createCurrencyInstance(locale_, err); break;
-#endif
case num_fmt_type::percent: return icu::NumberFormat::createPercentInstance(locale_, err); break;
case num_fmt_type::spell: return new icu::RuleBasedNumberFormat(icu::URBNF_SPELLOUT, locale_, err); break;
case num_fmt_type::ordinal: return new icu::RuleBasedNumberFormat(icu::URBNF_ORDINAL, locale_, err); break;
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/formatters_cache.hpp b/contrib/restricted/boost/locale/src/icu/formatters_cache.hpp
index d0e4978d550..2d4c950c543 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/formatters_cache.hpp
+++ b/contrib/restricted/boost/locale/src/icu/formatters_cache.hpp
@@ -9,7 +9,7 @@
#define BOOST_LOCALE_PREDEFINED_FORMATTERS_HPP_INCLUDED
#include <boost/locale/config.hpp>
-#include "boost/locale/icu/icu_util.hpp"
+#include "icu_util.hpp"
#include <boost/thread/tss.hpp>
#include <locale>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/icu_backend.cpp b/contrib/restricted/boost/locale/src/icu/icu_backend.cpp
index ecb78ae45ca..4b70e9750fd 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/icu_backend.cpp
+++ b/contrib/restricted/boost/locale/src/icu/icu_backend.cpp
@@ -5,14 +5,14 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/icu/icu_backend.hpp"
+#include "icu_backend.hpp"
#include <boost/locale/gnu_gettext.hpp>
#include <boost/locale/localization_backend.hpp>
#include <boost/locale/util.hpp>
-#include "boost/locale/icu/all_generator.hpp"
-#include "boost/locale/icu/cdata.hpp"
-#include "boost/locale/shared/message.hpp"
-#include "boost/locale/util/make_std_unique.hpp"
+#include "../shared/message.hpp"
+#include "../util/make_std_unique.hpp"
+#include "all_generator.hpp"
+#include "cdata.hpp"
#include <unicode/ucnv.h>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/icu_backend.hpp b/contrib/restricted/boost/locale/src/icu/icu_backend.hpp
index 8266856dc1f..8266856dc1f 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/icu_backend.hpp
+++ b/contrib/restricted/boost/locale/src/icu/icu_backend.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/icu_util.hpp b/contrib/restricted/boost/locale/src/icu/icu_util.hpp
index 70f4cefa36b..70f4cefa36b 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/icu_util.hpp
+++ b/contrib/restricted/boost/locale/src/icu/icu_util.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/numeric.cpp b/contrib/restricted/boost/locale/src/icu/numeric.cpp
index d81f55f7baf..e54ab1c498a 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/numeric.cpp
+++ b/contrib/restricted/boost/locale/src/icu/numeric.cpp
@@ -1,14 +1,15 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
+// Copyright (c) 2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/locale/formatting.hpp>
-#include "boost/locale/icu/all_generator.hpp"
-#include "boost/locale/icu/cdata.hpp"
-#include "boost/locale/icu/formatter.hpp"
-#include "boost/locale/icu/formatters_cache.hpp"
+#include "all_generator.hpp"
+#include "cdata.hpp"
+#include "formatter.hpp"
+#include "formatters_cache.hpp"
#include <algorithm>
#include <ios>
#include <limits>
@@ -19,41 +20,31 @@
namespace boost { namespace locale { namespace impl_icu {
namespace detail {
- template<typename T, bool integer = std::numeric_limits<T>::is_integer>
- struct icu_format_type;
+ template<typename T, typename PreferredType, typename AlternativeType>
+ struct choose_type_by_digits
+ : std::conditional<std::numeric_limits<T>::digits <= std::numeric_limits<PreferredType>::digits,
+ PreferredType,
+ AlternativeType> {};
- template<typename T>
- struct icu_format_type<T, true> {
- // ICU supports 32 and 64 bit ints, use the former as long as it fits, else the latter
- typedef typename std::conditional<std::numeric_limits<T>::digits <= 31, int32_t, int64_t>::type type;
+ template<typename T, bool integer = std::numeric_limits<T>::is_integer>
+ struct icu_format_type {
+ static_assert(sizeof(T) <= sizeof(int64_t), "Only up to 64 bit integer types are supported by ICU");
+ // ICU supports (only) int32_t and int64_t, use the former as long as it fits, else the latter
+ using large_type = typename choose_type_by_digits<T, int64_t, uint64_t>::type;
+ using type = typename choose_type_by_digits<T, int32_t, large_type>::type;
};
template<typename T>
struct icu_format_type<T, false> {
// Only float type ICU supports is double
- typedef double type;
- };
-
- // ICU does not support uint64_t values so fall back to the parent/std formatting
- // if the number is to large to fit into an int64_t
- template<typename T,
- bool BigUInt = !std::numeric_limits<T>::is_signed && std::numeric_limits<T>::is_integer
- && (sizeof(T) >= sizeof(uint64_t))>
- struct use_parent_traits {
- static bool use(T /*v*/) { return false; }
- };
- template<typename T>
- struct use_parent_traits<T, true> {
- static bool use(T v) { return v > static_cast<T>(std::numeric_limits<int64_t>::max()); }
+ using type = double;
};
template<typename ValueType>
- static bool use_parent(std::ios_base& ios, ValueType v)
+ static bool use_parent(std::ios_base& ios)
{
const uint64_t flg = ios_info::get(ios).display_flags();
if(flg == flags::posix)
return true;
- if(use_parent_traits<ValueType>::use(v))
- return true;
if(!std::numeric_limits<ValueType>::is_integer)
return false;
@@ -105,22 +96,23 @@ namespace boost { namespace locale { namespace impl_icu {
template<typename ValueType>
iter_type do_real_put(iter_type out, std::ios_base& ios, CharType fill, ValueType val) const
{
- if(detail::use_parent(ios, val))
+ if(detail::use_parent<ValueType>(ios))
return std::num_put<CharType>::do_put(out, ios, fill, val);
- const auto formatter = formatter_type::create(ios, loc_, enc_);
+ const std::unique_ptr<formatter_type> formatter = formatter_type::create(ios, loc_, enc_);
if(!formatter)
return std::num_put<CharType>::do_put(out, ios, fill, val);
+ using icu_type = typename detail::icu_format_type<ValueType>::type;
size_t code_points;
- typedef typename detail::icu_format_type<ValueType>::type icu_type;
- const string_type& str = formatter->format(static_cast<icu_type>(val), code_points);
+ const string_type str = formatter->format(static_cast<icu_type>(val), code_points);
+
std::streamsize on_left = 0, on_right = 0, points = code_points;
if(points < ios.width()) {
- std::streamsize n = ios.width() - points;
+ const std::streamsize n = ios.width() - points;
- std::ios_base::fmtflags flags = ios.flags() & std::ios_base::adjustfield;
+ const std::ios_base::fmtflags flags = ios.flags() & std::ios_base::adjustfield;
// We do not really know internal point, so we assume that it does not
// exist. So according to the standard field should be right aligned
@@ -239,10 +231,10 @@ namespace boost { namespace locale { namespace impl_icu {
do_real_get(iter_type in, iter_type end, std::ios_base& ios, std::ios_base::iostate& err, ValueType& val) const
{
stream_type* stream_ptr = dynamic_cast<stream_type*>(&ios);
- if(!stream_ptr || detail::use_parent(ios, ValueType(0)))
+ if(!stream_ptr || detail::use_parent<ValueType>(ios))
return std::num_get<CharType>::do_get(in, end, ios, err, val);
- const auto formatter = formatter_type::create(ios, loc_, enc_);
+ const std::unique_ptr<formatter_type> formatter = formatter_type::create(ios, loc_, enc_);
if(!formatter)
return std::num_get<CharType>::do_get(in, end, ios, err, val);
@@ -256,7 +248,7 @@ namespace boost { namespace locale { namespace impl_icu {
while(tmp.size() < 4096 && in != end && *in != '\n')
tmp += *in++;
- typedef typename detail::icu_format_type<ValueType>::type icu_type;
+ using icu_type = typename detail::icu_format_type<ValueType>::type;
icu_type value;
size_t parsed_chars;
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/time_zone.hpp b/contrib/restricted/boost/locale/src/icu/time_zone.hpp
index 87ab0c44165..d265b1d6e45 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/time_zone.hpp
+++ b/contrib/restricted/boost/locale/src/icu/time_zone.hpp
@@ -1,5 +1,6 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
+// Copyright (c) 2022-2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
@@ -14,9 +15,14 @@
namespace boost { namespace locale { namespace impl_icu {
- // Provides a workaround for an ICU default timezone bug and also
- // handles time_zone string correctly - if empty returns default
- // otherwise returns the instance created with time_zone
- icu::TimeZone* get_time_zone(const std::string& time_zone);
+ // Return an ICU time zone instance.
+ // If the argument is empty returns the default timezone.
+ inline icu::TimeZone* get_time_zone(const std::string& time_zone)
+ {
+ if(time_zone.empty())
+ return icu::TimeZone::createDefault();
+ else
+ return icu::TimeZone::createTimeZone(time_zone.c_str());
+ }
}}} // namespace boost::locale::impl_icu
#endif
diff --git a/contrib/restricted/boost/locale/src/boost/locale/icu/uconv.hpp b/contrib/restricted/boost/locale/src/icu/uconv.hpp
index 6563afb627b..f801f10edd7 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/icu/uconv.hpp
+++ b/contrib/restricted/boost/locale/src/icu/uconv.hpp
@@ -9,7 +9,7 @@
#define BOOST_SRC_LOCALE_ICU_UCONV_HPP
#include <boost/locale/encoding.hpp>
-#include "boost/locale/icu/icu_util.hpp"
+#include "icu_util.hpp"
#include <boost/core/exchange.hpp>
#include <memory>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/posix/all_generator.hpp b/contrib/restricted/boost/locale/src/posix/all_generator.hpp
index da4d4a82d99..da4d4a82d99 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/posix/all_generator.hpp
+++ b/contrib/restricted/boost/locale/src/posix/all_generator.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/posix/codecvt.cpp b/contrib/restricted/boost/locale/src/posix/codecvt.cpp
index d2c5acf0065..3f0a0ed43c5 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/posix/codecvt.cpp
+++ b/contrib/restricted/boost/locale/src/posix/codecvt.cpp
@@ -6,9 +6,9 @@
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/locale/encoding_errors.hpp>
-#include "boost/locale/posix/all_generator.hpp"
-#include "boost/locale/shared/iconv_codecvt.hpp"
-#include "boost/locale/util/encoding.hpp"
+#include "../shared/iconv_codecvt.hpp"
+#include "../util/encoding.hpp"
+#include "all_generator.hpp"
#include <stdexcept>
namespace boost { namespace locale { namespace impl_posix {
diff --git a/contrib/restricted/boost/locale/src/boost/locale/posix/collate.cpp b/contrib/restricted/boost/locale/src/posix/collate.cpp
index c9fb0251ff3..bd8ab36053e 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/posix/collate.cpp
+++ b/contrib/restricted/boost/locale/src/posix/collate.cpp
@@ -8,6 +8,8 @@
#if defined(__FreeBSD__)
# include <xlocale.h>
#endif
+#include "../shared/mo_hash.hpp"
+#include "all_generator.hpp"
#include <clocale>
#include <cstring>
#include <ios>
@@ -17,9 +19,6 @@
#include <vector>
#include <wchar.h>
-#include "boost/locale/posix/all_generator.hpp"
-#include "boost/locale/shared/mo_hash.hpp"
-
namespace boost { namespace locale { namespace impl_posix {
template<typename CharType>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/posix/converter.cpp b/contrib/restricted/boost/locale/src/posix/converter.cpp
index b787a562c5a..13477aa03bb 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/posix/converter.cpp
+++ b/contrib/restricted/boost/locale/src/posix/converter.cpp
@@ -7,7 +7,7 @@
#include <boost/locale/conversion.hpp>
#include <boost/locale/encoding.hpp>
#include <boost/locale/generator.hpp>
-#include "boost/locale/util/encoding.hpp"
+#include "../util/encoding.hpp"
#include <cctype>
#include <cstring>
#include <langinfo.h>
@@ -18,7 +18,7 @@
# include <xlocale.h>
#endif
-#include "boost/locale/posix/all_generator.hpp"
+#include "all_generator.hpp"
namespace boost { namespace locale { namespace impl_posix {
@@ -125,7 +125,7 @@ namespace boost { namespace locale { namespace impl_posix {
return std::locale(in, new std_converter<char>(std::move(lc)));
}
case char_facet_t::wchar_f: return std::locale(in, new std_converter<wchar_t>(std::move(lc)));
-#ifndef BOOST_LOCALE_NO_CXX20_STRING8
+#ifdef __cpp_lib_char8_t
case char_facet_t::char8_f: return std::locale(in, new utf8_converter<char8_t>(std::move(lc)));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;
diff --git a/contrib/restricted/boost/locale/src/boost/locale/posix/numeric.cpp b/contrib/restricted/boost/locale/src/posix/numeric.cpp
index a3ee2c40551..2810b821af1 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/posix/numeric.cpp
+++ b/contrib/restricted/boost/locale/src/posix/numeric.cpp
@@ -27,8 +27,8 @@
#include <vector>
#include <wctype.h>
-#include "boost/locale/posix/all_generator.hpp"
-#include "boost/locale/util/numeric.hpp"
+#include "../util/numeric.hpp"
+#include "all_generator.hpp"
namespace boost { namespace locale { namespace impl_posix {
diff --git a/contrib/restricted/boost/locale/src/boost/locale/posix/posix_backend.cpp b/contrib/restricted/boost/locale/src/posix/posix_backend.cpp
index 020d0c77e0f..98aadf211e3 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/posix/posix_backend.cpp
+++ b/contrib/restricted/boost/locale/src/posix/posix_backend.cpp
@@ -5,7 +5,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/posix/posix_backend.hpp"
+#include "posix_backend.hpp"
#include <boost/locale/gnu_gettext.hpp>
#include <boost/locale/info.hpp>
#include <boost/locale/localization_backend.hpp>
@@ -19,10 +19,10 @@
# include <xlocale.h>
#endif
-#include "boost/locale/posix/all_generator.hpp"
-#include "boost/locale/shared/message.hpp"
-#include "boost/locale/util/gregorian.hpp"
-#include "boost/locale/util/make_std_unique.hpp"
+#include "../shared/message.hpp"
+#include "../util/gregorian.hpp"
+#include "../util/make_std_unique.hpp"
+#include "all_generator.hpp"
namespace boost { namespace locale { namespace impl_posix {
diff --git a/contrib/restricted/boost/locale/src/boost/locale/posix/posix_backend.hpp b/contrib/restricted/boost/locale/src/posix/posix_backend.hpp
index 925c9580d53..925c9580d53 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/posix/posix_backend.hpp
+++ b/contrib/restricted/boost/locale/src/posix/posix_backend.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/date_time.cpp b/contrib/restricted/boost/locale/src/shared/date_time.cpp
index c418406d18c..c418406d18c 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/date_time.cpp
+++ b/contrib/restricted/boost/locale/src/shared/date_time.cpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/format.cpp b/contrib/restricted/boost/locale/src/shared/format.cpp
index 7ee809fe709..9853c7ff622 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/format.cpp
+++ b/contrib/restricted/boost/locale/src/shared/format.cpp
@@ -1,5 +1,6 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
+// Copyright (c) 2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
@@ -7,7 +8,7 @@
#include <boost/locale/format.hpp>
#include <boost/locale/generator.hpp>
#include <boost/locale/info.hpp>
-#include "boost/locale/util/numeric.hpp"
+#include "../util/numeric_conversion.hpp"
#include <algorithm>
#include <iostream>
#include <limits>
@@ -63,10 +64,9 @@ namespace boost { namespace locale { namespace detail {
{
if(key.empty())
return;
- int position;
- if(util::try_to_int(key, position) && position > 0) {
- static_assert(sizeof(unsigned) <= sizeof(decltype(d->position)), "Possible lossy conversion");
- d->position = static_cast<unsigned>(position - 1);
+ decltype(d->position) position;
+ if(util::try_to_int(key, position) && position > 0u) {
+ d->position = position - 1u;
} else if(key == "num" || key == "number") {
as::number(ios_);
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/formatting.cpp b/contrib/restricted/boost/locale/src/shared/formatting.cpp
index 457ba782e94..53f436a30e3 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/formatting.cpp
+++ b/contrib/restricted/boost/locale/src/shared/formatting.cpp
@@ -6,7 +6,7 @@
#include <boost/locale/date_time.hpp>
#include <boost/locale/formatting.hpp>
-#include "boost/locale/shared/ios_prop.hpp"
+#include "ios_prop.hpp"
namespace boost { namespace locale {
ios_info::ios_info() : flags_(0), domain_id_(0), time_zone_(time_zone::global()) {}
@@ -65,7 +65,7 @@ namespace boost { namespace locale {
{
time_zone_ = tz;
}
- std::string ios_info::time_zone() const
+ const std::string& ios_info::time_zone() const
{
return time_zone_;
}
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/generator.cpp b/contrib/restricted/boost/locale/src/shared/generator.cpp
index baf424bea8c..ddff3ba655e 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/generator.cpp
+++ b/contrib/restricted/boost/locale/src/shared/generator.cpp
@@ -1,5 +1,6 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
+// Copyright (c) 2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
@@ -93,9 +94,7 @@ namespace boost { namespace locale {
std::locale generator::generate(const std::string& id) const
{
- std::locale base = std::locale::classic();
-
- return generate(base, id);
+ return generate(std::locale::classic(), id);
}
std::locale generator::generate(const std::locale& base, const std::string& id) const
@@ -110,8 +109,8 @@ namespace boost { namespace locale {
set_all_options(*backend, id);
std::locale result = base;
- category_t facets = d->cats;
- char_facet_t chars = d->chars;
+ const category_t facets = d->cats;
+ const char_facet_t chars = d->chars;
for(category_t facet = per_character_facet_first; facet <= per_character_facet_last; ++facet) {
if(!(facets & facet))
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/iconv_codecvt.cpp b/contrib/restricted/boost/locale/src/shared/iconv_codecvt.cpp
index 2ed618a0ae4..481973079fe 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/iconv_codecvt.cpp
+++ b/contrib/restricted/boost/locale/src/shared/iconv_codecvt.cpp
@@ -12,9 +12,9 @@
#include <limits>
#include <vector>
#ifdef BOOST_LOCALE_WITH_ICONV
-# include "boost/locale/util/encoding.hpp"
-# include "boost/locale/util/iconv.hpp"
-# include "boost/locale/util/make_std_unique.hpp"
+# include "../util/encoding.hpp"
+# include "../util/iconv.hpp"
+# include "../util/make_std_unique.hpp"
#endif
namespace boost { namespace locale {
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/iconv_codecvt.hpp b/contrib/restricted/boost/locale/src/shared/iconv_codecvt.hpp
index 51ddc71b683..51ddc71b683 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/iconv_codecvt.hpp
+++ b/contrib/restricted/boost/locale/src/shared/iconv_codecvt.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/ids.cpp b/contrib/restricted/boost/locale/src/shared/ids.cpp
index 819de7f9935..2d5ef255a39 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/ids.cpp
+++ b/contrib/restricted/boost/locale/src/shared/ids.cpp
@@ -11,7 +11,7 @@
#include <boost/locale/date_time_facet.hpp>
#include <boost/locale/info.hpp>
#include <boost/locale/message.hpp>
-#include "boost/locale/util/foreach_char.hpp"
+#include "../util/foreach_char.hpp"
#include <boost/core/ignore_unused.hpp>
namespace boost { namespace locale {
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/ios_prop.hpp b/contrib/restricted/boost/locale/src/shared/ios_prop.hpp
index d8256592f79..d8256592f79 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/ios_prop.hpp
+++ b/contrib/restricted/boost/locale/src/shared/ios_prop.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/localization_backend.cpp b/contrib/restricted/boost/locale/src/shared/localization_backend.cpp
index 951cb3beb49..beace3e3afe 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/localization_backend.cpp
+++ b/contrib/restricted/boost/locale/src/shared/localization_backend.cpp
@@ -12,19 +12,19 @@
#include <vector>
#ifdef BOOST_LOCALE_WITH_ICU
-# include "boost/locale/icu/icu_backend.hpp"
+# include "../icu/icu_backend.hpp"
#endif
#ifndef BOOST_LOCALE_NO_POSIX_BACKEND
-# include "boost/locale/posix/posix_backend.hpp"
+# include "../posix/posix_backend.hpp"
#endif
#ifndef BOOST_LOCALE_NO_STD_BACKEND
-# include "boost/locale/std/std_backend.hpp"
+# include "../std/std_backend.hpp"
#endif
#ifndef BOOST_LOCALE_NO_WINAPI_BACKEND
-# include "boost/locale/win32/win_backend.hpp"
+# include "../win32/win_backend.hpp"
#endif
namespace boost { namespace locale {
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/message.cpp b/contrib/restricted/boost/locale/src/shared/message.cpp
index da8b4b934f7..70eafd22e93 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/message.cpp
+++ b/contrib/restricted/boost/locale/src/shared/message.cpp
@@ -1,6 +1,6 @@
//
// Copyright (c) 2009-2015 Artyom Beilis (Tonkikh)
-// Copyright (c) 2021-2023 Alexander Grund
+// Copyright (c) 2021-2025 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
@@ -20,13 +20,13 @@
#include <boost/locale/encoding.hpp>
#include <boost/locale/message.hpp>
-#include "boost/locale/shared/message.hpp"
-#include "boost/locale/shared/mo_hash.hpp"
-#include "boost/locale/shared/mo_lambda.hpp"
-#include "boost/locale/util/encoding.hpp"
-#include "boost/locale/util/foreach_char.hpp"
+#include "../util/encoding.hpp"
+#include "../util/foreach_char.hpp"
+#include "message.hpp"
+#include "mo_hash.hpp"
+#include "mo_lambda.hpp"
#include <boost/assert.hpp>
-#include <boost/utility/string_view.hpp>
+#include <boost/core/detail/string_view.hpp>
#include <cstdio>
#include <map>
#include <memory>
@@ -141,7 +141,7 @@ namespace boost { namespace locale { namespace gnu_gettext {
hash_offset_ = get(24);
}
- string_view find(const char* context_in, const char* key_in) const
+ core::string_view find(const char* context_in, const char* key_in) const
{
if(!has_hash())
return {};
@@ -192,20 +192,20 @@ namespace boost { namespace locale { namespace gnu_gettext {
return data_.data() + off;
}
- string_view value(unsigned id) const
+ core::string_view value(unsigned id) const
{
const uint32_t len = get(translations_offset_ + id * 8);
const uint32_t off = get(translations_offset_ + id * 8 + 4);
if(len > data_.size() || off > data_.size() - len)
throw std::runtime_error("Bad mo-file format");
- return string_view(&data_[off], len);
+ return core::string_view(&data_[off], len);
}
bool has_hash() const { return hash_size_ != 0; }
size_t size() const { return size_; }
- bool empty() { return size_ == 0; }
+ bool empty() const { return size_ == 0; }
private:
uint32_t get(unsigned offset) const
@@ -233,7 +233,7 @@ namespace boost { namespace locale { namespace gnu_gettext {
template<typename CharType>
struct mo_file_use_traits {
static constexpr bool in_use = false;
- using string_view_type = basic_string_view<CharType>;
+ using string_view_type = core::basic_string_view<CharType>;
static string_view_type use(const mo_file&, const CharType*, const CharType*)
{
throw std::logic_error("Unexpected call"); // LCOV_EXCL_LINE
@@ -243,7 +243,7 @@ namespace boost { namespace locale { namespace gnu_gettext {
template<>
struct mo_file_use_traits<char> {
static constexpr bool in_use = true;
- using string_view_type = basic_string_view<char>;
+ using string_view_type = core::basic_string_view<char>;
static string_view_type use(const mo_file& mo, const char* context, const char* key)
{
return mo.find(context, key);
@@ -254,10 +254,10 @@ namespace boost { namespace locale { namespace gnu_gettext {
template<>
struct mo_file_use_traits<char8_t> {
static constexpr bool in_use = true;
- using string_view_type = basic_string_view<char8_t>;
+ using string_view_type = core::basic_string_view<char8_t>;
static string_view_type use(const mo_file& mo, const char8_t* context, const char8_t* key)
{
- string_view res = mo.find(reinterpret_cast<const char*>(context), reinterpret_cast<const char*>(key));
+ core::string_view res = mo.find(reinterpret_cast<const char*>(context), reinterpret_cast<const char*>(key));
return {reinterpret_cast<const char8_t*>(res.data()), res.size()};
}
};
@@ -551,10 +551,10 @@ namespace boost { namespace locale { namespace gnu_gettext {
return true;
}
- static std::string extract(boost::string_view meta, const std::string& key, const boost::string_view separators)
+ static std::string extract(core::string_view meta, const std::string& key, const core::string_view separators)
{
const size_t pos = meta.find(key);
- if(pos == boost::string_view::npos)
+ if(pos == core::string_view::npos)
return "";
meta.remove_prefix(pos + key.size());
const size_t end_pos = meta.find_first_of(separators);
@@ -620,7 +620,7 @@ namespace boost { namespace locale { namespace detail {
case char_facet_t::nochar: break;
case char_facet_t::char_f: return std::locale(in, gnu_gettext::create_messages_facet<char>(minf));
case char_facet_t::wchar_f: return std::locale(in, gnu_gettext::create_messages_facet<wchar_t>(minf));
-#ifndef BOOST_LOCALE_NO_CXX20_STRING8
+#ifdef __cpp_lib_char8_t
case char_facet_t::char8_f: return std::locale(in, gnu_gettext::create_messages_facet<char8_t>(minf));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/message.hpp b/contrib/restricted/boost/locale/src/shared/message.hpp
index a68cefcab66..a68cefcab66 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/message.hpp
+++ b/contrib/restricted/boost/locale/src/shared/message.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/mo_hash.hpp b/contrib/restricted/boost/locale/src/shared/mo_hash.hpp
index 702ea7aece6..702ea7aece6 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/mo_hash.hpp
+++ b/contrib/restricted/boost/locale/src/shared/mo_hash.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/mo_lambda.cpp b/contrib/restricted/boost/locale/src/shared/mo_lambda.cpp
index 7b37ca91e84..e2a16c8c60e 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/mo_lambda.cpp
+++ b/contrib/restricted/boost/locale/src/shared/mo_lambda.cpp
@@ -5,7 +5,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/shared/mo_lambda.hpp"
+#include "mo_lambda.hpp"
#include <boost/assert.hpp>
#include <algorithm>
#include <cstdlib>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/mo_lambda.hpp b/contrib/restricted/boost/locale/src/shared/mo_lambda.hpp
index ff415175def..ff415175def 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/mo_lambda.hpp
+++ b/contrib/restricted/boost/locale/src/shared/mo_lambda.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/shared/std_collate_adapter.hpp b/contrib/restricted/boost/locale/src/shared/std_collate_adapter.hpp
index ee4ff43b8c8..ee4ff43b8c8 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/shared/std_collate_adapter.hpp
+++ b/contrib/restricted/boost/locale/src/shared/std_collate_adapter.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/std/all_generator.hpp b/contrib/restricted/boost/locale/src/std/all_generator.hpp
index 5dd020815bf..5dd020815bf 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/std/all_generator.hpp
+++ b/contrib/restricted/boost/locale/src/std/all_generator.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/std/codecvt.cpp b/contrib/restricted/boost/locale/src/std/codecvt.cpp
index 22af5d76399..58d4ff8df8e 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/std/codecvt.cpp
+++ b/contrib/restricted/boost/locale/src/std/codecvt.cpp
@@ -5,7 +5,7 @@
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/locale/util.hpp>
-#include "boost/locale/std/all_generator.hpp"
+#include "all_generator.hpp"
#include <locale>
namespace boost { namespace locale { namespace impl_std {
diff --git a/contrib/restricted/boost/locale/src/boost/locale/std/collate.cpp b/contrib/restricted/boost/locale/src/std/collate.cpp
index 48d80bcc972..d7e5e7af5ba 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/std/collate.cpp
+++ b/contrib/restricted/boost/locale/src/std/collate.cpp
@@ -5,7 +5,7 @@
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/locale/encoding.hpp>
-#include "boost/locale/std/all_generator.hpp"
+#include "all_generator.hpp"
#include <boost/assert.hpp>
#include <ios>
#include <locale>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/std/converter.cpp b/contrib/restricted/boost/locale/src/std/converter.cpp
index ce08606b06e..ec60a58dc29 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/std/converter.cpp
+++ b/contrib/restricted/boost/locale/src/std/converter.cpp
@@ -11,7 +11,7 @@
#include <stdexcept>
#include <vector>
-#include "boost/locale/std/all_generator.hpp"
+#include "all_generator.hpp"
namespace boost { namespace locale { namespace impl_std {
@@ -104,7 +104,7 @@ namespace boost { namespace locale { namespace impl_std {
else
return std::locale(in, new std_converter<char>(locale_name));
case char_facet_t::wchar_f: return std::locale(in, new std_converter<wchar_t>(locale_name));
-#ifndef BOOST_LOCALE_NO_CXX20_STRING8
+#ifdef __cpp_lib_char8_t
case char_facet_t::char8_f: return std::locale(in, new utf8_converter<char8_t>(locale_name));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;
diff --git a/contrib/restricted/boost/locale/src/boost/locale/std/numeric.cpp b/contrib/restricted/boost/locale/src/std/numeric.cpp
index fe3dc09515a..b88cbd56530 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/std/numeric.cpp
+++ b/contrib/restricted/boost/locale/src/std/numeric.cpp
@@ -14,8 +14,8 @@
#include <sstream>
#include <string>
-#include "boost/locale/std/all_generator.hpp"
-#include "boost/locale/util/numeric.hpp"
+#include "../util/numeric.hpp"
+#include "all_generator.hpp"
namespace boost { namespace locale { namespace impl_std {
/// Forwarding time_put facet
diff --git a/contrib/restricted/boost/locale/src/boost/locale/std/std_backend.cpp b/contrib/restricted/boost/locale/src/std/std_backend.cpp
index 4a134c25840..1eadfd2491c 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/std/std_backend.cpp
+++ b/contrib/restricted/boost/locale/src/std/std_backend.cpp
@@ -5,7 +5,7 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/std/std_backend.hpp"
+#include "std_backend.hpp"
#include <boost/locale/gnu_gettext.hpp>
#include <boost/locale/localization_backend.hpp>
#include <boost/locale/util.hpp>
@@ -20,15 +20,15 @@
# ifndef NOMINMAX
# define NOMINMAX
# endif
-# include "boost/locale/win32/lcid.hpp"
+# include "../win32/lcid.hpp"
# include <windows.h>
#endif
-#include "boost/locale/shared/message.hpp"
-#include "boost/locale/std/all_generator.hpp"
-#include "boost/locale/util/encoding.hpp"
-#include "boost/locale/util/gregorian.hpp"
-#include "boost/locale/util/make_std_unique.hpp"
-#include "boost/locale/util/numeric.hpp"
+#include "../shared/message.hpp"
+#include "../util/encoding.hpp"
+#include "../util/gregorian.hpp"
+#include "../util/make_std_unique.hpp"
+#include "../util/numeric_conversion.hpp"
+#include "all_generator.hpp"
namespace {
struct windows_name {
diff --git a/contrib/restricted/boost/locale/src/boost/locale/std/std_backend.hpp b/contrib/restricted/boost/locale/src/std/std_backend.hpp
index 4ce6b271e36..4ce6b271e36 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/std/std_backend.hpp
+++ b/contrib/restricted/boost/locale/src/std/std_backend.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/codecvt_converter.cpp b/contrib/restricted/boost/locale/src/util/codecvt_converter.cpp
index b1cf9df9a9b..26af5005ed5 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/codecvt_converter.cpp
+++ b/contrib/restricted/boost/locale/src/util/codecvt_converter.cpp
@@ -15,8 +15,8 @@
#include <cstddef>
#include <cstring>
-#include "boost/locale/util/encoding.hpp"
-#include "boost/locale/util/make_std_unique.hpp"
+#include "encoding.hpp"
+#include "make_std_unique.hpp"
#ifdef BOOST_MSVC
# pragma warning(disable : 4244) // loose data
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/default_locale.cpp b/contrib/restricted/boost/locale/src/util/default_locale.cpp
index 74cf7705dc8..74cf7705dc8 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/default_locale.cpp
+++ b/contrib/restricted/boost/locale/src/util/default_locale.cpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/encoding.cpp b/contrib/restricted/boost/locale/src/util/encoding.cpp
index 8a6bf183be0..8b893f1c4a0 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/encoding.cpp
+++ b/contrib/restricted/boost/locale/src/util/encoding.cpp
@@ -1,14 +1,14 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2022-2023 Alexander Grund
+// Copyright (c) 2022-2025 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/util/encoding.hpp"
-#include "boost/locale/util/string.hpp"
+#include "encoding.hpp"
+#include <boost/locale/util/string.hpp>
#if BOOST_LOCALE_USE_WIN32_API
-# include "boost/locale/util/win_codepages.hpp"
+# include "win_codepages.hpp"
# ifndef NOMINMAX
# define NOMINMAX
# endif
@@ -18,7 +18,7 @@
#include <cstring>
namespace boost { namespace locale { namespace util {
- std::string normalize_encoding(const string_view encoding)
+ std::string normalize_encoding(const core::string_view encoding)
{
std::string result;
result.reserve(encoding.length());
@@ -51,7 +51,7 @@ namespace boost { namespace locale { namespace util {
return -1;
}
- int encoding_to_windows_codepage(const string_view encoding)
+ int encoding_to_windows_codepage(const core::string_view encoding)
{
return normalized_encoding_to_windows_codepage(normalize_encoding(encoding));
}
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/encoding.hpp b/contrib/restricted/boost/locale/src/util/encoding.hpp
index 0f4c3b56e58..2f73d49a339 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/encoding.hpp
+++ b/contrib/restricted/boost/locale/src/util/encoding.hpp
@@ -1,6 +1,6 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2022-2023 Alexander Grund
+// Copyright (c) 2022-2025 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
@@ -9,7 +9,7 @@
#define BOOST_LOCALE_UTIL_ENCODING_HPP
#include <boost/locale/config.hpp>
-#include <boost/utility/string_view.hpp>
+#include <boost/core/detail/string_view.hpp>
#include <cstdint>
#include <string>
#include <type_traits>
@@ -48,7 +48,7 @@ namespace boost { namespace locale { namespace util {
#endif
/// Make encoding lowercase and remove all non-alphanumeric characters
- BOOST_LOCALE_DECL std::string normalize_encoding(string_view encoding);
+ BOOST_LOCALE_DECL std::string normalize_encoding(core::string_view encoding);
/// True if the normalized encodings are equal
inline bool are_encodings_equal(const std::string& l, const std::string& r)
{
@@ -58,10 +58,10 @@ namespace boost { namespace locale { namespace util {
BOOST_LOCALE_DECL std::vector<std::string> get_simple_encodings();
#if BOOST_LOCALE_USE_WIN32_API
- int encoding_to_windows_codepage(string_view encoding);
+ int encoding_to_windows_codepage(core::string_view encoding);
#else
// Requires WinAPI -> Dummy returning invalid
- inline int encoding_to_windows_codepage(string_view) // LCOV_EXCL_LINE
+ inline int encoding_to_windows_codepage(core::string_view) // LCOV_EXCL_LINE
{
return -1; // LCOV_EXCL_LINE
}
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/foreach_char.hpp b/contrib/restricted/boost/locale/src/util/foreach_char.hpp
index 37328e12169..1c0dc35ff01 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/foreach_char.hpp
+++ b/contrib/restricted/boost/locale/src/util/foreach_char.hpp
@@ -9,7 +9,7 @@
#include <boost/locale/config.hpp>
-#ifndef BOOST_LOCALE_NO_CXX20_STRING8
+#ifdef __cpp_lib_char8_t
# define BOOST_LOCALE_FOREACH_CHAR_I_CHAR8_T(F) F(char8_t)
# define BOOST_LOCALE_FOREACH_CHAR_I2_CHAR8_T(F) F(char8_t)
#elif defined(__cpp_char8_t)
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/gregorian.cpp b/contrib/restricted/boost/locale/src/util/gregorian.cpp
index b0bc6e8a291..3183d4ae6cb 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/gregorian.cpp
+++ b/contrib/restricted/boost/locale/src/util/gregorian.cpp
@@ -4,11 +4,11 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/util/gregorian.hpp"
+#include "gregorian.hpp"
#include <boost/locale/date_time.hpp>
#include <boost/locale/date_time_facet.hpp>
#include <boost/locale/hold_ptr.hpp>
-#include "boost/locale/util/timezone.hpp"
+#include "timezone.hpp"
#include <boost/assert.hpp>
#include <algorithm>
#include <cstdlib>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/gregorian.hpp b/contrib/restricted/boost/locale/src/util/gregorian.hpp
index e3a3a462385..e3a3a462385 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/gregorian.hpp
+++ b/contrib/restricted/boost/locale/src/util/gregorian.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/iconv.hpp b/contrib/restricted/boost/locale/src/util/iconv.hpp
index ed8157ba978..ed8157ba978 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/iconv.hpp
+++ b/contrib/restricted/boost/locale/src/util/iconv.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/info.cpp b/contrib/restricted/boost/locale/src/util/info.cpp
index 2dcbbee1784..2dcbbee1784 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/info.cpp
+++ b/contrib/restricted/boost/locale/src/util/info.cpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/locale_data.cpp b/contrib/restricted/boost/locale/src/util/locale_data.cpp
index f95d28a5803..1fded47a90b 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/locale_data.cpp
+++ b/contrib/restricted/boost/locale/src/util/locale_data.cpp
@@ -1,19 +1,39 @@
//
// Copyright (c) 2009-2011 Artyom Beilis (Tonkikh)
-// Copyright (c) 2022-2023 Alexander Grund
+// Copyright (c) 2022-2024 Alexander Grund
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/locale/util/locale_data.hpp>
-#include "boost/locale/util/encoding.hpp"
-#include "boost/locale/util/string.hpp"
+#include <boost/locale/util/string.hpp>
+#include "encoding.hpp"
#include <boost/assert.hpp>
#include <algorithm>
#include <stdexcept>
#include <string>
namespace boost { namespace locale { namespace util {
+ /// Convert uppercase ASCII to lower case, return true if converted
+ static bool make_lower(char& c)
+ {
+ if(is_upper_ascii(c)) {
+ c += 'a' - 'A';
+ return true;
+ } else
+ return false;
+ }
+
+ /// Convert lowercase ASCII to upper case, return true if converted
+ static bool make_upper(char& c)
+ {
+ if(is_lower_ascii(c)) {
+ c += 'A' - 'a';
+ return true;
+ } else
+ return false;
+ }
+
locale_data::locale_data()
{
reset();
@@ -28,6 +48,7 @@ namespace boost { namespace locale { namespace util {
void locale_data::reset()
{
language_ = "C";
+ script_.clear();
country_.clear();
encoding_ = "US-ASCII";
variant_.clear();
@@ -37,6 +58,8 @@ namespace boost { namespace locale { namespace util {
std::string locale_data::to_string() const
{
std::string result = language_;
+ if(!script_.empty())
+ (result += '_') += script_;
if(!country_.empty())
(result += '_') += country_;
if(!encoding_.empty() && !util::are_encodings_equal(encoding_, "US-ASCII"))
@@ -60,9 +83,7 @@ namespace boost { namespace locale { namespace util {
return false;
// lowercase ASCII
for(char& c : tmp) {
- if(is_upper_ascii(c))
- c += 'a' - 'A';
- else if(!is_lower_ascii(c))
+ if(!is_lower_ascii(c) && !make_lower(c))
return false;
}
if(tmp != "c" && tmp != "posix") // Keep default
@@ -71,6 +92,33 @@ namespace boost { namespace locale { namespace util {
if(end >= input.size())
return true;
else if(input[end] == '-' || input[end] == '_')
+ return parse_from_script(input.substr(end + 1));
+ else if(input[end] == '.')
+ return parse_from_encoding(input.substr(end + 1));
+ else {
+ BOOST_ASSERT_MSG(input[end] == '@', "Unexpected delimiter");
+ return parse_from_variant(input.substr(end + 1));
+ }
+ }
+
+ bool locale_data::parse_from_script(const std::string& input)
+ {
+ const auto end = input.find_first_of("-_@.");
+ std::string tmp = input.substr(0, end);
+ // Script is exactly 4 ASCII characters, otherwise it is not present
+ if(tmp.length() != 4)
+ return parse_from_country(input);
+
+ for(char& c : tmp) {
+ if(!is_lower_ascii(c) && !make_lower(c))
+ return parse_from_country(input);
+ }
+ make_upper(tmp[0]); // Capitalize first letter only
+ script_ = tmp;
+
+ if(end >= input.size())
+ return true;
+ else if(input[end] == '-' || input[end] == '_')
return parse_from_country(input.substr(end + 1));
else if(input[end] == '.')
return parse_from_encoding(input.substr(end + 1));
@@ -91,10 +139,9 @@ namespace boost { namespace locale { namespace util {
return false;
// Make uppercase
- for(char& c : tmp) {
- if(util::is_lower_ascii(c))
- c += 'A' - 'a';
- }
+ for(char& c : tmp)
+ make_upper(c);
+
// If it's ALL uppercase ASCII, assume ISO 3166 country id
if(std::find_if_not(tmp.begin(), tmp.end(), util::is_upper_ascii) != tmp.end()) {
// else handle special cases:
@@ -142,20 +189,16 @@ namespace boost { namespace locale { namespace util {
return false;
variant_ = input;
// No assumptions, just make it lowercase
- for(char& c : variant_) {
- if(util::is_upper_ascii(c))
- c += 'a' - 'A';
- }
+ for(char& c : variant_)
+ make_lower(c);
return true;
}
locale_data& locale_data::encoding(std::string new_encoding, const bool uppercase)
{
if(uppercase) {
- for(char& c : new_encoding) {
- if(util::is_lower_ascii(c))
- c += 'A' - 'a';
- }
+ for(char& c : new_encoding)
+ make_upper(c);
}
encoding_ = std::move(new_encoding);
utf8_ = util::normalize_encoding(encoding_) == "utf8";
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/make_std_unique.hpp b/contrib/restricted/boost/locale/src/util/make_std_unique.hpp
index d7492adc039..d7492adc039 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/make_std_unique.hpp
+++ b/contrib/restricted/boost/locale/src/util/make_std_unique.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/numeric.hpp b/contrib/restricted/boost/locale/src/util/numeric.hpp
index 146309e3576..e54c95c5580 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/numeric.hpp
+++ b/contrib/restricted/boost/locale/src/util/numeric.hpp
@@ -10,11 +10,8 @@
#include <boost/locale/info.hpp>
#include <boost/predef/os.h>
#include <algorithm>
-#include <cerrno>
-#include <cstdlib>
#include <ctime>
#include <ios>
-#include <limits>
#include <locale>
#include <sstream>
#include <string>
@@ -23,22 +20,6 @@
#include "timezone.hpp"
namespace boost { namespace locale { namespace util {
-
- inline bool try_to_int(const std::string& s, int& res)
- {
- if(s.empty())
- return false;
- errno = 0;
- char* end_char{};
- const auto v = std::strtol(s.c_str(), &end_char, 10);
- if(errno == ERANGE || end_char != s.c_str() + s.size())
- return false;
- if(v < std::numeric_limits<int>::min() || v > std::numeric_limits<int>::max())
- return false;
- res = v;
- return true;
- }
-
template<typename CharType>
struct formatting_size_traits {
static size_t size(const std::basic_string<CharType>& s, const std::locale& /*l*/) { return s.size(); }
@@ -175,11 +156,11 @@ namespace boost { namespace locale { namespace util {
iter_type
format_time(iter_type out, std::ios_base& ios, CharType fill, std::time_t time, const string_type& format) const
{
- std::string tz = ios_info::get(ios).time_zone();
- std::tm tm;
-#if BOOST_OS_LINUX || BOOST_OS_BSD_FREE || defined(__APPLE__)
- std::vector<char> tmp_buf(tz.c_str(), tz.c_str() + tz.size() + 1);
+ const std::string& tz = ios_info::get(ios).time_zone();
+#if BOOST_OS_BSD_FREE || defined(__APPLE__)
+ std::vector<char> tz_nonconst;
#endif
+ std::tm tm;
if(tz.empty()) {
#ifdef BOOST_WINDOWS
// Windows uses TLS
@@ -200,8 +181,13 @@ namespace boost { namespace locale { namespace util {
#if BOOST_OS_LINUX || BOOST_OS_BSD_FREE || defined(__APPLE__)
// These have extra fields to specify timezone
if(gmtoff != 0) {
+# if BOOST_OS_BSD_FREE || defined(__APPLE__)
// bsd and apple want tm_zone be non-const
- tm.tm_zone = tmp_buf.data();
+ tz_nonconst.assign(tz.begin(), tz.end());
+ tm.tm_zone = tz_nonconst.data();
+# else
+ tm.tm_zone = tz.data();
+# endif
tm.tm_gmtoff = gmtoff;
}
#endif
diff --git a/contrib/restricted/boost/locale/src/util/numeric_conversion.hpp b/contrib/restricted/boost/locale/src/util/numeric_conversion.hpp
new file mode 100644
index 00000000000..5cc15bf9e77
--- /dev/null
+++ b/contrib/restricted/boost/locale/src/util/numeric_conversion.hpp
@@ -0,0 +1,147 @@
+//
+// Copyright (c) 2024-2025 Alexander Grund
+//
+// Distributed under the Boost Software License, Version 1.0.
+// https://www.boost.org/LICENSE_1_0.txt
+
+#ifndef BOOST_LOCALE_IMPL_UTIL_NUMERIC_CONVERSIONS_HPP
+#define BOOST_LOCALE_IMPL_UTIL_NUMERIC_CONVERSIONS_HPP
+
+#include <boost/locale/config.hpp>
+#include <boost/assert.hpp>
+#include <boost/charconv/from_chars.hpp>
+#include <boost/core/detail/string_view.hpp>
+#include <algorithm>
+#include <array>
+#include <limits>
+#include <type_traits>
+#ifdef BOOST_LOCALE_WITH_ICU
+# include <unicode/fmtable.h>
+#endif
+
+namespace boost { namespace locale { namespace util {
+ namespace {
+
+ // Create lookup table where: powers_of_10[i] == 10**i
+ constexpr uint64_t pow10(unsigned exponent)
+ {
+ return (exponent == 0) ? 1 : pow10(exponent - 1) * 10u;
+ }
+ template<bool condition, std::size_t Length>
+ using array_if_true = typename std::enable_if<condition, std::array<uint64_t, Length>>::type;
+
+ template<std::size_t Length, typename... Values>
+ constexpr array_if_true<sizeof...(Values) == Length, Length> make_powers_of_10(Values... values)
+ {
+ return {{values...}};
+ }
+ template<std::size_t Length, typename... Values>
+ constexpr array_if_true<sizeof...(Values) < Length, Length> make_powers_of_10(Values... values)
+ {
+ return make_powers_of_10<Length>(values..., pow10(sizeof...(Values)));
+ }
+ constexpr auto powers_of_10 = make_powers_of_10<std::numeric_limits<uint64_t>::digits10 + 1>();
+#ifndef BOOST_NO_CXX14_CONSTEXPR
+ static_assert(powers_of_10[0] == 1u, "!");
+ static_assert(powers_of_10[1] == 10u, "!");
+ static_assert(powers_of_10[5] == 100000u, "!");
+#endif
+ } // namespace
+
+ template<typename Integer>
+ bool try_to_int(core::string_view s, Integer& value)
+ {
+ if(s.size() >= 2 && s[0] == '+') {
+ if(s[1] == '-') // "+-" is not allowed, invalid "+<number>" is detected by parser
+ return false;
+ s.remove_prefix(1);
+ }
+ const auto res = boost::charconv::from_chars(s, value);
+ return res && res.ptr == (s.data() + s.size());
+ }
+
+ /// Parse a string in scientific format to an integer.
+ /// In particular the "E notation" is used.
+ /// I.e. "\d.\d+E\d+", e.g. 5.12E3 == 5120; 5E2 == 500; 2E+1 == 20)
+ /// Additionally plain integers are recognized.
+ template<typename Integer>
+ bool try_scientific_to_int(const core::string_view s, Integer& value)
+ {
+ static_assert(std::is_integral<Integer>::value && std::is_unsigned<Integer>::value,
+ "Must be an unsigned integer");
+ if(s.size() < 3) // At least: iEj for E notation
+ return try_to_int(s, value);
+ if(s[0] == '-')
+ return false;
+ constexpr auto maxDigits = std::numeric_limits<Integer>::digits10 + 1;
+
+ const auto expPos = s.find('E', 1);
+ if(expPos == core::string_view::npos)
+ return (s[1] != '.') && try_to_int(s, value); // Shortcut: Regular integer
+ uint8_t exponent; // Negative exponent would be a fractional
+ if(BOOST_UNLIKELY(!try_to_int(s.substr(expPos + 1), exponent)))
+ return false;
+
+ core::string_view significant = s.substr(0, expPos);
+ Integer significant_value;
+ if(s[1] == '.') {
+ const auto numSignificantDigits = significant.size() - 1u; // Exclude dot
+ const auto numDigits = exponent + 1u; // E0 -> 1 digit
+ if(BOOST_UNLIKELY(numDigits < numSignificantDigits))
+ return false; // Fractional
+ else if(BOOST_UNLIKELY(numDigits > maxDigits))
+ return false; // Too large
+ // Factor to get from the fractional number to an integer
+ BOOST_ASSERT(numSignificantDigits - 1u < powers_of_10.size());
+ const auto factor = static_cast<Integer>(powers_of_10[numSignificantDigits - 1]);
+ exponent = static_cast<uint8_t>(numDigits - numSignificantDigits);
+
+ const unsigned firstDigit = significant[0] - '0';
+ if(firstDigit > 9u)
+ return false; // Not a digit
+ if(numSignificantDigits == maxDigits) {
+ const auto maxFirstDigit = std::numeric_limits<Integer>::max() / powers_of_10[maxDigits - 1];
+ if(firstDigit > maxFirstDigit)
+ return false;
+ }
+ significant.remove_prefix(2);
+ if(BOOST_UNLIKELY(!try_to_int(significant, significant_value)))
+ return false;
+ // firstDigit * factor + significant_value <= max
+ if(static_cast<Integer>(firstDigit) > (std::numeric_limits<Integer>::max() - significant_value) / factor)
+ return false;
+ significant_value += static_cast<Integer>(firstDigit * factor);
+ } else if(BOOST_UNLIKELY(significant.size() + exponent > maxDigits))
+ return false;
+ else if(BOOST_UNLIKELY(!try_to_int(significant, significant_value)))
+ return false;
+ // Add zeros if necessary
+ if(exponent > 0u) {
+ BOOST_ASSERT(exponent < powers_of_10.size());
+ const auto factor = static_cast<Integer>(powers_of_10[exponent]);
+ if(significant_value > std::numeric_limits<Integer>::max() / factor)
+ return false;
+ value = significant_value * factor;
+ } else
+ value = significant_value;
+ return true;
+ }
+
+#ifdef BOOST_LOCALE_WITH_ICU
+ template<typename Integer>
+ bool try_parse_icu(icu::Formattable& fmt, Integer& value)
+ {
+ if(!fmt.isNumeric())
+ return false;
+ // Get value as a decimal number and parse that
+ UErrorCode err = U_ZERO_ERROR;
+ const auto decimals = fmt.getDecimalNumber(err);
+ if(U_FAILURE(err))
+ return false; // Memory error LCOV_EXCL_LINE
+ const core::string_view s(decimals.data(), decimals.length());
+ return try_scientific_to_int(s, value);
+ }
+#endif
+}}} // namespace boost::locale::util
+
+#endif
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/timezone.hpp b/contrib/restricted/boost/locale/src/util/timezone.hpp
index 617f40a9772..617f40a9772 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/timezone.hpp
+++ b/contrib/restricted/boost/locale/src/util/timezone.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/util/win_codepages.hpp b/contrib/restricted/boost/locale/src/util/win_codepages.hpp
index 4c3df668b5d..4c3df668b5d 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/util/win_codepages.hpp
+++ b/contrib/restricted/boost/locale/src/util/win_codepages.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/win32/all_generator.hpp b/contrib/restricted/boost/locale/src/win32/all_generator.hpp
index 3cf7da94fb0..3cf7da94fb0 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/win32/all_generator.hpp
+++ b/contrib/restricted/boost/locale/src/win32/all_generator.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/win32/api.hpp b/contrib/restricted/boost/locale/src/win32/api.hpp
index 33791ef9689..e9b95b7ff5a 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/win32/api.hpp
+++ b/contrib/restricted/boost/locale/src/win32/api.hpp
@@ -15,7 +15,7 @@
#include <string>
#include <vector>
-#include "boost/locale/win32/lcid.hpp"
+#include "lcid.hpp"
#ifndef NOMINMAX
# define NOMINMAX
diff --git a/contrib/restricted/boost/locale/src/boost/locale/win32/collate.cpp b/contrib/restricted/boost/locale/src/win32/collate.cpp
index 16fe38d1f8d..dcdb2c99ea1 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/win32/collate.cpp
+++ b/contrib/restricted/boost/locale/src/win32/collate.cpp
@@ -6,9 +6,9 @@
#include <boost/locale/encoding.hpp>
#include <boost/locale/generator.hpp>
-#include "boost/locale/shared/mo_hash.hpp"
-#include "boost/locale/shared/std_collate_adapter.hpp"
-#include "boost/locale/win32/api.hpp"
+#include "../shared/mo_hash.hpp"
+#include "../shared/std_collate_adapter.hpp"
+#include "api.hpp"
#include <ios>
#include <locale>
#include <string>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/win32/converter.cpp b/contrib/restricted/boost/locale/src/win32/converter.cpp
index ed29aedc69d..fe168df79d0 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/win32/converter.cpp
+++ b/contrib/restricted/boost/locale/src/win32/converter.cpp
@@ -7,8 +7,8 @@
#include <boost/locale/conversion.hpp>
#include <boost/locale/encoding.hpp>
#include <boost/locale/generator.hpp>
-#include "boost/locale/win32/all_generator.hpp"
-#include "boost/locale/win32/api.hpp"
+#include "all_generator.hpp"
+#include "api.hpp"
#include <cstring>
#include <locale>
#include <stdexcept>
@@ -62,7 +62,7 @@ namespace boost { namespace locale { namespace impl_win {
case char_facet_t::nochar: break;
case char_facet_t::char_f: return std::locale(in, new utf8_converter<char>(lc));
case char_facet_t::wchar_f: return std::locale(in, new wide_converter(lc));
-#ifndef BOOST_LOCALE_NO_CXX20_STRING8
+#ifdef __cpp_lib_char8_t
case char_facet_t::char8_f: return std::locale(in, new utf8_converter<char8_t>(lc));
#elif defined(__cpp_char8_t)
case char_facet_t::char8_f: break;
diff --git a/contrib/restricted/boost/locale/src/boost/locale/win32/lcid.cpp b/contrib/restricted/boost/locale/src/win32/lcid.cpp
index 1435455775c..e1b998d66b3 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/win32/lcid.cpp
+++ b/contrib/restricted/boost/locale/src/win32/lcid.cpp
@@ -8,7 +8,7 @@
# define NOMINMAX
#endif
-#include "boost/locale/win32/lcid.hpp"
+#include "lcid.hpp"
#include <boost/locale/util/locale_data.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/win32/lcid.hpp b/contrib/restricted/boost/locale/src/win32/lcid.hpp
index 19a801d4a87..19a801d4a87 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/win32/lcid.hpp
+++ b/contrib/restricted/boost/locale/src/win32/lcid.hpp
diff --git a/contrib/restricted/boost/locale/src/boost/locale/win32/numeric.cpp b/contrib/restricted/boost/locale/src/win32/numeric.cpp
index 556de79a851..3286424e909 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/win32/numeric.cpp
+++ b/contrib/restricted/boost/locale/src/win32/numeric.cpp
@@ -4,12 +4,12 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/util/numeric.hpp"
+#include "../util/numeric.hpp"
#include <boost/locale/encoding.hpp>
#include <boost/locale/formatting.hpp>
#include <boost/locale/generator.hpp>
-#include "boost/locale/win32/all_generator.hpp"
-#include "boost/locale/win32/api.hpp"
+#include "all_generator.hpp"
+#include "api.hpp"
#include <algorithm>
#include <cctype>
#include <cstdlib>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/win32/win_backend.cpp b/contrib/restricted/boost/locale/src/win32/win_backend.cpp
index 48155d6c23c..2ce4d460892 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/win32/win_backend.cpp
+++ b/contrib/restricted/boost/locale/src/win32/win_backend.cpp
@@ -5,17 +5,17 @@
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
-#include "boost/locale/win32/win_backend.hpp"
+#include "win_backend.hpp"
#include <boost/locale/gnu_gettext.hpp>
#include <boost/locale/info.hpp>
#include <boost/locale/localization_backend.hpp>
#include <boost/locale/util.hpp>
#include <boost/locale/util/locale_data.hpp>
-#include "boost/locale/shared/message.hpp"
-#include "boost/locale/util/gregorian.hpp"
-#include "boost/locale/util/make_std_unique.hpp"
-#include "boost/locale/win32/all_generator.hpp"
-#include "boost/locale/win32/api.hpp"
+#include "../shared/message.hpp"
+#include "../util/gregorian.hpp"
+#include "../util/make_std_unique.hpp"
+#include "all_generator.hpp"
+#include "api.hpp"
#include <algorithm>
#include <iterator>
#include <vector>
diff --git a/contrib/restricted/boost/locale/src/boost/locale/win32/win_backend.hpp b/contrib/restricted/boost/locale/src/win32/win_backend.hpp
index 8980535e742..8980535e742 100644
--- a/contrib/restricted/boost/locale/src/boost/locale/win32/win_backend.hpp
+++ b/contrib/restricted/boost/locale/src/win32/win_backend.hpp