diff options
| author | chenzizhan <[email protected]> | 2023-07-26 15:49:56 +0800 |
|---|---|---|
| committer | chenzizhan <[email protected]> | 2023-07-26 15:49:56 +0800 |
| commit | a92d75582346a2ed8d7801401da29a6a11a8fe45 (patch) | |
| tree | 1970096ae2f039662e36617ff29c8eacf5d03478 /vendors | |
| parent | f8ac5d3a6eaa9e3b477415a66cdfdac4f90c89f8 (diff) | |
cJson with long long
Diffstat (limited to 'vendors')
| -rw-r--r-- | vendors/cjson/cJSON.c | 8 | ||||
| -rw-r--r-- | vendors/cjson/cJSON.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/vendors/cjson/cJSON.c b/vendors/cjson/cJSON.c index 5df10e2..5830a27 100644 --- a/vendors/cjson/cJSON.c +++ b/vendors/cjson/cJSON.c @@ -112,7 +112,7 @@ static const char *parse_number(cJSON *item,const char *num) n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */ item->valuedouble=n; - item->valueint=(int)n; + item->valueint=(long long)n; item->type=cJSON_Number; return num; } @@ -122,10 +122,10 @@ static char *print_number(cJSON *item) { char *str; double d=item->valuedouble; - if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN) + if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=LLONG_MAX && d>=LLONG_MIN) { str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */ - if (str) sprintf(str,"%d",item->valueint); + if (str) sprintf(str,"%lld",item->valueint); } else { @@ -542,7 +542,7 @@ cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->ty cJSON *cJSON_CreateTrue(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;} cJSON *cJSON_CreateFalse(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;} cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;} -cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;} +cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(long long)num;}return item;} cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);}return item;} cJSON *cJSON_CreateArray(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;} cJSON *cJSON_CreateObject(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;} diff --git a/vendors/cjson/cJSON.h b/vendors/cjson/cJSON.h index 1ce513d..994891d 100644 --- a/vendors/cjson/cJSON.h +++ b/vendors/cjson/cJSON.h @@ -50,7 +50,7 @@ typedef struct cJSON { int type; /* The type of the item, as above. */ char *valuestring; /* The item's string, if type==cJSON_String */ - int valueint; /* The item's number, if type==cJSON_Number */ + long long valueint; /* The item's number, if type==cJSON_Number */ double valuedouble; /* The item's number, if type==cJSON_Number */ char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ |
