Commit Graph
860 Commits
Author SHA1 Message Date
Nicolas Williams 8aecf82bfe WriteFile() on WIN32 when stdout isatty (fix #824)
Use WriteFile() and bypass stdio IFF stdout isatty and we're on Windows.
2015-06-22 20:47:47 -05:00
Nicolas Williams 10cbb9b580 Fix test failure introduced by previous commit 2015-06-22 18:32:28 -05:00
David Tolnay 4a316fbb5a fix errors flagged by clang static analyzer
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-20 16:08:56 -05:00
Nicolas Williams 7811ef1e17 Fix #811: use CommandLineToArgvW() and _wfopen() 2015-06-19 18:54:44 -05:00
David Tolnay b04cd6aada fix use after free in f_strptime 2015-06-19 00:34:27 -05:00
David Tolnay 1146b8b84a separate jq, oniguruma, sh, and man tests 2015-06-18 23:55:43 -05:00
Nicolas Williams 292f2d3208 argv[] may not be UTF-8 (fix #811) 2015-06-18 21:31:22 -05:00
Doug Luce 3cbefde376 Add alloca() discovery to configure.ac
The build failed on FreeBSD as there is no alloca.h.  This patch is
lifted from the autoconf documentation.
2015-06-18 19:19:15 -05:00
Nicolas Williams 0b42457929 Fix finites 2015-06-18 10:14:52 -05:00
David Tolnay 51a81c96f1 fix broken tests in manual.yml 2015-06-18 00:06:52 -05:00
Nicolas Williams 6083581fea Fix #802 2015-06-18 00:03:46 -05:00
Nicolas Williams 164b877bfa Add isnormal and related, rename *inf 2015-06-17 23:14:26 -05:00
Nicolas Williams b9c2a326ba Fix #814: raise on div-0, add inf isinf nan isnan 2015-06-17 19:58:55 -05:00
Nicolas Williams bdc1feb50e Fix infinite loop on error in sequence parser 2015-06-17 19:58:49 -05:00
Nicolas Williams 4ef04e5b5c Sequence parser: wait for RS on startup (fix #687)
Per-RFC7464.
2015-06-17 11:24:34 -05:00
Nicolas Williams 0f5345e515 Fix infinite loop on EOF bug 2015-06-17 11:23:58 -05:00
Aaron Peschel c95b4a8ab4 Add Missing Makefile Dependency
main.c requires version.h, but there is no logic marking this dependency
in the Makefile. This commit adds the dependency to the Makefile
template.
2015-06-09 19:01:20 -05:00
Nicolas Williams 520b429ca0 Clarify array destructuring docs 2015-06-09 17:29:48 -05:00
David Tolnay d3343d5113 array and object destructuring (fix #533)
`. as [$i, $j, $k] | ...`
`. as {a: $i, b: $j} | ...`
`. as [[[$i]], {a: $j}] | ...`
`foreach . as [$i, $j, $k] (...)`
`reduce . as {a: $i, b: $j} (...)`
2015-06-09 17:29:48 -05:00
cdnbacon 2e96fb2c9b Remove extension from links
The downloads are available without an extension.
2015-06-08 21:30:40 -05:00
Nicolas Williams 24a5e5b1b1 Add --tab and -indent n options 2015-06-03 20:20:11 -05:00
Nicolas Williams 74ecb88935 Improve usage message 2015-05-29 15:35:30 -05:00
Nicolas Williams 33874eb513 Fixup --slurpfile/argile docs 2015-05-29 15:25:30 -05:00
Nicolas Williams 1de56bc5df Add --slurpfile 2015-05-29 14:24:33 -05:00
Nicolas Williams 8a79f1d0a3 Better handling of stdout errors 2015-05-29 11:50:08 -05:00
Nicolas Williams f4f5d8882d Fix --argfile memleak (fix #799 part 2) 2015-05-29 11:49:45 -05:00
Nicolas Williams 4451c08007 Fix jv_load_file() (partial fix #799) 2015-05-29 11:48:10 -05:00
Nicolas Williams 89c57f7936 Revert "Fix #705 (--argfile weirdness)"
This reverts commit 3d2ab93b11.
2015-05-29 10:38:08 -05:00
Nicolas Williams 6af7857ccd Revert "Better argfile fix (#705, fix #736)"
This reverts commit 4f8567476d.
2015-05-29 10:37:58 -05:00
Nicolas Williams dff96aebcf Add jv_mem_strdup*() and callocs too 2015-05-25 21:20:37 -05:00
Nicolas Williams 8af52aaf52 Add ./configure --enable-all-static instead 2015-05-25 21:19:56 -05:00
Nicolas Williams d66e434fb4 Always add -all-static when --enable-static 2015-05-25 14:14:53 -05:00
Nicolas Williams 3700b457aa Update parser.c 2015-05-25 13:35:23 -05:00
Nicolas Williams 11f084f9a7 Keywords should be OK as object keys (fix #794)
With this change it's now OK to use keywords as object keys like so:

    {if:0}
2015-05-25 13:34:07 -05:00
Nicolas Williams 454a9dc042 Fix Windows build: util.c 2015-05-25 02:06:44 -05:00
Steven Penny ff458803ce Fix #793 2015-05-25 02:05:07 -05:00
Travis Gockel 110e009996 Add wrapping and clamping to jv_array_slice
Fix #716.  Fix #717.
2015-05-21 19:17:16 -05:00
Assaf Gordon 7b6a018dff Print offending object in runtime error messages
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-21 18:49:24 -05:00
Nicolas Williams a50e548cc5 Fix error message for @tsv 2015-05-21 18:20:15 -05:00
Nicolas Williams 4b258f7d31 Don't test input_filename/line_number yet 2015-05-21 17:55:27 -05:00
Assaf Gordon d1cb8ee0ad Add filename/line functions to jq (fix #753)
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-21 00:49:32 -05:00
Nicolas Williams c7f063188f Fix formatting error in manual.yml 2015-05-21 00:11:21 -05:00
Assaf Gordon a6460f4fe2 Report filename:line on runtime errors (fix #752)
With this patch, jq run-time errors printed to stderr will contain the
filename and line of the offending input.

But note that the JSON text parser does (yet) print the input filename
on parse error.  A jq run-time error is a jq program error, not
including syntax errors nor JSON text input format errors.

Examples:

With stdin and multiple lines:

    $ printf '{"a":43}\n{"a":{"b":66}}\n' | ./jq '.a+1'
    44
    jq: error (at stdin:2): object and number cannot be added

With multiple files:

    $ printf '{"a":43}' > 1.json
    $ printf '{"a":"hello"}\n' > 2.json
    $ printf '{"a":{"b":66}}\n' > 3.json
    $ ./jq '[.a]|@tsv' 1.json 2.json 3.json
    "43"
    "hello"
    jq: error (at 3.json:1): object is not valid in a csv row

With very long lines (spanning multiple `fgets` calls):

    $ (  printf '{"a":43}\n' ;
         printf '{"a":{"b":[' ; seq 10000 | paste -d, -s | tr -d '\n' ;
         printf ']}}\n' ;
         printf '{"a":"hello"}\n' ) | ./jq '[.a] | @tsv'
    "43"
    jq: error (at stdin:2): object is not valid in a csv row
    "hello"

With raw input:

    $ seq 1000 | ./jq --raw-input 'select(.=="700") | . + 10'
    jq: error (at stdin:700): string and number cannot be added

Caveat:
The reported line will be the last line of the (valid) parsed JSON data.
Example:

    $ printf '{\n"a":\n"hello"\n\n\n}\n' | ./jq '.a+4'
    jq: error (at stdin:6): string and number cannot be added
2015-05-20 23:38:22 -05:00
Nicolas Williams 2e257563a6 Fix spelling 2015-05-20 10:21:30 -05:00
Nicolas Williams ad0090964b Document gsub/3 2015-05-19 01:19:51 -05:00
Nicolas Williams cbdaeb4062 Fix gsub, add gsub/3 (fix #782) 2015-05-18 23:02:11 -05:00
Nicolas Williams cf1306f469 Add -all-static when --enable-static 2015-05-18 12:07:29 -05:00
Nicolas Williams 7675f7434a Fix --stream assertion 2015-05-11 21:36:47 -05:00
Nicolas Williams 821d6404b6 Add error injection library 2015-05-11 21:36:46 -05:00
Nicolas Williams e3cb1f76cd Report read errors too (and fix #772) 2015-05-11 21:36:26 -05:00