mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-06-15 08:26:08 +08:00
Compare commits
15 Commits
4c1d4a45fa
...
b47a1a5c19
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b47a1a5c19 | ||
|
|
8234a89623 | ||
|
|
0dce102cb4 | ||
|
|
30868f8734 | ||
|
|
8e6edc8ad2 | ||
|
|
82882b237d | ||
|
|
937198691a | ||
|
|
0352ba3fef | ||
|
|
6ae691372f | ||
|
|
8fe7a9405b | ||
|
|
e8ec8e8f34 | ||
|
|
c05156ff60 | ||
|
|
23e245f2b3 | ||
|
|
e0b53eaf63 | ||
|
|
94b28d9321 |
8
.github/dependabot.yml
vendored
8
.github/dependabot.yml
vendored
@ -3,6 +3,14 @@
|
|||||||
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
|
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file#package-ecosystem
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
|
- package-ecosystem: bazel
|
||||||
|
directory: /
|
||||||
|
groups:
|
||||||
|
bazel:
|
||||||
|
patterns:
|
||||||
|
- "*" # Group all Bzlmod updates into a single larger pull request
|
||||||
|
schedule:
|
||||||
|
interval: weekly
|
||||||
- package-ecosystem: github-actions
|
- package-ecosystem: github-actions
|
||||||
directory: /
|
directory: /
|
||||||
groups:
|
groups:
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
cmake_minimum_required(VERSION 3.14)
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
|
||||||
|
|
||||||
project(fast_float VERSION 8.2.6 LANGUAGES CXX)
|
project(fast_float VERSION 8.2.9 LANGUAGES CXX)
|
||||||
set(FASTFLOAT_CXX_STANDARD 11 CACHE STRING "the C++ standard to use for fastfloat")
|
set(FASTFLOAT_CXX_STANDARD 11 CACHE STRING "the C++ standard to use for fastfloat")
|
||||||
set(CMAKE_CXX_STANDARD ${FASTFLOAT_CXX_STANDARD})
|
set(CMAKE_CXX_STANDARD ${FASTFLOAT_CXX_STANDARD})
|
||||||
option(FASTFLOAT_TEST "Enable tests" OFF)
|
option(FASTFLOAT_TEST "Enable tests" OFF)
|
||||||
|
|||||||
@ -531,7 +531,7 @@ sufficiently recent version of CMake (3.11 or better at least):
|
|||||||
FetchContent_Declare(
|
FetchContent_Declare(
|
||||||
fast_float
|
fast_float
|
||||||
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
|
GIT_REPOSITORY https://github.com/fastfloat/fast_float.git
|
||||||
GIT_TAG tags/v8.2.6
|
GIT_TAG tags/v8.2.9
|
||||||
GIT_SHALLOW TRUE)
|
GIT_SHALLOW TRUE)
|
||||||
|
|
||||||
FetchContent_MakeAvailable(fast_float)
|
FetchContent_MakeAvailable(fast_float)
|
||||||
@ -547,7 +547,7 @@ You may also use [CPM](https://github.com/cpm-cmake/CPM.cmake), like so:
|
|||||||
CPMAddPackage(
|
CPMAddPackage(
|
||||||
NAME fast_float
|
NAME fast_float
|
||||||
GITHUB_REPOSITORY "fastfloat/fast_float"
|
GITHUB_REPOSITORY "fastfloat/fast_float"
|
||||||
GIT_TAG v8.2.6)
|
GIT_TAG v8.2.9)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Using as single header
|
## Using as single header
|
||||||
@ -559,7 +559,7 @@ if desired as described in the command line help.
|
|||||||
|
|
||||||
You may directly download automatically generated single-header files:
|
You may directly download automatically generated single-header files:
|
||||||
|
|
||||||
<https://github.com/fastfloat/fast_float/releases/download/v8.2.6/fast_float.h>
|
<https://github.com/fastfloat/fast_float/releases/download/v8.2.9/fast_float.h>
|
||||||
|
|
||||||
## Benchmarking
|
## Benchmarking
|
||||||
|
|
||||||
|
|||||||
@ -600,7 +600,8 @@ parse_int_string(UC const *p, UC const *pend, T &value,
|
|||||||
|
|
||||||
UC const *const start_digits = p;
|
UC const *const start_digits = p;
|
||||||
|
|
||||||
FASTFLOAT_IF_CONSTEXPR17((std::is_same<T, std::uint8_t>::value)) {
|
FASTFLOAT_IF_CONSTEXPR17(
|
||||||
|
(std::is_same<T, std::uint8_t>::value && sizeof(UC) == 1)) {
|
||||||
if (base == 10) {
|
if (base == 10) {
|
||||||
const size_t len = (size_t)(pend - p);
|
const size_t len = (size_t)(pend - p);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
@ -692,7 +693,8 @@ parse_int_string(UC const *p, UC const *pend, T &value,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
FASTFLOAT_IF_CONSTEXPR17((std::is_same<T, std::uint16_t>::value)) {
|
FASTFLOAT_IF_CONSTEXPR17(
|
||||||
|
(std::is_same<T, std::uint16_t>::value && sizeof(UC) == 1)) {
|
||||||
if (base == 10) {
|
if (base == 10) {
|
||||||
const size_t len = size_t(pend - p);
|
const size_t len = size_t(pend - p);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
|
|||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
#define FASTFLOAT_VERSION_MAJOR 8
|
#define FASTFLOAT_VERSION_MAJOR 8
|
||||||
#define FASTFLOAT_VERSION_MINOR 2
|
#define FASTFLOAT_VERSION_MINOR 2
|
||||||
#define FASTFLOAT_VERSION_PATCH 6
|
#define FASTFLOAT_VERSION_PATCH 9
|
||||||
|
|
||||||
#define FASTFLOAT_STRINGIZE_IMPL(x) #x
|
#define FASTFLOAT_STRINGIZE_IMPL(x) #x
|
||||||
#define FASTFLOAT_STRINGIZE(x) FASTFLOAT_STRINGIZE_IMPL(x)
|
#define FASTFLOAT_STRINGIZE(x) FASTFLOAT_STRINGIZE_IMPL(x)
|
||||||
@ -207,7 +207,11 @@ using parse_options = parse_options_t<char>;
|
|||||||
// to a no-op elsewhere (e.g. pre-C++20 MSVC, which has no equivalent hint).
|
// to a no-op elsewhere (e.g. pre-C++20 MSVC, which has no equivalent hint).
|
||||||
#ifdef __has_cpp_attribute
|
#ifdef __has_cpp_attribute
|
||||||
#if __has_cpp_attribute(unlikely) >= 201803L
|
#if __has_cpp_attribute(unlikely) >= 201803L
|
||||||
#define FASTFLOAT_USE_UNLIKELY_ATTR 1
|
// g++-9 hits hits this branch, but then fails to compile
|
||||||
|
// [[unlikely]]. This happens only with g++-9.
|
||||||
|
#if !defined(__GNUC__) || (__GNUC__ != 9)
|
||||||
|
#define FASTFLOAT_USE_UNLIKELY_ATTR
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -358,7 +358,9 @@ from_chars_float_advanced(UC const *first, UC const *last, T &value,
|
|||||||
// This is unfortunate.
|
// This is unfortunate.
|
||||||
#ifdef __clang__
|
#ifdef __clang__
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
|
#if (!defined(__APPLE_CC__) && __clang_major__ >= 10) || (__clang_major__ >= 13)
|
||||||
#pragma clang diagnostic ignored "-Wc++20-extensions"
|
#pragma clang diagnostic ignored "-Wc++20-extensions"
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
if fastfloat_unlikely (pns.too_many_digits) {
|
if fastfloat_unlikely (pns.too_many_digits) {
|
||||||
return parse_number_slow_path<T, UC>(first, last, value, options, bjf);
|
return parse_number_slow_path<T, UC>(first, last, value, options, bjf);
|
||||||
|
|||||||
@ -1295,6 +1295,59 @@ int main() {
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// The uint8_t and uint16_t base-10 paths use a byte-oriented fast path. A
|
||||||
|
// wider code unit whose low byte is an ASCII digit (e.g. U+2131..U+2139) must
|
||||||
|
// not be mistaken for that digit. The generic path already rejects these for
|
||||||
|
// int; the fixed-width fast paths must agree. Lengths of 1..5 exercise both
|
||||||
|
// the uint8_t path and the 4-digit uint16_t SWAR path.
|
||||||
|
{
|
||||||
|
const std::u16string bad16[] = {
|
||||||
|
u"ℹ", u"ℱℲ", u"ℱℲℳ", u"ℱℲℳℴ", u"ℱℲℳℴℵ",
|
||||||
|
};
|
||||||
|
const std::u32string bad32[] = {
|
||||||
|
U"ℹ",
|
||||||
|
U"ℱℲℳ",
|
||||||
|
U"ℱℲℳℴ",
|
||||||
|
U"ℱℲℳℴℵ",
|
||||||
|
};
|
||||||
|
bool failed = false;
|
||||||
|
for (auto const &s : bad16) {
|
||||||
|
uint8_t r8 = 123;
|
||||||
|
auto a8 = fast_float::from_chars(s.data(), s.data() + s.size(), r8);
|
||||||
|
if (a8.ec == std::errc()) {
|
||||||
|
failed = true;
|
||||||
|
std::cerr << "Incorrectly parsed wide units as uint8_t " << unsigned(r8)
|
||||||
|
<< "." << std::endl;
|
||||||
|
}
|
||||||
|
uint16_t r16 = 123;
|
||||||
|
auto a16 = fast_float::from_chars(s.data(), s.data() + s.size(), r16);
|
||||||
|
if (a16.ec == std::errc()) {
|
||||||
|
failed = true;
|
||||||
|
std::cerr << "Incorrectly parsed wide units as uint16_t " << r16 << "."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (auto const &s : bad32) {
|
||||||
|
uint8_t r8 = 123;
|
||||||
|
auto a8 = fast_float::from_chars(s.data(), s.data() + s.size(), r8);
|
||||||
|
if (a8.ec == std::errc()) {
|
||||||
|
failed = true;
|
||||||
|
std::cerr << "Incorrectly parsed wide units as uint8_t " << unsigned(r8)
|
||||||
|
<< "." << std::endl;
|
||||||
|
}
|
||||||
|
uint16_t r16 = 123;
|
||||||
|
auto a16 = fast_float::from_chars(s.data(), s.data() + s.size(), r16);
|
||||||
|
if (a16.ec == std::errc()) {
|
||||||
|
failed = true;
|
||||||
|
std::cerr << "Incorrectly parsed wide units as uint16_t " << r16 << "."
|
||||||
|
<< std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed) {
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -65,6 +65,4 @@ int main() {
|
|||||||
#endif
|
#endif
|
||||||
std::cout << "All tests passed successfully." << std::endl;
|
std::cout << "All tests passed successfully." << std::endl;
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
@ -45,11 +45,6 @@ void all_32bit_values() {
|
|||||||
std::cerr << "I got " << std::hexfloat << result_value
|
std::cerr << "I got " << std::hexfloat << result_value
|
||||||
<< " but I was expecting " << v << std::endl;
|
<< " but I was expecting " << v << std::endl;
|
||||||
abort();
|
abort();
|
||||||
} else if (std::isnan(v)) {
|
|
||||||
if (!std::isnan(result_value)) {
|
|
||||||
std::cerr << "not nan" << buffer << std::endl;
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
} else if (result_value != v) {
|
} else if (result_value != v) {
|
||||||
std::cerr << "no match ? " << buffer << std::endl;
|
std::cerr << "no match ? " << buffer << std::endl;
|
||||||
std::cout << "started with " << std::hexfloat << v << std::endl;
|
std::cout << "started with " << std::hexfloat << v << std::endl;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user