Make json_error_t transparent again
After looking at the new code for a few days, I didn't like it
anymore. To prepare for the future, a few fields will be added to the
json_error_t struct later.
This reverts commit 23dd078c8d. Some
adjustments were needed because of newer commits.
This commit is contained in:
@@ -31,7 +31,7 @@ int main(int argc, char *argv[])
|
||||
size_t flags = 0;
|
||||
|
||||
json_t *json;
|
||||
json_error_t *error;
|
||||
json_error_t error;
|
||||
|
||||
if(argc != 1) {
|
||||
fprintf(stderr, "usage: %s\n", argv[0]);
|
||||
@@ -61,10 +61,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
json = json_loadf(stdin, 0, &error);
|
||||
if(!json) {
|
||||
fprintf(stderr, "%d\n%s\n",
|
||||
json_error_line(error),
|
||||
json_error_msg(error));
|
||||
free(error);
|
||||
fprintf(stderr, "%d\n%s\n", error.line, error.text);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,8 +47,6 @@ json_object_iter_set_new
|
||||
json_dumps
|
||||
json_dumpf
|
||||
json_dump_file
|
||||
json_error_line
|
||||
json_error_msg
|
||||
json_loads
|
||||
json_loadf
|
||||
json_load_file
|
||||
|
||||
@@ -12,16 +12,13 @@
|
||||
int main()
|
||||
{
|
||||
json_t *json;
|
||||
json_error_t *error;
|
||||
json_error_t error;
|
||||
|
||||
json = json_load_file("/path/to/nonexistent/file.json", 0, &error);
|
||||
if(json)
|
||||
fail("json_load didn't return an error!");
|
||||
if(json_error_line(error) != -1)
|
||||
if(error.line != -1)
|
||||
fail("json_load_file returned an invalid line number");
|
||||
if(strcmp(json_error_msg(error), "unable to open /path/to/nonexistent/file.json: No such file or directory") != 0)
|
||||
if(strcmp(error.text, "unable to open /path/to/nonexistent/file.json: No such file or directory") != 0)
|
||||
fail("json_load_file returned an invalid error message");
|
||||
|
||||
free(error);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user