]> granicus.if.org Git - jq/commitdiff
Fix bug with path handling (used in assignments).
authorStephen Dolan <mu@netsoc.tcd.ie>
Sat, 11 May 2013 17:10:21 +0000 (18:10 +0100)
committerStephen Dolan <mu@netsoc.tcd.ie>
Sat, 11 May 2013 17:10:21 +0000 (18:10 +0100)
Closes #67

execute.c
tests/all.test

index 7deeb0aeaafb1723cf131f7e8481460df51e1845..e424ed8c55d6cc96c2e991ff3740612f7faa58fd 100644 (file)
--- a/execute.c
+++ b/execute.c
@@ -180,7 +180,8 @@ jv jq_next(jq_state *jq) {
         }
         if (!param) break;
         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>");
@@ -298,7 +299,7 @@ jv jq_next(jq_state *jq) {
       jv_free(path_end.value);
       jv path = jv_array();
       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));
       break;
index 83f91dae8ffb015e933c9ffd40e0df733a4105da..97af7e55a2a9de2ef981dba29339f9c5a72c305a 100644 (file)
@@ -574,3 +574,11 @@ unique
 .foo[.baz]
 {"foo":{"bar":4},"baz":"bar"}
 4
+
+.[] | .error = "no, it's OK"
+[{"error":true}]
+{"error": "no, it's OK"}
+
+[{a:1}] | .[] | .a=999
+null
+{"a": 999}