Commit Graph
38 Commits
Author SHA1 Message Date
Nicolas Williams 11c528d04d Add setlocale() call (fix #1740) 2023-09-06 14:05:10 -05:00
Mattias WadmanandNicolas Williams fdab39bc7b Build windows 64bit binary using UCRT64 (#2832)
* Build windows 64bit binary using UCRT64

Is the default and recommended msystem setting. Will produce
binaries that are compatible with windows 10 and later.

Also run tests for 32bit build.

Related to #2831

* Use jq -b in tests/shtest

* Add Windows strptime

* Make Windows-optional tests not run on Windows again

---------

Co-authored-by: Nicolas Williams <nico@cryptonector.com>
2023-08-12 20:18:45 +02:00
itchyny a692060129 Change the default color of null to Bright Black 2023-08-05 23:21:12 -05:00
itchyny fd0d475694 Fix a test case added in #2790 2023-08-02 22:33:09 +09:00
Nicolas Williams 27a4d5757e Require a main program (fix #2785) 2023-08-01 23:06:01 -05:00
itchyny 0f80921268 Fix constant folding of division and reminder with zero divisor
Previously constant folding of zero division (e.x. 1/0) produces a
compile error. This was incorrectly implemented by checking if the
division result is infinite, so produces wrong results compared to the
query where no constant folding is processed (e.x. 1e308/0.1). This
patch delays the operation when the divisor is zero. This makes the
results more consistent, but changes the exit code on zero division from
3 to 5. Also 0/0 now produces the zero division error, not NaN.

This patch also fixes the modulo operation. Previously constant folding
logic does not take care of the % operator, but now it folds if the both
dividend and divisor are safe numbers to cast to the integer type, and
the divisor is not zero. This patch also fixes some code that relies on
undefined cast behaviors in C. The modulo operation produces NaN if
either the dividend or divisor is NaN.
2023-07-31 15:39:13 -05:00
itchyny a1e791acf8 Rename --nul-output to --raw-output0, abort on string containing NUL
The option naming --nul-output was confusing, especially when we have a
similar option for input stream in the future (--nul-input vs --null-input).
Based on the observation of other command line tools, we rename the option
to --raw-output0. We also drop the short option -0 to avoid confusion on
introducing the NUL-delimited input option.

Unlike the other command line tools outputting file names with NUL delimiter,
jq deals with JSON, and its strings may contain NUL character. To protect
users from the risk of injection attacks, we abort the program and print an
error message before outputting strings including NUL character. Closes #2683.
2023-07-26 23:55:00 -05:00
itchyny 98f709d0c1 Fix stderr to output string with no decoration (fix #2063) 2023-07-23 17:06:00 -05:00
Nicolas Williams f64ef1a7d7 Fix --stream-errors w/o --stream, and doc+test (close #2748) 2023-07-23 03:33:28 -05:00
itchyny c9c45d7f03 Add tests for --arg, --argjson, and similar options 2023-07-22 12:29:24 -05:00
itchyny 0615d4982c Respect NO_COLOR environment variable to disable color output 2023-07-19 00:05:41 -05:00
0b558f6ed4 Make object key color configurable (close #1739, #1791, #2638)
Co-authored-by: David Haguenauer <ml@kurokatta.org>
Co-authored-by: Eric Pruitt <eric.pruitt@gmail.com>
2023-07-18 17:53:29 -05:00
Emanuele Torre 4b3090a9ab Make stream parser error when a non-empty object or array is used as key
Fixes #2463
2023-07-17 13:15:55 -05:00
itchyny 6944d81bc8 Fix dumping large floating numbers (fix #2367) (#2661) 2023-07-06 21:44:17 +09:00
itchyny a881532b29 Fix exit code on JSON parse error (#2654) 2023-07-06 10:01:59 +09:00
Mattias Wadman 95625c3fdb Validate JSON for --jsonarg
Fixes #2572
2023-07-05 16:30:14 -05:00
Mattias Wadman dfd440f0de Setup path correctly after stream parsing a key:value object pair (#2642) 2023-07-05 04:23:52 +09:00
itchyny 98835eec24 Fix halt_error to print message without prefix in raw mode (fix #1902) (#2632) 2023-06-27 07:33:21 +09:00
Josh Soref 5cebe86a7b Fix misspellings (#2609) 2023-06-13 20:01:20 +09:00
Anthony Sottile 6c5c8f2115 fix handling of -0 (#2235) 2023-06-06 20:19:43 +09:00
Nicolas Williams e01398c9db Fix tests/shtest broken by 2b4d51f 2019-03-25 09:52:42 -05:00
Muh Muhten 141bb78e96 Fix regression on ~/.jq being a directory 2019-02-26 21:57:08 -06:00
Muh Muhten 30afc86af1 Fix alpine build 2019-02-26 21:40:59 -06:00
Nicolas Williams 6df393c902 Make shtest verbose 2 diag. alpine build failure
Temporarily(?) make tests/shtest verbose to help diagnose Travis alpine
build failures.
2019-02-26 11:17:20 -06:00
Muh Muhten 6a0bdf6063 Remove scalars_or_empty 2019-02-26 11:05:25 -06:00
Ryoichi KATO 6d3d2750ec fix --exit-code issues #1142 and #1139
* Set default error code to -4 in main(), Fixes #1142
* fix --exit-code with more than one object in input, Fixes #1139
    - Return code 1 or 4 based on last output, not last input.
2018-12-18 14:17:47 -06:00
David Fetter 2ce1e323df Change backticks to the more legible $() 2018-02-20 15:54:21 -05:00
William Langford 79ece35981 Fix hang for slurped inputs with trailing newline 2017-12-04 20:10:56 -05:00
William Langford f06deb828a Fix #1534 2017-12-04 19:20:58 -05:00
Nico Williams 6d89e297fe Add JQ_COLORS env var for color config (fix #1252) 2017-04-29 14:00:52 -04:00
Nicolas Williams 8ea21a54ad Add halt, halt_error builtins (fix #386) 2017-02-26 16:34:56 -06:00
Nicolas Williams 8619c6e060 Make test/shtest test of constant folding robust
Rather than testing that a constant expression produces so many
instructions, test that a variety of of such expressions produce the
same number of instructions.  This will make future changes in the
compiler less likely to break this test.
2017-02-25 19:13:28 -06:00
Nicolas Williams c514368f98 Make it possible to run tests with set -x
One can now run:

    make TRACE_TESTS=1 check

to get detailed output
2016-01-17 12:45:01 -06:00
Nicolas Williams 8f6f28c8d3 Make it easier to use jq with shebangs (fix #1044)
Allow a continuation on a comment immediately after a shebang to make
this traditional hack possible:

    #!/bin/sh
    # this next line is ignored by jq \
    exec jq -f "$0" "$@"
    # jq code follows

But continue only on the first line following a shebang, and only if
it's a comment.
2015-12-14 22:08:17 -08:00
Nicolas Williams c4524da3e0 EOF after newline in string mishandled (fix #951) 2015-09-22 20:11:54 -07:00
Nicolas Williams b119853aef Test main.c fix for #817 2015-08-13 09:08:37 -07:00
Nicolas Williams 25d47ca08e Add streaming utilities (fix #827) 2015-06-26 20:45:06 -05:00
David Tolnay 1146b8b84a separate jq, oniguruma, sh, and man tests 2015-06-18 23:55:43 -05:00