mirror of
https://github.com/nlohmann/json.git
synced 2026-11-03 11:25:33 +00:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
baba5db36f | ||
|
|
07876e2292 |
No files matched your search
@@ -1168,20 +1168,20 @@ indent_done:
|
||||
if (negative)
|
||||
{
|
||||
++p;
|
||||
if (NLOHMANN_VIEW_UNLIKELY(cur() < '0' || cur() > '9'))
|
||||
{
|
||||
return fail(error_code::number_after_minus);
|
||||
}
|
||||
}
|
||||
const unsigned char* const int_start = p;
|
||||
if (cur() == '0')
|
||||
{
|
||||
++p;
|
||||
}
|
||||
else if (!negative || NLOHMANN_VIEW_LIKELY(cur() >= '1' && cur() <= '9'))
|
||||
{
|
||||
// (without a sign, the dispatch saw a digit)
|
||||
p = skip_digits(p + 1, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
return fail(error_code::number_after_minus);
|
||||
// (a digit: the dispatch or the check after the sign saw it)
|
||||
p = skip_digits(p + 1, e);
|
||||
}
|
||||
const auto int_digits = static_cast<std::size_t>(p - int_start);
|
||||
std::size_t frac_digits = 0;
|
||||
|
||||
@@ -230,8 +230,7 @@ void value_range(const document_data& d, const node* n, std::size_t& start, std:
|
||||
|
||||
/// the context basic_json puts in front of the message of an exception about
|
||||
/// a value: "(/path) " with JSON_DIAGNOSTICS (none for the root), then
|
||||
/// "(bytes a-b) " with JSON_DIAGNOSTIC_POSITIONS (also for the root); with
|
||||
/// JSON_DIAGNOSTICS, nothing for a value that is no longer part of the document
|
||||
/// "(bytes a-b) " with JSON_DIAGNOSTIC_POSITIONS (also for the root)
|
||||
///
|
||||
/// This and the throw helpers that take an error_site are templates, so that
|
||||
/// the path and range code is instantiated only where an exception can be
|
||||
@@ -252,12 +251,10 @@ std::string diagnostics(const error_site site)
|
||||
std::string context;
|
||||
#if JSON_DIAGNOSTICS
|
||||
std::vector<std::string> tokens;
|
||||
// a value that is no longer part of the document has no path, and its
|
||||
// node still holds the bytes it had in the source: no context at all
|
||||
const bool found = edited ? value_path<true>(d, site.value(), tokens) : value_path<false>(d, site.value(), tokens);
|
||||
if (!found)
|
||||
{
|
||||
// context is still empty; returning it keeps the copy elided (-Wnrvo)
|
||||
// a value that is not found has no path, and with it no bytes
|
||||
return context;
|
||||
}
|
||||
if (!tokens.empty())
|
||||
|
||||
Generated
+8
-11
@@ -2473,20 +2473,20 @@ indent_done:
|
||||
if (negative)
|
||||
{
|
||||
++p;
|
||||
if (NLOHMANN_VIEW_UNLIKELY(cur() < '0' || cur() > '9'))
|
||||
{
|
||||
return fail(error_code::number_after_minus);
|
||||
}
|
||||
}
|
||||
const unsigned char* const int_start = p;
|
||||
if (cur() == '0')
|
||||
{
|
||||
++p;
|
||||
}
|
||||
else if (!negative || NLOHMANN_VIEW_LIKELY(cur() >= '1' && cur() <= '9'))
|
||||
{
|
||||
// (without a sign, the dispatch saw a digit)
|
||||
p = skip_digits(p + 1, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
return fail(error_code::number_after_minus);
|
||||
// (a digit: the dispatch or the check after the sign saw it)
|
||||
p = skip_digits(p + 1, e);
|
||||
}
|
||||
const auto int_digits = static_cast<std::size_t>(p - int_start);
|
||||
std::size_t frac_digits = 0;
|
||||
@@ -5059,8 +5059,7 @@ void value_range(const document_data& d, const node* n, std::size_t& start, std:
|
||||
|
||||
/// the context basic_json puts in front of the message of an exception about
|
||||
/// a value: "(/path) " with JSON_DIAGNOSTICS (none for the root), then
|
||||
/// "(bytes a-b) " with JSON_DIAGNOSTIC_POSITIONS (also for the root); with
|
||||
/// JSON_DIAGNOSTICS, nothing for a value that is no longer part of the document
|
||||
/// "(bytes a-b) " with JSON_DIAGNOSTIC_POSITIONS (also for the root)
|
||||
///
|
||||
/// This and the throw helpers that take an error_site are templates, so that
|
||||
/// the path and range code is instantiated only where an exception can be
|
||||
@@ -5081,12 +5080,10 @@ std::string diagnostics(const error_site site)
|
||||
std::string context;
|
||||
#if JSON_DIAGNOSTICS
|
||||
std::vector<std::string> tokens;
|
||||
// a value that is no longer part of the document has no path, and its
|
||||
// node still holds the bytes it had in the source: no context at all
|
||||
const bool found = edited ? value_path<true>(d, site.value(), tokens) : value_path<false>(d, site.value(), tokens);
|
||||
if (!found)
|
||||
{
|
||||
// context is still empty; returning it keeps the copy elided (-Wnrvo)
|
||||
// a value that is not found has no path, and with it no bytes
|
||||
return context;
|
||||
}
|
||||
if (!tokens.empty())
|
||||
|
||||
@@ -505,8 +505,8 @@ struct locale_switching_token
|
||||
{
|
||||
using value_type = char;
|
||||
|
||||
locale_switching_token(std::string text_, const char* switch_to_)
|
||||
: text(std::move(text_)), switch_to(switch_to_)
|
||||
locale_switching_token(std::string text_, std::string switch_to_)
|
||||
: text(std::move(text_)), switch_to(std::move(switch_to_))
|
||||
{}
|
||||
|
||||
std::size_t size() const
|
||||
@@ -523,13 +523,13 @@ struct locale_switching_token
|
||||
{
|
||||
if (!switched)
|
||||
{
|
||||
switched = std::setlocale(LC_NUMERIC, switch_to) != nullptr;
|
||||
switched = std::setlocale(LC_NUMERIC, switch_to.c_str()) != nullptr;
|
||||
}
|
||||
return &text[0];
|
||||
}
|
||||
|
||||
std::string text;
|
||||
const char* switch_to;
|
||||
std::string switch_to;
|
||||
bool switched = false;
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user