Skip to content
Myr

Allow .[-1] in path expressions

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nicolas Williams · committed by Nico Williams · parent d319eb2 · Browse files · 1 file+8 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−0 removed

  • other:+8 added−0 removed

1 file+8 added−0 removed

modified:src/execute.c+8 added
685 unmodified lines
686 jv_dump_string_trunc(t, objbuf, sizeof(objbuf)));687 set_error(jq, jv_invalid_with_msg(msg));688 goto do_backtrack;689 }690 // $array | .[-1]691 if (jv_get_kind(k) == JV_KIND_NUMBER && jv_get_kind(t) == JV_KIND_ARRAY) {692 int idx = jv_number_value(k);693 if (idx < 0) {694 jv_free(k);695 k = jv_number(jv_array_length(jv_copy(t)) + idx);696 }697 }698 jv v = jv_get(t, jv_copy(k));699 if (jv_is_valid(v)) {700 path_append(jq, k, jv_copy(v));701 stack_push(jq, v);
649 unmodified lines