Fix for printing values that contain % literals. Thanks to Jimmy Tam!

git-svn-id: http://svn.code.sf.net/p/cjson/code@11 e3330c51-1366-4df0-8b21-3ccf24e3d50e
This commit is contained in:
Dave Gamble 2009-11-06 15:41:44 +00:00
parent 7ca2c994a7
commit 37da1d2493

View File

@ -312,7 +312,7 @@ static char *print_array(cJSON *item,int depth)
len+=strlen(ret)+3;
out=(char*)cJSON_realloc(out,len);
ptr=out+strlen(out);
ptr+=sprintf(ptr,ret);
ptr+=sprintf(ptr,"%s",ret);
if (child->next) {*ptr++=',';*ptr++=' ';*ptr=0;}
child=child->next;
cJSON_free(ret);
@ -374,9 +374,9 @@ static char *print_object(cJSON *item,int depth)
out=(char*)cJSON_realloc(out,len);
ptr=out+strlen(out);
for (i=0;i<depth;i++) *ptr++='\t';
ptr+=sprintf(ptr,str);
ptr+=sprintf(ptr,"%s",str);
*ptr++=':';*ptr++='\t';
ptr+=sprintf(ptr,ret);
ptr+=sprintf(ptr,"%s",ret);
if (child->next) *ptr++=',';
*ptr++='\n';*ptr=0;
child=child->next;