From: Stephen Dolan Date: Sun, 16 Dec 2012 13:10:48 +0000 (+0000) Subject: Fix a bug uncovered by tests extracted from manual. X-Git-Tag: jq-1.2~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3ae8fb7371085f7507de6324c391c9953fc638e3;p=jq Fix a bug uncovered by tests extracted from manual. `null | length` should give 0, and now does. --- diff --git a/builtin.c b/builtin.c index f046e91..4f9fab5 100644 --- a/builtin.c +++ b/builtin.c @@ -191,6 +191,9 @@ static jv f_length(jv input) { return jv_number(jv_object_length(input)); } else if (jv_get_kind(input) == JV_KIND_STRING) { return jv_number(jv_string_length(input)); + } else if (jv_get_kind(input) == JV_KIND_NULL) { + jv_free(input); + return jv_number(0); } else { return type_error(input, "has no length"); }