From: Stephen Dolan Date: Sun, 9 Sep 2012 17:09:05 +0000 (+0100) Subject: Bugfix for expanding objects. X-Git-Tag: jq-1.1~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a4ff3d4670b6a64f41569fa0f7ae1fba0781625f;p=jq Bugfix for expanding objects. --- diff --git a/c/jv.c b/c/jv.c index c4a5af1..1d5c981 100644 --- a/c/jv.c +++ b/c/jv.c @@ -58,6 +58,10 @@ jv jv_null() { return JV_NULL; } +jv jv_bool(int x) { + return x ? JV_TRUE : JV_FALSE; +} + /* * Numbers */ @@ -617,11 +621,12 @@ static jv* jvp_object_write(jv_complex* object, jvp_string* key) { if (slot) { // already has the key jvp_string_free_p(key); - } else { - slot = jvp_object_add_slot(object, key, bucket); - slot->value = jv_invalid(); + return &slot->value; } - if (slot == 0) { + slot = jvp_object_add_slot(object, key, bucket); + if (slot) { + slot->value = jv_invalid(); + } else { jvp_object_rehash(object); bucket = jvp_object_find_bucket(object, key); assert(!jvp_object_find_slot(object, key, bucket)); diff --git a/c/jv.h b/c/jv.h index 8d9ebad..6872ec5 100644 --- a/c/jv.h +++ b/c/jv.h @@ -52,6 +52,7 @@ jv jv_invalid(); jv jv_null(); jv jv_true(); jv jv_false(); +jv jv_bool(int); jv jv_number(double); double jv_number_value(jv);