summaryrefslogtreecommitdiff
path: root/json_pointer.c
diff options
context:
space:
mode:
authordota17 <chenguopingdota@163.com>2020-03-27 13:04:50 +0800
committerdota17 <chenguopingdota@163.com>2020-04-03 11:28:04 +0800
commitc117d8a8a83d5bcdd433b05e1846ccb73eb3413d (patch)
tree3105c0ed492366534aa812754c649fc96a202abe /json_pointer.c
parenta8cec740f01ea4ec92e8728fcc82c2edb96bd7dd (diff)
downloadjson-c-c117d8a8a83d5bcdd433b05e1846ccb73eb3413d.tar.gz
add the disabling formatting coments and adjust the partial code manuly
Diffstat (limited to 'json_pointer.c')
-rw-r--r--json_pointer.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/json_pointer.c b/json_pointer.c
index 9531c03..b2c8526 100644
--- a/json_pointer.c
+++ b/json_pointer.c
@@ -41,8 +41,9 @@ static void string_replace_all_occurrences_with_char(char *s, const char *occur,
static int is_valid_index(struct json_object *jo, const char *path, int32_t *idx)
{
int i, len = strlen(path);
- /* this code-path optimizes a bit, for when we reference the 0-9 index range in a JSON array
- and because leading zeros not allowed */
+ /* this code-path optimizes a bit, for when we reference the 0-9 index range
+ * in a JSON array and because leading zeros not allowed
+ */
if (len == 1) {
if (isdigit((unsigned char)path[0])) {
*idx = (path[0] - '0');
@@ -124,12 +125,14 @@ static int json_pointer_set_single_path(
}
/* path replacements should have been done in json_pointer_get_single_path(),
- and we should still be good here */
+ * and we should still be good here
+ */
if (json_object_is_type(parent, json_type_object))
return json_object_object_add(parent, path, value);
- /* Getting here means that we tried to "dereference" a primitive JSON type (like string, int, bool).
- i.e. add a sub-object to it */
+ /* Getting here means that we tried to "dereference" a primitive JSON type
+ * (like string, int, bool).i.e. add a sub-object to it
+ */
errno = ENOENT;
return -1;
}
@@ -158,7 +161,8 @@ static int json_pointer_get_recursive(
return rc;
if (endp) {
- *endp = '/'; /* Put the slash back, so that the sanity check passes on next recursion level */
+ /* Put the slash back, so that the sanity check passes on next recursion level */
+ *endp = '/';
return json_pointer_get_recursive(obj, endp, value);
}