mirror of
https://github.com/open-source-parsers/jsoncpp.git
synced 2025-10-15 15:16:47 +02:00
clang-tidy fixes again (#1087)
* [clang-tidy] Do not use else after return Found with readability-else-after-return Signed-off-by: Rosen Penev <rosenp@gmail.com> * [clang-tidy] Convert several loops to be range based Found with modernize-loop-convert Signed-off-by: Rosen Penev <rosenp@gmail.com> * [clang-tidy] Replace deprecated C headers Found with modernize-deprecated-headers Signed-off-by: Rosen Penev <rosenp@gmail.com> * [clang-tidy] Use auto where applicable Found with modernize-use-auto Signed-off-by: Rosen Penev <rosenp@gmail.com> * .clang-tidy: Add these checks
This commit is contained in:
@@ -637,7 +637,7 @@ bool Reader::decodeString(Token& token, String& decoded) {
|
||||
Char c = *current++;
|
||||
if (c == '"')
|
||||
break;
|
||||
else if (c == '\\') {
|
||||
if (c == '\\') {
|
||||
if (current == end)
|
||||
return addError("Empty escape sequence in string", token, current);
|
||||
Char escape = *current++;
|
||||
@@ -1358,11 +1358,10 @@ bool OurReader::readCStyleComment(bool* containsNewLineResult) {
|
||||
|
||||
while ((current_ + 1) < end_) {
|
||||
Char c = getNextChar();
|
||||
if (c == '*' && *current_ == '/') {
|
||||
if (c == '*' && *current_ == '/')
|
||||
break;
|
||||
} else if (c == '\n') {
|
||||
if (c == '\n')
|
||||
*containsNewLineResult = true;
|
||||
}
|
||||
}
|
||||
|
||||
return getNextChar() == '/';
|
||||
@@ -1586,9 +1585,9 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
|
||||
// then take the inverse. This assumes that minLargestInt is only a single
|
||||
// power of 10 different in magnitude, which we check above. For the last
|
||||
// digit, we take the modulus before negating for the same reason.
|
||||
static constexpr Value::LargestUInt negative_threshold =
|
||||
static constexpr auto negative_threshold =
|
||||
Value::LargestUInt(-(Value::minLargestInt / 10));
|
||||
static constexpr Value::UInt negative_last_digit =
|
||||
static constexpr auto negative_last_digit =
|
||||
Value::UInt(-(Value::minLargestInt % 10));
|
||||
|
||||
const Value::LargestUInt threshold =
|
||||
@@ -1602,7 +1601,7 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
|
||||
if (c < '0' || c > '9')
|
||||
return decodeDouble(token, decoded);
|
||||
|
||||
const Value::UInt digit(static_cast<Value::UInt>(c - '0'));
|
||||
const auto digit(static_cast<Value::UInt>(c - '0'));
|
||||
if (value >= threshold) {
|
||||
// We've hit or exceeded the max value divided by 10 (rounded down). If
|
||||
// a) we've only just touched the limit, meaing value == threshold,
|
||||
@@ -1619,7 +1618,7 @@ bool OurReader::decodeNumber(Token& token, Value& decoded) {
|
||||
|
||||
if (isNegative) {
|
||||
// We use the same magnitude assumption here, just in case.
|
||||
const Value::UInt last_digit = static_cast<Value::UInt>(value % 10);
|
||||
const auto last_digit = static_cast<Value::UInt>(value % 10);
|
||||
decoded = -Value::LargestInt(value / 10) * 10 - last_digit;
|
||||
} else if (value <= Value::LargestUInt(Value::maxLargestInt)) {
|
||||
decoded = Value::LargestInt(value);
|
||||
@@ -1669,9 +1668,9 @@ bool OurReader::decodeString(Token& token, String& decoded) {
|
||||
Location end = token.end_ - 1; // do not include '"'
|
||||
while (current != end) {
|
||||
Char c = *current++;
|
||||
if (c == '"') {
|
||||
if (c == '"')
|
||||
break;
|
||||
} else if (c == '\\') {
|
||||
if (c == '\\') {
|
||||
if (current == end)
|
||||
return addError("Empty escape sequence in string", token, current);
|
||||
Char escape = *current++;
|
||||
|
Reference in New Issue
Block a user