mirror of
https://github.com/fastfloat/fast_float.git
synced 2026-04-30 19:09:19 +08:00
lint
This commit is contained in:
parent
df5db2cfbf
commit
6eb3dcdcd3
@ -2,13 +2,12 @@
|
||||
#define __FAST_FLOAT_STRTOD_H__
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
extern "C" {
|
||||
#endif
|
||||
/**
|
||||
* @brief Convert a string to a double using the fast_float library. This is
|
||||
* a C-compatible wrapper around the fast_float parsing functionality, designed to
|
||||
* mimic the behavior of the standard strtod function.
|
||||
* a C-compatible wrapper around the fast_float parsing functionality, designed
|
||||
* to mimic the behavior of the standard strtod function.
|
||||
*
|
||||
* This function parses the initial portion of the null-terminated string `nptr`
|
||||
* and converts it to a `double`, similar to the standard `strtod` function but
|
||||
@ -23,7 +22,7 @@ extern "C"
|
||||
* to the beginning of the string.
|
||||
* @return The converted double value on success, or 0.0 on failure.
|
||||
*/
|
||||
double fast_float_strtod(const char *in, char **out);
|
||||
double fast_float_strtod(const char *in, char **out);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
@ -5,20 +5,20 @@
|
||||
#include <system_error>
|
||||
|
||||
extern "C" double fast_float_strtod(const char *nptr, char **endptr) {
|
||||
double result = 0.0;
|
||||
double result = 0.0;
|
||||
|
||||
// Parse the string using fast_float's from_chars function
|
||||
auto parse_result = fast_float::from_chars(nptr, nptr + strlen(nptr), result);
|
||||
// Parse the string using fast_float's from_chars function
|
||||
auto parse_result = fast_float::from_chars(nptr, nptr + strlen(nptr), result);
|
||||
|
||||
// Check if parsing encountered an error
|
||||
if (parse_result.ec != std::errc{}) {
|
||||
errno = EINVAL;
|
||||
}
|
||||
// Check if parsing encountered an error
|
||||
if (parse_result.ec != std::errc{}) {
|
||||
errno = EINVAL;
|
||||
}
|
||||
|
||||
// Update endptr if provided
|
||||
if (endptr != nullptr) {
|
||||
*endptr = const_cast<char*>(parse_result.ptr);
|
||||
}
|
||||
// Update endptr if provided
|
||||
if (endptr != nullptr) {
|
||||
*endptr = const_cast<char *>(parse_result.ptr);
|
||||
}
|
||||
|
||||
return result;
|
||||
return result;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user