summaryrefslogtreecommitdiffstats
path: root/builtin.c
diff options
context:
space:
mode:
authorNicolas Williams <nico@cryptonector.com>2015-03-23 14:57:35 -0500
committerNicolas Williams <nico@cryptonector.com>2015-03-24 01:21:17 -0500
commitffa2832e3345c7a405dfaabf1deb923c07d2627c (patch)
treef028d227fda2b1493ec5258d3ff9a928e6f661e1 /builtin.c
parent0f7759f83106098312224e9cabc5464b8e19a3d0 (diff)
Drop name-less label/break for now
See #734 and #658.
Diffstat (limited to 'builtin.c')
-rw-r--r--builtin.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/builtin.c b/builtin.c
index 03c90814..462307dd 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1253,16 +1253,16 @@ static const char* const jq_builtins[] = {
"def paths: path(recurse(if (type|. == \"array\" or . == \"object\") then .[] else empty end))|select(length > 0);",
"def paths(node_filter): . as $dot|paths|select(. as $p|$dot|getpath($p)|node_filter);",
"def any(generator; condition):"
- " [label | foreach generator as $i"
+ " [label $out | foreach generator as $i"
" (false;"
- " if . then break elif $i | condition then true else . end;"
+ " if . then break $out elif $i | condition then true else . end;"
" if . then . else empty end)] | length == 1;",
"def any(condition): any(.[]; condition);",
"def any: any(.);",
"def all(generator; condition): "
- " [label | foreach generator as $i"
+ " [label $out | foreach generator as $i"
" (true;"
- " if .|not then break elif $i | condition then . else false end;"
+ " if .|not then break $out elif $i | condition then . else false end;"
" if .|not then . else empty end)] | length == 0;",
"def all(condition): all(.[]; condition);",
"def all: all(.);",
@@ -1373,8 +1373,8 @@ static const char* const jq_builtins[] = {
" def _until: "
" if cond then . else (next|_until) end;"
" _until;",
- "def limit($n; exp): if $n < 0 then exp else label | foreach exp as $item ([$n, null]; if .[0] < 1 then break else [.[0] -1, $item] end; .[1]) end;",
- "def first(g): label | foreach g as $item ([false, null]; if .[0]==true then break else [true, $item] end; .[1]);",
+ "def limit($n; exp): if $n < 0 then exp else label $out | foreach exp as $item ([$n, null]; if .[0] < 1 then break $out else [.[0] -1, $item] end; .[1]) end;",
+ "def first(g): label $out | foreach g as $item ([false, null]; if .[0]==true then break $out else [true, $item] end; .[1]);",
"def last(g): reduce g as $item (null; $item);",
"def nth($n; g): if $n < 0 then error(\"nth doesn't support negative indices\") else last(limit($n + 1; g)) end;",
"def first: .[0];",