Fix bug with path handling (used in assignments).

Closes #67
This commit is contained in:
Stephen Dolan committed 2013-05-11 18:10:21 +01:00
1 parent 7ca5127fcc
commit e29db8d272
2 files changed
+11 -2

No files matched your search

+3 -2
View File
@@ -180,7 +180,8 @@ jv jq_next(jq_state *jq) {
} }
if (!param) break; if (!param) break;
jv_dump(jv_copy(param->sv.value), 0); jv_dump(jv_copy(param->sv.value), 0);
printf("<%d>", jv_get_refcnt(param->sv.value)); //printf("<%d>", jv_get_refcnt(param->sv.value));
printf("<%d>", param->sv.pathidx);
} }
if (backtracking) printf("\t<backtracking>"); if (backtracking) printf("\t<backtracking>");
@@ -298,7 +299,7 @@ jv jq_next(jq_state *jq) {
jv_free(path_end.value); jv_free(path_end.value);
jv path = jv_array(); jv path = jv_array();
for (int i=path_start.pathidx; i<path_end.pathidx; i++) { for (int i=path_start.pathidx; i<path_end.pathidx; i++) {
path = jv_array_set(path, i, jv_copy(jq->pathbuf[i])); path = jv_array_append(path, jv_copy(jq->pathbuf[i]));
} }
stack_push(jq, stackval_replace(path_start, path)); stack_push(jq, stackval_replace(path_start, path));
break; break;
+8
View File
@@ -574,3 +574,11 @@ unique
.foo[.baz] .foo[.baz]
{"foo":{"bar":4},"baz":"bar"} {"foo":{"bar":4},"baz":"bar"}
4 4
.[] | .error = "no, it's OK"
[{"error":true}]
{"error": "no, it's OK"}
[{a:1}] | .[] | .a=999
null
{"a": 999}