From 61921498d0842a2372766ca4ef158a9505acbd8f Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Mon, 20 Feb 2017 11:32:53 +0100 Subject: [PATCH] print_number: remove special case for 0 Now that printbuffer is used for everything, it's not needed anymore. --- cJSON.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/cJSON.c b/cJSON.c index 598f9cf..06b4c09 100644 --- a/cJSON.c +++ b/cJSON.c @@ -330,17 +330,8 @@ static unsigned char *print_number(const cJSON *item, printbuffer *p) return NULL; } - /* special case for 0. */ - if (d == 0) - { - str = ensure(p, 2); - if (str != NULL) - { - strcpy((char*)str,"0"); - } - } /* 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. */ str = ensure(p, 21); @@ -375,6 +366,7 @@ static unsigned char *print_number(const cJSON *item, printbuffer *p) } } } + return str; } -- GitLab