Skip to content

Commit

Permalink
Rename fixedp serialization to integer/fractional
Browse files Browse the repository at this point in the history
  • Loading branch information
sturnclaw committed Oct 7, 2023
1 parent 56bdbe9 commit c09da89
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/JsonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -560,18 +560,18 @@ void from_json(const Json &obj, fixed &f)
throw Json::type_error::create(320, "cannot pickle string to fixed point number");

char *next_str = const_cast<char *>(str.c_str()) + 1;
int64_t numerator = std::strtol(next_str, &next_str, 10);
int64_t integer = std::strtol(next_str, &next_str, 10);

// handle cases: f/34, f1356, f14+4
if (next_str == nullptr || size_t(next_str - str.c_str()) >= str.size() || *next_str++ != '/')
throw Json::type_error::create(320, "cannot pickle string to fixed point number");

int64_t denominator = std::strtol(next_str, &next_str, 10);
int64_t fractional = std::strtol(next_str, &next_str, 10);
// handle cases f1345/7684gfrty; fixed numbers should not have any garbage data involved
if (next_str != str.c_str() + str.size())
throw Json::type_error::create(320, "cannot pickle string to fixed point number");

f = fixed(numerator << f.FRAC | denominator);
f = fixed(integer << f.FRAC | fractional);
}
}

Expand Down

0 comments on commit c09da89

Please sign in to comment.