0001-godot-changes.patch 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. diff --git a/thirdparty/grisu2/grisu2.h b/thirdparty/grisu2/grisu2.h
  2. index 19886cce47f..dbc09755fad 100644
  3. --- a/thirdparty/grisu2/grisu2.h
  4. +++ b/thirdparty/grisu2/grisu2.h
  5. @@ -1,15 +1,12 @@
  6. -#ifndef SIMDJSON_SRC_TO_CHARS_CPP
  7. -#define SIMDJSON_SRC_TO_CHARS_CPP
  8. -
  9. -#include <base.h>
  10. +#pragma once
  11. #include <cstring>
  12. #include <cstdint>
  13. #include <array>
  14. #include <cmath>
  15. -namespace simdjson {
  16. -namespace internal {
  17. +namespace grisu2 {
  18. /*!
  19. implements the Grisu2 algorithm for binary to decimal floating-point
  20. conversion.
  21. @@ -26,7 +23,6 @@ PLDI 2010 [2] Burger, Dybvig, "Printing Floating-Point Numbers Quickly and
  22. Accurately", Proceedings of the ACM SIGPLAN 1996 Conference on Programming
  23. Language Design and Implementation, PLDI 1996
  24. */
  25. -namespace dtoa_impl {
  26. template <typename Target, typename Source>
  27. Target reinterpret_bits(const Source source) {
  28. @@ -718,7 +714,7 @@ v = buf * 10^decimal_exponent
  29. len is the length of the buffer (number of decimal digits)
  30. The buffer must be large enough, i.e. >= max_digits10.
  31. */
  32. -inline void grisu2(char *buf, int &len, int &decimal_exponent, diyfp m_minus,
  33. +inline void grisu2_core(char *buf, int &len, int &decimal_exponent, diyfp m_minus,
  34. diyfp v, diyfp m_plus) {
  35. // --------(-----------------------+-----------------------)-------- (A)
  36. @@ -775,7 +771,7 @@ len is the length of the buffer (number of decimal digits)
  37. The buffer must be large enough, i.e. >= max_digits10.
  38. */
  39. template <typename FloatType>
  40. -void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value) {
  41. +void grisu2_wrap(char *buf, int &len, int &decimal_exponent, FloatType value) {
  42. static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
  43. "internal error: not enough precision");
  44. @@ -804,7 +800,7 @@ void grisu2(char *buf, int &len, int &decimal_exponent, FloatType value) {
  45. const boundaries w = compute_boundaries(value);
  46. #endif
  47. - grisu2(buf, len, decimal_exponent, w.minus, w.w, w.plus);
  48. + grisu2_core(buf, len, decimal_exponent, w.minus, w.w, w.plus);
  49. }
  50. /*!
  51. @@ -864,10 +860,7 @@ inline char *format_buffer(char *buf, int len, int decimal_exponent,
  52. // len <= max_exp + 2
  53. std::memset(buf + k, '0', static_cast<size_t>(n) - static_cast<size_t>(k));
  54. - // Make it look like a floating-point number (#362, #378)
  55. - buf[n + 0] = '.';
  56. - buf[n + 1] = '0';
  57. - return buf + (static_cast<size_t>(n)) + 2;
  58. + return buf + (static_cast<size_t>(n));
  59. }
  60. if (0 < n && n <= max_exp) {
  61. @@ -909,8 +902,6 @@ inline char *format_buffer(char *buf, int len, int decimal_exponent,
  62. return append_exponent(buf, n - 1);
  63. }
  64. -} // namespace dtoa_impl
  65. -
  66. /*!
  67. The format of the resulting decimal representation is similar to printf's %g
  68. format. Returns an iterator pointing past-the-end of the decimal representation.
  69. @@ -918,19 +909,15 @@ format. Returns an iterator pointing past-the-end of the decimal representation.
  70. @note The buffer must be large enough.
  71. @note The result is NOT null-terminated.
  72. */
  73. -char *to_chars(char *first, const char *last, double value) {
  74. - static_cast<void>(last); // maybe unused - fix warning
  75. +template <typename FloatType>
  76. +char *to_chars(char *first, FloatType value) {
  77. bool negative = std::signbit(value);
  78. if (negative) {
  79. value = -value;
  80. *first++ = '-';
  81. }
  82. -
  83. if (value == 0) // +-0
  84. {
  85. - *first++ = '0';
  86. - // Make it look like a floating-point number (#362, #378)
  87. - *first++ = '.';
  88. *first++ = '0';
  89. return first;
  90. }
  91. @@ -940,15 +927,13 @@ char *to_chars(char *first, const char *last, double value) {
  92. // len is the length of the buffer, i.e. the number of decimal digits.
  93. int len = 0;
  94. int decimal_exponent = 0;
  95. - dtoa_impl::grisu2(first, len, decimal_exponent, value);
  96. + grisu2_wrap(first, len, decimal_exponent, value);
  97. // Format the buffer like printf("%.*g", prec, value)
  98. constexpr int kMinExp = -4;
  99. constexpr int kMaxExp = std::numeric_limits<double>::digits10;
  100. - return dtoa_impl::format_buffer(first, len, decimal_exponent, kMinExp,
  101. - kMaxExp);
  102. + return format_buffer(first, len, decimal_exponent, kMinExp, kMaxExp);
  103. }
  104. -} // namespace internal
  105. -} // namespace simdjson
  106. +} // namespace grisu2
  107. -#endif // SIMDJSON_SRC_TO_CHARS_CPP