summaryrefslogtreecommitdiffstats
path: root/builtin.c
AgeCommit message (Collapse)Author
2015-08-23Move source files to src/David Tolnay
2015-08-11walk/1pkoppstein
2015-08-06Fix range(value;stream) (fix #886)David Tolnay
2015-07-24Implement flatten/0 in terms of flatten/1Santiago Lapresta
2015-07-24simplify implementation of bsearch to use "until" and avoid "last"; testedpkoppstein
2015-07-19Clean up trailing whitespaceDavid Tolnay
2015-07-10input_filename should never emptyNicolas Williams
2015-07-09Fixing missing D in LIBM_DDD_NO macro nameMike Fletcher
2015-07-01strftime wrong day-of-week (fix #838)David Tolnay
2015-06-27Add `pow`, better libm detection (fix #443)Nicolas Williams
2015-06-26Add streaming utilities (fix #827)Nicolas Williams
2015-06-23Add combinations/0 and combinations/1Santiago Lapresta
2015-06-20fix errors flagged by clang static analyzerDavid Tolnay
builtin.c: bug - free of uninitialized jv compile.c: missing assertion jq_test.c: buggy logic / unreachable code jv.c: missing assertion jv_alloc.c: false positive - intentional read of uninitialized memory jv_file.c: dead code
2015-06-19fix use after free in f_strptimeDavid Tolnay
2015-06-18Add alloca() discovery to configure.acDoug Luce
The build failed on FreeBSD as there is no alloca.h. This patch is lifted from the autoconf documentation.
2015-06-18Fix `finites`Nicolas Williams
2015-06-17Add isnormal and related, rename *infNicolas Williams
2015-06-17Fix #814: raise on div-0, add inf isinf nan isnanNicolas Williams
2015-05-25Fix #793Steven Penny
2015-05-21Print offending object in runtime error messagesAssaf Gordon
When reporting an error to the user, add information about the offending object/value (possibly truncated). The goal is to give a user some context regarding which input object caused the runtime error. Examples: $ echo '"hello"' | ./jq '-.' jq: error: string ("hello") cannot be negated $ echo '"very-long-string"' | ./jq '-.' jq: error: string ("very-long-...) cannot be negated $ echo '["1",2]' | ./jq '.|join(",")' jq: error: string (",") and number (2) cannot be added $ echo '["1","2",{"a":{"b":{"c":33}}}]' | ./jq '.|join(",")' jq: error: string (",") and object ({"a":{"b":{...) cannot be added $ echo '{"a":{"b":{"c":33}}}' | ./jq '.a | @tsv' jq: error: object ({"b":{"c":33}}) cannot be tsv-formatted, only array (Fix #754)
2015-05-21Fix error message for @tsvNicolas Williams
2015-05-21Add filename/line functions to jq (fix #753)Assaf Gordon
This adds `input_filename` and `input_line_number` built-in functions for use in, for example, `error` messages. Example: $ printf '{"a":1}\n{"a":2}\n' > 4.json $ printf '{"a":"hello"}\n' > 5.json $ ./jq '{ "file":input_filename, "line":input_line_number, "value":.a }' 4.json 5.json { "file": "4.json", "line": 1, "value": 1 } { "file": "4.json", "line": 2, "value": 2 } { "file": "5.json", "line": 1, "value": "hello" }
2015-05-20Fix spellingNicolas Williams
2015-05-18Fix gsub, add gsub/3 (fix #782)Nicolas Williams
2015-04-23from_entries is broken (fix #767)Nicolas Williams
2015-04-22regex functions: report informative error if not available.Assaf Gordon
When trying to use the new regex functions (match/test/sub/capture/etc) in a JQ that was compiled without the ONIGURAMA regex library, report an informative error message instead of a 'not defined' error. Before: $ echo '"foo"' | ./jq-old 'test("foo")' jq: error: test/1 is not defined at <top-level>, line 1: test("foo") jq: 1 compile error After: $ echo '"foo"' | ./jq 'test("foo")' jq: error: jq was compiled without ONIGURAMA regex libary. match/test/sub and related functions are not available.
2015-04-20Handle NUL in escaped-string outputAssaf Gordon
When escaping string (e.g. for `@tsv` or `@csv` outputs), escape NULs as '\0'. Existing behaviour, unchanged by this patch: $ echo '"a\u0000b"' | ./jq '.' "a\u0000b" $ echo '"a\u0000b"' | ./jq -r '.' | od -a 0000000 a nul b nl 0000004 When using `@tsv`, escape NUL to `\0`: $ echo '"a\u0000b"' | ./jq -r '[.]|@tsv' a\0b $ echo '"a\u0000b"' | ./jq '[.]|@tsv' "a\\0b"
2015-04-15@tsv: escape \r, \n, \\Assaf Gordon
When using '@tsv' output format with '-r' option, escape \r, \n and \\ in addition to \t. Example: $ printf '{"id":"hello\\ttab\\nworld","x":43 }' | jq . { "id": "hello\ttab\nworld", "x": 43 } Before: newlines are not escaped, generating invalid TSV output: $ printf '{"id":"hello\\ttab\\nworld","x":43 }' \ | ./jq-old -r '[.id,.x] | @tsv' hello\ttab world 43 After: newlines are properly escaped: $ printf '{"id":"hello\\ttab\\nworld","x":43 }' \ | ./jq-new -r '[.id, .x] | @tsv' hello\ttab\nworld 43 Before: backslashes themselves are not escaped, so there's no way to distinguish between escaped characters and 'real' backslashes (in the example below, there is should not be newline, despite the output containing "\n". $ printf '{"x":"hello\\ttab\\\\new world"}' \ | ./jq-old -r '[.x]|@tsv' hello\ttab\new world After: backslashes are escaped: $ printf '{"x":"hello\\ttab\\\\new world"}' \ | ./jq-new -r '[.x]|@tsv' hello\ttab\\new world
2015-03-31Test fix for mktimeNicolas Williams
2015-03-30Include filename and lineno in error messagesNicolas Williams
2015-03-24Drop name-less label/break for nowNicolas Williams
See #734 and #658.
2015-03-23Fix #735William Langford
2015-03-09Add more date builtinsNicolas Williams
2015-03-06Fix #718Nicolas Williams
2015-03-06Add date builtins (fix #364)Nicolas Williams
Windows support for strptime() is missing. We can add a copy of one from a BSD later.
2015-02-18Fix #702Nicolas Williams
2015-02-15Make Oniguruma/regexp optionalNicolas Williams
Tests won't pass if built without Oniguruma. We don't have a way to make a test optional yet. That will come later. For now the ability to reduce build-time dependencies could really help some users.
2015-02-13Reduce number of msg callback typedefsNicolas Williams
2015-02-10Enhance from_entries to better deal with Amazon AWS TagsKim Toms
2015-01-14Empty arrays join/1 to an empty string, fixes #668 bug introduced by 9760245Joel Purra
2015-01-14Add `debug` and `stderr` builtinsNicolas Williams
And refactor setup of jv dump flags.
2015-01-14join/1: respect empty strings (fix #668)Nicolas Williams
2014-12-31Further module system revamp (fix #659)Nicolas Williams
To import a module now use: # Import module.jq file: import "relative/path/to/module" as foo; # Use the module's defs as foo::<def-name> To import a JSON file: # Read file.json: import "relative/path/to/file" as $foo; # # Use as $foo::foo Using `-L` now drops the builtin library path and appends the requested path to the empty array (or the result of an earlier `-L`). Support for the `$JQ_LIBRARY_PATH` environment variable has been removed.
2014-12-30Add `label $name | EXP`; fix `break`Nicolas Williams
This is to fix the problem where `break` is dynamic, not lexical. With this it should be possible to do this sort of thing: label $break | inputs | if ... then $break|error else . end This is a backwards-incompatible change for master, but the previous `break` hadn't shipped yet. Still needed: - testing
2014-12-30Remove string indexing by string (fix #454)Nicolas Williams
This turns out to have been a bad idea: "foo"|.["o"] it interacts badly with `path()`. See #454 for the gory details.
2014-12-27bsearch(x) (binary search): builtin.c (tested), with documentation and test ↵pkoppstein
case. Always yields an integer (even if input is unsorted); returns (-1 - ix) if x is not in input array.
2014-12-27ascii_upcase/0 and ascii_downcase/0pkoppstein
2014-12-27Add `debug` builtinNicolas Williams
And refactor setup of jv dump flags.
2014-12-27Don't force C API users to set input cbNicolas Williams
2014-12-26Add Streaming parser (--stream)Nicolas Williams
Streaming means that outputs are produced as soon as possible. With the `foreach` syntax one can write programs which reduce portions of the streaming parse of a large input (reduce into proper JSON values, for example), and discard the rest, processing incrementally. This: $ jq -c --stream . should produce the same output as this: $ jq -c '. as $dot | path(..) as $p | $dot | getpath($p) | [$p,.]' The output of `jq --stream .` should be a sequence of`[[<path>],<leaf>]` and `[[<path>]]` values. The latter indicate that the array/object at that path ended. Scalars and empty arrays and objects are leaf values for this purpose. For example, a truncated input produces a path as soon as possible, then later the error: $ printf '[0,\n'|./jq -c --stream . [[0],0] parse error: Unfinished JSON term at EOF at line 3, column 0 $