Skip to content

Commit

Permalink
fix: use sscanf_s if available
Browse files Browse the repository at this point in the history
  • Loading branch information
ToruNiina committed Jun 16, 2024
1 parent a18ce2a commit a12a09b
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions include/toml11/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <vector>

#include <cstdint>
#include <cstdio>

namespace toml
{
Expand Down Expand Up @@ -155,7 +156,11 @@ read_int(const std::string& str, const source_location src, const std::uint8_t b
inline result<float, error_info>
read_hex_float(const std::string& str, const source_location src, float val)
{
#if defined(_MSC_VER) && ! defined(__clang__)
const auto res = std::sscanf_s(str.c_str(), "%a", std::addressof(val));
#else
const auto res = std::sscanf(str.c_str(), "%a", std::addressof(val));
#endif
if(res != 1)
{
return err(make_error_info("toml::parse_floating: "
Expand All @@ -167,7 +172,11 @@ read_hex_float(const std::string& str, const source_location src, float val)
inline result<double, error_info>
read_hex_float(const std::string& str, const source_location src, double val)
{
#if defined(_MSC_VER) && ! defined(__clang__)
const auto res = std::sscanf_s(str.c_str(), "%la", std::addressof(val));
#else
const auto res = std::sscanf(str.c_str(), "%la", std::addressof(val));
#endif
if(res != 1)
{
return err(make_error_info("toml::parse_floating: "
Expand Down

0 comments on commit a12a09b

Please sign in to comment.