From f70b0622cf18650e073c4946838435eb5d306c31 Mon Sep 17 00:00:00 2001 From: Jakob Olsson <jakob.olsson@iopsys.eu> Date: Fri, 4 Oct 2019 09:47:50 +0200 Subject: [PATCH] json_editor: minor stylistic fixes and remove unused vars --- src/json-editor.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/json-editor.c b/src/json-editor.c index 04c0366..d809049 100644 --- a/src/json-editor.c +++ b/src/json-editor.c @@ -482,6 +482,7 @@ struct json_object *json_object_get_by_string_delimiter(struct json_object *src, for (char *key = strtok(fmt_cpy,delimiter); key != NULL; key = strtok(NULL, delimiter)) { int len = 0; + len = get_idx(key, idx, parsed_key); json_object_object_get_ex(outer_obj, parsed_key, &ptr); @@ -490,6 +491,7 @@ struct json_object *json_object_get_by_string_delimiter(struct json_object *src, return NULL; int index = (idx[i] == -1 ? json_object_array_length(ptr) -1 : idx[i]); + ptr = json_object_array_get_idx(ptr, index); } @@ -507,11 +509,10 @@ int json_object_del_by_string(struct json_object *src, char *fmt) int json_object_del_by_string_delimiter(struct json_object *src, char *fmt, const char *delimiter) { - struct json_object *ptr, *outer_obj, *j_idx; + struct json_object *ptr, *outer_obj; char fmt_cpy[1024] = {0}, parsed_key[32] = {0}; char *p, *key = fmt; int idx[32]; - int len; if (!src) { fprintf(stderr, "%s error: No object\n", __func__); @@ -534,6 +535,7 @@ int json_object_del_by_string_delimiter(struct json_object *src, char *fmt, cons if (p) { int len = 0; + len = get_idx(key, idx, parsed_key); json_object_object_get_ex(outer_obj, parsed_key, &ptr); @@ -542,6 +544,7 @@ int json_object_del_by_string_delimiter(struct json_object *src, char *fmt, cons return -1; int index = (idx[i] == -1 ? json_object_array_length(ptr) -1 : idx[i]); + ptr = json_object_array_get_idx(ptr, index); } -- GitLab