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

228 Commits

Author SHA1 Message Date
600e602548 Fix empty regular expression matches (fix #2565) 2023-07-09 12:51:53 -05:00
cac216a39c Fix manual on paths/1 to use boolean filter for its argument 2023-07-09 10:54:13 -05:00
ab1a68144d Support .a.[] and .a.[]? each syntax
Fixes #1699
2023-07-09 10:08:31 -05:00
d8072564c2 Fix nth/2 to emit empty on index out of range 2023-07-08 23:13:15 -05:00
cac3ea3726 Fix string multiplication by 0 (and less than 1) to emit empty string 2023-07-08 22:25:22 -05:00
88b45771bd Fix string multiplication with a value between 0.0 and 1.0
This commit fixes a regression of 6306ac89667c.
2023-07-08 22:25:22 -05:00
371abc73ba Fix deletion using assigning empty against arrays (fix #2051) 2023-07-07 20:11:10 -05:00
0ecededefa Remove deprecated filters: leaf_paths, recurse_down 2023-07-07 10:53:40 -05:00
6944d81bc8 Fix dumping large floating numbers (fix #2367) (#2661) 2023-07-06 21:44:17 +09:00
416e8ada7d builtin: add pick(stream)
pick(stream) works on both arrays and objects

Restrictions on the dot-paths are specified in manual.yml

See #2578
2023-07-05 23:48:31 -05:00
a881532b29 Fix exit code on JSON parse error (#2654) 2023-07-06 10:01:59 +09:00
95625c3fdb Validate JSON for --jsonarg
Fixes #2572
2023-07-05 16:30:14 -05:00
886a9b18b1 Make 0 divided by 0 results in NaN consistently (#2253) 2023-07-05 04:28:08 +09:00
dfd440f0de Setup path correctly after stream parsing a key:value object pair (#2642) 2023-07-05 04:23:52 +09:00
12ce4e3b54 Support optional else-branch for if-then-elif-end (#2598) 2023-07-04 07:51:29 +09:00
4dc2a2fb9d Implement scan/2 filter (#1961) 2023-07-04 07:48:29 +09:00
83f375cc83 Revamp sub/3 to resolve most issues with gsub (and sub with "g") (#2641)
The primary purpose of this commit is to rectify most problems with
`gsub` (and also `sub` with the `g` option), in particular fix #1425 ('\b'),
fix #2354 (lookahead), and fix #2532 (regex == `"^(?!cd ).*$|^cd "`).

This commit also partly resolves #2148 and resolves #1206 in that
`gsub` no longer loops infinitely; however, because the new `gsub`
depends critically on `match/2`, the behavior when regex == `""` is
sometimes non-standard.

The documentation has been updated to reflect the fact that `sub`
and `gsub` are intended to be regular in the second argument.

Also, `_nwise/1` has been tweaked to take advantage of TCO.
2023-07-04 07:46:29 +09:00
3c76a5b3f3 manual.yml: fix references to javascript, and clarify semantics of == (#2645)
remove inaccurate and confusing references to javascript; clarify semantics of ==
2023-07-03 12:35:41 +09:00
f88c4e5888 Move an example to the manual and regenerate man.test (#2639) 2023-06-30 07:45:29 +09:00
6d694a4a58 Validate module metadata to be an object (#2357) 2023-06-28 17:59:46 +09:00
98835eec24 Fix halt_error to print message without prefix in raw mode (fix #1902) (#2632) 2023-06-27 07:33:21 +09:00
73966c80ec Fix number lexer to avoid conflict with object indexing (#2254) 2023-06-27 07:24:49 +09:00
fac5553b22 Fix overflow exception of the modulo operator (fix #1176) (#2629) 2023-06-27 07:23:41 +09:00
5cebe86a7b Fix misspellings (#2609) 2023-06-13 20:01:20 +09:00
6c5c8f2115 fix handling of -0 (#2235) 2023-06-06 20:19:43 +09:00
4975b01a21 Merge old jqlang/jq master to the latest (#2596)
* Try making some GitHub Actions

* GHA: Add OS X, Windows, and Linux w/ scan-build builds

* Add link to discord server

Add link to discord server

* Update Ubuntu to 22.04 for GitHub Actions

* Remove if condition for Ubuntu build

* Fix MacOS OS on GitHub Actions

* Fix python3 package on GitHub Actions

* Disalbe valgrind

Getting failed tests: https://github.com/jqlang/jq/actions/runs/5113866588/jobs/9193542140#step:9:341

* Format file

* Fix macos build

* Fix syntax errors of windows build

https://github.com/jqlang/jq/actions/runs/5114162556/workflow

* Install windows package with choco

* Pin oniguruma to 5a24a49d710a9e3bb8ff11d12e1eae5a9f9df40c

MacOS build [fails](https://github.com/jqlang/jq/actions/runs/5114162555/jobs/9194126677#step:6:3160) due to

```
posix.c:94:3: error: implicit declaration of function 'onig_end' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
  onig_end();
```

The current `oniguruma` revision
6fa38f4084b448592888ed9ee43c6e90a46b5f5c (15 Mar 2017) lacks the following explicit declaration in src/onigposix.h:

```
ONIG_EXTERN int onig_end P_((void));
```

This was added to oniguruma in revision 5a24a49d710a9e3bb8ff11d12e1eae5a9f9df40c (8 Sep 2017).

Ref: https://github.com/jqlang/jq/issues/2381

* Revert windows build to use pacman

* Don't zip jq.exe

* Fixing windows build

* Update .gitattriutes for eol on Windows

* Skip workflow_dispatch for windows build

* Clean up builds

* Use LF line endings for all text

Ref: https://github.com/actions/checkout/issues/135

* Fix test that has rounding error

https://github.com/jqlang/jq/pull/2596#issuecomment-1568498993

* Enable CI for all

---------

Co-authored-by: Nicolas Williams <nico@cryptonector.com>
2023-06-01 10:09:39 -07:00
c4d39c4d22 Fix iterration problem for non decimal string
When the string transformation to number failed, all following
transformation failed too.

This happend because status in decNumberFromString function is
updated just in error case. Reusing the DEC_CONTEXT that failed
before results into error even if the string is valid number.
2022-05-26 16:02:10 -05:00
50a7022ea6 Rework pipenv requirement to be more relaxed
Keep a cached copy of the man tests that we can use when no manpage
changes are made. This allows automated systems that might not have
easy access to a pipenv to build and run tests.
2020-03-02 11:05:43 -05:00
5b9e63e4af fix typos 2020-01-14 10:18:22 -06:00
e74eab828e Fix nesting try/catch inside internal errors 2019-11-21 17:53:12 -05:00
cf4b48c7ba Save literal value of the parsed number to preserve it for the output
Extend jv_number to use decNumber for storing number literals. Any math
operations on the numbers will truncate them to double precision.
Comparisons when both numbers are literal numbers will compare them
without truncation.

Delay conversion of numbers to doubles until a math operation is performed,
to preserve precision. A literal jv_number will only need conversion to
double once, and will reuse the resultant double on subsequent
conversions.

Outputting literal jv_numbers preserves the original precision.

Add strong pthread requirement to manage contexts/allocations for
converting numbers between their decNumber, string, and double formats.
2019-10-22 14:11:04 -04:00
b34af08f67 Fix tests/jq.test for c72ed135 2019-03-25 09:56:53 -05:00
e01398c9db Fix tests/shtest broken by 2b4d51f 2019-03-25 09:52:42 -05:00
c72ed135e4 Allow keywords in more places (fix #1868) 2019-03-24 23:19:09 -05:00
3ea0199e03 Restore cfunction arity in builtins/0
Count arguments up-front at definition/invocation instead of doing it at
bind time, which comes after generating builtins/0 since e843a4f.
2019-02-26 22:39:57 -06:00
abed751e96 Bind libraries backward for consistent shadowing 2019-02-26 21:57:08 -06:00
141bb78e96 Fix regression on ~/.jq being a directory 2019-02-26 21:57:08 -06:00
30afc86af1 Fix alpine build 2019-02-26 21:40:59 -06:00
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
53a3f47076 Remove ruby dependency from mantests 2019-02-26 11:10:38 -06:00
76e72a301d Simplify and optimize SQLish builtins 2019-02-26 11:05:25 -06:00
a1626adb7e Fix bizarre bsearch/1 behaviour with a stream argument 2019-02-26 11:05:25 -06:00
d3abe3a468 Add more tests for any and all 2019-02-26 11:05:25 -06:00
6a0bdf6063 Remove scalars_or_empty 2019-02-26 11:05:25 -06:00
130152a2ac Ensure limit(0; ...) is empty 2019-02-21 04:11:41 -05:00
4f6045a94e Support "if" without "else" clause
Defaults the else clause to the identity filter "." if an else clause is
missing.

The following two jq programs are considered equivalent:

```
if .foo then
    .foo = "bar"
else
    .
end
```

```
if .foo then
    .foo = "bar"
end
```
2019-02-20 20:03:26 -06:00
1ef90acb38 Bind data imports properly when already resolved 2019-02-20 20:02:41 -06:00
2660b04a73 Fix infinite loop in index("") (fix #1815) 2019-02-08 20:40:55 -06:00
63ba2b1637 Add tests for built-in function contains 2019-01-22 11:00:08 -06:00
61cd6dbb3b contains should handle embedded NULs (fix #1732) 2019-01-18 22:33:46 -06:00