aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Sadie Powell2024-08-03 12:32:14 +0100
committerGravatar Sadie Powell2024-08-03 12:32:14 +0100
commit3479a556d02fdce721aa837a494a6af25c5688ec (patch)
treeef3b18337f177792cb5cf37f247635892bed004f
parentOnly allow the IRCv3 WebSocket subprotocols on client connections. (diff)
Update the vendored libraries.
-rw-r--r--vendor/README.md2
-rw-r--r--vendor/fmt/base.h78
-rw-r--r--vendor/fmt/format-inl.h40
-rw-r--r--vendor/fmt/format.h36
-rw-r--r--vendor/fmt/ranges.h2
5 files changed, 103 insertions, 55 deletions
diff --git a/vendor/README.md b/vendor/README.md
index d50e7f3e5..1447f3b80 100644
--- a/vendor/README.md
+++ b/vendor/README.md
@@ -18,7 +18,7 @@ This directory contains vendored dependencies that are shipped with InspIRCd to
**License** — MIT License
-**Version** — 11.0.1
+**Version** — 11.0.2
**Website** — [https://github.com/fmtlib/fmt/](https://github.com/fmtlib/fmt/)
diff --git a/vendor/fmt/base.h b/vendor/fmt/base.h
index f440cffd2..627649425 100644
--- a/vendor/fmt/base.h
+++ b/vendor/fmt/base.h
@@ -23,7 +23,7 @@
#endif
// The fmt library version in the form major * 10000 + minor * 100 + patch.
-#define FMT_VERSION 110001
+#define FMT_VERSION 110002
// Detect compiler versions.
#if defined(__clang__) && !defined(__ibmxl__)
@@ -441,7 +441,8 @@ struct is_std_string_like : std::false_type {};
template <typename T>
struct is_std_string_like<T, void_t<decltype(std::declval<T>().find_first_of(
typename T::value_type(), 0))>>
- : std::true_type {};
+ : std::is_convertible<decltype(std::declval<T>().data()),
+ const typename T::value_type*> {};
// Returns true iff the literal encoding is UTF-8.
constexpr auto is_utf8_enabled() -> bool {
@@ -466,6 +467,7 @@ template <typename Char> FMT_CONSTEXPR auto length(const Char* s) -> size_t {
template <typename Char>
FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n)
-> int {
+ if (!is_constant_evaluated() && sizeof(Char) == 1) return memcmp(s1, s2, n);
for (; n != 0; ++s1, ++s2, --n) {
if (*s1 < *s2) return -1;
if (*s1 > *s2) return 1;
@@ -473,14 +475,22 @@ FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, std::size_t n)
return 0;
}
+namespace adl {
+using namespace std;
+
+template <typename Container>
+auto invoke_back_inserter()
+ -> decltype(back_inserter(std::declval<Container&>()));
+} // namespace adl
+
template <typename It, typename Enable = std::true_type>
struct is_back_insert_iterator : std::false_type {};
+
template <typename It>
struct is_back_insert_iterator<
- It,
- bool_constant<std::is_same<
- decltype(back_inserter(std::declval<typename It::container_type&>())),
- It>::value>> : std::true_type {};
+ It, bool_constant<std::is_same<
+ decltype(adl::invoke_back_inserter<typename It::container_type>()),
+ It>::value>> : std::true_type {};
// Extracts a reference to the container from *insert_iterator.
template <typename OutputIt>
@@ -611,11 +621,12 @@ namespace detail {
// to it, deducing Char. Explicitly convertible types such as the ones returned
// from FMT_STRING are intentionally excluded.
template <typename Char, FMT_ENABLE_IF(is_char<Char>::value)>
-auto to_string_view(const Char* s) -> basic_string_view<Char> {
+constexpr auto to_string_view(const Char* s) -> basic_string_view<Char> {
return s;
}
template <typename T, FMT_ENABLE_IF(is_std_string_like<T>::value)>
-auto to_string_view(const T& s) -> basic_string_view<typename T::value_type> {
+constexpr auto to_string_view(const T& s)
+ -> basic_string_view<typename T::value_type> {
return s;
}
template <typename Char>
@@ -919,12 +930,9 @@ template <typename T> class buffer {
try_reserve(size_ + count);
auto free_cap = capacity_ - size_;
if (free_cap < count) count = free_cap;
- if (std::is_same<T, U>::value) {
- memcpy(ptr_ + size_, begin, count * sizeof(T));
- } else {
- T* out = ptr_ + size_;
- for (size_t i = 0; i < count; ++i) out[i] = begin[i];
- }
+ // A loop is faster than memcpy on small sizes.
+ T* out = ptr_ + size_;
+ for (size_t i = 0; i < count; ++i) out[i] = begin[i];
size_ += count;
begin += count;
}
@@ -1157,6 +1165,7 @@ template <typename T> class basic_appender {
using difference_type = ptrdiff_t;
using pointer = T*;
using reference = T&;
+ using container_type = detail::buffer<T>;
FMT_UNCHECKED_ITERATOR(basic_appender);
FMT_CONSTEXPR basic_appender(detail::buffer<T>& buf) : buffer_(&buf) {}
@@ -1173,6 +1182,8 @@ template <typename T> class basic_appender {
using appender = basic_appender<char>;
namespace detail {
+template <typename T>
+struct is_back_insert_iterator<basic_appender<T>> : std::true_type {};
template <typename T, typename Enable = void>
struct locking : std::true_type {};
@@ -1189,12 +1200,6 @@ FMT_CONSTEXPR inline auto is_locking() -> bool {
}
// An optimized version of std::copy with the output value type (T).
-template <typename T, typename InputIt>
-auto copy(InputIt begin, InputIt end, appender out) -> appender {
- get_container(out).append(begin, end);
- return out;
-}
-
template <typename T, typename InputIt, typename OutputIt,
FMT_ENABLE_IF(is_back_insert_iterator<OutputIt>::value)>
auto copy(InputIt begin, InputIt end, OutputIt out) -> OutputIt {
@@ -1209,14 +1214,6 @@ FMT_CONSTEXPR auto copy(InputIt begin, InputIt end, OutputIt out) -> OutputIt {
return out;
}
-template <typename T>
-FMT_CONSTEXPR auto copy(const T* begin, const T* end, T* out) -> T* {
- if (is_constant_evaluated()) return copy<T, const T*, T*>(begin, end, out);
- auto size = to_unsigned(end - begin);
- if (size > 0) memcpy(out, begin, size * sizeof(T));
- return out + size;
-}
-
template <typename T, typename V, typename OutputIt>
FMT_CONSTEXPR auto copy(basic_string_view<V> s, OutputIt out) -> OutputIt {
return copy<T>(s.begin(), s.end(), out);
@@ -1238,12 +1235,25 @@ constexpr auto has_const_formatter() -> bool {
return has_const_formatter_impl<Context>(static_cast<T*>(nullptr));
}
+template <typename It, typename Enable = std::true_type>
+struct is_buffer_appender : std::false_type {};
+template <typename It>
+struct is_buffer_appender<
+ It, bool_constant<
+ is_back_insert_iterator<It>::value &&
+ std::is_base_of<buffer<typename It::container_type::value_type>,
+ typename It::container_type>::value>>
+ : std::true_type {};
+
// Maps an output iterator to a buffer.
-template <typename T, typename OutputIt>
+template <typename T, typename OutputIt,
+ FMT_ENABLE_IF(!is_buffer_appender<OutputIt>::value)>
auto get_buffer(OutputIt out) -> iterator_buffer<OutputIt, T> {
return iterator_buffer<OutputIt, T>(out);
}
-template <typename T> auto get_buffer(basic_appender<T> out) -> buffer<T>& {
+template <typename T, typename OutputIt,
+ FMT_ENABLE_IF(is_buffer_appender<OutputIt>::value)>
+auto get_buffer(OutputIt out) -> buffer<T>& {
return get_container(out);
}
@@ -1475,6 +1485,12 @@ template <typename Context> struct arg_mapper {
FMT_MAP_API auto map(void* val) -> const void* { return val; }
FMT_MAP_API auto map(const void* val) -> const void* { return val; }
+ FMT_MAP_API auto map(volatile void* val) -> const void* {
+ return const_cast<const void*>(val);
+ }
+ FMT_MAP_API auto map(const volatile void* val) -> const void* {
+ return const_cast<const void*>(val);
+ }
FMT_MAP_API auto map(std::nullptr_t val) -> const void* { return val; }
// Use SFINAE instead of a const T* parameter to avoid a conflict with the
@@ -1760,7 +1776,7 @@ template <typename Context> class basic_format_arg {
* `vis(value)` will be called with the value of type `double`.
*/
template <typename Visitor>
- FMT_CONSTEXPR auto visit(Visitor&& vis) const -> decltype(vis(0)) {
+ FMT_CONSTEXPR FMT_INLINE auto visit(Visitor&& vis) const -> decltype(vis(0)) {
switch (type_) {
case detail::type::none_type:
break;
diff --git a/vendor/fmt/format-inl.h b/vendor/fmt/format-inl.h
index 8d07cc672..a887483b6 100644
--- a/vendor/fmt/format-inl.h
+++ b/vendor/fmt/format-inl.h
@@ -1443,12 +1443,26 @@ template <typename T> struct span {
size_t size;
};
-#ifdef _WIN32
-inline void flockfile(FILE* f) { _lock_file(f); }
-inline void funlockfile(FILE* f) { _unlock_file(f); }
-inline int getc_unlocked(FILE* f) { return _fgetc_nolock(f); }
+template <typename F> auto flockfile(F* f) -> decltype(_lock_file(f)) {
+ _lock_file(f);
+}
+template <typename F> auto funlockfile(F* f) -> decltype(_unlock_file(f)) {
+ _unlock_file(f);
+}
+
+#ifndef getc_unlocked
+template <typename F> auto getc_unlocked(F* f) -> decltype(_fgetc_nolock(f)) {
+ return _fgetc_nolock(f);
+}
#endif
+template <typename F = FILE, typename Enable = void>
+struct has_flockfile : std::false_type {};
+
+template <typename F>
+struct has_flockfile<F, void_t<decltype(flockfile(&std::declval<F&>()))>>
+ : std::true_type {};
+
// A FILE wrapper. F is FILE defined as a template parameter to make system API
// detection work.
template <typename F> class file_base {
@@ -1619,7 +1633,15 @@ inline auto get_file(FILE* f, ...) -> fallback_file<FILE> { return f; }
using file_ref = decltype(get_file(static_cast<FILE*>(nullptr), 0));
+template <typename F = FILE, typename Enable = void>
class file_print_buffer : public buffer<char> {
+ public:
+ explicit file_print_buffer(F*) : buffer(nullptr, size_t()) {}
+};
+
+template <typename F>
+class file_print_buffer<F, enable_if_t<has_flockfile<F>::value>>
+ : public buffer<char> {
private:
file_ref file_;
@@ -1634,7 +1656,7 @@ class file_print_buffer : public buffer<char> {
}
public:
- explicit file_print_buffer(FILE* f) : buffer(grow, size_t()), file_(f) {
+ explicit file_print_buffer(F* f) : buffer(grow, size_t()), file_(f) {
flockfile(f);
file_.init_buffer();
auto buf = file_.get_write_buffer();
@@ -1643,7 +1665,8 @@ class file_print_buffer : public buffer<char> {
~file_print_buffer() {
file_.advance_write_buffer(size());
bool flush = file_.needs_flush();
- funlockfile(file_);
+ F* f = file_; // Make funlockfile depend on the template parameter F
+ funlockfile(f); // for the system API detection to work.
if (flush) fflush(file_);
}
};
@@ -1692,8 +1715,9 @@ FMT_FUNC void vprint_buffered(std::FILE* f, string_view fmt, format_args args) {
}
FMT_FUNC void vprint(std::FILE* f, string_view fmt, format_args args) {
- if (!detail::file_ref(f).is_buffered()) return vprint_buffered(f, fmt, args);
- auto&& buffer = detail::file_print_buffer(f);
+ if (!detail::file_ref(f).is_buffered() || !detail::has_flockfile<>())
+ return vprint_buffered(f, fmt, args);
+ auto&& buffer = detail::file_print_buffer<>(f);
return detail::vformat_to(buffer, fmt, args);
}
diff --git a/vendor/fmt/format.h b/vendor/fmt/format.h
index 7c2a19b40..67f0ab739 100644
--- a/vendor/fmt/format.h
+++ b/vendor/fmt/format.h
@@ -106,6 +106,13 @@
# define FMT_NOINLINE
#endif
+namespace std {
+template <> struct iterator_traits<fmt::appender> {
+ using iterator_category = output_iterator_tag;
+ using value_type = char;
+};
+} // namespace std
+
#ifndef FMT_THROW
# if FMT_EXCEPTIONS
# if FMT_MSC_VERSION || defined(__NVCC__)
@@ -546,6 +553,7 @@ constexpr auto to_pointer(OutputIt, size_t) -> T* {
template <typename T> auto to_pointer(basic_appender<T> it, size_t n) -> T* {
buffer<T>& buf = get_container(it);
auto size = buf.size();
+ buf.try_reserve(size + n);
if (buf.capacity() < size + n) return nullptr;
buf.try_resize(size + n);
return buf.data() + size;
@@ -1119,7 +1127,7 @@ template <typename Char, typename Sign> constexpr auto sign(Sign s) -> Char {
#if !FMT_GCC_VERSION || FMT_GCC_VERSION >= 604
static_assert(std::is_same<Sign, sign_t>::value, "");
#endif
- return static_cast<Char>("\0-+ "[s]);
+ return static_cast<char>(((' ' << 24) | ('+' << 16) | ('-' << 8)) >> (s * 8));
}
template <typename T> FMT_CONSTEXPR auto count_digits_fallback(T n) -> int {
@@ -2317,15 +2325,13 @@ FMT_CONSTEXPR auto write(OutputIt out, T value) -> OutputIt {
if (negative) abs_value = ~abs_value + 1;
int num_digits = count_digits(abs_value);
auto size = (negative ? 1 : 0) + static_cast<size_t>(num_digits);
- auto it = reserve(out, size);
- if (auto ptr = to_pointer<Char>(it, size)) {
+ if (auto ptr = to_pointer<Char>(out, size)) {
if (negative) *ptr++ = static_cast<Char>('-');
format_decimal<Char>(ptr, abs_value, num_digits);
return out;
}
- if (negative) *it++ = static_cast<Char>('-');
- it = format_decimal<Char>(it, abs_value, num_digits).end;
- return base_iterator(out, it);
+ if (negative) *out++ = static_cast<Char>('-');
+ return format_decimal<Char>(out, abs_value, num_digits).end;
}
// DEPRECATED!
@@ -3629,9 +3635,7 @@ auto write(OutputIt out, monostate, format_specs = {}, locale_ref = {})
template <typename Char, typename OutputIt>
FMT_CONSTEXPR auto write(OutputIt out, basic_string_view<Char> value)
-> OutputIt {
- auto it = reserve(out, value.size());
- it = copy_noinline<Char>(value.begin(), value.end(), it);
- return base_iterator(out, it);
+ return copy_noinline<Char>(value.begin(), value.end(), out);
}
template <typename Char, typename OutputIt, typename T,
@@ -3972,15 +3976,19 @@ struct formatter<T, Char, enable_if_t<detail::has_format_as<T>::value>>
: formatter<detail::format_as_t<T>, Char> {
template <typename FormatContext>
auto format(const T& value, FormatContext& ctx) const -> decltype(ctx.out()) {
- using base = formatter<detail::format_as_t<T>, Char>;
auto&& val = format_as(value); // Make an lvalue reference for format.
- return base::format(val, ctx);
+ return formatter<detail::format_as_t<T>, Char>::format(val, ctx);
}
};
-#define FMT_FORMAT_AS(Type, Base) \
- template <typename Char> \
- struct formatter<Type, Char> : formatter<Base, Char> {}
+#define FMT_FORMAT_AS(Type, Base) \
+ template <typename Char> \
+ struct formatter<Type, Char> : formatter<Base, Char> { \
+ template <typename FormatContext> \
+ auto format(Type value, FormatContext& ctx) const -> decltype(ctx.out()) { \
+ return formatter<Base, Char>::format(value, ctx); \
+ } \
+ }
FMT_FORMAT_AS(signed char, int);
FMT_FORMAT_AS(unsigned char, unsigned);
diff --git a/vendor/fmt/ranges.h b/vendor/fmt/ranges.h
index f387903cf..0d3dfbd8d 100644
--- a/vendor/fmt/ranges.h
+++ b/vendor/fmt/ranges.h
@@ -490,7 +490,7 @@ struct range_formatter<
auto out = ctx.out();
auto it = detail::range_begin(range);
auto end = detail::range_end(range);
- if (is_debug) return write_debug_string(out, it, end);
+ if (is_debug) return write_debug_string(out, std::move(it), end);
out = detail::copy<Char>(opening_bracket_, out);
int i = 0;