|
|
@@ -130,13 +130,15 @@ int json_object_to_file(char *filename, struct json_object *obj) |
|
|
|
int json_parse_int64(const char *buf, int64_t *retval) |
|
|
|
{ |
|
|
|
int64_t num64; |
|
|
|
const char *buf_skip_space; |
|
|
|
int orig_has_neg; |
|
|
|
if (sscanf(buf, "%" SCNd64, &num64) != 1) |
|
|
|
{ |
|
|
|
MC_DEBUG("Failed to parse, sscanf != 1\n"); |
|
|
|
return 1; |
|
|
|
} |
|
|
|
const char *buf_skip_space = buf; |
|
|
|
int orig_has_neg = 0; |
|
|
|
buf_skip_space = buf; |
|
|
|
orig_has_neg = 0; |
|
|
|
// Skip leading spaces |
|
|
|
while (isspace((int)*buf_skip_space) && *buf_skip_space) |
|
|
|
buf_skip_space++; |
|
|
@@ -156,6 +158,7 @@ int json_parse_int64(const char *buf, int64_t *retval) |
|
|
|
char buf_cmp[100]; |
|
|
|
char *buf_cmp_start = buf_cmp; |
|
|
|
int recheck_has_neg = 0; |
|
|
|
int buf_cmp_len; |
|
|
|
snprintf(buf_cmp_start, sizeof(buf_cmp), "%" PRId64, num64); |
|
|
|
if (*buf_cmp_start == '-') |
|
|
|
{ |
|
|
@@ -164,7 +167,7 @@ int json_parse_int64(const char *buf, int64_t *retval) |
|
|
|
} |
|
|
|
// No need to skip leading spaces or zeros here. |
|
|
|
|
|
|
|
int buf_cmp_len = strlen(buf_cmp_start); |
|
|
|
buf_cmp_len = strlen(buf_cmp_start); |
|
|
|
/** |
|
|
|
* If the sign is different, or |
|
|
|
* some of the digits are different, or |
|
|
|