|
|
@@ -273,7 +273,7 @@ typedef struct {
|
|
|
#define buffer_at_offset(buffer) ((buffer)->content + (buffer)->offset)
|
|
|
|
|
|
/* Converts an array of characters to double. Alternative implementation of strtod() */
|
|
|
-double string_to_double(const char* str, size_t* len) {
|
|
|
+double string_to_double(const char* str, char** endptr) {
|
|
|
double result = 0.0;
|
|
|
int sign = 1;
|
|
|
const char* p = str;
|
|
|
@@ -323,7 +323,7 @@ double string_to_double(const char* str, size_t* len) {
|
|
|
result *= pow(10, exponent);
|
|
|
}
|
|
|
|
|
|
- *len = p - str;
|
|
|
+ *endptr = (char*)p;
|
|
|
|
|
|
return sign * result;
|
|
|
}
|
|
|
@@ -373,8 +373,7 @@ static cJSON_bool parse_number(cJSON* const item, parse_buffer* const input_buff
|
|
|
loop_end:
|
|
|
number_c_string[i] = '\0';
|
|
|
|
|
|
- size_t len = 0;
|
|
|
- number = string_to_double((const char*)number_c_string, &len);
|
|
|
+ number = string_to_double((const char*)number_c_string, (char**)&after_end);
|
|
|
if(number_c_string == after_end) {
|
|
|
return false; /* parse_error */
|
|
|
}
|
|
|
@@ -392,7 +391,7 @@ loop_end:
|
|
|
|
|
|
item->type = cJSON_Number;
|
|
|
|
|
|
- input_buffer->offset += len;
|
|
|
+ input_buffer->offset += (size_t)(after_end - number_c_string);
|
|
|
return true;
|
|
|
}
|
|
|
|