Skip to content

Commit

Permalink
minor fixes for 64 bits and refactor code
Browse files Browse the repository at this point in the history
  • Loading branch information
GermanAizek authored and BillyDonahue committed Jan 15, 2021
1 parent eab8ebe commit c9a9762
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
1 change: 1 addition & 0 deletions src/jsontestrunner/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ int main(int argc, const char* argv[]) {
std::cerr << "Unhandled exception:" << std::endl << e.what() << std::endl;
return 1;
}
return 0;
}

#if defined(__GNUC__)
Expand Down
29 changes: 14 additions & 15 deletions src/lib_json/json_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

#if !defined(isnan)
// IEEE standard states that NaN values will not compare to themselves
#define isnan(x) (x != x)
#define isnan(x) ((x) != (x))
#endif

#if !defined(__APPLE__)
Expand Down Expand Up @@ -272,7 +272,7 @@ static void appendHex(String& result, unsigned ch) {
result.append("\\u").append(toHex16Bit(ch));
}

static String valueToQuotedStringN(const char* value, unsigned length,
static String valueToQuotedStringN(const char* value, size_t length,
bool emitUTF8 = false) {
if (value == nullptr)
return "";
Expand Down Expand Up @@ -350,7 +350,7 @@ static String valueToQuotedStringN(const char* value, unsigned length,
}

String valueToQuotedString(const char* value) {
return valueToQuotedStringN(value, static_cast<unsigned int>(strlen(value)));
return valueToQuotedStringN(value, strlen(value));
}

// Class Writer
Expand Down Expand Up @@ -399,7 +399,7 @@ void FastWriter::writeValue(const Value& value) {
char const* end;
bool ok = value.getString(&str, &end);
if (ok)
document_ += valueToQuotedStringN(str, static_cast<unsigned>(end - str));
document_ += valueToQuotedStringN(str, static_cast<size_t>(end - str));
break;
}
case booleanValue:
Expand All @@ -422,8 +422,7 @@ void FastWriter::writeValue(const Value& value) {
const String& name = *it;
if (it != members.begin())
document_ += ',';
document_ += valueToQuotedStringN(name.data(),
static_cast<unsigned>(name.length()));
document_ += valueToQuotedStringN(name.data(), name.length());
document_ += yamlCompatibilityEnabled_ ? ": " : ":";
writeValue(value[name]);
}
Expand Down Expand Up @@ -468,7 +467,7 @@ void StyledWriter::writeValue(const Value& value) {
char const* end;
bool ok = value.getString(&str, &end);
if (ok)
pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end - str)));
pushValue(valueToQuotedStringN(str, static_cast<size_t>(end - str)));
else
pushValue("");
break;
Expand Down Expand Up @@ -509,7 +508,7 @@ void StyledWriter::writeValue(const Value& value) {
}

void StyledWriter::writeArrayValue(const Value& value) {
unsigned size = value.size();
size_t size = value.size();
if (size == 0)
pushValue("[]");
else {
Expand All @@ -518,7 +517,7 @@ void StyledWriter::writeArrayValue(const Value& value) {
writeWithIndent("[");
indent();
bool hasChildValue = !childValues_.empty();
unsigned index = 0;
ArrayIndex index = 0;
for (;;) {
const Value& childValue = value[index];
writeCommentBeforeValue(childValue);
Expand All @@ -541,7 +540,7 @@ void StyledWriter::writeArrayValue(const Value& value) {
{
assert(childValues_.size() == size);
document_ += "[ ";
for (unsigned index = 0; index < size; ++index) {
for (size_t index = 0; index < size; ++index) {
if (index > 0)
document_ += ", ";
document_ += childValues_[index];
Expand Down Expand Up @@ -686,7 +685,7 @@ void StyledStreamWriter::writeValue(const Value& value) {
char const* end;
bool ok = value.getString(&str, &end);
if (ok)
pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end - str)));
pushValue(valueToQuotedStringN(str, static_cast<size_t>(end - str)));
else
pushValue("");
break;
Expand Down Expand Up @@ -960,8 +959,8 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
char const* end;
bool ok = value.getString(&str, &end);
if (ok)
pushValue(valueToQuotedStringN(str, static_cast<unsigned>(end - str),
emitUTF8_));
pushValue(
valueToQuotedStringN(str, static_cast<size_t>(end - str), emitUTF8_));
else
pushValue("");
break;
Expand All @@ -984,8 +983,8 @@ void BuiltStyledStreamWriter::writeValue(Value const& value) {
String const& name = *it;
Value const& childValue = value[name];
writeCommentBeforeValue(childValue);
writeWithIndent(valueToQuotedStringN(
name.data(), static_cast<unsigned>(name.length()), emitUTF8_));
writeWithIndent(
valueToQuotedStringN(name.data(), name.length(), emitUTF8_));
*sout_ << colonSymbol_;
writeValue(childValue);
if (++it == members.end()) {
Expand Down

0 comments on commit c9a9762

Please sign in to comment.