From 467dc6ae058e68aaf9d3bbfdf1d2447f4742f64d Mon Sep 17 00:00:00 2001 From: Austin Brunkhorst Date: Sun, 24 Jul 2016 11:34:17 -0700 Subject: [PATCH 1/2] Fixes warning C4800: 'int': forcing value to bool 'true' or 'false' on MSVC 14 --- json11.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/json11.cpp b/json11.cpp index 5f3b7ef..f977e16 100644 --- a/json11.cpp +++ b/json11.cpp @@ -375,38 +375,38 @@ struct JsonParser final { if (str[i] == '/') { i++; if (i == str.size()) - return fail("unexpected end of input inside comment", 0); + return !!fail("unexpected end of input inside comment", 0); if (str[i] == '/') { // inline comment i++; if (i == str.size()) - return fail("unexpected end of input inside inline comment", 0); + return !!fail("unexpected end of input inside inline comment", 0); // advance until next line while (str[i] != '\n') { i++; if (i == str.size()) - return fail("unexpected end of input inside inline comment", 0); + return !!fail("unexpected end of input inside inline comment", 0); } comment_found = true; } else if (str[i] == '*') { // multiline comment i++; if (i > str.size()-2) - return fail("unexpected end of input inside multi-line comment", 0); + return !!fail("unexpected end of input inside multi-line comment", 0); // advance until closing tokens while (!(str[i] == '*' && str[i+1] == '/')) { i++; if (i > str.size()-2) - return fail( + return !!fail( "unexpected end of input inside multi-line comment", 0); } i += 2; if (i == str.size()) - return fail( + return !!fail( "unexpected end of input inside multi-line comment", 0); comment_found = true; } else - return fail("malformed comment", 0); + return !!fail("malformed comment", 0); } return comment_found; } From 40f10bd28d42a560749bb033d33bfecc494b02a5 Mon Sep 17 00:00:00 2001 From: Austin Brunkhorst Date: Mon, 25 Jul 2016 17:28:15 -0700 Subject: [PATCH 2/2] Use `false` instead of `0` + conversion. --- json11.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/json11.cpp b/json11.cpp index f977e16..e3dc119 100644 --- a/json11.cpp +++ b/json11.cpp @@ -375,38 +375,38 @@ struct JsonParser final { if (str[i] == '/') { i++; if (i == str.size()) - return !!fail("unexpected end of input inside comment", 0); + return fail("unexpected end of input inside comment", false); if (str[i] == '/') { // inline comment i++; if (i == str.size()) - return !!fail("unexpected end of input inside inline comment", 0); + return fail("unexpected end of input inside inline comment", false); // advance until next line while (str[i] != '\n') { i++; if (i == str.size()) - return !!fail("unexpected end of input inside inline comment", 0); + return fail("unexpected end of input inside inline comment", false); } comment_found = true; } else if (str[i] == '*') { // multiline comment i++; if (i > str.size()-2) - return !!fail("unexpected end of input inside multi-line comment", 0); + return fail("unexpected end of input inside multi-line comment", false); // advance until closing tokens while (!(str[i] == '*' && str[i+1] == '/')) { i++; if (i > str.size()-2) - return !!fail( - "unexpected end of input inside multi-line comment", 0); + return fail( + "unexpected end of input inside multi-line comment", false); } i += 2; if (i == str.size()) - return !!fail( - "unexpected end of input inside multi-line comment", 0); + return fail( + "unexpected end of input inside multi-line comment", false); comment_found = true; } else - return !!fail("malformed comment", 0); + return fail("malformed comment", false); } return comment_found; }