提交 61921498 编写于 作者: M Max Bruckner

print_number: remove special case for 0

Now that printbuffer is used for everything, it's not needed anymore.
上级 4758d62f
...@@ -330,17 +330,8 @@ static unsigned char *print_number(const cJSON *item, printbuffer *p) ...@@ -330,17 +330,8 @@ static unsigned char *print_number(const cJSON *item, printbuffer *p)
return NULL; return NULL;
} }
/* special case for 0. */
if (d == 0)
{
str = ensure(p, 2);
if (str != NULL)
{
strcpy((char*)str,"0");
}
}
/* value is an int */ /* value is an int */
else if ((fabs(((double)item->valueint) - d) <= DBL_EPSILON) && (d <= INT_MAX) && (d >= INT_MIN)) if ((fabs(((double)item->valueint) - d) <= DBL_EPSILON) && (d <= INT_MAX) && (d >= INT_MIN))
{ {
/* 2^64+1 can be represented in 21 chars. */ /* 2^64+1 can be represented in 21 chars. */
str = ensure(p, 21); str = ensure(p, 21);
...@@ -375,6 +366,7 @@ static unsigned char *print_number(const cJSON *item, printbuffer *p) ...@@ -375,6 +366,7 @@ static unsigned char *print_number(const cJSON *item, printbuffer *p)
} }
} }
} }
return str; return str;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册