mirror of
https://github.com/json-c/json-c.git
synced 2026-04-14 09:49:07 +08:00
Reformat json_object_double_to_json_string_format() to have consistent spacing.
This commit is contained in:
@@ -749,13 +749,17 @@ static int json_object_double_to_json_string_format(struct json_object* jso,
|
||||
NaN or Infinity as numeric values
|
||||
ECMA 262 section 9.8.1 defines
|
||||
how to handle these cases as strings */
|
||||
if(isnan(jso->o.c_double))
|
||||
if (isnan(jso->o.c_double))
|
||||
{
|
||||
size = snprintf(buf, sizeof(buf), "NaN");
|
||||
else if(isinf(jso->o.c_double))
|
||||
}
|
||||
else if (isinf(jso->o.c_double))
|
||||
{
|
||||
if(jso->o.c_double > 0)
|
||||
size = snprintf(buf, sizeof(buf), "Infinity");
|
||||
else
|
||||
size = snprintf(buf, sizeof(buf), "-Infinity");
|
||||
}
|
||||
else
|
||||
{
|
||||
const char *std_format = "%.17g";
|
||||
@@ -783,12 +787,12 @@ static int json_object_double_to_json_string_format(struct json_object* jso,
|
||||
return -1;
|
||||
|
||||
p = strchr(buf, ',');
|
||||
if (p) {
|
||||
if (p)
|
||||
*p = '.';
|
||||
} else {
|
||||
else
|
||||
p = strchr(buf, '.');
|
||||
}
|
||||
if (p && (flags & JSON_C_TO_STRING_NOZERO)) {
|
||||
if (p && (flags & JSON_C_TO_STRING_NOZERO))
|
||||
{
|
||||
/* last useful digit, always keep 1 zero */
|
||||
p++;
|
||||
for (q=p ; *q ; q++) {
|
||||
|
||||
Reference in New Issue
Block a user