* Add back sign reversal in nested object parse as error pointer value is negative, while error value is positive. Michael Clark <michael@metaparadigm.com> git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@8 327403b1-1117-474d-bef2-5cb71233fd97tags/json-c-0.10-20120530
@@ -1,3 +1,9 @@ | |||||
0.4 | |||||
* Fix additional error case in object parsing | |||||
* Add back sign reversal in nested object parse as error pointer | |||||
value is negative, while error value is positive. | |||||
Michael Clark <michael@metaparadigm.com> | |||||
0.3 | 0.3 | ||||
* fix pointer arithmetic bug for error pointer check in is_error() macro | * fix pointer arithmetic bug for error pointer check in is_error() macro | ||||
* fix type passed to printbuf_memappend in json_tokener | * fix type passed to printbuf_memappend in json_tokener | ||||
@@ -8,7 +8,7 @@ | |||||
</head> | </head> | ||||
<body> | <body> | ||||
<h2>JSON-C - A JSON implementation in C</h2> | <h2>JSON-C - A JSON implementation in C</h2> | ||||
<p>Latest release: <a href="json-c-0.3.tar.gz">json-c-0.3.tar.gz</a></p> | |||||
<p>Latest release: <a href="json-c-0.4.tar.gz">json-c-0.4.tar.gz</a></p> | |||||
<p>JSON-C implements a reference counting object model that allows you to easily | <p>JSON-C implements a reference counting object model that allows you to easily | ||||
construct JSON objects in C, output them as JSON formatted strings and parse | construct JSON objects in C, output them as JSON formatted strings and parse | ||||
JSON formatted strings back into the C representation of JSON objects.</p> | JSON formatted strings back into the C representation of JSON objects.</p> | ||||
@@ -1,5 +1,5 @@ | |||||
/* | /* | ||||
* $Id: json_tokener.c,v 1.15 2005/07/15 03:19:43 mclark Exp $ | |||||
* $Id: json_tokener.c,v 1.17 2005/07/26 07:49:11 mclark Exp $ | |||||
* | * | ||||
* Copyright Metaparadigm Pte. Ltd. 2004. | * Copyright Metaparadigm Pte. Ltd. 2004. | ||||
* Michael Clark <michael@metaparadigm.com> | * Michael Clark <michael@metaparadigm.com> | ||||
@@ -350,7 +350,7 @@ static struct json_object* json_tokener_do_parse(struct json_tokener *this) | |||||
} else { | } else { | ||||
obj = json_tokener_do_parse(this); | obj = json_tokener_do_parse(this); | ||||
if(is_error(obj)) { | if(is_error(obj)) { | ||||
err = (enum json_tokener_error)obj; | |||||
err = -(enum json_tokener_error)obj; | |||||
goto out; | goto out; | ||||
} | } | ||||
json_object_array_add(current, obj); | json_object_array_add(current, obj); | ||||
@@ -389,6 +389,9 @@ static struct json_object* json_tokener_do_parse(struct json_tokener *this) | |||||
printbuf_reset(this->pb); | printbuf_reset(this->pb); | ||||
state = json_tokener_state_object_field; | state = json_tokener_state_object_field; | ||||
start_offset = ++this->pos; | start_offset = ++this->pos; | ||||
} else { | |||||
err = json_tokener_error_parse_object; | |||||
goto out; | |||||
} | } | ||||
break; | break; | ||||
@@ -419,7 +422,7 @@ static struct json_object* json_tokener_do_parse(struct json_tokener *this) | |||||
case json_tokener_state_object_value: | case json_tokener_state_object_value: | ||||
obj = json_tokener_do_parse(this); | obj = json_tokener_do_parse(this); | ||||
if(is_error(obj)) { | if(is_error(obj)) { | ||||
err = (enum json_tokener_error)obj; | |||||
err = -(enum json_tokener_error)obj; | |||||
goto out; | goto out; | ||||
} | } | ||||
json_object_object_add(current, obj_field_name, obj); | json_object_object_add(current, obj_field_name, obj); | ||||
@@ -457,5 +460,5 @@ static struct json_object* json_tokener_do_parse(struct json_tokener *this) | |||||
mc_debug("json_tokener_do_parse: error=%d state=%d char=%c\n", | mc_debug("json_tokener_do_parse: error=%d state=%d char=%c\n", | ||||
err, state, c); | err, state, c); | ||||
json_object_put(current); | json_object_put(current); | ||||
return error_ptr((ptrdiff_t)-err); | |||||
return error_ptr(-err); | |||||
} | } |
@@ -121,6 +121,9 @@ int main(int argc, char **argv) | |||||
printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); | printf("new_obj.to_string()=%s\n", json_object_to_json_string(new_obj)); | ||||
json_object_put(new_obj); | json_object_put(new_obj); | ||||
new_obj = json_tokener_parse("{ foo }"); | |||||
if(is_error(new_obj)) printf("got error as expected\n"); | |||||
new_obj = json_tokener_parse("foo"); | new_obj = json_tokener_parse("foo"); | ||||
if(is_error(new_obj)) printf("got error as expected\n"); | if(is_error(new_obj)) printf("got error as expected\n"); | ||||