From 4678f33b5c84728ec8549b4a0cb5a12ef35d5ab7 Mon Sep 17 00:00:00 2001 From: Dave Gamble Date: Tue, 5 Feb 2013 17:00:31 +0000 Subject: [PATCH] Fix up ANSI issues. git-svn-id: http://svn.code.sf.net/p/cjson/code@43 e3330c51-1366-4df0-8b21-3ccf24e3d50e --- cJSON.c | 22 +++++++++++----------- cJSON.h | 12 ++++++------ 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cJSON.c b/cJSON.c index eb7c2f9..27c3385 100644 --- a/cJSON.c +++ b/cJSON.c @@ -34,7 +34,7 @@ static const char *ep; -const char *cJSON_GetErrorPtr() {return ep;} +const char *cJSON_GetErrorPtr(void) {return ep;} static int cJSON_strcasecmp(const char *s1,const char *s2) { @@ -70,7 +70,7 @@ void cJSON_InitHooks(cJSON_Hooks* hooks) } /* Internal constructor. */ -static cJSON *cJSON_New_Item() +static cJSON *cJSON_New_Item(void) { cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON)); if (node) memset(node,0,sizeof(cJSON)); @@ -167,13 +167,13 @@ static const char *parse_string(cJSON *item,const char *str) case 'u': /* transcode utf16 to utf8. */ sscanf(ptr+1,"%4x",&uc);ptr+=4; /* get the unicode char. */ - if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; // check for invalid. + if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) break; /* check for invalid. */ - if (uc>=0xD800 && uc<=0xDBFF) // UTF16 surrogate pairs. + if (uc>=0xD800 && uc<=0xDBFF) /* UTF16 surrogate pairs. */ { - if (ptr[1]!='\\' || ptr[2]!='u') break; // missing second-half of surrogate. + if (ptr[1]!='\\' || ptr[2]!='u') break; /* missing second-half of surrogate. */ sscanf(ptr+3,"%4x",&uc2);ptr+=6; - if (uc2<0xDC00 || uc2>0xDFFF) break; // invalid second-half of surrogate. + if (uc2<0xDC00 || uc2>0xDFFF) break; /* invalid second-half of surrogate. */ uc=0x10000 | ((uc&0x3FF)<<10) | (uc2&0x3FF); } @@ -498,14 +498,14 @@ void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON * void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}} /* Create basic types: */ -cJSON *cJSON_CreateNull() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;} -cJSON *cJSON_CreateTrue() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;} -cJSON *cJSON_CreateFalse() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;} +cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;} +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_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() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;} -cJSON *cJSON_CreateObject() {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;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;} /* Create Arrays: */ cJSON *cJSON_CreateIntArray(int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && ichild=n;else suffix_object(p,n);p=n;}return a;} diff --git a/cJSON.h b/cJSON.h index b7a6cd3..97d529a 100644 --- a/cJSON.h +++ b/cJSON.h @@ -79,17 +79,17 @@ extern cJSON *cJSON_GetArrayItem(cJSON *array,int item); extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string); /* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ -extern const char *cJSON_GetErrorPtr(); +extern const char *cJSON_GetErrorPtr(void); /* These calls create a cJSON item of the appropriate type. */ -extern cJSON *cJSON_CreateNull(); -extern cJSON *cJSON_CreateTrue(); -extern cJSON *cJSON_CreateFalse(); +extern cJSON *cJSON_CreateNull(void); +extern cJSON *cJSON_CreateTrue(void); +extern cJSON *cJSON_CreateFalse(void); extern cJSON *cJSON_CreateBool(int b); extern cJSON *cJSON_CreateNumber(double num); extern cJSON *cJSON_CreateString(const char *string); -extern cJSON *cJSON_CreateArray(); -extern cJSON *cJSON_CreateObject(); +extern cJSON *cJSON_CreateArray(void); +extern cJSON *cJSON_CreateObject(void); /* These utilities create an Array of count items. */ extern cJSON *cJSON_CreateIntArray(int *numbers,int count);