1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00
Commit Graph

1579 Commits

Author SHA1 Message Date
Mattias Wadman
5a52553a3b Make sure to init key and dbl_key also on win32
Hopefully fixes page fault for mingw build

Related to #2831
2023-08-10 13:06:03 -05:00
Mattias Wadman
765a5c77eb Make sure to init dtoa_ctx_key also on win32 (#2834)
Fixes page fault for mingw build

Related to #2831
2023-08-10 18:53:50 +02:00
Naïm Favier
d1a6da2205 docs: fix delpaths description 2023-08-09 18:20:04 +02:00
itchyny
a692060129 Change the default color of null to Bright Black 2023-08-05 23:21:12 -05:00
Emanuele Torre
f94a9d463f Let error(null) throw null
This patch removes the weird behaviour of jv_invalid_with_msg(jv_null())
that returns jv_invalid() (i.e. empty), instead of a boxed jv_null().

The previous behaviour of  null|error  was obviously unintentional, and
allowing is jv_invalid_with_msg() to return values on which you can't
call jv_invalid_get_msg() is only error prone.
2023-08-04 17:38:52 -05:00
Emanuele Torre
3b6e7ddd72 Constant fold all kinds of constants
This patch exports all the binary operator builtins functions from
builtin.c and uses them for constant folding in the parser, allowing
constant folding to work will all kinds and combinations of constants.

Now string*number,  $ARGS+$ARGS,  string/string,  etc will also be
constant folded and the implementation of constant folded operators and
runtime operators will be the same.

And thanks to the new ERRORK bytecode operation, errors are constant
folded too! (e.g. 1 / 0   [] * {}   etc)
2023-08-04 11:47:34 -05:00
Emanuele Torre
5fc5453409 Add ERRORK opcode to trigger constant errors 2023-08-04 11:47:34 -05:00
Nicolas Williams
71941a0d47 Clarify the // operator (fix typo) 2023-08-03 23:24:12 -05:00
Emanuele Torre
dcaf701ef6 Simplify String rule in parser (#2805)
Use a StringStart component that is either FORMAT QQSTRING_START or
QQSTRING_START instead of having two similar rules for String.

This is simpler and avoids having to use an untyped mid-rule action
component to copy FORMAT at the top of the stack before QQString, and
having to use jv_free($<literal>3) instead of jv_free($1) just to make
bison not complain about the "unused" mid-rule component.
2023-08-04 08:21:25 +09:00
Nicolas Williams
d8327a90b8 Add a bit more text about generators 2023-08-03 14:41:53 -05:00
Nicolas Williams
ddef804945 Clarify the // operator (close #2189) 2023-08-03 14:41:53 -05:00
itchyny
949d38e6dc Fix crash on numeric comparison (ref #2804) (#2818) 2023-08-03 23:19:52 +09:00
Owen Ou
53a62cf2b0 Improve README to be more structural and more readable (#2814) 2023-08-03 22:27:09 +09:00
Nicolas Williams
ff4bf68b29 Enable stack protection (CI release executables) 2023-08-02 12:19:19 -05:00
itchyny
fd0d475694 Fix a test case added in #2790 2023-08-02 22:33:09 +09:00
itchyny
680baeffeb Fix rounding small (but not too small) numbers to zero on calculation
Co-authored-by: Leonid S. Usov <leonid.s.usov@gmail.com>
2023-08-02 00:32:32 -05:00
Nicolas Williams
27a4d5757e Require a main program (fix #2785) 2023-08-01 23:06:01 -05:00
pkoppstein
044b38595c NEWS.md - sub and gsub (#2809) 2023-08-02 08:38:27 +09:00
Owen Ou
161ab0402b Fix typo in CI env vars for Linux build (#2810)
For some reason, the env vars are set correctly without refering the variable in `matrix` case-sensitvely:

```
2023-08-01T05:05:58.4626090Z env:
2023-08-01T05:05:58.4626367Z   AR: arm-linux-gnueabihf-ar
2023-08-01T05:05:58.4626690Z   CHOST: arm-linux-gnueabihf
2023-08-01T05:05:58.4626961Z   CC: arm-linux-gnueabihf-gcc
2023-08-01T05:05:58.4627332Z   CPP: arm-linux-gnueabihf-cpp
2023-08-01T05:05:58.4627662Z   CXX: arm-linux-gnueabihf-g++
```

For clarify, we update them to match the definitions. Besides, `CXX` is
not needed and removed.
2023-08-01 07:32:52 -07:00
Nicolas Williams
29698118c5 Update download page with new release key 2023-07-31 23:59:09 -05:00
Emanuele Torre
96263f2e4b Don't unnecessarily ignore missing-field-initializers warnings 2023-07-31 23:16:02 -05:00
Nicolas Williams
90a6b2d9e6 Re-generate src/parser.[ch] 2023-07-31 20:04:41 -05:00
pkoppstein
4d4c17ca6a Simple and efficient implementation of walk/1 (#2795) 2023-08-01 07:54:21 +09: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
Emanuele Torre
6716e23ae6 Declare cfunction.fptr as jv (*)() to avoid having to cast everywhere
You only need to specify the return type in a function pointer
declaration in C.

If you use () in the declaration, the function pointer can be called
with any arguments, and the type of the arguments is decided for each
function call based on the types of the arguments used for the call.
(To declare a function pointer for a function with no arguments, you use
`(void)'.)

Since all the cfunction structs have a  fptr  that points to a functions
that return jv, not void, we can we can just declare cfunction.fptr as
jv (*)()  and avoid having those annoying and technically not C-standard
compliant casts everywhere.
2023-07-31 15:28:01 -05:00
Mattias Wadman
f61f842ad0 Massage --help text to use max 72 characters width 2023-07-31 18:05:35 +02:00
Nicolas Williams
69deec63e5 Add new release public key 2023-07-31 10:12:18 -05:00
github-actions[bot]
77c4c8afc5 Update signatures of 1.7rc1 2023-07-31 09:31:05 -05:00
itchyny
c8e28da129 Redesign website (#2628)
* Bump up Bootstrap to v5.3.1, Bootstrap Icon to v1.10.5.
* Use autoComplete.js to drop dependency on jQuery and typeahead.js.
* Support dark mode.
* New svg logo and icon with responsive color mode support.
* Normalize section ids to lower kebab-case for easiness of linking.
* Use relative paths for links for local development (--root /output).
* Various markup cleanups and accessibility improvements.
2023-07-31 09:52:52 +09:00
Owen Ou
4af3f99728 Update bug_report.md with Discord link jq-1.7rc1 2023-07-30 04:28:38 +02:00
Owen Ou
82f7f772e6 Redirect questions to Discord
We now have an official Discord server and most maintainers are hanging
out there. It would be a good idea to redirect questions to Discord.
2023-07-30 04:28:38 +02:00
Nicolas Williams
f733a1535e Use -Wno-cast-function-type to quiet many warnings 2023-07-30 04:25:54 +02:00
Nicolas Williams
c8b30dff4a Add JQ_FALLTHROUGH and use it to quiet warnings 2023-07-30 04:25:54 +02:00
Emanuele Torre
a6eb055c47 Fix typo in manual: "-seq" => "--seq" 2023-07-29 18:27:59 -05:00
Owen Ou
ee2a215f2e Backfill with references in NEWS.md (#2788)
Backfill with references to PRs & issues in NEWS.md
2023-07-29 07:38:08 -07:00
pkoppstein
70bbd10b0b NEWS.md: tweaks
correct grammar, add attributions, clarify abs
2023-07-28 17:25:41 -05:00
Mattias Wadman
28af007518 Replace NEWS with NEWS.md with more details and examples
Changes mentioned based on picking user facing changes from:
git log --oneline -r master...jq-1.6 | grep -v Merge
2023-07-28 13:43:14 -05:00
pkoppstein
336c3deb8a Test negative indices in path expressions 2023-07-28 12:34:26 -05:00
Nicolas Williams
086a156ec3 Allow .[-1] in path expressions 2023-07-28 12:34:26 -05:00
itchyny
d319eb2187 Fix PR creation by using fully qualified refname on release 2023-07-28 17:47:51 +09:00
Emanuele Torre
17889a1a85 Fix memory leak for { $foo: bar }
{ BINDING: ExpD } wasn't freeing BINDING.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60865
2023-07-27 20:59:35 -05:00
itchyny
5b9d0750db Fix PR creation by specifying the branch on release 2023-07-28 10:25:06 +09:00
itchyny
b33725c96e Fix gh pr create option on release 2023-07-28 10:04:35 +09:00
itchyny
72f147e82e Fix release job to create a pull request for signatures 2023-07-27 19:18:16 -05:00
itchyny
4160a36fb5 Commit GPG signatures on release 2023-07-27 17:01:24 -05:00
itchyny
668607e305 Enable gamma, drem on macOS 2023-07-26 23:56:01 -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
pkoppstein
13fbe98dff manual.yml: remove contingent tests
Also clarify non-prescriptive nature of some tests in jq.test
2023-07-25 23:43:57 -05:00
pkoppstein
7b725378b9 builtin.jq: naive abs/0
manual.yml explains that the def is naive, and mentions fabs, etc.
2023-07-25 23:43:57 -05:00
Emanuele Torre
3a1ba0c42d Only care about RS when parsing with --seq
RS should only only have special meaning when parsing json-seq.
Before this fix, RS was sometimes treated as a value terminator, causing
weird results.

Bug discovered by OSS fuzz.
Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60835
2023-07-25 16:42:32 -05:00