Compare commits

...
1677 Commits
Author SHA1 Message Date
Jay Hemnani ac35c7dcbb Default the day of the month to 1 in strptime/1 (#3679)
A format without %d left the day of the month at 0, which mktime and
todate read as the last day of the previous month, and the weekday was
wrong for dates in January and February of 1900 and 2100.

Start parsing from the 1st, so a format without a day now gives the
first of the month, and a time-only format no longer outputs the 8 and
367 placeholders for the weekday and day of the year. This also fixes
the weekday of dates in January and February of 1900 and 2100.
2026-10-25 14:40:52 +09:00
Michiel van Slobbe 864d769d88 Implement ascii_downcase and ascii_upcase in C (#3689)
Both were defined as explode | map(...) | implode, which took 4 seconds
on a 10 MB string, about 90 times as long as parsing it.

Change the case of A-Z or a-z a byte at a time in C, copying multibyte
UTF-8 sequences unchanged, so the output stays the same and the 10 MB
case now takes about 60 ms including parsing. On a non-string input the
error now names the function, "ascii_downcase input must be a string",
instead of "explode input must be a string".
2026-10-25 14:18:21 +09:00
Huang-404-Q bd56a74562 Fix halt_error adding a newline to non-string output (#3694)
The manual says halt_error prints its input with no decoration, not
even a newline, but non-string values such as {"a":"xyz"} were printed
with a trailing newline.

Dump non-string values to JSON and print them the same way as strings,
so {"a":"xyz"} | halt_error(1) now writes exactly {"a":"xyz"} to stderr.
2026-10-24 15:19:14 +09:00
itchyny da4da65c0c docs: rewrite the tutorial (#3631)
The tutorial is where most people meet jq, but it was missing key
filters like select and abbreviated commands in ways that are hard for
beginners to follow.

Grow the page from 7 examples to 24, newly covering -r and -c, chained
paths and slicing, map, sort_by, group_by, select, test, to_entries,
from_entries, with_entries, string interpolation and @tsv. The sample
data is pinned with the API's until parameter and the outputs avoid
GitHub account data, so running the commands gives exactly the output
shown.
2026-10-24 09:41:07 +09:00
Douglas Adolph 53bbd4a3f9 docs: add ldconfig and make clean to the README source build (#3692) 2026-10-24 09:33:07 +09:00
qodelicious 49fbca1242 docs: explain that semicolons separate function arguments (#3685)
The manual's "Defining Functions" section shows only one-argument
functions, so it never says how to pass more than one. This adds a short
paragraph: arguments are separated by `;` in both `def f(a; b):` and
`f(.x; .y)`, and `f(.x, .y)` instead calls a one-argument `f` with the
filter `.x, .y`. It also adds an example for each. `tests/man.test` and
`jq.1.prebuilt` are regenerated.

Fixes #2163
2026-10-22 20:24:55 +02:00
qodelicious e440cccc0a docs: fix arithmetic update-assignment equivalence (#3682)
The manual said `a op= b` is equivalent to `a |= . op b`. It is actually
equivalent to `(b as $b | a |= . op $b)`: the right-hand side gets `.`
as input, not the value being updated, and each value it outputs gives a
separate result.

This updates the description and adds two examples, `.a += .b` and `.a
+= (1,2)`. `tests/man.test` and `jq.1.prebuilt` are regenerated.

Fixes #2119, fixes #2407
2026-10-22 20:23:52 +02:00
mika 94b00aa807 test: check that --run-tests reports failing tests (#3650)
Nothing tested that jq --run-tests exits with status 1 when the
tests fail, so a failure could have been reported as a pass.

Add shell tests with incorrect, missing and extra output that check
both the exit status and the reported message, such as "Insufficient
results", along with a passing control. Under Valgrind, memory errors
exit with status 99 so they are not mistaken for a test failure.
2026-10-21 21:40:49 +09:00
qodelicious 4b45d6c1ba docs: print one example output per line in the man page (#3683) 2026-10-21 21:34:38 +09:00
Léane GRASSER 175b8e3c51 docs: update quoting rules for PowerShell 7.3+ (#3649)
The manual recommended backslash-escaped double quotes inside the jq
program for all PowerShell versions, but since PowerShell 7.3 native
command arguments are passed with standard quoting by default, so the
backslashes reach jq literally.

Describe the quoting rules separately for Unix shells and PowerShell
7.3+, for older PowerShell and Windows PowerShell, and for cmd.exe, and
update the examples to match.
2026-10-20 22:28:24 +09:00
qodelicious ec0e2f3f94 docs: mention conda-forge on the download page (#3684) 2026-10-20 22:25:13 +09:00
fhgffy afa23a53cd Keep the sign of zero when negating a number literal (#3662)
Since jq 1.8.0, negating a number literal computed 0 - x, so -0 and
0 | -. printed 0 while (0+0) | -. printed -0.

Flip the sign bit with decNumberCopyNegate() instead, so -0 prints -0
again as it did in jq 1.7, and -(-0) is still 0.
2026-10-20 22:16:56 +09:00
Michiel van Slobbe 852c4d6096 Improve performance of UTF-8 validation (#3675)
jvp_utf8_next() had a fast path for ASCII, but it is not inlined into
its callers, so every byte of a string cost a function call.

Move the end check and the ASCII case into a static inline function in
jv_unicode.h and keep the rest out of line. This speeds up parsing of
string-heavy input by up to 1.17x and string functions such as length,
explode and @html, with the same output for every input.
2026-10-20 22:03:29 +09:00
Dmitri Vereshchagin 633ae6058a Disable colored output on a dumb terminal (#3552)
Enable colored output by default only when the TERM environment variable
is set to a value other than dumb, as git and grep do, so that users no
longer need to pass -M or set NO_COLOR on terminals that cannot display
escape sequences. Colored output is now disabled not only for TERM=dumb
but also when TERM is unset or empty. The -C option still enables colors
in all these cases. On Windows, colored output is still decided by
ANSICON and the console mode, and TERM is not checked.
2026-10-16 21:50:47 +09:00
Doha Nam 6b53f80311 Fix strftime/1 and strflocaltime/1 to allow an empty result (#3670)
These functions failed with "unknown system failure" whenever strftime()
returned 0 for a non-empty format, but 0 also means the format expands to
an empty string, as %p does in a locale without AM/PM.

Prepend a character to the format and trim it from the result, so that 0
can only mean the result is too long. Now 0 | strflocaltime("%p") gives
"" in fr_FR.UTF-8, and a result that is still too long fails with
"result too long" error instead. The size limit is unchanged.
2026-10-13 16:47:58 +09:00
Michiel van Slobbe 80fc7a169d Skip to the next RS after a parse error in --seq mode (#3654)
In --seq mode, a parse error was reported as "need RS to resync", but
parsing continued in the middle of the broken text, so fragments of it
were reported as more errors or output as values.

Set the parser state to wait for the next RS after resetting the parser,
instead of before, so that the rest of the broken text is skipped as
RFC 7464 recommends.
2026-10-12 13:40:40 +09:00
Hugohong258 611c575a97 docs: add simple and nested update-assignment examples (#3664) 2026-10-12 00:24:32 +09:00
Michiel van Slobbe b904884b94 Improve performance of string output (#3643)
Printing a string wrote each character with a separate call, one
fwrite() per character, or one jv_string_append_buf() for tojson and
tostring, which made output of string-heavy data slow.

Scan ahead for the next byte that needs escaping and write the run of
bytes before it with a single call, without changing the output.
Printing strings is now significantly faster, most of all for long
strings with few characters to escape, and the same applies to tojson
and tostring. With --ascii-output, text that is almost all non-ASCII is
about the same speed, since nearly every byte is escaped anyway.
2026-10-10 21:50:10 +09:00
itchyny a5323a369c Fix assertion failure on too many parameters in a nested function (#3663)
A call passing more than 4095 arguments at the start of a nested
function body aborted jq after reporting the compile errors, with
"Assertion failed: (nemb > 0 && sz > 0), function jv_mem_calloc" and
exit status 134.

Stop compiling a function before its bytecode is allocated when it has
compile errors, since the bytecode is only generated and used when
compilation succeeds. jq now prints the same compile errors followed by
"jq: 2 compile errors" and exits with status 3, as it does for other
compile errors, instead of crashing.
2026-10-10 21:29:56 +09:00
qodelicious 04042494cf Exit with the given status for negative halt_error codes (#3660)
halt_error with a negative exit code did not exit with that code. The
code collided with the internal status values for null or false output
and for no output, so halt_error(-1) exited with 0, or with 1 under
--exit-status.

Keep the low 8 bits of a negative code, as exit(3) does on POSIX
systems, so halt_error(-1) now exits with 255 and halt_error(-2) with
254, the same with or without --exit-status. Under --exit-status this
replaces the previous absolute value, so halt_error(-2) used to exit
with 2 and halt_error(-255) with 255, and they now exit with 254 and 1.
2026-10-10 21:26:02 +09:00
omkar bhor a8e6d5f871 Fix undefined behavior on out-of-range array index in has() and del() (#3560)
Converting a double outside the int range to int is undefined behavior,
and has() and del() did it on array indices like infinite or 1e10, which
UBSan reports as "inf is outside the range of representable values of
type 'int'". Only NaN was guarded against.

Clamp the index to the int range in has(), as getting and setting array
elements already do, and drop out-of-range indices in del() before they
are converted. Such indices can never refer to an element, so has()
returns false and del() leaves the array unchanged, the same as for
indices past the end of the array. Valid indices deleted together with
out-of-range ones, as in del(.[0, 1e10]), are still deleted.
2026-10-09 09:22:59 +09:00
neil dbbae0dee3 Add FreeBSD and NetBSD CI (#3600)
Add a BSD workflow with FreeBSD and NetBSD jobs that run the same build
and tests as the linux job, each inside a VM booted under QEMU on an
ubuntu-latest runner. The tests/shtest $NO_COLOR pty checks are now
skipped on NetBSD, as they already are on SunOS.
2026-10-08 23:38:20 +09:00
itchyny e001deb4cf Strip UTF-8 BOM at the start of each input file (#3657)
The UTF-8 BOM was stripped only at the start of the parser stream, but jq
feeds all input files into a single parser, so a BOM at the start of the
second and later files reached the parser as content and failed with a
confusing "Invalid numeric literal" error. Strip it in the file readers
instead, at the start of each input file including stdin, and in
jv_load_file.

This also strips the BOM for raw input, so -R and --rawfile no longer
yield a leading U+FEFF, and a BOM at the start of a -f program file or an
imported module is now accepted rather than reported as a syntax error.
In exchange, "\uFEFF1" | fromjson is now a parse error, since a U+FEFF
inside a string is content rather than an encoding marker, and the
dedicated "Malformed BOM" error is gone.
2026-10-08 23:01:36 +09:00
itchyny 17b87d25c7 Drop the date from the committed man page (#3659)
The date in the .TH line of jq.1.prebuilt changed whenever the manual was
regenerated in a new month, causing merge conflicts between pull requests
that touch the manual, and it did not reflect the release date anyway.
Generate the committed man page without a date.

Stamp the date into jq.1 at build time instead, taking it from the current
commit, or from SOURCE_DATE_EPOCH where that is set, so that release
tarballs and distribution builds still carry one and the behaviour added
in #3514 is kept. Write it in UTC and in ISO 8601 rather than the previous
"%B %Y", for which mandoc reports "cannot parse date, using it verbatim".
2026-10-08 22:16:42 +09:00
itchyny fd25c3e720 Parse the full ISO 8601 grammar in fromdateiso8601 (#3617)
`fromdateiso8601` was `strptime("%Y-%m-%dT%H:%M:%SZ") | mktime`, which
accepts only one of the many representations ISO 8601 permits. strptime
cannot be extended to cover the rest portably, since it has no specifier
for fractional seconds and glibc discards `%G` and `%V`.

Replace it with a parser in src/iso8601.c that handles basic and extended
representations, ordinal and week dates, fractional seconds, offsets and
date-only input. It uses integer arithmetic instead of `time_t`, so the
results no longer depend on the platform.

This is stricter than before. Impossible dates like `2015-02-30`, which
`mktime` used to normalize into March, and unpadded components like
`2015-3-5T6:00:00Z` are now errors. So is any trailing input, including
whitespace. Leading whitespace is rejected too; before, glibc skipped it
and macOS did not. A leap second now maps to the second before it rather
than the next minute. The error message has changed, and the result can
now be non-integer.
2026-10-08 08:24:10 +09:00
A4-Tacks a19efdd45d Parse ?// as ? and // outside destructuring patterns (#3593)
The lexer returned a single ALTERNATION token for `?//`, so any `?`
followed by `//` was consumed by it, and `.name?//"unknown"` failed
to parse even though they read as the optional operator followed by
the alternative operator.

Drop the lexer rule and spell the destructuring alternative operator
as `'?' "//"` instead. So `x ?// y` now parses as `x? // y`, while
`. as [$a] ?// [$b] | ...` keeps its meaning. Note that `?` and `//`
may now be separated by whitespaces inside a pattern.
2026-10-06 16:48:28 +09:00
itchyny f13c1effbf Run man page workflow on push only for master (#3648)
The push trigger had no branch filter, so pull requests from branches
in this repository (e.g. Dependabot) ran the workflow twice, once for
push and once for pull_request.
2026-10-01 15:39:23 +09:00
dependabot[bot] 57a03d610c build(deps): bump lxml from 6.1.2 to 6.1.3 in /docs (#3647) 2026-10-01 15:25:06 +09:00
dependabot[bot] 2bea9d6df9 build(deps): bump markdown from 3.10.3 to 3.11 in /docs (#3646) 2026-10-01 15:24:38 +09:00
Artem Lytkin 9a75bb0d43 Improve performance of join/1 on large arrays (#3639)
join/1 folded each element as `(acc + $x) + elem`, with the element
branch ending in `.//""`. Both leave a second live reference to the
accumulator: the nested + feeds the same `.` to both operands, and the
`//` leaves a forkpoint below it on the stack. `jvp_string_append`
therefore cannot grow the accumulator in place, and copies the whole
string once per element.

Pipe `acc + $x` into `. + elem` and drop the `//`, since adding null to
a string is already a no-op. join/1 is now linear: joining 8000
strings of 1000 chars goes from 6.5s to 0.06s, with output and error
messages unchanged.
2026-09-27 13:52:41 +09:00
Brandon 32580f5d83 Prefer getentropy() over arc4random() to seed the string hash (#3629)
glibc's arc4random() aborts with "Fatal glibc error: cannot get entropy
for arc4random" when the kernel lacks getrandom(2), so jq died on
startup on older kernels once 0c7d133 began seeding the hash on every
run.  getentropy() merely returns -1/ENOSYS there, so prefer it, and
route its failure through the existing `/dev/urandom` path - which works
on precisely those kernels -- instead of a guessable `getpid() ^ time()`.
2026-09-25 16:39:06 +09:00
itchyny df24981307 Fix reduce to preserve its input across init backtracking (#3633)
`reduce f as $x (init; update)` evaluated `f` against a stack slot
that forkpoints created while evaluating `init` restore. Both the
`DUPN` opening the reduction loop and the `LOADVN` retrieving the
result pop that slot destructively, nulling it out, so an `init`
that backtracks (e.g. `0, 0`) made `f` see `null` and fail with
"Cannot iterate over null".

Duplicate the input before the `FORK` instead of inside the loop,
and drop the leftover copy with `POP` once the loop is exhausted.
The slot left live at the `FORK` is then a block pushed after
`init` completed, which no earlier forkpoint can reach, so nulling
it is harmless. This is the same approach `gen_foreach` has used
since c70ae1a.

`DUPN` had no other user, so remove the opcode.
2026-09-19 15:21:29 +09:00
A4-Tacks 4beed4e01a perf: avoid the intermediate array in from_entries (#3626)
Define `from_entries` as `add(.[] | f) // {}` instead of
`map(f) | add // {}`. Since `add(f)` is `reduce f as $x (null; . + $x)`,
both fold the same values in the same order from the same seed, so the
only difference is that the array of single-key objects built by `map`
is never materialized.

Measured with both the generator and the result suppressed, so that only
the `from_entries` work differs: 6-15% less user time across input shapes,
which is 10-24% of what `from_entries` itself costs. For inputs above
roughly a thousand entries, peak RSS drops by 37%, around 80% of the
memory `from_entries` adds on top of its input; a 1,000,000 entry array
goes from 1064 MiB to 672 MiB.
2026-09-18 22:38:42 +09:00
itchyny 12cdd950e9 Register imported libraries in dependency order (#3620)
block_mark_referenced walks the joined block backwards and skips the
body of any definition not yet marked referenced, so a library must
precede its importers.  f58787c41 registered a library before walking
its dependencies, to have somewhere to keep the `loading` flag, which
reversed that order and made block_drop_unreferenced free definitions
that are still referenced through bound_by.

Keep the libraries being loaded on a stack threaded through the
load_library frames instead, so registration can move back after the
dependency walk.
2026-09-18 22:27:54 +09:00
itchyny e371bfaa92 Implement range/3 in C for consistent error handling (#3267) 2026-09-18 22:20:58 +09:00
Bumsu Hyeon dd409de28d Use WriteConsoleW() in priv_fwrite() too (#3607)
jq dumps JSON to the Windows console as UTF-16 with WriteConsoleW(),
but priv_fwrite() still writes the raw UTF-8 bytes with WriteFile(),
which the console decodes with its output code page.  So `jq .k` prints
non-ASCII correctly while `jq -r .k` prints mojibake, and the same goes
for -j, --raw-output0, --seq, halt_error and the `stderr` builtin.

The tty flag is computed once, from stdout, and passed to writes aimed
at stderr too, so ask the handle instead: with stdout on a console and
stderr redirected, WriteConsoleW() failed on the file handle and the
output was dropped.

One byte-level change: with stdout on a console and stderr redirected,
halt_error and the `stderr` builtin now go through the CRT, so bare LF
becomes CRLF and an existing CRLF becomes CR CRLF.  Use -b for
byte-exact output on that stream.
2026-09-18 20:12:34 +09:00
JUSHUANGHUI LI 7422e8c914 docs: clarify ownership of jv arguments and results (#3627)
The ownership comment in `jv.h` currently says every `jv_*` function
except `jv_copy` consumes its input. Several accessors and
object-iteration functions borrow their arguments instead, which makes
that guidance misleading for callers and language bindings.

Document the borrowing exceptions beside their declarations, including
numeric helpers and `jv_show`. Clarify that returned `jv` values are
owned, while the pointers returned by `jv_string_value` and
`jv_number_get_literal` belong to their input values. This changes
comments only.
2026-09-18 18:52:18 +09:00
itchyny 6aeafff056 Fix gmtime and localtime on negative timestamps with fractional seconds (#3634)
The whole seconds were truncated toward zero while the fractional part
was measured from the floor, so any negative non-integral timestamp was
rendered one second late; gmtime was not monotonic across the epoch.
2026-09-18 18:45:36 +09:00
itchyny 57f5976edf website: fold older versions on the download page (#3635)
Only the latest release stays visible in the binary, checksum and
signature, and source tarball lists; older versions move into
collapsible `<details>` sections. Condense the repetitive per-version
checksum and signature sentences into a single list.
2026-09-18 17:07:54 +09:00
Hugohong258andHugohong258 1b4109b0d0 docs: clarify that prebuilt downloads are standalone executables (#3632)
State explicitly in the README and download page that the
platform-specific prebuilt files are standalone executables, not
archives. Include the rename and executable-permission step for macOS
and Linux in the README.

Addresses #2956. Source archives are not described as executables.

Validation: the official `docs/build_website.py` completed and the
generated download page contains the new guidance. Used a Python venv
with the site's required rendering packages; restored the Windows
checkout's manual symlink in a temporary build copy only. jq itself was
not built or tested for this documentation-only change.

Co-authored-by: Hugohong258 <282228220+Hugohong258@users.noreply.github.com>
2026-09-15 11:13:25 +02:00
dependabot[bot] 9d241e2772 build(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622) 2026-09-01 15:30:46 +09:00
dependabot[bot] 8bce8b6543 build(deps): bump lxml from 6.1.1 to 6.1.2 in /docs (#3621) 2026-09-01 15:24:58 +09:00
Anna Rift 41b8edfe54 Fix a handful of typos (#3605) 2026-08-24 00:06:16 +09:00
Thomas Klausner 17b411837d Fix strftime-related functions on NetBSD. (#3579) 2026-08-24 00:03:21 +09:00
august fbee8f48ba Reject raw NUL bytes in the parser instead of silently truncating tokens (#3606) 2026-08-24 00:01:54 +09:00
A4-Tacks 8cf81cb80c docs: in example use [3,4] instead of [0,1] (#3599) 2026-08-23 23:28:10 +09:00
Anna Rift 4bb50d772b Fix typo 'you may wish [to] use' (#3604)
Fix all instances of the phrase "you may wish use `fabs`" -> "you may
wish _to_ use `fabs`" (emphasis mine) in the manual.
2026-08-12 21:02:39 +02:00
dependabot[bot] 603db3f577 build(deps): bump actions/setup-python from 6 to 7 in the official-actions group (#3595) 2026-07-26 10:10:34 +09:00
ded-furby 2d410d6d86 docs: clarify join behavior on objects (#3555) 2026-07-19 21:27:45 +09:00
WinkleMad f1f39b42e3 Advance past the whole codepoint after a zero-width regex match (#3586) 2026-07-19 21:13:51 +09:00
pavel kuliaka dbcaa9d491 shtest: skip locale test if date lacks locale support (#3583) 2026-07-18 17:03:18 +09:00
Thomas Klausner 579e6f76cf Cast char to unsigned char before passing to isspace (#3574) 2026-07-02 14:45:10 +09:00
itchyny 42d4035d4f Add a download link for Windows arm64 2026-06-22 19:31:20 +09:00
itchyny 3c81b62958 Update jq documentation for jq 1.8.2 release 2026-06-20 23:17:39 +09:00
github-actions[bot]andgithub-actions[bot] f0dabad36a Update signatures of 1.8.2 (#3566)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2026-06-20 23:12:40 +09:00
dependabot[bot] 34f7186b86 build(deps): bump actions/checkout from 6 to 7 in the official-actions group (#3565) 2026-06-20 20:58:06 +09:00
itchyny 88e83408f2 Update NEWS.md and AUTHORS for 1.8.2 (#3529) 2026-06-17 22:33:44 +09:00
itchyny a5a29cccc5 Upload attestation bundle as a release artifact (#3563)
The bundle generated by actions/attest is currently only retrievable
via the GitHub attestations API, which requires authentication.
Uploading it as jq-attestation.json lets downstream consumers
(distro packagers, unauthenticated CI) verify provenance offline.
2026-06-16 14:35:02 +09:00
itchynyandDirk Müller 46d1da3094 Tighten string length bounds and propagate invalid jv in implode
The bound added in CVE-2026-32316 (e47e56d22) still allowed
`sizeof(jvp_string) + (currlen + len) * 2 + 1` to wrap `size_t` on
32-bit platforms. Tighten the threshold so the final allocation
fits in 32-bit `size_t`.

Also break out of `jv_string_implode` and `f_string_implode` once
`jv_string_append_codepoint` returns an invalid `jv`; otherwise the
next iteration triggers the assertion in `jvp_string_ptr` (or
invokes undefined behavior under `-DNDEBUG`).

Fixes CVE-2026-54679.

Co-authored-by: Dirk Müller <dirk@dmllr.de>
2026-06-16 14:33:04 +09:00
itchyny e987df0d46 Fix heap-buffer-overflow in raw file loading
When `jv_string_append_buf` overflows the string length limit,
it returns an invalid `jv`; `jv_load_file` then re-entered it
on the invalid value and overran the heap. Break out of the loop
once the value is invalid.

Fixes CVE-2026-49839.
2026-06-08 22:15:06 +09:00
dependabot[bot] 985abe534f build(deps): bump lxml from 6.1.0 to 6.1.1 in /docs (#3553) 2026-06-02 08:36:56 +09:00
theyoucheng df924eae91 Fix undefined pointer arithmetic in UTF-8 helpers
Fixes GHSA-ggc9-rpv2-xgpm and GHSA-gvwx-xj9r-3frq.
2026-05-23 10:11:11 +09:00
itchyny a829f678f3 Fix one-byte over-read in BASE64_DECODE_TABLE (#3547)
The table was declared with 255 entries but indexed by an unsigned
char, so the decoder would read one byte past the array for input
bytes equal to 0xFF. Through jq's normal input paths the over-read
is unreachable because invalid UTF-8 bytes are normalized to U+FFFD
before reaching @base64d, but the table is still wrong at the C
level and reachable by libjq callers that construct strings via
the C API without UTF-8 validation.
2026-05-23 09:36:15 +09:00
Yu-Fu Fu 7122866869 Guard deep structural equality and comparison recursion (#3539)
jv_equal and jv_cmp overflows the C stack on deeply nested
input. Cap recursion at 10000 with -1 / INT_MIN sentinels;
operators that compose user expressions surface this as
"Equality check too deep" / "Comparison too deep".

Fixes CVE-2026-47770.
2026-05-22 20:07:16 +09:00
itchyny f58787c418 Detect circular module imports to prevent stack overflow
jq used to recurse without bound on mutual or self-referential
`import` declarations, exhausting the stack. Track each library's
load state with a `loading` flag set before its dependencies are
processed; a recursive reference to an in-progress library now
reports "circular import of X".

Fixes CVE-2026-44777.
2026-05-11 20:41:38 +09:00
itchyny 9d223f153c Reject embedded NUL bytes in module import paths
jq accepts embedded NUL bytes at the language level but resolves
module import paths through NUL-terminated C strings, so the path
validated by policy or audit code could differ from the on-disk
path jq actually opens. Pass jv through gen_import so the AST
preserves the original bytes, and reject embedded NULs in
validate_relpath.

Fixes CVE-2026-43895.
2026-05-09 17:08:43 +09:00
itchyny 9761ceb7d6 Reject numeric literals longer than DEC_MAX_DIGITS (999999999)
A signed-int overflow in decNumber's D2U macro lets huge literals
write attacker-controlled bytes past a stack buffer. Cap the length
before calling decNumberFromString, and pre-slice long strings in
jv_dump_string_trunc so the resulting error message doesn't itself
allocate a multi-GiB buffer.

Fixes CVE-2026-43894.
2026-05-06 19:45:24 +09:00
itchyny 532ccea608 Limit recursive object merge depth to prevent stack overflow
This fixes CVE-2026-43896.
2026-05-05 22:44:02 +09:00
itchyny 33d7bce321 Avoid stack overflow when freeing deeply nested values 2026-05-05 20:31:29 +09:00
itchyny 7316e5ce4b Fix CI to add artifact-metadata permission for actions/attest (#3530) 2026-05-05 14:06:45 +09:00
itchyny 63751f8a9f Fix signed-int overflow in tokenadd to prevent buffer overflow 2026-04-26 22:59:17 +09:00
Rohan Santhosh Kumar 5f2a14dd1b docs: fix "happened" spelling in tutorial changelog entries (#3525) 2026-04-24 22:33:53 +09:00
itchyny 5a015deae3 Fix NUL truncation in program files loaded with -f
This fixes CVE-2026-41256.
2026-04-24 22:15:08 +09:00
itchyny 01b3cded76 Fix signed-int overflow in stack_reallocate
This fixes CVE-2026-41257.
2026-04-24 22:09:44 +09:00
itchyny d1a12569d9 Limit the containment check depth
This fixes CVE-2026-40612.
2026-04-24 22:02:24 +09:00
dependabot[bot] 870207323d build(deps): bump lxml from 6.0.2 to 6.1.0 in /docs (#3526) 2026-04-22 15:36:33 +09:00
dependabot[bot] 1eaa31acea build(deps): bump actions/upload-pages-artifact from 4 to 5 in the official-actions group (#3523) 2026-04-22 15:36:15 +09:00
itchyny fb59f14910 Limit path depth to prevent stack overflow
Deeply nested path arrays can cause unbounded recursion in
`jv_setpath`, `jv_getpath`, and `jv_delpaths`, leading to
stack overflow. Add a depth limit of 10000 to match the
existing `tojson` depth limit. This fixes CVE-2026-33947.
2026-04-13 11:23:40 +09:00
itchynyandMattias Wadman 2f09060afa Fix out-of-bounds read in jv_parse_sized()
This fixes CVE-2026-39979.

Co-authored-by: Mattias Wadman <mattias.wadman@gmail.com>
2026-04-13 11:04:52 +09:00
itchynyandAsaf Meizner 0c7d133c3c Randomize hash seed to mitigate hash collision DoS attacks
The hash function used a fixed seed, allowing attackers to craft colliding keys
and cause O(n^2) object parsing performance. Initialize the seed from a random
source at process startup to prevent the attack. This fixes CVE-2026-40164.

Co-authored-by: Asaf Meizner <asafmeizner@gmail.com>
2026-04-13 08:53:26 +09:00
itchyny 6374ae0bcd Fix NUL truncation in the JSON parser
This fixes CVE-2026-33948.
2026-04-13 08:46:11 +09:00
tlsbollei fdf8ef0f08 Add runtime type checks to f_string_indexes
This fixes CVE-2026-39956.
2026-04-08 21:43:46 +02:00
itchyny e47e56d226 Fix heap buffer overflow in jvp_string_append and jvp_string_copy_replace_bad
In `jvp_string_append`, the allocation size `(currlen + len) * 2` could
overflow `uint32_t` when `currlen + len` exceeds `INT_MAX`, causing a small
allocation followed by a large `memcpy`.

In `jvp_string_copy_replace_bad`, the output buffer size calculation
`length * 3 + 1` could overflow `uint32_t`, again resulting in a small
allocation followed by a large write.

Add overflow checks to both functions to return an error for strings
that would exceed `INT_MAX` in length. Fixes CVE-2026-32316.
2026-04-13 08:27:16 +09:00
Vladimír Marek 9f778b4cb5 Add Solaris support (#3515)
I love jq :) So while updating the version we ship in Solaris I have
tried to modify stuff to make everything work out of the box. Just

```
autoreconf -fiv
./configure
gmake
gmake check
```

I also went ahead and created Solaris test action should you be
interested in having it too. The changes are not extensive and I have
tried to comment them nicely in each commit. Hopefully that's enough.

Thanks for jq!
2026-04-08 16:02:41 +02:00
Peter KjellerstedtandPeter Kjellerstedt 27f417f481 Support building with --disable-maintainer-mode and source != build dir (#3518)
If --disable-maintainer-mode is enabled, then the rules for generating
parser.[ch] and lexer.[ch] did nothing. This worked fine if the source
and build directories are the same as the pre-generated parser.c and
lexer.c files would suffice. However, if the build directory is not the
same as the source directory, then the rest of the Make rules expect
parser.[ch] and lexer.[ch] to have been created in the build directory
if their source files (parser.y and lexer.l) are newer than the target
files, which can happen in case the source is fetched using Git.

Avoid the problem by copying the files to the build directory if needed.

Co-authored-by: Peter Kjellerstedt <pkj@axis.com>
2026-04-08 12:58:49 +09:00
itchyny 69785bf77f Use // instead of //= in from_entries definition (#3516) 2026-04-02 22:04:51 +09:00
dependabot[bot] 847b6afd2c build(deps): bump actions/deploy-pages from 4 to 5 in the official-actions group (#3513) 2026-04-02 14:15:32 +09:00
McSinyx c26756395c Respect SOURCE_DATE_EPOCH while generating man page (#3514) 2026-04-02 14:14:54 +09:00
itchyny cec6b0f346 Fix crashes and resource leaks in jq_testsuite (#3509)
- Fix segfault when --skip/--take is the last argument.
- Fix FILE handle leak: opened test files were never closed.
- Support running multiple test files in one invocation.
2026-03-15 21:45:16 +09:00
Ze Sheng b6a9e260cd fix jq_fuzz_parse_stream: use iterative parser API for streaming mode (#3499) 2026-03-11 11:49:14 +09:00
dependabot[bot] 1a394919f9 build(deps): bump the docker-actions group with 5 updates (#3506) 2026-03-09 20:50:20 +09:00
itchyny 4b145b3a58 Group Docker actions updates in dependabot config 2026-03-09 17:34:16 +09:00
dependabot[bot] 03a269b2f7 build(deps): bump crazy-max/ghaction-import-gpg from 6 to 7 (#3501) 2026-03-09 17:31:28 +09:00
Scott Seal 3985b80ce5 Fix use-after-free in args2obj() array argument path (#3498)
Copy `kk` and `vk` before passing to jv_object_get(), which consumes
its arguments. Without copies, subsequent loop iterations read freed
memory (CWE-416) and post-loop jv_free() double-frees (CWE-415).

This bug was introduced in `b279713e` when array processing was hoisted
out of
the loop into locals without accounting for jv_object_get() semantics.
Fixes GHSA-gf4g-95wj-4q4r.
2026-03-09 17:30:08 +09:00
itchyny 3cd7e0da00 Fix crash when importing a module with errors twice (#3497)
When a module fails to parse as a library, `load_library` cached the
invalid block. A second import/include of the same module would find
the cached invalid block and pass it to `block_bind_library`,
triggering the assertion failure. Skip caching the block when there
are parse errors to avoid this problem.
2026-03-06 15:32:29 +09:00
itchyny ed3c7f214b Fix tonumber and toboolean to reject strings with embedded null bytes (#3496) 2026-03-05 08:28:43 +09:00
itchyny bfcf82fde1 Refactor @uri and @urid and fix multi-byte UTF-8 corruption (#3495)
This commit improves performance by refactoring `@uri` and `@urid`
to pre-alloacte buffers and build the `jv` string at the end.
Also, this fixes `@urid` to prevent multi-byte UTF-8 corruption,
and to preserve embedded null bytes.
2026-03-05 08:28:09 +09:00
dependabot[bot] 36b6ae00b1 build(deps): bump the official-actions group with 3 updates (#3494) 2026-03-03 15:36:54 +09:00
itchyny 0df54c888a Fix infinite loop and undefined behavior in del(.[nan]) (#3490) 2026-03-02 21:58:28 +09:00
itchyny 262f0b81c1 Add missing validity check in f_strflocaltime after f_localtime (#3491) 2026-03-02 21:58:07 +09:00
itchyny c3d3e7d656 Fix buttons in tutorial to toggle labels when clicked on (#3493) 2026-03-02 17:46:58 +09:00
dependabot[bot] 2beac1aed0 build(deps): bump markdown from 3.10 to 3.10.2 in /docs (#3492) 2026-03-01 16:06:09 +09:00
dependabot[bot] 2d5239e8c1 build(deps): bump jsonschema from 4.25.1 to 4.26.0 in /docs (#3474) 2026-03-01 16:04:55 +09:00
itchyny 601a37f452 Refactor tm2jv to handle fractional seconds removing duplicated code (#3489) 2026-03-01 06:18:14 +09:00
itchyny 750dbe723b Fix memory leaks and double frees (#3487) 2026-03-01 06:15:58 +09:00
Fabian Fleischer 2ad99a6c70 Pre-allocate tokenbuf for string parser (#3485)
Fixes #3483
2026-02-28 15:45:16 +01:00
Fabian Fleischer 061fd14d74 Fix off-by-one in modulo operator (#3486) 2026-02-27 04:35:36 +09:00
itchyny 22361cfb87 Improve error message truncation with closing delimiters (#3478)
Truncated strings now show closing delimiters: `..."` for strings,
`...]` for arrays, and `...}` for objects, making error messages
clearer.
2026-02-25 08:14:23 +09:00
Ze Sheng a2741ee0a8 Limit number of function parameters and definitions to prevent SEGV (#3460) 2026-02-25 07:49:40 +09:00
itchyny b33a7634ba Fix reversed pointer subtraction in f_env bounds check (#3465) 2026-01-20 21:56:09 +09:00
itchyny d44baeb67a Support arm/v7 architecture in Docker images (#3463) 2026-01-15 14:10:07 +09:00
dependabot[bot] ea9e41f758 build(deps): bump the official-actions group with 2 updates (#3450) 2025-12-17 11:24:39 +09:00
dependabot[bot] f46dc3dd61 build(deps): bump markdown from 3.9 to 3.10 in /docs (#3442) 2025-12-17 11:24:12 +09:00
José Joaquín Atria 88b9c4920e Fix stder typo (#3446)
The manual was missing an "r" in "stderr".
2025-12-12 10:54:39 +01:00
bigmoonbit 0eb3da11ed chore: fix typo in tests/jq.test (#3441)
fix typo in  tests/jq.test

Signed-off-by: bigmoonbit <bigmoonbit@outlook.com>
2025-11-27 10:44:45 +01:00
dependabot[bot] 39572e129f build(deps): bump actions/checkout from 5 to 6 in the official-actions group (#3439) 2025-11-24 15:15:18 +09:00
Jan-Piet Mens 4829059147 Add missing word in manual for rawfile (#3434) 2025-11-18 09:49:59 +09:00
itchyny 33b3a68f9c Fix expected value assertion (fix #3430, ref #3393) (#3431) 2025-11-04 21:21:21 +09:00
Mattias Wadman cff4e00982 website: Add wiki link to navigation bar (#3424)
Related to #3423
2025-10-31 10:17:25 +01:00
itchyny 5529788292 Fix slurping raw input not to corrupt multi-byte characters (fix #3389) (#3421) 2025-10-31 15:16:29 +09:00
dependabot[bot] 8d9a3c3ab3 build(deps): bump the official-actions group with 2 updates (#3429) 2025-10-27 16:48:33 +09:00
Ish Nagy b29504b4e1 Increase the maximum printing depth from 256 to 10000 (fixes #3413) (#3414) 2025-10-14 14:12:57 +09:00
Sudhakar Verma 589a6947fa jq_fuzz_execute: limit oniguruma depth to 1024 (#3377)
Fixes #3375 - I'll also fix the oss-fuzz build for this in a PR

Signed-off-by: Sudhakar Verma <sudhakar.verma@canonical.com>
2025-10-05 12:50:42 +09:00
dependabot[bot] c9c96b3cdd build(deps): bump lxml from 6.0.1 to 6.0.2 in /docs (#3416) 2025-10-01 06:39:11 +00:00
dependabot[bot] f240512140 build(deps): bump markdown from 3.8.2 to 3.9 in /docs (#3418) 2025-10-01 06:37:39 +00:00
dependabot[bot] 2b084a6d2d build(deps): bump pyyaml from 6.0.2 to 6.0.3 in /docs (#3417) 2025-10-01 06:37:20 +00:00
A4-Tacks 169457328d Fix rtrimstr("") always output "" (#3415)
Example
---
**Before this fix**:

```sh
$ jq -n '"foo"|rtrimstr("")'
""
```

**After this fix**:

```sh
$ jq -n '"foo"|rtrimstr("")'
"foo"
```
2025-09-29 17:15:43 +02:00
itchyny c8017bf079 Fix localization test for time formatting functions (fix #3368) (#3409) 2025-09-15 07:48:02 +09:00
itchyny a4d9d54010 Fix expected value assertion for NaN value (fix #3393) (#3408) 2025-09-15 07:47:51 +09:00
itchyny 695830c453 Fix year 2038 problem on 32-bit platforms (fix #3369) (#3407) 2025-09-15 07:46:29 +09:00
Kartik Shah cd3a4c3d31 Remove extra space from die func output (#3391) 2025-09-15 07:43:10 +09:00
dependabot[bot] 63c5f4e196 build(deps): bump the official-actions group with 2 updates (#3405) 2025-09-09 11:57:01 +00:00
dependabot[bot] 755ac61755 build(deps): bump jsonschema from 4.25.0 to 4.25.1 in /docs (#3404) 2025-09-05 12:02:28 +00:00
dependabot[bot] 68f9e0a7e1 build(deps): bump lxml from 6.0.0 to 6.0.1 in /docs (#3403) 2025-09-05 12:01:56 +00:00
dependabot[bot] 21471c5e3b build(deps): bump the official-actions group across 1 directory with 3 updates (#3401) 2025-08-27 03:05:20 +00:00
dependabot[bot] a8115e5bc9 build(deps): bump jsonschema from 4.24.0 to 4.25.0 in /docs (#3382)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-08-04 21:12:16 +09:00
itchyny 0ff997f7c4 Update GPG signing key (fix #3381) 2025-07-31 23:00:24 +09:00
Dennis Ameling 4357b6154e CI: add builds for Windows arm64 (#3376) 2025-07-27 08:23:57 +09:00
Alyssa Ross 3c5ceac8e7 jq.test: drop non-portable %F test (#3365)
%F is a non-portable GNU extension, not supported by all strptime
implementations (for example musl's).
2025-07-05 01:25:28 +09:00
itchyny b9e19de76e Update jq documentation for jq 1.8.1 release 2025-07-01 20:54:28 +09:00
github-actions[bot]andgithub-actions[bot] 3db7b519bf Update signatures of 1.8.1 (#3364)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-07-01 20:50:42 +09:00
itchyny 4467af7068 Update NEWS.md and AUTHORS for 1.8.1 (#3353) 2025-07-01 19:36:14 +09:00
dependabot[bot] 98a1176cff build(deps): bump pyyaml from 6.0.1 to 6.0.2 in /docs (#3363)
Bumps [pyyaml](https://github.com/yaml/pyyaml) from 6.0.1 to 6.0.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/yaml/pyyaml/releases">pyyaml's
releases</a>.</em></p>
<blockquote>
<h2>6.0.2</h2>
<h2>What's Changed</h2>
<ul>
<li>Support for Cython 3.x and Python 3.13.</li>
</ul>
<p><strong>Full Changelog</strong>: <a
href="https://github.com/yaml/pyyaml/compare/6.0.1...6.0.2">https://github.com/yaml/pyyaml/compare/6.0.1...6.0.2</a></p>
<h2>6.0.2rc1</h2>
<ul>
<li>Support for extension build with Cython 3.x</li>
<li>Support for Python 3.13</li>
<li>Added PyPI wheels for musllinux on aarch64</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/yaml/pyyaml/blob/main/CHANGES">pyyaml's
changelog</a>.</em></p>
<blockquote>
<p>6.0.2 (2024-08-06)</p>
<ul>
<li><a
href="https://redirect.github.com/yaml/pyyaml/pull/808">yaml/pyyaml#808</a>
-- Support for Cython 3.x and Python 3.13</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/yaml/pyyaml/commit/41309b0bcb4559edb1d691d47199035ef539d785"><code>41309b0</code></a>
Release 6.0.2 (<a
href="https://redirect.github.com/yaml/pyyaml/issues/819">#819</a>)</li>
<li><a
href="https://github.com/yaml/pyyaml/commit/dd9f0e1236775dcce682c91823e009556ce2a271"><code>dd9f0e1</code></a>
6.0.2rc1 (<a
href="https://redirect.github.com/yaml/pyyaml/issues/809">#809</a>)</li>
<li><a
href="https://github.com/yaml/pyyaml/commit/f5527a26d518b3e9c66f9211e0af00c83f09a97e"><code>f5527a2</code></a>
disable CI trigger on PR edits</li>
<li><a
href="https://github.com/yaml/pyyaml/commit/b4d80a742142004490d2da7691d534923820b81c"><code>b4d80a7</code></a>
Python 3.12 + musllinux_1_1_x86_64 wheel support</li>
<li>See full diff in <a
href="https://github.com/yaml/pyyaml/compare/6.0.1...6.0.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=pyyaml&package-manager=pip&previous-version=6.0.1&new-version=6.0.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 19:29:37 +09:00
dependabot[bot] 205b3a2d75 build(deps): bump lxml from 5.4.0 to 6.0.0 in /docs (#3362)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=lxml&package-manager=pip&previous-version=5.4.0&new-version=6.0.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 17:31:54 +09:00
dependabot[bot] d21e506d52 build(deps): bump markdown from 3.8 to 3.8.2 in /docs (#3361)
[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=markdown&package-manager=pip&previous-version=3.8&new-version=3.8.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)


</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-07-01 17:19:03 +09:00
TheOdd 11f43e9d93 Fixed minor typo in docs (#3359) 2025-06-30 07:31:28 +09:00
엄태용 2e6987967e Use jv_mem_alloc to allocate dtoa_context in tsd_dtoa_context_get (#3356) 2025-06-30 07:27:24 +09:00
itchyny 0b1ef46973 Add oniguruma library path to link jq program 2025-06-24 23:49:32 +09:00
Mattias Wadman 5e159b34b1 Fix GHSA-f946-j5j2-4w5m stack-overflow by limit regex parse depth
Was detect by AFL build but it's unsure if possible to trigger in non-fuzz build.

Oniguruma has a default limit of 4096 but this is not be low enough to
protect from stack-overflows in some builds like with AFL where it seems
to use more stack space. A limit of 1024 should be enough usage-wise
and also give more margin.
2025-06-24 15:39:40 +02:00
Mattias Wadman 499c91bca9 Fixes CVE-2025-49014 which was introduced in 1.8.0 2025-06-19 00:11:01 +02:00
itchyny edbc1da809 Revert "fix: reduce/foreach state variable should not be reset each iteration" (#3349)
This reverts 96e8d893c1. The change
introduced a serious performance regression as reported in #3345.
2025-06-17 15:29:46 +09:00
itchyny a587ddc5a3 Fix syntax error assertion failure (fix #3348) (#3350) 2025-06-17 15:25:46 +09:00
itchyny 78045d8aa9 Add LICENSE notice of NetBSD's strptime() to COPYING (#3344) 2025-06-14 08:01:10 +09:00
itchyny 7cc202aa6e Fix portability of strptime especially for Windows (#3342) 2025-06-14 08:00:55 +09:00
dependabot[bot] 859a8073ee build(deps): bump jsonschema from 4.23.0 to 4.24.0 in /docs (#3332) 2025-06-03 06:24:14 +09:00
Binbin Qian 023f274ee9 Fix build on old Macs (#3336) 2025-06-03 06:22:20 +09:00
itchyny 62cafa2367 Update jq documentation for jq 1.8.0 release (#3333) 2025-06-01 16:38:16 +09:00
github-actions[bot]andgithub-actions[bot] 89d657e3fa Update signatures of 1.8.0 (#3331)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2025-06-01 15:05:24 +09:00
itchyny d23a7b9db9 Update NEWS.md and AUTHORS for 1.8.0 (#3330) 2025-06-01 14:51:21 +09:00
itchyny d3cf5caf72 Add more test cases for JQ_COLORS support (ref #3288) 2025-05-31 16:29:02 +09:00
SArpnt aa977aa716 Dynamically allocate JQ_COLORS escapes for truecolor support (#3282) 2025-05-31 15:49:17 +09:00
itchyny c6e041699d Fix heap buffer overflow when formatting an empty string
The `jv_string_empty` did not properly null-terminate the string data,
which could lead to a heap buffer overflow. The test case of
GHSA-p7rr-28xf-3m5w (`0[""*0]`) was fixed by the commit dc849e9bb7,
but another case (`0[[]|implode]`) was still vulnerable. This commit
ensures string data is properly null-terminated, and fixes CVE-2025-48060.
2025-05-31 11:46:40 +09:00
itchyny 3b00981acd Fix quotes in 1.7 manual for ease of taking diff between versions (#3329) 2025-05-31 11:31:54 +09:00
itchyny f28720f699 Increase the maximum parsing depth for parsing JSON to 10000 (#3328)
This is the same limit as encoding/json in Go and should be sufficient for most use cases.
2025-05-30 20:19:34 +09:00
Thalia Archibald 9ac6ddae22 Fix whitespace in number parsing (#3195)
* Handle input errors for --indent

Handle malformed and overflowing arguments. Also, forbid leading and
trailing spaces to match the behavior of tonumber from commit ce0e788
(improve tonumber/0 performance by parsing input as number literal,
2024-03-02).

* Do not skip leading whitespace in jvp_strtod

`jvp_strtod` skips leading whitespace, but its decnum counterpart
`decNumberFromString` (called within `jv_number_with_literal`) does not.
Those two are called interchangeably, so it leads to inconsistent
behavior depending on whether the decnum feature is enabled.
Additionally, `classify`, used in the token scanner, only considers
[ \t\n\r] to be whitespace, but `jvp_strtod` consumes the larger set
[ \t\n\v\f\r], so those extra characters are considered literals.

Changing this deviates from the behavior of `strdod` from <stdlib.h> and
is technically a breaking API change, since it is a public symbol.
2025-05-29 04:11:00 +09:00
itchyny aaace5432a Fix parser to allow binary operators for binding syntax (#3326)
Previously, the precedence of `as` binding was higher than the binary
operators. This results in unexpected behaviors, `1 + 2 as $x | -$x`
was `-1` instead of `-3`. The commit 92daac90f6 (PR #3053) changed
the behavior to emit syntax error on this case. Now, this commit allows
binary operators with `as` binding. This fixes #2446, and fixes #3284.
2025-05-23 21:25:30 +09:00
itchyny 4e3088f188 Fix behavior of --slurp --stream when input has no trailing newline character (#3279)
This commit fixes a strange behavior of the combination of `--slurp` and
`--stream` flags when the input has no trailing newline character.
2025-05-22 08:04:05 +09:00
Gabriel Marin 7d8c096e48 Add trimstr/1 function (#3319) 2025-05-21 18:46:04 +09:00
itchyny de21386681 Fix signed integer overflow in jvp_array_write and jvp_object_rehash
This commit fixes signed integer overflow and SEGV issues on growing
arrays and objects. The size of arrays and objects is now limited to
`536870912` (`0x20000000`). This fixes CVE-2024-23337 and fixes #3262.
2025-05-21 07:48:23 +09:00
itchyny 4e2ccc4c9b Fix and refactor scan-build workflow to run on the master branch (#3325) 2025-05-20 20:00:53 +09:00
itchyny b733dfaee7 Improve error messages to show problematic position in the filter (#3292)
This commit improves the parser and compiler error messages, making
it more easier to understand where in the filter the problem is.
Like modern compilers, jq will show the line in the filter where the
error occurred, will display squiggly line under the invalid token.
2025-05-18 16:36:32 +09:00
Brahm Lower c350566001 Adds "toboolean" builtin function for converting strings to booleans (#2098) 2025-05-18 16:31:10 +09:00
itchyny 92daac90f6 Fix unary operator precedence, allow some expressions as object values (#3053)
This commit improves the parser to fix some unintuitive results of the unary
operator `-` (e.g. `[-1 as $x | 1,$x]` is now `[1,-1]`, previously `[-1,-1]`).
Also, this commit now allows to use binary operator expressions, `reduce`,
`foreach`, `if`, and `try` expressions for object values.
2025-05-18 16:13:55 +09:00
itchyny b088e83a82 Refactor splits/2 using foreach syntax (remove private filter _nwise) (#3260)
This commit refactors `splits/2` implementation using `foreach` syntax
and reduces intermediate arrays. This refactoring removes an unnecessary
private (and undocumented) filter `_nwise` and closes #3148.
2025-05-18 08:27:44 +09:00
itchyny 96d19ca2ee Fix use of uninitialized value in check_literal (fix #3316) (#3324) 2025-05-18 08:06:54 +09:00
itchyny ecea2d29bd Update CI runners to Ubuntu 24.04 and macOS Sonoma (#3208) 2025-05-18 08:06:16 +09:00
itchyny eff9caf6c7 Disable shared libraries on macOS to avoid conflict with -all-static (#3261) 2025-05-17 04:57:17 +09:00
Steven Ihde 77d23e9a5f Test daylight time for strflocaltime (#3323)
This test case covers the behavior described in issue #1912, fixed by #3203.
2025-05-15 07:16:25 +09:00
Thomas Sibley 931a362f8b docs: Use a better input example in the streaming section (#3322)
The introduction says all the usage examples (e.g. of truncate_stream,
etc) in the section use [0,[1]] as input, but they actually use [1,[2]].
["a",["b"]] seems better than [1,[2]] as the string values won't be
confusable with the indexes in <path>.
2025-05-14 20:46:31 +09:00
itchyny a8f27cc4db Fix warning: a function definition without a prototype is deprecated (#3259) 2025-05-07 21:25:32 +09:00
dependabot[bot] 9f6bcdc321 build(deps): bump lxml from 5.3.1 to 5.4.0 in /docs (#3311)
Bumps [lxml](https://github.com/lxml/lxml) from 5.3.1 to 5.4.0.
- [Release notes](https://github.com/lxml/lxml/releases)
- [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt)
- [Commits](https://github.com/lxml/lxml/compare/lxml-5.3.1...lxml-5.4.0)

---
updated-dependencies:
- dependency-name: lxml
  dependency-version: 5.4.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-07 11:01:19 +00:00
dependabot[bot] 622e2d1d7f build(deps): bump markdown from 3.7 to 3.8 in /docs (#3312)
Bumps [markdown](https://github.com/Python-Markdown/markdown) from 3.7 to 3.8.
- [Release notes](https://github.com/Python-Markdown/markdown/releases)
- [Changelog](https://github.com/Python-Markdown/markdown/blob/master/docs/changelog.md)
- [Commits](https://github.com/Python-Markdown/markdown/compare/3.7...3.8)

---
updated-dependencies:
- dependency-name: markdown
  dependency-version: '3.8'
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-05-07 11:01:11 +00:00
itchyny 43506372b5 Update builtin oniguruma to 6.9.10 to suppress clang warnings (#3258) 2025-05-07 10:50:42 +00:00
itchyny abde27d0f5 Revert "Move closer to the standard autotools idiom. (#3187)" (#3255)
This partially reverts commit d8463c2549.
Revert reason: version string should be updated more often.
2025-05-07 17:26:19 +09:00
Emanuele Torre aea8efaf0b jv_unique: don't leak non-unique elements that are not returned (#3304) 2025-03-29 07:16:46 +09:00
dependabot[bot] 947fcbbb1f build(deps): bump jsonschema from 4.18.4 to 4.23.0 in /docs (#3302)
Bumps [jsonschema](https://github.com/python-jsonschema/jsonschema) from 4.18.4 to 4.23.0.
- [Release notes](https://github.com/python-jsonschema/jsonschema/releases)
- [Changelog](https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst)
- [Commits](https://github.com/python-jsonschema/jsonschema/compare/v4.18.4...v4.23.0)

---
updated-dependencies:
- dependency-name: jsonschema
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-28 09:57:51 +09:00
dependabot[bot] 1e22960cf5 build(deps): bump lxml from 4.9.3 to 5.3.1 in /docs (#3301)
Bumps [lxml](https://github.com/lxml/lxml) from 4.9.3 to 5.3.1.
- [Release notes](https://github.com/lxml/lxml/releases)
- [Changelog](https://github.com/lxml/lxml/blob/master/CHANGES.txt)
- [Commits](https://github.com/lxml/lxml/compare/lxml-4.9.3...lxml-5.3.1)

---
updated-dependencies:
- dependency-name: lxml
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-28 09:56:51 +09:00
dependabot[bot] 0b2bda8108 build(deps): bump markdown from 3.4.3 to 3.7 in /docs (#3300)
Bumps [markdown](https://github.com/Python-Markdown/markdown) from 3.4.3 to 3.7.
- [Release notes](https://github.com/Python-Markdown/markdown/releases)
- [Changelog](https://github.com/Python-Markdown/markdown/blob/master/docs/changelog.md)
- [Commits](https://github.com/Python-Markdown/markdown/compare/3.4.3...3.7)

---
updated-dependencies:
- dependency-name: markdown
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-28 09:55:39 +09:00
itchyny 5f7b1aed16 fix usage in help to use jq not the invoked command path (#3299) 2025-03-28 08:43:06 +09:00
itchyny 8819eb8fb4 Enable dependabot PR to update Pipenv dependencies (#3270) 2025-03-28 08:42:44 +09:00
dependabot[bot] 313b0e3735 build(deps): bump jinja2 from 3.1.5 to 3.1.6 in /docs (#3298)
Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.5 to 3.1.6.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/jinja/compare/3.1.5...3.1.6)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-03-27 21:33:55 +09:00
liviubobocu 4b84a6e2f6 Include column number in parser and compiler error messages (#3257)
Resolves #1027, resolves #2334, and resolves #3256.
2025-03-10 22:17:49 +09:00
itchyny 668871bdfa Fix warning: sign-compare in @base64d format (#3287) 2025-03-06 17:07:54 +09:00
itchyny 94fd973ebb Fix calloc error on @base64d format (ref #3280) (#3286)
This commit fixes a regression of a8ce2ff, e.g. `"=" | @base64d`.
2025-03-06 04:30:46 +09:00
Nicole Wren c70ae1ada4 fix: foreach should not break init backtracking with DUPN (#3266)
Simplifies the compilation of `foreach` to avoid the problem in #3227 by
removing unnecessary `FORK ... BACKTRACK`.

Does not address `reduce`, which is less trivial.
2025-03-05 22:01:48 +09:00
sachint f65d088b75 Enable IBM z/OS support (#3277) 2025-03-05 17:21:05 +09:00
itchyny 7e5cad359a Add autotools temporary files to .gitignore (#3285) 2025-03-05 16:57:11 +09:00
SArpnt 9d6efec198 fix: unset environment variables before shtests (#3283)
Tests no longer fail if `JQ_COLORS` and `NO_COLOR` are already set.
2025-03-05 07:59:46 +09:00
itchyny a09a4dfd55 Reject NaN with payload while parsing JSON
This commit drops support for parsing NaN with payload in JSON like
`NaN123` and fixes CVE-2024-53427. Other JSON extensions like `NaN` and
`Infinity` are still supported. Fixes #3023, fixes #3196, fixes #3246.
2025-03-05 07:43:54 +09:00
itchyny a8ce2ff09a Avoid zero-length calloc (#3280)
Using `calloc` function with a count of zero elements is implementation
defined and it may cause allocation errors on some platforms (ref #3277).
This commit fixes `jv_mem_calloc` callers to avoid undefined behavior.
2025-03-04 22:33:51 +09:00
itchyny 4003202ccf Fix segmentation fault on strftime/1 and strflocaltime/1 (#3271)
When we use a large format string to `strftime/1` and `strflocaltime/1`,
we get segmentation fault. This happens because the result buffer is
allocated on the stack using `alloca` function, and `strftime` function
writes out of the space when the size is not enough to format time.
I fixed the segmentation fault issue by allocating the result buffer on
the heap using `malloc` function, because `alloca` function does not
provide a way to detect insufficient space.
2025-03-04 22:28:09 +09:00
itchyny dc849e9bb7 Improve performance of repeating strings (#3272)
This commit improves the performance of repeating strings, by copying
the result string instead of the string being repeated. Also it adds
an error message when the result string is too long.
2025-03-04 22:13:55 +09:00
itchyny 5df471fa5b Disable Valgrind by default during testing (#3269)
Previously, the configure script automatically enables Valgrind during
testing when the valgrind command is found. However, running tests with
Valgrind is quite slow, so it is better to disable it by default, and
to enable it only when the user specifies the `--enable-valgrind` flag.
2025-03-04 22:12:25 +09:00
itchyny c4e1fb08fb Support CRLF line breaks in filters (#3274) 2025-03-04 22:11:40 +09:00
itchyny b7a1201b72 Preserve numerical precision on length/0 (#3275) 2025-03-04 22:09:33 +09:00
itchyny 17be97a8ad Define _BSD_SOURCE in builtin.c for OpenBSD support (#3278)
On OpenBSD, some prototypes are hidden behind `_BSD_SOURCE`.
Defining this variable fixes #3252, and also fixes #3276.
This can be seen as a regression of #2631.
2025-03-04 21:39:52 +09:00
itchyny 95ee663b28 improve performance of unique and unique_by (#3254)
Previously, `unique` and `unique_by` filters are implemented using
`group_by` and then `map(.[0])`. This commit re-implements in C, to
avoid unnecessary boxing of grouping, and improves the performance.
2025-03-04 19:59:41 +09:00
Owen Ou 8ba03f788f Replace jqplay.org with play.jqlang.org (#3265)
As discussed in https://github.com/jqlang/jq/discussions/3244, we are
moving jqplay to the jqlang GitHub organization. This updates all
references from jqplay.org to play.jqlang.org.
2025-02-18 08:22:05 +09:00
Marcin Serwin f3d4c1165d fix: copy the string returned by getenv (#3264) 2025-02-18 07:54:13 +09:00
itchyny 70e72abea3 Fix compiler warning type-limits in found_string (ref #2911) (#3263)
Whether `char` has a sign is implementation dependent, and `c >= 0` may
result in a compiler warning. We can use bitwise operator to check
whether the character is a control character, regardless of the sign.
2025-02-18 07:52:58 +09:00
Marcin Serwin 6d8e9f98ae fix: populate timezone data when formatting time (#3203)
The `jv2tm` function was zeroing fields of `struct tm` that were not
specified by the standard. However, depending on the libc this produced
incorrect timezone data when used together with formatting functions.
This change tries to fill the timezone data using either `mktime`,
`timegm`, or manually.

Apple's Libc implementation contains a bug which causes it to ignore
the offset data present in the `struct tm` in favor of the older heuristic
needed by legacy standards. This workaround temporarily sets the global
timezone so it gets picked up during formatting.
2025-02-17 21:41:01 +09:00
itchyny b86ff49f46 fix: jv_number_value should cache the double value of literal numbers (#3245)
The code of `jv_number_value` is intended to cache the double value of
literal numbers, but it does not work because it accepts the `jv` struct
by value. This patch fixes the behavior by checking if the double value
is `NaN`, which indicates the unconverted value. This patch improves the
performance of major use cases; e.g. `range(1000000)` runs 25% faster.
2025-02-16 22:08:36 +09:00
itchyny 64bd8ba374 fix: jv_dump_string_trunc should not break unicode characters (#3249) 2025-02-16 21:40:18 +09:00
itchyny fa6a2ff688 website: remove unused root path on building website (#3248)
We no longer use the `--root` option of `build_website.py` since we have
moved to jqlang.org (from jqlang.github.io/jq where the root was `/jq`).
We don't need the option on local development either since `http.server`
has the `-d` option to specify the directory to serve from.
2025-02-06 22:42:27 +09:00
Mattias Wadman e33578a53e Add opengraph meta tags (#3247)
Makes the site preview a bit nicer when sharing
2025-02-06 22:14:29 +09:00
itchyny 6ce3bdf382 fix: preserve numerical precision on unary negation (#3242) 2025-02-06 07:50:21 +09:00
itchyny 972772153f Move oniguruma and decNumber to vendor directory (#3234) 2025-02-06 07:49:56 +09:00
Mattias Wadman 2755664a8e Non-matched optional capture group should be null and offset -1 (#3238)
Fixes #3093
2025-02-04 19:18:58 +01:00
d0adcbfebb Fix --indent 0 implicitly enabling compact-output (#3232)
Now it will retain pretty-printing, just remove any indentation.

Co-authored-by: Andrew Marshall <andrew@johnandrewmarshall.com>
Co-authored-by: Gabriel Marin <marin.gabriel@protonmail.com>
2025-02-01 15:09:30 +09:00
orbea 07af9c11b7 build: fix insecure RUNPATH (#3212)
The -static-libtool-libs flag causes GNU libtool to add a rpath to the .libs
build directory, which is intended for internal use by the libtool
implementation and is not installed in the resulting package causing Gentoo to
print a QA notice. See Gentoo issue: https://bugs.gentoo.org/945698.
2025-02-01 15:07:54 +09:00
itchyny 0d1e371e63 website: switch to custom domain jqlang.org (#3243) 2025-02-01 11:54:32 +09:00
itchyny dea5e61cde docs: fix example links to jqplay.org (#3241) 2025-01-28 22:15:19 +09:00
itchyny ce54621904 docs: mention the behavior of scan using regex with capturing groups (#3240) 2025-01-28 11:41:17 +09:00
itchyny 39eea145b4 website: deploy website from GitHub Actions (#3237)
Deploying GitHub Pages from the gh-pages branch is a classic way.
We can use actions/deploy-pages action to deploy GitHub Pages.
2025-01-28 11:40:55 +09:00
Han Jiang da28628edd Fix redundant subexpression in Generators and iterators example in doc (#3239) 2025-01-27 19:45:27 +09:00
itchyny 31dac287cc tests: quote .[] in shtest which can break syntax highlight (#3235) 2025-01-26 08:08:31 +09:00
Eloy Coto 562ffec869 refactor: move bsearch function to C-code (#2945)
This commit fixes issue #527 and move the bsearch function to a native
C-code. This change improves the performance of this function.
2025-01-25 22:09:43 +09:00
Michael Färber 18bd8374c1 Escape some code parts in manual. (#3184) 2025-01-25 21:55:06 +09:00
Dag-Erling Smørgrav d8463c2549 Move closer to the standard autotools idiom. (#3187)
* Create `src/config.h` instead of passing everything on the compiler
  command line.

* To reduce the magnitude of this change, add `--include src/config.h`
  to CFLAGS instead of adding `#include "src/config.h"` at the top of
  each source file.  Not all compilers support this, but I don't think
  we care about anything other than gcc and clang at this point.

* Rather than generate `src/config_opts.inc`, emit `JQ_CONFIG` directly
  into `src/config.h`.

* Rather than generate `src/version.h`, define `JQ_VERSION` as an alias
  for the standard `PACKAGE_VERSION`.
2025-01-25 17:10:05 +09:00
itchyny 71ed7b3412 tests: refactor constant folding tests (#3233) 2025-01-25 13:58:47 +09:00
dependabot[bot] 588ff1874c build(deps): bump jinja2 from 3.1.4 to 3.1.5 in /docs (#3226)
Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.4 to 3.1.5.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/jinja/compare/3.1.4...3.1.5)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-12-29 21:54:10 +09:00
lectrical bcbf2b4616 Generate provenance attestations for release artifacts and docker image (#3225)
Adding https://github.com/actions/attest-build-provenance to the ci builds so
that the release assets and docker image for the next release tag generate
signed build provenance attestations for workflow artifacts.
2024-12-29 21:53:16 +09:00
Emanuele Torre 8bcdc9304a jq_next: simplify CALL_BUILTIN implementation 2024-12-01 11:49:44 +01:00
Emanuele Torre 0b82b3841b builtin.c: typecheck builtin cfunctions in function_list
In C23 (default C standard used by GCC 15),  jv (*fptr)();  has become
equivalent to  jv (*fptr)(void);  so we can no longer assign builtin
implemenations directly to the fptr member of cfunctions without
generating a compile error.

Since there does not seem to be any straight-forward way to tell
autoconf to force the compiler to use C99 short of explicitly adding
-std=c99 to CFLAGS, it is probably a cleaner solution to just make the
code C23 compatible.

A possible solution could have been to just redeclare  cfunction.fptr
as void*, but then the functions' return type would not have been type
checked (e.g. if you tried to add a {printf, "printf", 2}, where printf
is a function that does not return jv, the compiler wouldn't have
complained.)
We were already not typechecking the arguments of the functions, so e.g.
  {binop_plus, "_plus", 3},  /* instead of {f_plus, "_plus, 3},       */
  {f_setpath, "setpath", 4}, /* instead of {f_setpath, "setpath", 3}, */
compile without errors despite not having the correct prototype.

So I thought of instead improving the situation by redefining
cfunction.fptr as a union of function pointers with the prototypes that
the jq bytecode interpreter can call, and use a macro to add the builtin
functions to function_list using to the arity argument to assign the
implementation function to the appropriate union member.

Now the code won't compile if the wrong arity, or an arity not supported
by the bytecode interpreter (>5 = 1input+4arguments), or a prototype not
jallable by the bytecode interpreter (e.g. binop_plus that doesn't
expect a  jq_state*  argument).

Also, the code now compiles with gcc -std=c23.

Fixes #3206
2024-12-01 11:49:44 +01:00
itchyny 96e8d893c1 fix: reduce/foreach state variable should not be reset each iteration (#3205)
When the UPDATE query in a reduce or foreach syntax does not emit
a value, it should simply skip updating the state variable. But
currently it resets the state variable to null.
2024-11-21 08:12:18 +09:00
Mattias Wadman 8619f8a8ac Use codepoint index for indices/1, index/ 1 and rindex/1 (#3065)
Previsouly byte index was used.

Fixes #1430 #1624 #3064
2024-11-17 10:22:05 +01:00
itchyny a7b22539a4 fix: make last(empty) yield no output values (#3179) 2024-11-13 20:35:50 +09:00
Dag-Erling Smørgrav 3c5707f7fb Improve reliability of NO_COLOR tests. (#3188)
* Improve reliability of NO_COLOR tests.

Use `env` to ensure that `NO_COLOR` is set to the desired value
regardless of any initialization that may occur when `script`
forks a shell to run jq in.

Note that `env -u` is not portable, so there is no good solution
for the first test case.

* Always use /bin/sh, not the user's login shell.
2024-11-13 20:35:22 +09:00
Thalia Archibald 32a304b912 Clarify -f argument parsing (#3199) 2024-11-09 15:48:24 +01:00
Thalia Archibald eb9bdca296 Remove outdated FIXME
This comment predates the addition of $ARGS in jq 1.6, so there was no
way to access named arguments with an invalid identifier. Rather than
forbid such names, update the manual to clarify.
2024-11-08 19:07:55 +01:00
Thalia Archibald 7cac5e80ec Remove dead flag 2024-11-08 19:07:55 +01:00
Thalia Archibald 7a1fd72d2d Fix missing program from file
When jq is not supplied with a program, it usually exits with an error
and usage text, except for when jq is not connected to a TTY (i.e., not
interactive), in which case a default program of `.` is used. Combined
with `-f`, it then tries to read `.` as the filename.

    $ jq
    jq - commandline JSON processor [version 1.7.1]
    …
    $ jq -f
    jq - commandline JSON processor [version 1.7.1]
    …
    $ jq | cat
    ^C
    $ jq -f | cat
    jq: Could not open .: It's a directory
2024-11-08 19:07:55 +01:00
Thalia Archibald 0558e77e8c Add --library-path long option for -L
-L is the only option without a long form.
2024-11-08 19:07:55 +01:00
Thalia Archibald ff4acba769 Parse short options in order given
Fixes:
* Short options cannot be repeated in the same group:
  e.g., `-nn` fails, but `--null-input --null-input` works
* Short options are processed in an arbitrary fixed order, not the order
  given by the user: e.g., `-hV`, `-Vh`, `-h -V`, and `--help --version`
  are processed as `-h`, but `-V -h` and `--version --help` are
  processed as `-V`
* `-L` cannot be a part of a short option group (as the last one):
  e.g., `-nLlib` and `-nL lib` fail
2024-11-08 19:07:55 +01:00
Matt Meyers 562d5c5222 Return error for string literal beginning with single quote (#2964)
In order for a string literal to be valid in JSON, the value must be
surrounded by double quotes.
2024-10-06 08:52:56 +09:00
itchyny 1bebd23aad add skip/2 as the counterpart to limit/2 (#3181)
I also changed the behavior of limit/2 with negative count to emit an error, like nth/2 does.
Also, I redefined nth/2 using skip/2 to minimize the impact of growth of builtin filters.
2024-10-06 08:25:38 +09:00
Nathan Baulch 860af44fee Fix typos (#3173) 2024-09-13 18:30:49 +09:00
Chris LaRose 37f4cd2648 Fix docs for strptime(fmt) (#3164) 2024-08-27 10:59:43 +09:00
Kirk McKelvey 6322b99252 fix: find and source ~/.jq file on windows (fixes #3104) (#3114) 2024-08-24 08:44:08 +09:00
Emanuele Torre da2a0b970c mktime/0: remove unnecessary length>=6 input requirement (#3162)
This check was redundant and useless since jv2tm() used to require 8
elements, and errored anyway if not enough elements were provided.
After commit bc96146, this check also prevents mktime/0 from accepting
now supported inputs with less than 8 elements.

Ref: https://github.com/jqlang/jq/pull/3070#issuecomment-2299902072

Reported-by: itchyny <itchyny@cybozu.co.jp>
2024-08-22 08:17:54 +09:00
fletcher gornick 0e0cdd552e feat: uri decode function (#3161) 2024-08-22 08:07:24 +09:00
myaaaaaaaaa 0b5ae30f19 Implement add/1 (#3144) 2024-08-20 21:02:24 +09:00
Emanuele Torre 137018d2ae jv.h: define empty JV_{,V}PRINTF_LIKE macros if __GNUC__ is not defined
Fixes #3159

Reported-by: Hsiang-Ying Fu
2024-08-13 12:20:02 +02:00
Mattias Wadman c1d885b024 website: Make latest release (1.7) be default manual (#3130)
Fixes issue with confusion about features that has not been
released yet.

Move deveopment manual.yml to dev/manual.yml
Symlink manual.yml to v1.7/manual.yml
Refactor to share history header with links to other manual versions.
Change man.test and man page generation to use dev/manual.yml

Related to #3078 #3127
2024-07-12 17:43:02 +02:00
riastradh 2ee20ca604 Avoid ctype.h abuse: cast char to unsigned char first.
fix #3151
2024-07-11 23:17:06 +02:00
dependabot[bot] e2ffb5360a build(deps): bump zipp from 3.16.2 to 3.19.1 in /docs
Bumps [zipp](https://github.com/jaraco/zipp) from 3.16.2 to 3.19.1.
- [Release notes](https://github.com/jaraco/zipp/releases)
- [Changelog](https://github.com/jaraco/zipp/blob/main/NEWS.rst)
- [Commits](https://github.com/jaraco/zipp/compare/v3.16.2...v3.19.1)

---
updated-dependencies:
- dependency-name: zipp
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-11 09:18:50 +02:00
dependabot[bot] ba741e5968 build(deps): bump docker/build-push-action from 5 to 6 (#3143)
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 5 to 6.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v5...v6)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-06-25 08:30:43 +09:00
Samar Sunkaria 7be6870751 Remove multiple calls to free when successively calling jq_reset. (#3134)
`jq_reset` calls `jv_free` on the `exit_code` and the `error_message` stored on the jq state.
However, it doesn't replace the actual instance of those members. This means that subsequent
calls to `jq_reset` will call `jv_free` again on those members, which in turn may call `free`
on the same pointer multiple times. Freeing the same pointer multiple times is undefined
behavior and can cause heap corruption, which is how I spotted this issue.

In practice, this issue only occurs when using a program that may `halt_error`, because that
is when the `exit_code` and `error_message` are set to values other than `jv_invalid`.
Subsequent attempts to call `jq_start` (which calls `jq_reset` internally) after hitting a
`halt_error` can cause you to run into this issue.

The changes simply reset the `exit_code` and the `error_message` to `jv_invalid` (the initial
value set in `jq_init`) after they are freed.
2024-06-05 13:19:08 +09:00
Christoph Anton Mitterer 5208a4425f fix option parsing of --binary on non-Windows platforms (#3131)
`-b`/`--binary` should be accepted on all platforms so that they can be used in
code that is meant to be portable.

Signed-off-by: Christoph Anton Mitterer <mail@christoph.anton.mitterer.name>
2024-05-30 08:21:10 +09:00
J. B. Rainsberger 7cd23f1f2f Improve formatting of the build instructions.
Line up the comments, because reasons. :)
2024-05-21 10:35:37 -05:00
J. B. Rainsberger 4842146e1b Add "make clean" to build instructions
When I tried to build a new version in the same working directory I'd used to build a previous version, I saw build errors. After a few attempts, I remembered that "make clean" might get past the problem. It seems like a nice thing to suggest to everyone who might fall into the same trap.
2024-05-21 10:35:37 -05:00
Nicolas Williams 6d02d53f51 Make tests pass when --disable-decnum 2024-05-15 12:48:00 -05:00
dependabot[bot] c1276169d6 build(deps): bump jinja2 from 3.1.3 to 3.1.4 in /docs
Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.3 to 3.1.4.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/jinja/compare/3.1.3...3.1.4)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-07 01:56:22 +02:00
sheepsterandSheepster ed8f7154f4 doc(readme): Fix docker run with mounted volume command (#3105)
Co-authored-by: Sheepster <sheepstert>
2024-05-01 17:56:48 +02:00
Emanuele Torre 9afc450930 COPYING: adding missing line from decNumber's licence
Fixes #3079

Also clarify what files the Kungliga Tekniska Högskolan copyright notice
applies to.
2024-05-01 16:41:44 +02:00
sheepsteranditchyny d875ff5c7a doc(readme): Add docker usage doc (#3103)
* doc(readme): Add docker usage doc

* fix heading size

Co-authored-by: itchyny <itchyny@cybozu.co.jp>
2024-05-01 06:07:10 +02:00
goodactive 6ce6e7c713 chore: fix some typos in comments (#3096)
Signed-off-by: goodactive <goodactive@qq.com>
2024-04-29 21:03:46 +02:00
Andy Lester e4d0b12d7d A couple of teeny tweaks (#3091)
* Don't get HOMEDRIVE unless needed

* Use put_char instead of put_str
2024-04-23 16:10:42 +09:00
Fabian Dellwing 6eff31a204 Add strptime fallback not only for Windows 2024-04-18 01:38:29 +02:00
maflcko 6408338e93 Update jq_fuzz_load_file.c: Add missing include unistd.h (#3085) 2024-03-29 10:13:25 +01:00
Emanuele Torre 5bbd02f581 jv_setpath: fix leak when indexing an array with an array
arrays[arrays] is a special case of "INDEX" that actually returns an
array containing the indices in which the array that is being indexed
contains the start of the key array.

So array keys, for array values, are a kind of key that can be "got",
but not "set". jv_setpath() was not freeing the value it "got" from
indexing that key, in case the following "set" on that key failed,
resulting in a leak.

    $ ./jq -n '[] | setpath([[1]]; 1)'
    jq: error (at <unknown>): Cannot update field at array index of array

    =================================================================
    ==953483==ERROR: LeakSanitizer: detected memory leaks

    Direct leak of 272 byte(s) in 1 object(s) allocated from:
        #0 0x725f4d4e1359 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
        #1 0x5ec17b1a7438 in jv_mem_alloc src/jv_alloc.c:141

    SUMMARY: AddressSanitizer: 272 byte(s) leaked in 1 allocation(s).

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66061
2024-03-28 18:10:38 +01:00
Mattias Wadman afe0afaf06 ci: Remove unnecessary apt-get upgrade (#3082)
Causes update to irrelevant packages and added flakeyness

Fixes #3066
2024-03-28 14:01:03 +01:00
Emanuele Torre ce2638af40 jv_aux.c: replace jv_array_foreach with regular loop in jv_dels()
The code was only conditionally using the value
2024-03-28 12:12:39 +01:00
Emanuele Torre ea78b5a030 jv_array_indexes: remove a bunch of unnecessary copies/gets 2024-03-28 12:12:39 +01:00
Emanuele Torre 22a03e9e06 @base64d: fix unhandled overflow
$ ./jq-before -n '238609295*"|||"|@base64d|"."'
    src/builtin.c:718:29: runtime error: signed integer overflow: 715827885 * 3 cannot be represented in type 'int'
    jq: error: cannot allocate memory
    Aborted (core dumped)

    $ ./jq-after -n '238609295*"|||"|@base64d|"."'
    jq: error (at <unknown>): string ("||||||||||...) is not valid base64 data

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=67640
2024-03-27 10:16:15 +01:00
Mattias Wadman be437ec049 Add trim/0, ltrim/0 and rtrim/0 that trims leading and trailing whitespace (#3056) 2024-03-20 11:04:17 +01:00
itchyny 81f4f883ac Remove non-standard pow10 filter in favor of exp10 (#3059)
The pow10 function was a glibc extension removed in 2.27. Use exp10 filter instead.
2024-03-20 18:23:08 +09:00
Emanuele Torre b6da71bf68 declare static arrays const where possible
Some static arrays that could be readonly memory were declared mutable.
2024-03-20 00:22:54 +01:00
Emanuele Torre bc96146825 builtin.c: jv2tm: fix UB and accept array inputs with not all the values
Now, time functions accept array inputs even if they don't have all the
elements, 0 will be assumed if a value is not present.

Also, jv2tm now properly clamps large number values to a signed 32-bit
integer and rejects nan.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=65885
2024-03-19 02:01:53 +01:00
Colin Leroy-Mira d69733154a Fix valgrind warning on aarch64/glibc 2.31
tests/mantest were failing on Raspberry Pi OS 11:

==10205== Conditional jump or move depends on uninitialised value(s)
==10205==    at 0x48806F8: checkfail (jq_test.c:58)
==10205==    by 0x48806F8: run_jq_tests (jq_test.c:99)
==10205==    by 0x4880FCB: jq_testsuite (jq_test.c:39)
==10205==    by 0x10B37F: main (main.c:576)
==10205==
==10205== Conditional jump or move depends on uninitialised value(s)
==10205==    at 0x4880714: checkfail (jq_test.c:58)
==10205==    by 0x4880714: run_jq_tests (jq_test.c:99)
==10205==    by 0x4880FCB: jq_testsuite (jq_test.c:39)
==10205==    by 0x10B37F: main (main.c:576)
2024-03-18 19:42:22 +01:00
Emanuele Torre 10ea3c7d9f util.c: update strptime to revision 1.66 2024-03-18 19:10:21 +01:00
Emanuele Torre d777b6570c util.c: fix _WIN32 port of strptime (#3071)
In windows, time_t is a signed 32-bit integer type, so TIME_MAX needs to
be declared as INT32_MAX instead of INT64_MAX.

Also bump NetBSD's strptime to revision 1.65 from 1.63 to fix undefined
behaviour (signed integer overflow) bugs.

Related NetBSD problem report:
https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=58041

Noticed thanks to a compiler warning in the windows build CI.

I declared the d variable as  time_t  instead of as  unsigned  to ensure
that the signedness/size of  TIME_MAX-d  in the  sse > TIME_MAX-d check
is always correct, and to prevent -Wsign-compare warnings from
triggering in the windows build.
2024-03-18 17:22:59 +01:00
Emanuele Torre 1411ce63d5 strftime/1: fix validation of non-string argument with number input
There was a incorrect else, that caused jq to not ensure that the
argument to strftime/1 is a string when the input is a number; this ends
up calling jv_string_value on a non-string value, which does not work,
and causes an assert failure.

Also fix same bug in strflocaltime/1.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=67403
2024-03-15 14:30:23 +01:00
Emanuele Torre 6f67bae60b EACH: fix leak when an error is triggered by non-last element of object
Object keys are strings, so they need to be freed.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=66070
2024-03-15 14:30:03 +01:00
wellweek c95b34ff82 remove repetitive words
Signed-off-by: wellweek <xiezitai@outlook.com>
2024-03-08 10:43:29 +01:00
itchyny ce0e788ce2 improve tonumber/0 performance by parsing input as number literal
Previously, the tonumber/0 filter parses the input as JSON values, but
this is less-performant on large non-number strings. Parsing the input
string as number literal fixes the performance issue. Also, this fix
changes the filter to reject numbers with white spaces.
2024-03-01 16:33:17 +01:00
Bhargava Mummadireddy 913b26469f docs: Update chocolatey install command in default.yml (#3042) 2024-02-13 16:50:58 +01:00
Emanuele Torre fc9ecd71b3 tests: run tests in C locale
Fixes #3038
2024-02-10 18:23:50 +01:00
Ulrich Eckhardt 623d7a8bd6 src/jv_dtoa.c: Fix compiler error 2024-02-08 19:27:48 +01:00
Ulrich Eckhardt 6980cc9713 src/builtin.c: Add missing semicolon 2024-02-08 19:27:48 +01:00
J. B. RainsbergerandEmanuele Torre 92d35378ff Fix typo in documentation for map_values (#3035)
* Fix typo in documentation for map_values

"map_value(f)" -> "map_values(f)"

* map_value => map_values also in the devolpment manual

---------

Co-authored-by: Emanuele Torre <torreemanuele6@gmail.com>
2024-02-08 13:52:50 +00:00
Thalia Archibald 54cc15c127 Add missing string color case
Colors have a color separate from object keys, so were not tested.
2024-02-08 00:11:54 -06:00
Thalia Archibald 48df9bce0c Clear formatting immediately after colon 2024-02-08 00:11:54 -06:00
Thalia Archibald 76853f6046 Fix tests and test indented printing 2024-02-08 00:11:54 -06:00
Thalia Archibald 3c37522aaa Consistently reset color formatting in jv_dump_term
Before, arrays would not reset colors after `[` and `,`, but objects
would; it would reset colors twice before `]` and `}`; and some cases of
indentation would have colors applied. Now, colors are reset immediately
after any token that is colored, before any indentation. This makes the
formatting consistent, for the benefit of custom `JQ_COLORS`.
2024-02-08 00:11:54 -06:00
Tomas Halman 8a9a74dc12 License: Improve license statement.
The README mentions only the MIT license but in fact part of `jq`
is under ICU license and the documentation is under CC.

Also jq.spec claimed that it is licensed under BSD.
2024-02-06 14:51:46 +01:00
Emanuele Torre 13e02ba348 docs: rename example jq utility to total
Apparently sum(1) is a BSD and GNU coreutil used to compute the
"16-bit BSD checksum" of a file.
2024-01-30 12:23:33 -06:00
Emanuele Torre bd3c828f98 libm.h+builtin.c: add and use LIBM_DA and LIBM_DA_NO macros
For functions that from one double return an array with two numbers.
2024-01-26 16:16:25 -06:00
Emanuele Torre 605836b263 builtin.c: fix build with -Woverlength-strings
C99 only allows string literals long at most 4095 characters.
jq_builtins was a lot longer than that.

I rewrote all the optional libm error stubs in C so the value of
jq_builtins is not build dependent.

I replaced the command that generates builtin.inc with a POSIX compliant
od|sed command that encodes builtin.jq as a comma delimited list of
octal numbers (that can be embedded in C using a {} literal).

I also added -Woverlength-strings to AM_CFLAGS to verify that the
problem is fixed.

Fixes #1481
2024-01-26 16:16:25 -06:00
Emanuele Torre 7bdc9a7a63 Makefile.am: fix lines indented with tabs instead of spaces 2024-01-26 16:13:35 -06:00
Jonathan Chan Kwan Yin 1daabc67ed typo contruct->construct (#3017) 2024-01-25 22:21:41 +01:00
Mattias Wadman c95f6ce700 Fix "in the a search" typo (#3015)
Fixes #3014
2024-01-24 23:34:41 +01:00
Emanuele Torre 1f1e619f4e builtins: make ltrimstr and rtrimstr error for non-string inputs
Previously, ltrimstr/rtrimstr would just let the input pass through for
non-string inputs or arguments.

That was happening because, they were leaking the errors returned by
startswith/endswith treating them as if they were jv_false().
The leak was resolved by #2977 for 1.7.1

This patch rewrites ltrimstr and rtrimstr in jq, and makes them not
ignore startswith and endswith errors anymore.
2024-01-16 16:57:37 -06:00
Emanuele Torre 71e7bcdfc1 Revert "lexer: temporarily revert #\ patch; keep CR in comment bug fix"
This reverts commit 5d95791a67.
2024-01-16 16:08:03 -06:00
George Hopkins f954e82b14 Provide strptime implementation on all systems 2024-01-16 16:01:27 -06:00
dependabot[bot] f51e841fbc Bump jinja2 from 3.1.2 to 3.1.3 in /docs (#3009)
Bumps [jinja2](https://github.com/pallets/jinja) from 3.1.2 to 3.1.3.
- [Release notes](https://github.com/pallets/jinja/releases)
- [Changelog](https://github.com/pallets/jinja/blob/main/CHANGES.rst)
- [Commits](https://github.com/pallets/jinja/compare/3.1.2...3.1.3)

---
updated-dependencies:
- dependency-name: jinja2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-01-13 11:24:16 +09:00
dependabot[bot]anditchyny 2381d15d3e Bump the official-actions group with 2 updates (#2998)
* Bump the official-actions group with 2 updates

Bumps the official-actions group with 2 updates: [actions/upload-artifact](https://github.com/actions/upload-artifact) and [actions/download-artifact](https://github.com/actions/download-artifact).


Updates `actions/upload-artifact` from 3 to 4
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v3...v4)

Updates `actions/download-artifact` from 3 to 4
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: official-actions
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
  dependency-group: official-actions
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix CI workflow for updating artifact actions to v4

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: itchyny <itchyny@cybozu.co.jp>
2024-01-09 09:33:26 +09:00
Mattias Wadman 701c880805 Add jq 1.7.1 news item (#3004) 2023-12-26 15:22:39 +09:00
wllm-rbnt 0b922725b1 Fix typo (#3002) 2023-12-24 11:22:20 +01:00
Mattias Wadman e011f003b6 Add jq 1.7.1 to webpage (#3003)
Make it the default download
2023-12-24 11:17:21 +01:00
itchyny 56828b6d04 Always build Docker image on CI, group Dependabot PRs for official actions (#2997)
* Always build docker image on CI

* Revert "Bump actions/download-artifact from 3 to 4"

This reverts commit 9e2695e117.

* Group Dependabot PRs for official actions
2023-12-19 17:54:53 +09:00
dependabot[bot] 9e2695e117 Bump actions/download-artifact from 3 to 4
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 3 to 4.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-18 15:18:47 +01:00
github-actions[bot]andgithub-actions[bot] 95c50a2d0d Update signatures of 1.7.1
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2023-12-13 20:52:03 +01:00
Emanuele Torre 71c2ab509a Merge pull request from GHSA-686w-5m7m-54vc
decNumberToString calls for a buffer that can hold a string of digits+14
characters, not a buffer of size digits+14.
We need to allocate an extra byte for the NUL byte.

-10E-1000010001, for example, will be stringified as -1.0E-1000010000
and decNumberToString will currently write an extra NUL byte after the
allocated buffer in the heap.

Originally reported by @SEU-SSL on GitHub.

Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64574

Fixes GHSA-686w-5m7m-54vc
2023-12-13 20:20:22 +01:00
Emanuele Torre c9a5156521 Merge pull request from GHSA-7hmr-442f-qc8j
The unit allocated for decNumberCompare was accidentally removed by
commit 680baeffeb (PR #2804)

This caused a stack overflow when comparing a nan with a payload of 1000
or more.

This bug was found by OSS-fuzz.
Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64771
Fixes GHSA-7hmr-442f-qc8j

It also fixes 1e999999999 > 1e-1147483646   triggering UBSAN errors
Fixes #2968
2023-12-13 20:17:17 +01:00
Emanuele Torre c5fd64ba97 jv_parse: let decNumberFromString/strtod parse complex nans as a NaN
Before this patch (when using decNumber), "Nan123" was parsed as a NaN,
only if the first n was uppercase.
2023-12-13 20:14:31 +01:00
Emanuele Torre dcf9a8e580 NEWS.md: fix markdown syntax; mention more bug fixs; list cves (#2987) 2023-12-13 18:39:24 +01:00
Mattias Wadman c3b14967d3 Update NEWS.md with changes since 1.7 (#2948) 2023-12-13 15:38:59 +00:00
Emanuele Torre 5d95791a67 lexer: temporarily revert #\ patch; keep CR in comment bug fix
This commit temporarily reverts the commit that allows #\ "tcl-style"
comments everywhere and documents them, for the 1.7.1 patch release
cca1f7d18f.

\r is removed from the list of characters not allowed in a comment to
preserve that bugfix.
2023-12-13 16:38:18 +01:00
Emanuele Torre 511d50b15b ltrimstr/1+rtrimstr/1: don't leak on invalid input or arguments
ltrimstr/rtrimstr was ignoring and leaking the error returned by
f_startswith()/f_endswith().

This also means that they just let the input pass through for non-string
inputs or arguments.

Only fix the leak for now; in the next release, #2969 will make them
rethrow the error returned by startswith/endswith.

Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64946
2023-12-13 15:13:46 +01:00
Emanuele Torre 7298972551 Makefile.am: don't use -lshlwapi to build jq on WIN32
It does not need it, only libjq needs this.
2023-12-13 13:08:57 +01:00
Emanuele Torre 19453a60cf ci.yml: use sysctl -n hw.logicalcpu instead of nproc on macos
The "macos (arm64)" runner on github does not have nproc.

/Users/runner/work/_temp/f44f0d9f-19eb-4a23-860e-26533d7efdfa.sh: line 10: nproc: command not found
2023-12-11 22:02:42 +01:00
Emanuele Torre 527c5abab1 jv_mem_calloc(): always call with (nmemb, size)
It does not matter much since they most likely just get multiplied
together, but some compilers would complain about this if these were
calls to calloc.
2023-12-11 20:47:32 +01:00
Emanuele Torre c2db51eeb3 shtest+configure: remove uses of non-portable/non-standard commands
Replace deprecated test(1) parentheses and -a logical operator with two
tests command.

Replace deprecated  tail -1  with  tail -n1.

Replace non-standard egrep(1) command with  grep -E  ; this also
prevents obsolescence warnings on GNU systems.
2023-12-11 20:46:54 +01:00
Emanuele Torre 507eb8283c shtest: fix out-of-source tests
The locale test was using ./jq intead of $JQ.

I also removed the use of obsolete egrep instead of grep -E that
triggers warnings on GNU systems, and the use of deprecated head -1
instead of head -n1.

Also removed the unnecessary hiding of strptime/1 errors with
? // false.
2023-12-11 20:45:14 +01:00
Jesper Rønn-Jensen 2ccab044fe chore: Improve readability (for Alternative operator '//')
The description of the Alternative operator `//` was hard for me to grasp in its wording.

I suggest dividing the looong sentence into two parts. Since it is actually an alternative formulation, the sentence can be divided into the first formulation, and the alternative formulation.
2023-12-11 11:38:54 +00:00
Emanuele Torre 7e54d9646e jq.test: fix setpath PR number
It was #2970, not 2967.
2023-12-11 09:58:09 +01:00
dependabot[bot] 22f81401f8 Bump actions/setup-python from 4 to 5
Bumps [actions/setup-python](https://github.com/actions/setup-python) from 4 to 5.
- [Release notes](https://github.com/actions/setup-python/releases)
- [Commits](https://github.com/actions/setup-python/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/setup-python
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-11 07:54:23 +01:00
Emanuele Torre 6b69ffe769 jv_setpath()+setpath/2: don't leak the input after an invalid get
Ref: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64906
2023-12-10 19:40:29 +01:00
Emanuele Torre 80bc768c5d jq_fuzz_fixed: fix test cases that use string interpolation
"\(" is implementation-defined in C++, and both clang and gcc treat it
as equivalent to "(", not "\\(".
This patch replaces "\(" with "\\(" so that tests with string
interpolation actually use string interpolation.
2023-12-10 15:22:03 +01:00
David Korczynski 5029328d35 tests: add new fuzzer
Signed-off-by: David Korczynski <david@adalogics.com>
2023-12-07 12:57:54 +01:00
DavidKorczynski 20a403e97e jq_fuzz_execute.cpp: fix false assert
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64632 by following the suggestion here: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=64632#c2 -- the issue is fixed when this attribute is set.

I did not add any of the other suggestions in the comment: we haven't run into these issues in the fuzzer so far.
2023-12-03 17:54:25 +01:00
DavidKorczynski 693a7261e5 jq_fuzz_execute: fix memory leak
Signed-off-by: David Korczynski <david@adalogics.com>
2023-12-03 03:53:49 +01:00
David Korczynski bfb7fd570f jq_fuzz_execute: cleanup un-needed extern
Signed-off-by: David Korczynski <david@adalogics.com>
2023-11-30 14:40:36 +01:00
David Korczynski 252ab244ce Add fuzzer targeting jq_next
Signed-off-by: David Korczynski <david@adalogics.com>
2023-11-30 14:40:36 +01:00
David Korczynski 13353515bd jq_fuzz_compile: dump disassembly
Signed-off-by: David Korczynski <david@adalogics.com>
2023-11-30 14:40:36 +01:00
Mattias Wadman 98a206964d Convert decnum to binary64 (double) instead of decimal64
This is what the JSON spec suggests and will also be less confusing compared to other jq implementations and langauges.

Related to #2939
2023-11-29 09:36:33 +01:00
Emanuele Torre 1617091033 website: use https URLs instead of http URLs in download page
Also add markdown formatting for decNumber URL so it gets rendered as a
link in the html page.
2023-11-29 09:35:36 +01:00
itchyny d14393f552 Keep releasing executables with legacy names 2023-11-28 22:51:20 +01:00
Tyler Rockwood 6b82dd3c47 libjq: extern C for C++
If using libjq from C++ it would be nice to not need to do this at the
import site, so just extern "C" to the public headers for libjq

Signed-off-by: Tyler Rockwood <rockwood@redpanda.com>
2023-11-28 22:50:25 +01:00
Emanuele Torre 460a5c12b4 jq_fuzz_parse_extended.c: don't jv_free() twice
jv_dump() frees its argument.

I missed this problem before merging #2952, whoops! =)

fixup from eb3b5654bb
2023-11-28 20:51:07 +01:00
David Korczynski 4570c23720 jv_parse: refactor jv_parse_sized
Signed-off-by: David Korczynski <david@adalogics.com>
2023-11-28 20:36:59 +01:00
David Korczynski eb3b5654bb test: add jv_dump to extended fuzzer
Signed-off-by: David Korczynski <david@adalogics.com>
2023-11-28 20:36:59 +01:00
David Korczynski 44300e4310 Extend fuzzing set up
Adds a parse function ins `jv_parse.c` that enables parsing using custom
flags for the parser. This is then used by two fuzzers added as well.

This is to make sure fuzzing hits various code parts currently not
fuzzed, e.g. `stream_token`:
https://storage.googleapis.com/oss-fuzz-coverage/jq/reports/20231125/linux/src/jq/src/jv_parse.c.html#L241

Signed-off-by: David Korczynski <david@adalogics.com>
2023-11-28 20:36:59 +01:00
Andreas Heiduk 88f01a741c simplify paths/0 and paths/1
`recurse/0` already handles traversing objects and arrays, so it is more
consistent to use that.
For `paths/1` it is easier to use the actual value returned by
`recurse` instead of querying that value with `getpath/1` afterwards.
2023-11-16 21:14:58 +01:00
Emanuele Torre 6c035133e8 README.md: tosed => to sed (#2944) 2023-11-06 23:59:22 +09:00
Emanuele Torre cca1f7d18f Comment bug fixes, and fully support Tcl-style multiline comments
* bugfix: comments were incorrectly being terminated by CR; for example
    jq -n $'1 #foo\r'
  fails to compile because the CR character terminates the comment, and
  CR is not a valid character in jq syntax.

* improvement: comments fully support Tcl-style line continuation.
  Previously this was only "supported" in `-f' scripts, whose first line
  starts with "#!", and second line starts with # and ends with \, only
  for the comment on the second line, only for one extra line.

* man: document comment syntax, which was previously undocumented.

* tests: add regression tests for the bugfix, and some tests for line
  continuation in comments.
2023-11-03 15:52:02 -05:00
Emanuele Torre f4929f3c19 src/builtin.c: remove unnecessary jv_copy-s in type_error/type_error2
Also fix doubled semicolon   jv ret;;   =>   jv ret;
2023-10-30 22:12:27 -05:00
Emanuele Torre d5590f90da jvp_object_contains: remove unnecessary jv_copy 2023-10-30 22:12:27 -05:00
Emanuele Torre e85e358233 Fix possible uninitialised value dereference if jq_init() fails
If jq_init() fails, goto out would try to free input_state which is
uninitialised. I initialised input_state to NULL to fix the problem.

Ref: https://github.com/jqlang/jq/pull/2934#discussion_r1367795641

Reported-By: Klemens Nanni <kn@openbsd.org>
2023-10-22 10:51:24 -05:00
Klemens Nanni 7ab117a483 Defer heap variable initialisation after pledge
Otherwise `AGRS` and `program_arguments` remain allocated/unfreed in the
early (extremely unlikely) pledge(2) failure case.

Move their allocation before jq_init(), the first case of jumping to
`out` where they are cleaned up, where it also seems to logically fit
better than above between function entry, locale setup and OpenBSD
specific pledge.
2023-10-21 23:30:36 -05:00
Klemens Nanni 77dcaf3fdc Remove unused mkstemp()
b82c231 "Remove -i option (#704)" removed its last usage in 2015.

Spotted while looking for code could potentially write/create/modify files.
2023-10-21 23:30:36 -05:00
Klemens Nanni f1bfd0c518 Restrict systems operations on OpenBSD
Use pledge(2)[0] to limit jq(1) to reading files.
It does not change files and only writes to standard output/error.
It never deals with TTY, network, process management or other subsystems.

This is to reduce jq's attack surface and potential damage.

OpenBSD is carrying a local patch[1] in its official jq port/package
since 2016.  An improved version:

- drop no longer needed "getpw" promise
  f1c4947 "Avoid getpwuid for static linking" removed getpwuid(3) usage
- pledge before jq_init() to simplify the error path
- use perror(3) to print errno(2)

No behaviour change in tests or real world usage observed on
OpenBSD/amd64 7.4.

0: https://man.openbsd.org/pledge.2
1: https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/textproc/jq/patches/patch-main_c
2023-10-21 23:30:36 -05:00
Emanuele Torre 9de0e26ce6 Generate links in man page
Some [foo](bar) links were added to manual.yml without updating
build_manpage.py to make it generate roff for "a" tags.

Fixes #2930
2023-10-12 15:32:23 -05:00
Gaelan Steele c10cbbff34 Remove undefined behavior caught by LLVM 10 UBSAN. 2023-10-08 12:32:22 -05:00
Emanuele Torre 6b6feaffbb Revert "Revert "od -c => od -tc: od -c is an XSI extension..."
This reverts commit 0e70f7a57e.

There is no reason to revert this change.

In #2922, I only disagreed with the commit message suggesting that
  LC_CTYPE=C od -t c    is   equivalent to   od -c

The only documented differences are that -tc is required to be
influenced by -N and -j, while -c is not, and that -c is required to
only support a subset of the backslash sequences that -tc should
support.
2023-10-05 15:37:44 +02:00
Nicolas Williams 0e70f7a57e Revert "od -c => od -tc: od -c is an XSI extension equivalent to LC_CTYPE=C od -tc and not universally available"
This reverts commit 0bce9fb8ed.
2023-10-04 22:28:24 -05:00
наб 0bce9fb8ed od -c => od -tc: od -c is an XSI extension equivalent to LC_CTYPE=C od -tc and not universally available 2023-10-04 17:46:13 -05:00
Emanuele Torre 4ebd21e1eb Allow passing the inline jq script before --
jq previously only allowed passing the inline script before -- (as if
they were options) even though one would expect the inline script to be
a positional argument.

Since jq previously also refused to run with a usage error if the script
was passed after -- (It was not assuming  .  as script as it does when
no arguments are passed), and positional arguments are allowed before --
and even before other options, it should not be a breaking change to
change that weird behaviour, and allow the script to appear after --.

It also simplifies the option parsing code a bunch.

Fixes #2918
2023-10-04 00:00:46 -05:00
Thomas Bozeman th026106 7f547827e4 Simplify pick example
Old pick example included input array in command line, making `input` confusing
and redundant.
2023-10-03 22:48:12 +02:00
Emanuele Torre 6b5a18f036 Actually use number correctly casted from double to int as index
The code was using (int)jv_number_value(k) instead of (int)didx.

follow-up from 0e067ef936

Useless assignments to didx detected by clang-tidy.
2023-09-27 22:54:23 -05:00
Emanuele Torre 8206bc8fd2 main.c: Remove unused EXIT_STATUS_EXACT option
In process there is a suspicious  options |= EXIT_STATUS_EXACT  that
is run when the jq script is terminated by halt, or halt_error.

That line of code acutally does nothing because options is a local
argument variable, and is not passed as a pointer. It was probably meant
to be a   *options |= EXIT_STATUS_EXACT   with the options argument
passed as a int*.

In any case, we do not want to run the code in main() that was supposed
to run if EXIT_STATUS_EXACT is set (but didn't since it is never added
to options); as far as I can tell, we only want to run that code when
the --exit-status/-e option is passed.

So I removed EXIT_STATUS_EXACT completely, and the useless assignment,
instead of fixing it since it was not used for anything else.

Useless assignment detected by clang-tidy.
2023-09-27 21:52:23 -05:00
Emanuele Torre 623ace27e8 Remove a bunch of unused variables, and useless assignments
Detected by clang-tidy.
2023-09-27 21:50:44 -05:00
Emanuele Torre 2b709727a9 Remove unused nref accumulator in block_bind_library
detected as a warning compiling jq with clang.
2023-09-27 21:50:44 -05:00
itchyny 07149397d1 Reject U+001F in string literals (fix #2909) 2023-09-26 12:53:44 -05:00
itchyny e526df15fe Correct typo in README.md: compilation (#2912) 2023-09-26 19:49:07 +02:00
taoky 8f81668014 Fix the default colors to use 39, the default foreground color (#2904) 2023-09-22 09:18:41 +09:00
dependabot[bot] de1c10ca8a Bump docker/setup-qemu-action from 2 to 3 (#2900)
Bumps [docker/setup-qemu-action](https://github.com/docker/setup-qemu-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-qemu-action/releases)
- [Commits](https://github.com/docker/setup-qemu-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-qemu-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 18:20:43 +09:00
dependabot[bot] a5afeea0a6 Bump docker/setup-buildx-action from 2 to 3 (#2901)
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 18:20:20 +09:00
dependabot[bot] b0b7614daf Bump actions/checkout from 1 to 4 (#2902)
Bumps [actions/checkout](https://github.com/actions/checkout) from 1 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v1...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-18 18:19:51 +09:00
Kamontat Chantrachirathumrong d3a356fa1c Fix checksum file spacing for shasum command (#2899) 2023-09-17 20:55:56 +09:00
dependabot[bot] 24e6e6ea39 Bump actions/upload-artifact from 2 to 3
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 2 to 3.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](https://github.com/actions/upload-artifact/compare/v2...v3)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-15 13:44:46 +02:00
dependabot[bot] fb493df018 Bump crazy-max/ghaction-import-gpg from 5 to 6
Bumps [crazy-max/ghaction-import-gpg](https://github.com/crazy-max/ghaction-import-gpg) from 5 to 6.
- [Release notes](https://github.com/crazy-max/ghaction-import-gpg/releases)
- [Commits](https://github.com/crazy-max/ghaction-import-gpg/compare/v5...v6)

---
updated-dependencies:
- dependency-name: crazy-max/ghaction-import-gpg
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-15 13:43:44 +02:00
dependabot[bot] f3a46a62de Bump docker/metadata-action from 4 to 5
Bumps [docker/metadata-action](https://github.com/docker/metadata-action) from 4 to 5.
- [Release notes](https://github.com/docker/metadata-action/releases)
- [Upgrade guide](https://github.com/docker/metadata-action/blob/master/UPGRADE.md)
- [Commits](https://github.com/docker/metadata-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/metadata-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-15 13:42:32 +02:00
dependabot[bot] e69398ea0f Bump docker/build-push-action from 4 to 5
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-15 13:41:27 +02:00
dependabot[bot] dfd930f81a Bump docker/login-action from 2 to 3
Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-15 13:40:33 +02:00
Yeikel 4c6f6dc231 Add dependabot (#2889) 2023-09-15 20:09:07 +09:00
itchyny 5ea1a4ab3b Disable core.autocrlf on Windows to prevent submodule diffs (fix #2886) (#2888) 2023-09-15 20:08:20 +09:00
Owen Ou 7a72f58d2e Standarize arch types to AMD64 & ARM64 from index page download dropdown (#2884)
Standarize arch types to AMD64 & ARM64 from index page download
dropdown. These are missed from https://github.com/jqlang/jq/pull/2879.
2023-09-07 11:55:14 -07:00
Owen Ouanditchyny 806475da29 Update webpage with 1.7 release (#2879)
* Update webpage with 1.7 release

Update webpage with 1.7 release

* Update docs/content/download/default.yml

Co-authored-by: itchyny <itchyny@cybozu.co.jp>

* Update docs/templates/index.html.j2

Co-authored-by: itchyny <itchyny@cybozu.co.jp>

* Update docs/content/download/default.yml

Co-authored-by: itchyny <itchyny@cybozu.co.jp>

* Don't mention 1.7rc signatures

* Add link to 1.7 manual

* binaries -> binary

* AMD 32-bit to i386

* Standarize arch types to AMD64, ARM64 & i386 in download page

---------

Co-authored-by: itchyny <itchyny@cybozu.co.jp>
2023-09-07 10:54:10 -07:00
github-actions[bot] 4b579ca31f Update signatures of 1.7 2023-09-06 17:53:36 -05:00
Nicolas Williams 11c528d04d Add setlocale() call (fix #1740) 2023-09-06 14:05:10 -05:00
Nicolas Williams ac3b70d3a1 Add a thank you note to the new owners, admins, and maintainers, and to @stedolan 2023-09-06 13:01:44 -05:00
Nico Williams df95871dd7 Fix leak on too-large programs, OSS Fuzz issue 61349
A very large program can cause these leaks:

  ==758838== 7,820 (16 direct, 7,804 indirect) bytes in 2 blocks are definitely lost in loss record 17 of 28
  ==758838==    at 0x4848A23: calloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==758838==    by 0x125D30: jv_mem_calloc (jv_alloc.c:153)
  ==758838==    by 0x162ADE: compile (compile.c:1286)
  ==758838==    by 0x162D4B: compile (compile.c:1304)
  ==758838==    by 0x163697: block_compile (compile.c:1381)
  ==758838==    by 0x11B5CA: jq_compile_args (execute.c:1245)
  ==758838==    by 0x115E20: main (main.c:691)
  ==758838==
  ==758838== 1,674,694 (103,576 direct, 1,571,118 indirect) bytes in 1,177 blocks are definitely lost in loss record 28 of 28
  ==758838==    at 0x4843839: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==758838==    by 0x125CD0: jv_mem_alloc (jv_alloc.c:141)
  ==758838==    by 0x162B19: compile (compile.c:1289)
  ==758838==    by 0x163697: block_compile (compile.c:1381)
  ==758838==    by 0x11B5CA: jq_compile_args (execute.c:1245)
  ==758838==    by 0x115E20: main (main.c:691)

This commit fixes that.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61349
2023-08-29 10:27:41 +02:00
github-actions[bot] 91d72575e4 Update signatures of 1.7rc2 2023-08-27 12:53:29 -05:00
Nicolas Williams 0e067ef936 Improve handling of non-integer numeric indices (fix #2815) 2023-08-27 12:32:12 +02:00
Emanuele Torre ab47880b4c Make jq_get_lib_dirs return an empty array if JQ_LIBRARY_PATH is not set
For the jq_state used by the jq utility, the JQ_LIBRARY_PATH attribute
will always be set, but, in general, it is possible that it might not
be.

If it is not set, jq_get_lib_dirs() will return jv_invalid().

That is not good, because some code in linker.c expects it to always
returns an array.

This patch makes jq_get_lib_dirs() return an empty array if
JQ_LIBRARY_PATH is not set to prevent problems.

This issue made OSS fuzz trigger failed assertions every time it tried
to compile a script that uses "include".

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=61796
2023-08-27 00:37:54 -05:00
Emanuele Torre 6436f1e0f8 Fix memory leak in find_lib for some invalid inputs 2023-08-26 17:17:29 -05:00
Nicolas Williams 2c3561810d Check nomem_handler->handler before calling it 2023-08-25 10:13:46 -05:00
itchyny 70807e2b1b Include more updates to NEWS.md and AUTHORS for 1.7 2023-08-23 15:59:19 -05:00
itchyny 080471b2a0 Add src/config_opts.inc to .gitignore 2023-08-21 16:06:58 +02:00
Nicolas Williams 583e4a2718 Add --config option printing ./configure options used 2023-08-19 17:40:08 -05:00
itchyny 7d64381016 Fix overflow on numeric comparison (#2849)
Although #2839 fixed the overflow of exponent subtraction,
there still is possibility of overflow in the `D2U` macro.
This patch fixes the overflow in the `D2U` macro, and also
truncates the maximum digits to `DEC_MAX_DIGITS`.
2023-08-17 15:56:57 +09:00
itchyny 0733fd3d58 Add a regression test for negative indices and fix a pick/1 test 2023-08-16 17:49:44 -05:00
itchyny f85c9fcb78 Revert "Allow .[-1] in path expressions"
This reverts commit 086a156ec3.

This commit leads to negative indexing wraps twice.
2023-08-16 17:49:44 -05:00
Emanuele Torre 4cf1408e0b Cast function pointers without prototype before calling them (#2842)
clang complained that this is deprecated in all versions of standard C,
and unsupported in C2x.
2023-08-13 22:39:54 +09:00
itchyny 3fa10e8cc1 Fix crash on numeric comparison again (ref #2825)
The decNumber library subtracts the exponents of two numbers,
we make sure to limit the number of digits not to make it overflows.
Since the maximum adjusted exponent is `emax` and the minimum is
`emin - digits + 1`, we follow `emax - (emin - digits + 1) <= INT32_MAX`.
2023-08-13 14:17:25 +02:00
itchyny f86566b263 Rename jv_type_private.h to jv_private.h, move jvp_number_is_nan there 2023-08-13 14:16:02 +02:00
Alex Wilson f31c180e8f Update documentation to reflect new defs field on modulemeta 2023-08-12 20:46:36 -05:00
Alex Wilson 65ed95c93a Expose the names of a module's defined function via modulemeta
This reuses the existing `block_list_funcs` capability and adds an extra field on the `modulemeta` output, called `defs`, containing that list of functions.
2023-08-12 20:46:36 -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
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
itchynyandLeonid S. Usov 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 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
Emanuele Torre ae95864b6b Make sure to free default @text format on error
It seems that bison doesn't call destructors for mid-rule action
components on error, since it does not know their type.

A mid-rule action was used to allocate the "text" string used as format
by string literals without a format, which would leak on error.
This patch replaces it with a new NoFormat component of type <literal>.
Now bison will call jv_free() on that string after a syntax error.

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60836

  $ ./jq '"'
  jq: error: syntax error, unexpected end of file, expecting QQSTRING_TEXT or QQSTRING_INTERP_START or QQSTRING_END (Unix shell quoting issues?) at <top-level>, line 1:
  "
  jq: 1 compile error

  =================================================================
  ==1495450==ERROR: LeakSanitizer: detected memory leaks

  Direct leak of 21 byte(s) in 1 object(s) allocated from:
      #0 0x7fc21aee1359 in __interceptor_malloc /usr/src/debug/gcc/gcc/libsanitizer/asan/asan_malloc_linux.cpp:69
      #1 0x557ccb6ff608 in jv_mem_alloc src/jv_alloc.c:141

  SUMMARY: AddressSanitizer: 21 byte(s) leaked in 1 allocation(s).
2023-07-25 14:51:58 -05:00
Mattias Wadman a949745059 implode: Better invalid input validation and handling
Error on non-number and nan codepoint, would asserd before
Replace negative codepoint and surrogate range with unicode replacement character, would assert before

Fixes #1160
2023-07-25 13:38:41 -05:00
itchyny a29ac81de1 Remove deprecated --argfile option 2023-07-25 10:21:01 -05:00
Mattias Wadman bb8221efdc Align prompt in help example
Was accidentally unaligned in #2747

Now looks like this:

Example:

	$ echo '{"foo": 0}' | jq .
	{
	  "foo": 0
	}

Before looks like this:

Example:

	 $ echo '{"foo": 0}' | jq .
	{
		"foo": 0
	}
2023-07-25 15:10:50 +02:00
itchyny 4705a22c7d Reorder the command line options in the manual (#2766) 2023-07-25 15:24:54 +09:00
pkoppstein 8f49600a6b builtin.jq: simpler and faster transpose (#2758) 2023-07-25 09:12:23 +09:00
Emanuele Torre 330559643a Run autoconf -i in the Build step of the scanbuild workflow
Fixup from 54fef09ac3
2023-07-24 18:55:48 +02:00
Tomas Halman cca0087ee6 Test that jq works in threads
This patch implements test that searches a key in simple
json in pthread.
2023-07-24 11:55:15 -05:00
Tomas Halman 2dbae5610b Fix segmentation fault when using jq in threads
In previous code nomem_handler in jv_alloc.c is called only once
and therefore the structure is not initialized for second and
following threads.

This leads to segmentation fault in multi-threading environment.

This patch moves initialization of nomem_handler out of the
pthread_once call.
2023-07-24 11:55:15 -05:00
itchyny 5300fbda58 Add decnum workflow to test building without decNumber support 2023-07-24 11:53:51 -05:00
itchyny c4d5ba954d Improve USE_DECNUM check position 2023-07-24 11:53:51 -05:00
Mattias Wadman 54fef09ac3 Make maintainer-mode default to disabled
This makes the standard build instructions a bit easier,
just ./configure, and also requires less tools installed (bison).

Also i think few people probably want to generate the lexer and paser code.
2023-07-24 11:26:17 -05:00
Mattias Wadman 4cc99831e4 Free expected value on invalid actual for test
valgrind (3.19.0) locally on macOS docker container seems to detect this leak but not CI.

$ cat modulemeta.test
modulemeta | .deps |= length
"c"
{"whatever":null,"deps":6}

$ valgrind --error-exitcode=1 --leak-check=full -q ./jq --run-tests < modulemeta.test
Test #1: 'modulemeta | .deps |= length' at line number 1
*** Insufficient results for test at line number 3: modulemeta | .deps |= length
0 of 1 tests passed (0 malformed, 0 skipped)
==14129== 482 (392 direct, 90 indirect) bytes in 1 blocks are definitely lost in loss record 7 of 8
==14129==    at 0x48407B4: malloc (vg_replace_malloc.c:381)
==14129==    by 0x13BC78: jv_mem_alloc (jv_alloc.c:122)
==14129==    by 0x1371C6: jvp_object_new (jv.c:1521)
==14129==    by 0x145840: parse_token (jv_parse.c:167)
==14129==    by 0x145840: scan (jv_parse.c:684)
==14129==    by 0x145840: jv_parser_next (jv_parse.c:793)
==14129==    by 0x1463CB: jv_parse_sized (jv_parse.c:865)
==14129==    by 0x136BD9: run_jq_tests (jq_test.c:183)
==14129==    by 0x1370FA: jq_testsuite (jq_test.c:34)
==14129==    by 0x13135C: main (main.c:582)
==14129==
2023-07-24 11:16:22 -05:00
Mattias Wadman 16ae275d4c Fix leaks on invalid input for strftime, strflocaltime and mktime 2023-07-24 16:45:43 +02:00
David Korczynski 97c6d2848c Add fuzzer targeting load_file
Signed-off-by: David Korczynski <david@adalogics.com>
2023-07-24 15:45:12 +02:00
Emanuele Torre 8a4f246876 Remove all #define _GNU_SOURCE in source files
This is unnecessary since we are using AC_USE_SYSTEM_EXTENSIONS in
configure.ac, which makes the compiler always run with -D_GNU_SOURCE=1
when building for GNU/Linux.

Also, the  #define _GNU_SOURCE  in src/util.c, and in
src/inject_errors.c (--enable-inject-errors), were not guarded by a
#ifndef _GNU_SOURCE  so they were just triggering redefinition warnings.
2023-07-24 15:44:29 +02:00
David Korczynski cf3c11bde8 Add compile fuzzer for OSS-Fuzz
Signed-off-by: David Korczynski <david@adalogics.com>
2023-07-24 13:44:27 +02:00
itchyny ed334b536f Improve manual in various ways (inputs, sort_by, foreach sections, etc.) (#2744)
- Add error/0 and mentions null input behavior (close #2231)
- Explain value iterator suffix syntax .foo[] (close #1047)
- Mention array slicing is also zero-based (close #2094)
- Add examples of input and inputs filters (close #2216, close #2470)
- Improve sort_by about multiple values (close #2103, close #2467, close #2474)
- Improve foreach section and simplify examples (close #1148, close #2169)
- Fix recurse/1 document on how it is identical using recurse/2 (close #2036, close #2412)
- Add non-string examples of index/1, rindex/1 (close #1422)
- Simplify the example of truncate_stream/1 (close #1736)
2023-07-24 20:24:44 +09:00
Nico Williams 1cf6515c06 Fix try/catch catches more than it should #1859
Close #1885, #2140, #2011, #2220, #2485, #2073

Rename the FORK_OPT opcode to TRY_BEGIN, add a TRY_END opcode, and wrap
errors when raising through a TRY_END so that they will not be caught by
the matching TRY_BEGIN.

Now a `try exp catch handler` expression generates code like:

    TRY_BEGIN handler
    <exp>
    TRY_END
    JUMP past_handler
    handler: <handler>
    past_handler:
    ...

On backtrack through TRY_BEGIN it just backtracks.

If anything past the whole thing raises when <exp> produced a value,
then the TRY_END will catch the error, wrap it in another, and
backtrack.  The TRY_BEGIN will see a wrapped error and then it will
unwrap and re-raise the error.

If <exp> raises, then TRY_BEGIN will catch the error and jump to the
handler, but the TRY_BEGIN will not stack_save() in that case, so on
raise/backtrack the TRY_BEGIN will not execute again (nor will the
TRY_END).
2023-07-24 13:20:21 +02:00
itchyny 98f709d0c1 Fix stderr to output string with no decoration (fix #2063) 2023-07-23 17:06:00 -05:00
itchyny dfdce8c6e7 Add checksum signature of old release artifacts (close #1999) 2023-07-23 12:24:59 -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 123c780607 Enable significand on macOS 2023-07-23 03:28:07 -05:00
itchyny 99a381b5aa Improve --help to mention all the command options 2023-07-23 03:26:44 -05:00
itchyny 575372222a Add importlib_resources dependency for older Python (fix #2753) (#2754) 2023-07-23 15:01:16 +09:00
itchyny 34629ed223 Fix manual source code to follow the schema definition 2023-07-22 19:00:16 -05:00
itchyny 9044f540bb Validate manual schema 2023-07-22 19:00:16 -05:00
itchyny c9c45d7f03 Add tests for --arg, --argjson, and similar options 2023-07-22 12:29:24 -05:00
itchyny 649d6b5f5e Update AUTHOR for the next release 2023-07-22 11:53:43 -05:00
itchyny e0e1b2293e Enable verbose output of make check 2023-07-21 19:49:48 -05:00
itchyny 3ed928954a Fail quickly if not in git repository in scripts/version 2023-07-21 08:59:17 -05:00
itchyny 4732dd82c0 Remove AppVeyor configuration (#2741) 2023-07-21 22:45:45 +09:00
pkoppstein 3553a9d617 manual.yml: some clarifications plus fixes for markdown bloopers (#2737) 2023-07-21 21:33:03 +09:00
itchyny 7c2bf9bd17 Clarify the Docker image location (close #1864) (#2740) 2023-07-21 20:42:11 +09:00
itchyny 99a77f724b Add a regression test for #2000 2023-07-21 09:01:28 +09:00
William Langford 515260213c Increment nlocals when compiling STORE_GLOBAL ops (#2000)
These are stored in vars, so we need to make sure that nlocals is large
enough to account for that
2023-07-21 09:01:16 +09:00
pkoppstein 3ec66c858c manual.yml: revise section on identity, clarifying what is subject to change
Mostly clarifications w.r.t. numbers.

The anomalous behavior of leading minus signs is documented, with an explicit notice that this will probably change.
2023-07-19 22:32:24 -05:00
Robert Aboukhalil a192e647c5 Move options to main and pass it to process 2023-07-19 13:07:46 -05:00
Robert Aboukhalil 4c25cf3f7c Reset options to 0 so can call main() multiple times in a row 2023-07-19 13:07:46 -05:00
itchyny f1c49473a3 Avoid getpwuid for static linking 2023-07-19 09:56:41 -05:00
itchyny f0306405c1 Add notes on NO_COLOR environment variable to the manual 2023-07-19 09:56:01 -05:00
itchyny 0615d4982c Respect NO_COLOR environment variable to disable color output 2023-07-19 00:05:41 -05:00
itchyny 87e3dfddb8 Enable valgrind in oniguruma workflow 2023-07-19 06:45:09 +02: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 62d65a8a9c Fix memory leaks in --with-oniguruma=no implementation of f_match
Found by LeakSanitizer running  ./jq -n '"" | test("")'  in a
--with-oniguruma=no --enable-ubsan --enable-asan  build.
2023-07-18 14:45:20 -05:00
itchyny 0e3c3913d8 Add oniguruma workflow to test regex options 2023-07-18 14:28:16 -05:00
Emanuele Torre 7ffb7943d4 Fix signed integer overflow undefined behaviour in decNumber.c
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60691

  $ ./jq <<< 0E2202012202
  src/decNumber/decNumber.c:598:18: runtime error: signed integer overflow: 440402440 + 1761609760 cannot be represented in type 'int'
  0E+999999999

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60683

  $ ./jq <<< 5E7657765755
  src/decNumber/decNumber.c:598:18: runtime error: left shift of 765776575 by 3 places cannot be represented in type 'int'
  src/decNumber/decNumber.c:598:18: runtime error: signed integer overflow: 1531553150 + 1831245304 cannot be represented in type 'int'
  1.7976931348623157e+308
2023-07-18 14:03:40 -05:00
Emanuele Torre 15fd31de78 Define examples in the "examples" field instead of "example"
Only examples defined in the "examples" field are generated, if they are
defined in "example", they are just ignored.

Also fix a bunch of incorrect tests.
2023-07-18 12:12:50 -05:00
Emanuele Torre 01dfd8b86d Populate captures also for zero-width matches
Instead of just using {"captures":[]}.

sub functions are use captures for replacement expressions.
If we don't populate, captures for empty matches, the replacement
expression is run with an empty object as input instead of an object
containing the named captures with "" as value:

* before:

  $ jq -n '"123foo456bar" | gsub("[^a-z]*(?<x>[a-z]*)"; "Z\(.x)")'
  "ZfooZbarZnull"

* after:

  $ jq -n '"123foo456bar" | gsub("[^a-z]*(?<x>[a-z]*)"; "Z\(.x)")'
  "ZfooZbarZ"

---

I also removed a redundant

  result = NULL;
  if (result) {
    ...
  }
2023-07-18 12:12:50 -05:00
Emanuele Torre bb0f898c01 Initialise jq_state->debug_cb{,_data} to NULL
To make debug/0 not call an uninitialised function pointer when using
--run-tests or when using a jq_state on which jq_set_debug_cb() has not
been called.
2023-07-18 12:12:50 -05:00
itchyny 9e4c71558a Split man.test to make tests pass without oniguruma (#2722) 2023-07-18 08:17:21 +09: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
Emanuele Torre e79335e3a5 Initialise jq_state->input_cb{,_data} to NULL in jq_init()
To avoid causing segmentation faults when  input/1  is called in a
jq_state on which  jq_set_input_cb()  has not been called; e.g. the one
used by  jq --run-tests.

That segfault could also be fixed in run_jq_tests() by calling:

  jq_set_input_cb(jq, NULL, NULL);

But I think it makes sense to just make jq_init() initialise those
values to NULL.

Ref: https://github.com/jqlang/jq/pull/2717#discussion_r1264338841
2023-07-16 00:03:46 -05:00
itchyny 1cb9ba3533 Fix autoreconf warnings 2023-07-16 00:02:46 -05:00
Emanuele Torre 1915b689f7 Fix indices/1 and rindex/1 in case of overlapping matches in strings
Fixes #2433
2023-07-14 23:40:37 -05:00
Emanuele Torre bf4390562f Add workflow that runs tests with valgrind on linux
To hopefully detect when we introduce new memory leaks. :-)
2023-07-15 01:29:13 +02:00
itchyny 24871fb4a3 Fix memory leak on halt_error/1 2023-07-14 13:39:21 +02:00
pkoppstein 07ef97c414 debug/1 (#2710)
* debug/1

This def ensures the output of debug(m1,m2) is kept together.

Closes #2709 #2111 #2112
2023-07-14 00:17:42 +02:00
Emanuele Torre 4b1ac7c95f Parse nan in JSON as NaN instead of triggering a parse error (#2712)
* Fix memory leak for has(nan)

jv_array_get() used to be responsible of freeing the input array, but
since b5c4c3d67d, it is no longer called
if the key is nan. We need to free it manually to avoid leaking the
array.

* Parse  nan  in JSON as NaN instead of triggering a parse error

Fixes #2021
2023-07-14 07:12:27 +09:00
itchyny 092fef740a Make sure distcheck passes and run dist job on Pull Request 2023-07-13 10:20:04 -05:00
itchyny 481167c8f1 Update jinja2 to fix deprecation warnings on building website (#2711) 2023-07-14 00:06:53 +09:00
itchyny 689a4e660b Fix uri format to follow RFC 3986 (#2157) 2023-07-13 23:23:23 +09:00
Emanuele Torre 55249e29be Also run manpage.yml workflow on pull requests that modify the manual 2023-07-13 06:20:11 +02:00
Emanuele Torre ab2779e2e5 Mark src/decNumber/** as vendored files
This excludes those files from the Languages statistics on github.
2023-07-12 11:14:39 -05:00
itchyny b5c4c3d67d Fix has(nan) on arrays to output false 2023-07-12 09:40:05 -05:00
itchyny 14e5e630ed Revert unexpected changes in decNumber code (ref #2031) 2023-07-11 18:36:36 -05:00
Emanuele Torre c99981c5b2 Update "tests/man.test" and remove superflous whitespace in manual.yml
tests/man.test was generated incorrectly and had some duplicate tests,
the new CI workflow didn't like that.
2023-07-11 00:24:50 -05:00
Emanuele Torre c049061084 Fix build_manpage.py with newer markdown versions
The markdown python changed its API for markdown extensions.

Bumping the markdown package version in previous commits broke
docs/build_manpage.py since it was using registering an extension with
the old API.
2023-07-11 00:24:50 -05:00
Emanuele Torre 83d4dd16ad Add CI workflow to make sure the man page and man.test can be built
And that man.test is up to date.
2023-07-11 00:24:50 -05:00
Owen Ou 4ff63d9365 Add checksums.txt for release
Add checksums.txt for release
2023-07-10 23:59:07 -05:00
itchyny 4c125c7ca6 Do not remove manpage prebuild file on build failure 2023-07-10 18:47:14 -05:00
Emanuele Torre 2377972dfe Use jinja2 ==3.0.2 for now
We are using some deprecated jinja2 features that have been removed in
newer versions.
2023-07-10 16:19:52 -05:00
Nicolas Williams 31280c3b50 Revert "Update docs/Pipfile.lock"
This reverts commit 7fba85095b.
2023-07-10 15:33:18 -05:00
Emanuele Torre 7fba85095b Update docs/Pipfile.lock 2023-07-10 15:23:00 -05:00
Emanuele Torre fc1bef0261 Mark generated manual files as linguist-generated=true 2023-07-10 15:23:00 -05:00
Nicolas Williams 295ff72dd0 Update docs/README.md 2023-07-10 14:35:11 -05:00
Nicolas Williams 1ec8be1422 Update tests/man.test 2023-07-10 14:18:27 -05:00
Nicolas Williams 2a67fc377d Update jq.1.prebuilt 2023-07-10 14:12:32 -05:00
davkor 3df8f90c4e Add first fuzzer for integration with OSS-Fuzz.
Signed-off-by: David Korczynski <david@adalogics.com>
2023-07-10 13:57:38 -05:00
Emanuele Torre 6ca7973d49 Allow using { $__loc__ } as shorthand for { __loc__: $__loc__ }
n.b.: { $__loc__: "foo" }  is still not allowed.

$__loc__ cannot be overwritten, and it is always an object.
Using { $x: "foo" } where $x is not a string is an error, so there is
not much of a point in supporting that.
2023-07-10 12:04:54 -05:00
itchyny 841445eea7 Build Docker image using pre-built executables (#2686) 2023-07-10 16:15:01 +09:00
pkoppstein 8345a8a62b manual.yml: further tweaks re map and map_values
Further tweaks, e.g. i.f.o. explicitness:

`map_values(f)` outputs an array if given an array,
or an object if given an object.
2023-07-10 00:06:58 -05:00
pkoppstein 39cf2fb7a6 manual.yml: further tweaks re map and map_values
A more systematic exposition
2023-07-10 00:06:58 -05:00
pkoppstein d710324ef8 manual.yml: clarify explanation of map_values, including description of new behavior
#2466
2023-07-10 00:06:58 -05:00
Owen Ou ce3701fe52 Cross compile for Linux, MacOS and Windows on CI (#2665) 2023-07-10 08:05:25 +09:00
Emanuele Torre 193f432e08 Lex $foo as a single token, instead of using '$' IDENT
Previously, bindings were parsed as the combination of two tokens:
  '$' IDENT

This meant that using a keyword as variable name (e.g. $then, $label)
did not work.
Attempts were made to allow $keyword to work by adding some '$' Keyword
rules in the parser, but this did not allow $keyword in all places:

  jq --arg label foo -n '$label'  # ok

  jq -n '"foo" as $label | .'     # error

Treating $foo as a single token is much simpler, in my opinion.

This patch also changes how LOC is lexed: "$__loc__" instead of as
"__loc__" that gets combined with '$' in the parser.

This patch also disallows having spaces after '$' when recalling a
variable  `$ foo'  since that was probably just an unintentional side
effect of the implementation, and it was not documented.

Fixes #2675
2023-07-09 17:23:19 -05:00
Emanuele Torre c08ecbaf23 Mark src/{parser,lexer}.{c,h} as generated files in .gitattributes
This should hide edit to those files in PR diffs making PRs easier to
review.
2023-07-09 14:38:17 -05:00
itchyny 600e602548 Fix empty regular expression matches (fix #2565) 2023-07-09 12:51:53 -05:00
itchyny cac216a39c Fix manual on paths/1 to use boolean filter for its argument 2023-07-09 10:54:13 -05:00
Mattias Wadman ab1a68144d Support .a.[] and .a.[]? each syntax
Fixes #1699
2023-07-09 10:08:31 -05:00
itchyny d8072564c2 Fix nth/2 to emit empty on index out of range 2023-07-08 23:13:15 -05:00
itchyny e2bc8de8bb Fix the latest manual on string multiplication by zero 2023-07-08 23:10:07 -05:00
itchyny cac3ea3726 Fix string multiplication by 0 (and less than 1) to emit empty string 2023-07-08 22:25:22 -05:00
itchyny 88b45771bd Fix string multiplication with a value between 0.0 and 1.0
This commit fixes a regression of 6306ac8966.
2023-07-08 22:25:22 -05:00
itchyny af57893bc2 Optimize appending deletion path in modify 2023-07-07 20:11:10 -05:00
itchyny 371abc73ba Fix deletion using assigning empty against arrays (fix #2051) 2023-07-07 20:11:10 -05:00
Emanuele Torre cd8898d5b9 exit immediately after halt or halt_error is called
Instead of continuing to the next input, and only exiting if there are
no more inputs.

Closes #2533
2023-07-07 11:13:28 -05:00
itchyny 0ecededefa Remove deprecated filters: leaf_paths, recurse_down 2023-07-07 10:53:40 -05:00
itchyny 6944d81bc8 Fix dumping large floating numbers (fix #2367) (#2661) 2023-07-06 21:44:17 +09:00
pkoppstein c68ad08805 manual.yml: pick(pathexps)
Change formal parameter name
2023-07-05 23:48:31 -05:00
pkoppstein 37225a9a07 builtin.jq: def pick(pathexps):
Change the name of the formal parameter.
2023-07-05 23:48:31 -05:00
pkoppstein 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
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
itchyny c077b95ba2 Remove outdated CI badges from README.md (#2653) 2023-07-05 07:51:25 +09:00
itchyny 9014c212e8 Release Docker image to GitHub Container Registry (#2652) 2023-07-05 04:33:57 +09:00
itchyny 886a9b18b1 Make 0 divided by 0 results in NaN consistently (#2253) 2023-07-05 04:28:08 +09: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 7d424fd52e Fix release workflow tag trigger pattern (#2651) 2023-07-04 16:00:25 +09:00
itchyny 2270e208d2 Improve Dockerfile: update base image and optimize image size (#2649)
Also, drop ineffectual flags from configure.
2023-07-04 16:00:04 +09:00
Mattias Wadman 12ce4e3b54 Support optional else-branch for if-then-elif-end (#2598) 2023-07-04 07:51:29 +09:00
itchyny 4dc2a2fb9d Implement scan/2 filter (#1961) 2023-07-04 07:48:29 +09:00
pkoppstein 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
itchyny edb0d88e3b Fix duplicate entry in .gitignore 2023-07-03 23:05:51 +09:00
itchyny 3847ebb699 Create dist and upload on release also disable docs on build (#2648) 2023-07-03 21:05:21 +09:00
pkoppstein 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
itchyny 4b5fcb936f Fix the default search paths and documentation (#2093) 2023-07-03 09:12:22 +09:00
itchyny 5ae04c0f52 Strip debug information from executables (fix #1221) (#2647) 2023-07-03 08:46:35 +09:00
Owen Ou 44a0f3448a Release pipeline (#2620)
* Release pipeline

* Group CI builds for different OSes into `ci.yml`.
* Add release job to release `jq` when tag is in the format of v*.
* Use `clang` as the only compiler on CI.
* Provide extensible matrix for future cross-compile builds, e.g.
  for https://github.com/jqlang/jq/pull/2618.

* Locate bison for Windows build

* Also install flex for Windows build

* Add matrix to test all available GH Actions images

* Enable all tests for Windows

* Run `brew update-reset` when `brew update` fails

`brew update` can fail for "Error: Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!"

Ref: https://github.com/owenthereal/jq/actions/runs/5432314910/jobs/9879266028#step:3:19

* Select gcc binaries to release

* Only enable CI when push to master & tag

* Try out statick build

* No need to enforce the same `AM_INIT_AUTOMAKE` version for MacOS

* Disable static build for ubuntu-20.04

See https://github.com/jqlang/jq/pull/2620#discussion_r1248936822
2023-07-02 10:48:26 -07:00
itchyny f88c4e5888 Move an example to the manual and regenerate man.test (#2639) 2023-06-30 07:45:29 +09:00
itchyny 03db5509cb Remove unused function: jv_mem_invalidate, jv_mem_uninit_setup (#2636) 2023-06-28 22:59:41 +09:00
Allan Clark d5dd41e2dc fix: tarball fails distcheck: add files missing from manifest (#2538) 2023-06-28 22:37:49 +09:00
itchyny d829524680 Remove deleted README file from jq.spec (#2637) 2023-06-28 22:37:31 +09:00
itchyny 6d694a4a58 Validate module metadata to be an object (#2357) 2023-06-28 17:59:46 +09:00
itchyny 5dacc6b3a1 Fix bison warnings on incompatibilities with POSIX Yacc (#2634) 2023-06-28 17:56:53 +09:00
itchyny 82d5602230 Fix "writing output failed" error of non ASCII output on Windows (#2633) 2023-06-28 17:54:40 +09:00
itchyny 7c1efd67ff Update oniguruma submodule (June 2023) (#2635) 2023-06-28 17:04:42 +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
itchyny e468eaa396 Fix glibc warning about _BSD_SOURCE and redefined _GNU_SOURCE (fix #1978) (#2631) 2023-06-27 07:25:55 +09:00
itchyny 44c89ad3da Ignore error of outdated manual test when docs disabled (fix #2310) (#2630) 2023-06-27 07:25:24 +09:00
itchyny 73966c80ec Fix number lexer to avoid conflict with object indexing (#2254) 2023-06-27 07:24:49 +09:00
itchyny fac5553b22 Fix overflow exception of the modulo operator (fix #1176) (#2629) 2023-06-27 07:23:41 +09:00
itchyny 6864aa8630 Fix manual section titles, minor typos, and improve inline codes (#2626) 2023-06-22 08:31:38 +09:00
Alex Jurkiewicz dd5ce98caf Document length for numbers and bools (#2625)
This was added in ae7a042876 but not explicitly documented.
2023-06-21 18:21:39 +09:00
itchyny 9a590427db Improve Download page: drop versions for each package manager (#2619) 2023-06-20 08:23:42 +09:00
Nico Williams f7102e9bed Create SECURITY.md 2023-06-19 00:07:29 -05:00
Dan Church 38b42e537f Fix double-installed doc (#2482)
The README symlink was causing the file to be installed twice in
<DOCDIR>.
2023-06-16 23:11:01 +09:00
Dan Church 076d0a2826 Use autotools standard ${docdir} (#2468)
Specified with `--docdir=<path>`, the `$(docdir)` variable is already
available, and has the same default as what it was being set to.

By specifying it here, it overrides what the `--docdir` option
specifies.
2023-06-16 23:06:34 +09:00
Dawid Ferenczy Rogožan 11d909170e Added usage under Powershell to the manual (#2306) 2023-06-16 22:47:37 +09:00
calpeconsulting c2026f5d9e Fedora link returns 404 (#2067) 2023-06-16 22:03:32 +09:00
Marcin Kłopotek 0567d26923 Add Windows installation via scoop (#2188) 2023-06-16 21:55:29 +09:00
pkoppstein d2f1ddbd5a manual.yml - Perl NG (#2614) 2023-06-16 07:59:48 +09:00
Florian Weimer 52d5988afb C99 compatibility enhancements for the configure script (#2519)
* configure.ac: Enable system extensions

Use AC_USE_SYSTEM_EXTENSIONS to build with _GNU_SOURCE (and similar
macros on non-GNU systems), to avoid an implicit declaration of the
strptime function.  This improves compatibility with future compilers
which do not support implicit function declarations.

* configure.ac: gettimeofday lives in <sys/time.h>

The gettimeofday function is declared in <sys/time.h>, not <time.h>,
according to POSIX and actual systems.  This avoids a configure
probe failure with compilers which do not support implicit function
declarations.
2023-06-14 21:41:04 +09:00
Rob Wills 9cb69ad5a5 Add a note about how to provide positional arguments without confusing the arg parser (#1989) 2023-06-14 08:45:02 +09:00
itchyny 2e5c3f490c Fix regular expression section on PCRE (fix #2439), also improve example format (#2613) 2023-06-14 07:36:06 +09:00
itchyny 433b79dddf Fix version scripts for some shallow clone situations (fix #1549) (#2608) 2023-06-14 07:33:25 +09:00
Josh Soref 5cebe86a7b Fix misspellings (#2609) 2023-06-13 20:01:20 +09:00
Josh Soref bd86ca3002 scanbuild: use ubuntu-latest (#2610) 2023-06-13 13:53:01 +09:00
AJ Jordan 840dc55263 Link to the Onigurama docs (#2355) 2023-06-13 13:49:46 +09:00
Josh Soref 1d69ca636a Fix macOS build - drop python3 (#2612)
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
2023-06-12 21:29:47 -07:00
itchyny e5414e6828 docs: Fix coding style of Python scripts using YAPF (#2606) 2023-06-08 19:04:19 +09:00
itchyny fd9da6647c docs: Fix example outputs added in #2391 2023-06-07 21:05:03 +09:00
Benjamin Wuethrich e066172aa1 Add fixes for manual (#2391) 2023-06-07 20:59:07 +09:00
Timothy John Perisho Eccleston a87dca3c87 fix typos in manual.yml (#2102) 2023-06-07 20:58:48 +09:00
Anthony Sottile 6c5c8f2115 fix handling of -0 (#2235) 2023-06-06 20:19:43 +09:00
itchyny b8816caf0a docs: Fix a try-catch example (fix #1558, #1777) (#2605) 2023-06-06 09:03:25 +09:00
Henré Botha df8ee8dd79 docs: fix typo in halt_error example (#2336) 2023-06-06 08:36:46 +09:00
Lucas Trzesniewski b7f9587bb9 docs: clarify split behavior (#2462) 2023-06-06 08:28:57 +09:00
Stefan 90bfa96249 Fixed typo in errors on missing some mathematical filters (#2434) 2023-06-06 06:59:29 +09:00
nmulcaheyanditchyny d178ebdc94 [docs] Use yaml.safe_load() in build_*.py scripts (#2432)
Co-authored-by: itchyny <itchyny@cybozu.co.jp>
2023-06-06 06:47:42 +09:00
Matti Åstrand b7511b9b1f Key should be "foo" without spaces (#2212) 2023-06-06 06:17:35 +09:00
itchyny c815794e4b Replace find with select function as the example of jq-coded functions (#1962) 2023-06-06 06:09:03 +09:00
itchyny 4e9a1a8037 Show missing backslash in manual (#2492) 2023-06-06 06:03:58 +09:00
zstadler a5ba98a55c Show missing backslash in manual (#2492) 2023-06-06 06:03:07 +09:00
itchyny d57a96e3f7 Fix website generation workflow 2023-06-06 05:57:31 +09:00
eitsupi 360cd8dbe2 docs: install via winget (#2600) 2023-06-06 05:52:09 +09:00
itchyny cd4dc1e6d1 Add a GitHub Actions workflow to build and update website (#2603) 2023-06-06 05:51:33 +09:00
itchyny 527ea012f3 Remove TravisCI configuration file and fix GitHub actions badges (#2602)
* Remove TravisCI configuration file

* Update CI badges in README.md to refer to GitHub Actions
2023-06-06 05:51:08 +09:00
itchyny 019a9ffbee Improve docs of optional indexing syntax to make it clear (ref #2588) (#2604)
* Revert "Typo in basic filters manual (#2588)"

This reverts commit 908f5d54a7.

* Improve docs of optional indexing syntax to make it clear
2023-06-06 05:43:06 +09:00
Benoit de ChezellesandOwen Ou 908f5d54a7 Typo in basic filters manual (#2588)
Co-authored-by: Owen Ou <169064+owenthereal@users.noreply.github.com>
2023-06-04 22:29:55 -07:00
Tom WolfandOwen Ou 91d10c556b docs: Update Flex URL (#2582)
Co-authored-by: Owen Ou <169064+owenthereal@users.noreply.github.com>
2023-06-04 22:29:36 -07:00
Hanson CharandHanson Char 13d1930154 Update git submodule commit of oniguruma from 5a24a49 to 078f95e (#2561)
Co-authored-by: Hanson Char <hchar@amazon.com>
2023-06-01 17:59:18 -07:00
Owen OuandNicolas Williams 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
Stephen Dolan 89caf46a5f Update URLs from stedolan to jqlang 2023-05-28 17:06:31 +01:00
Stephen Dolan eb610c0323 Fix website build by adding Loader parameter to yaml.load 2023-05-28 16:41:46 +01:00
Mattias Wadman cff5336ec7 docs: Document repeat(exp) 2022-05-26 16:04:32 -05:00
Mattias Wadman f2ad9517c7 Mention -n in IO-section and for input/inputs 2022-05-26 16:02:50 -05:00
Tomas Halman 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
Naïm Favier 174db0f935 docs: point to Libera.Chat instead of Freenode 2022-05-26 16:01:25 -05:00
Lukas Lansky 29cf77977e Missing "va_end" call. This was found by running the cppcheck static analysis where it shows as error. 2022-05-26 15:53:59 -05:00
Sean Wei 55e6e2c218 Add --recursive to git clone 2022-05-26 15:47:24 -05:00
Zhaohui Mei 88116ba76d docs(manual): fix the typo errors in the manual 2022-05-26 15:47:02 -05:00
Mattias Wadman 3678822e7f docs: Fix some format inconsistencies in manual 2022-05-26 15:46:40 -05:00
Gijs Kunze 0171a9eb60 fixes incorrect example in man page 2022-05-26 15:45:52 -05:00
dak180 edacc8f70d jq is now available through fink. 2022-05-26 15:45:08 -05:00
Ikko Ashimine 2a3e4cf7b2 Fix typo in compile.c
alrady -> already
2022-05-26 15:44:12 -05:00
Stefan 94e87c9377 Fixed typos 2022-05-26 15:43:55 -05:00
Owen Ou f9afa950e2 Update AUTHORS 2022-04-04 12:04:12 -05:00
Owen Ou 6c24c71ddb Update my contributor info
My GitHub profile is at https://github.com/owenthereal
2022-04-04 12:04:12 -05:00
Nicolas Williams a9f97e9e61 Fix accidentally quadratic behavior in _modify
We need to be careful to not grab an extra reference when mutating data
structures because that means we make extra copies.  Doing that every
time in `_modify` is really painful, as that function implements `|=`
and all modify-assign operators.

`jv_setpath()` also grabs additional references, so this is not the only
fix needed for the modify-assign operators to not be accidentally
quadratic.

We have to use `LOADVN` in order to make this fix possible, so we should
really byte-code `_modify` rather than jq-code it.  However, as a
stop-gap to make this fix easier, I'm adding syntax for referring to a
`$binding` such that you get `LOADVN` instead of `LOADV`.

This syntax is not meant to be used outside jq's internals!  Therefore
it is not documented.  I promise to break it later, so don't use it!

TBD, but later:

 - Optimize `_modify` for the case where `update` outputs more than one
   value.

   This is trivial: add a `setpath($p; null)` in the middle of `_modify`
   before calling `update`.  But unfortunately the VM retains a
   reference to `value_at_path` for path expression checking, and fixing
   that will require more work.
2021-10-24 16:23:26 -05:00
Nicolas Williams 0c3455d329 Fix accidentally quadratic behavior in setpath
We need to be careful to not grab an extra reference when mutating
data structures because that means we make extra copies.  Doing that
every time in `jv_setpath()` is really painful, as that function is used
in `_modify/2`, which is used in `|=` and all modify-assign operators.

`_modify` also grabs additional references, so this is not the only fix
needed for the modify-assign operators to not be accidentally quadratic.
2021-10-24 16:23:26 -05:00
Nicolas Williams 1a1804afcb Fix LOADV/LOADVN refcount printing 2021-10-24 16:23:26 -05:00
Nicolas Williams 582717a7b4 Fix crash in LOADVN when stack grows
This `stack_push()` call in LOADVN invalidates `var`:

       jv* var = frame_local_var(jq, v, level);
       jv_free(stack_popn(jq));
------>stack_push(jq, *var);
       *var = jv_null();
       ^^^^^^

We have to re-compute `var`:

       jv* var = frame_local_var(jq, v, level);
       jv_free(stack_popn(jq));
       stack_push(jq, *var);
------>var = frame_local_var(jq, v, level);
       *var = jv_null();
2021-10-24 16:23:26 -05:00
Nicolas Williams 07dc653ae1 Appveyor: Get Appveyor building again 2021-10-24 16:23:26 -05:00
Nicolas Williams d79fe7fd58 Update docs/Pipenv.lock 2021-10-24 16:23:26 -05:00
Nicolas Williams a9ce7244b4 Fix Windows build for 1.7 release (moar) 2021-09-06 22:17:57 -05:00
Nicolas Williams 34182cca7b Fix Windows build for 1.7 release (pthread stuff) 2021-09-03 14:18:18 -05:00
itchyny d18b2d078c Fix msys2 installation on AppVeyor
Ref: https://www.msys2.org/news/#2020-06-29-new-packagers
2021-05-01 14:34:26 -04:00
Mattias Wadman cc4efc49e1 Fix incorrect if empty string example 2021-05-01 14:33:01 -04:00
mjarosie e615bdc407 update the version available through Chocolatey 2021-05-01 14:32:38 -04:00
Aleksey Tsalolikhin 9600a5c781 Re-apply patch from ff8924ce16 to dev manual 2021-05-01 14:19:45 -04:00
Aleksey Tsalolikhin d57d9737d7 Remove decimal number text from v1.6 manual 2021-05-01 14:19:45 -04:00
Ciaran McNamara 2de3bc3732 Add large file support for 32-bit systems to fix issue 2167 2021-05-01 14:17:41 -04:00
William Langford 77417c1335 Clean up compile warnings on macOS 2020-12-19 15:18:29 -05:00
William Langford e660003abf Use AX_PTHREAD to properly detect pthread and flags 2020-12-19 15:18:29 -05:00
Alexandre Jasmin 80052e5275 Fix #2197 extended regex pattern example 2020-12-18 00:01:19 -05:00
Maximilian Roos a17dd3248a Add some missing code quoting to the manual 2020-06-08 12:35:13 -04:00
itchyny 6306ac8966 Reduce allocation on string multiplication 2020-05-26 12:30:27 -04:00
itchyny 9163e09605 Fix multiple string multiplication 2020-05-26 12:30:27 -04:00
itchyny 15fa1dec99 Fix error handling in strftime 2020-05-26 12:29:34 -04:00
Christopher Degawa ccc79e592c Makefile: prepend srcdir to jq.1.prebuilt to fix out of source compilation 2020-03-03 11:50:04 -05:00
William Langford 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
William Langford 8c61ebad0a Minor fixes to website generation 2020-03-02 10:55:51 -05:00
Gustav d24c3d2263 Change Homebrew version in docs to 1.6 2020-03-02 10:10:08 -05:00
Alanscut 63b5c7b553 compatibiltiy->compatibility 2020-03-02 10:05:32 -05:00
Alanscut 5b9e63e4af fix typos 2020-01-14 10:18:22 -06:00
Yoichi Nakayama 503fae5dc9 remove unused conditional branch
It has no effect after the change c4524da.

Bug reported by the clang static analyzer.

Description: Value stored to 'value' is never read
File: jq/src/util.c
Line: 439
2020-01-10 12:01:08 -06:00
Bernard Niset 087100183c Add information on how to install on OS X with MacPorts 2020-01-07 23:35:19 -06:00
William Chargin baecf2ce9e docs: --indent value has maximum of 7, not 8
Test Plan:
To verify that this is in fact the behavior:

```
$ jq --indent 7 -n '[1]'
[
       1
]
$ jq --indent 8 -n '[1]'
jq: --indent takes a number between -1 and 7
Use jq --help for help with command-line options,
or see the jq manpage, or online docs  at https://stedolan.github.io/jq
```

This patch was generated by running `git grep "no more than"` and fixing
up appropriate results.

wchargin-branch: docs-fix-indent-bounds
2020-01-07 23:34:52 -06:00
Alanscut e7d37983c4 outputing -> outputting 2020-01-03 09:56:04 -06:00
David Biesack 07b18a33fe Update other manual and source to use ;37 2020-01-02 15:47:26 -06:00
David Biesack cf615152e1 correct the default JQ_COLORS to use 37, not undefined color 39 2020-01-02 15:47:26 -06:00
Alanscut fa3733cc4c fix typos 2020-01-02 10:52:12 -06:00
Bradley Skaggs 82987df98d Improve formatting of flags and link to specific wiki article for cross-compilation. 2020-01-02 10:33:35 -06:00
MCApollo 839316e66b compile-ios.sh: realpath is not a default command. 2019-12-30 17:48:45 -06:00
MCApollo d235e97f5e compile-ios.sh: Update grammar 2019-12-30 17:48:45 -06:00
MCApollo 4c2e63a658 Updated compile-ios.sh script. 2019-12-30 17:48:45 -06:00
Paul Wise 24564b2d34 Add -0 / --nul-output option for processing values containing newlines
Closes: https://github.com/stedolan/jq/issues/1271
2019-12-30 15:37:14 -06:00
Felix Wolfsteller 707022b0e5 Rephrase doc "A string B is contained in A" ...
Minor rephrasing to prevent read/brain backtracking when using capital letter A as an article and a variable term.
2019-12-29 23:52:47 -06:00
Richard H Lee 2065d6c3aa Differentiate WIN32 / Cygwin in configure script
shlwapi.h is present on both systems
2019-12-29 19:24:04 -06:00
William Langford e74eab828e Fix nesting try/catch inside internal errors 2019-11-21 17:53:12 -05:00
William Langford bda75c3142 Ensure travis has a python version we expect 2019-10-23 21:31:05 -04:00
Leonid S. Usov 9b51a0852a Remove an accidentally committed debug file 2019-10-22 14:11:04 -04:00
William Langford 74c44bc9a3 Add configure guards around literal jv_numbers
Allow building jq in a mode that doesn't use decnumber for benchmarking
purposes. decnumber support is enabled by default, and this option is
meant to be removed once we're happy with the performance.
2019-10-22 14:11:04 -04:00
Leonid S. Usov 4860ed4396 [tests] print test # from the start of the tests file to help with skip and take 2019-10-22 14:11:04 -04:00
Leonid S. Usov 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
Leonid S. Usov b6be13d5de Add decNumber library
The library adds support for decimal numbers of arbitrary length.
Downloaded from ICU, under ICU 1.8.1 license
http://download.icu-project.org/files/decNumber/decNumber-icu-368.zip
2019-10-22 14:11:04 -04:00
William Langford 37b2d2129e Merge pull request #1948 from eli-schwartz/no-pacman-sy
docs: fix seriously dangerous download instructions for Arch Linux
2019-07-31 12:20:51 -04:00
Eli Schwartz 78774647e1 docs: fix seriously dangerous download instructions for Arch Linux
The current instructions tell users to perform two actions:
- update the package database
- install the jq package

The only thing users need to or should be doing is actually installing
the jq package -- regardless of which version is being installed.
Guidelines on how to perform system updates are massively out of scope.

In the case of partially performing a system update as a prerequisite
for installing jq, the official guidance from Arch Linux is not to do
this: partial updates are not supported, we refuse to support them, and
anyone who does try to perform them anyway is assumed to know so much
about their system that they clearly do not ever need help from anyone
else (which is a good thing since they won't get it). The result is a
frankensteined system that can only ever be supported by the person who
frankensteined it to begin with. The only reason the package manager
even allows it to occur in the first place is because other
distributions using pacman might have different LTS policies, and
because it would prevent expert users from being in control of their
system, as per the traditional Unix philosophy:

"Unix was not designed to stop you from doing stupid things, because
that would also stop you from doing clever things."

Consequences of performing partial updates without understanding the
ramifications in extensive detail can include breaking the partially
updated application (jq), breaking any application that shares a mutual
dependency with the partially updated application (which jq is *lucky*
to only depend on the ever-backwards-compatible glibc), or breaking the
entire operating system by leaving armed traps behind for the next time
a `pacman -S new-package` is executed and thereby breaks *its* cascading
dependencies.

See:
https://wiki.archlinux.org/index.php/System_maintenance#Partial_upgrades_are_unsupported
2019-07-21 14:40:47 -04:00
William Langford a97638713a Merge pull request #1944 from tessus/doc-improvement
clarify filter usage
2019-07-14 15:08:14 -04:00
Helmut K. C. Tessarek 8d9817d2f7 clarify filter usage
The current paragraph is not complete, since a digit is not a special character.

Changing it to:

    If the key contains special characters or starts with a digit,
    you need to surround it with double quotes like this:
    `."foo$"`, or else `.["foo$"]`.
2019-07-08 21:02:43 -04:00
Ricardo Constantino e944fe8436 Makefile.am: fix builtin.inc with out-of-root builds 2019-06-11 11:57:02 -05:00
Mark Feit ad9fc9f559 Improve jv_is_integer() 2019-04-07 14:33:36 -05:00
Mattias Hansson 263e1061ea jq_util_input_init: Zero memory using calloc
Calloc will zero the allocated memory which makes one memset and a
number of explicit zero assignments redundant.
2019-04-04 12:37:21 -05:00
Mattias Hansson 4f58a59f4d Dockerfile: Uninstall oniguruma before distclean
Run `make uninstall` for oniguruma before running the recursive
distclean that will remove oniguruma's Makefile and cause a build error
due to missing make target.
2019-03-29 08:19:41 -05:00
Mattias Hansson 584370127a Dockerfile: Fetch dependency as git submodule
Fetch oniguruma using git submodule instead of a release tarball. It
will fix a build problem, caused by jq's autotools configuration, trying
to run `make distclean` recursively in an empty modules directory. This
will also improve the maintainability of the Dockerfile.
2019-03-29 08:19:41 -05:00
Mattias Hansson 528a4f5945 Dockerfile: Change base image to Debian Stable 2019-03-29 08:19:41 -05:00
Mattias Hansson c4062e09b9 Dockerfile: Add missing dependency to pip3 2019-03-29 08:19:41 -05:00
Mattias Hansson 70e04d6a8e Dockerfile: Specify locale settings
Avoid RuntimeError in pipenv by setting LC_ALL and LANG to C.UTF-8.
2019-03-29 08:19:41 -05:00
Mattias Hansson bcd594ed69 Dockerfile: Set noninteractive
Configure the environment to inform debconf that it's running in
noninteractive mode, to avoid some warnings.
2019-03-29 08:19:41 -05:00
Mattias Hansson 3c4fcb1594 Add pkg-config file for libjq
pkg-config is a common interface to resolve build details. It will
become easier to incorporate libjq in other projects by providing this
interface.
2019-03-29 08:16:36 -05:00
Nicolas Williams b52fc1043b Fix assert in generator subexpressions (fix #1875)
Expressions of the form `path(EXPR) | select(GENERATOR)`, where `EXPR`
is a path expression and `GENERATOR` is a generator conditional
expression (e.g., `has("a"), has("b")`) cause an assertion if the
jq_state VM is torn down too soon.  That assert() was only correct if
assuming that the conditional is not a generator.

If the conditional is generator, then what we see is that when
backtracking a SUBEXP_END is executed without a corresponding
SUBEXP_BEGIN because the entire conditional is bracketed with
SUBEXP_BEGIN and SUBEXP_END, and since it's resumed in the middle, in
between the brackets.

Rather than assert that the jq->path_len being restored has some
particular value, we can simply re-compute it from the restored
jq->path.
2019-03-26 18:58:55 -05:00
Nicolas Williams b34af08f67 Fix tests/jq.test for c72ed135 2019-03-25 09:56:53 -05:00
Nicolas Williams e01398c9db Fix tests/shtest broken by 2b4d51f 2019-03-25 09:52:42 -05:00
Nicolas Williams dffba62e13 Disable docs by default; don't mantest if no docs 2019-03-24 23:36:50 -05:00
Nicolas Williams 2b4d51f697 Identify progname in more errors (fix #1860)
However, we should really use the argv[0] progname, not just jq.
Someday we may want to support aliases which automatically add certain
options, etc.
2019-03-24 23:36:18 -05:00
Nicolas Williams 0dab2b18d7 Add -b / --binary option for Windows 2019-03-24 23:23:16 -05:00
Nicolas Williams 3e0a118886 Allow .["foo"].["bar"] 2019-03-24 23:23:16 -05:00
Nicolas Williams c72ed135e4 Allow keywords in more places (fix #1868) 2019-03-24 23:19:09 -05:00
Muh Muhten 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
Muh Muhten abed751e96 Bind libraries backward for consistent shadowing 2019-02-26 21:57:08 -06: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
William Langford f951d0241c Change contains to return true for empty string needles
The behavior of memmem for an empty needle is inconsistent between
implementations of libc.
Our tests imply that we want an empty string needle to be true,
so check for an empty needle before calling memmem.
2019-02-26 11:10:38 -06:00
William Langford cc724f105d Configure appveyor build to use python 2019-02-26 11:10:38 -06:00
William Langford a4756fde3f Cleanup leftover references to ruby 2019-02-26 11:10:38 -06:00
William Langford 15be4e7915 Configure travis build to use python 2019-02-26 11:10:38 -06:00
William Langford 53a3f47076 Remove ruby dependency from mantests 2019-02-26 11:10:38 -06:00
William Langford 175dbc4e25 Remove ruby dependency from manpage build 2019-02-26 11:10:38 -06:00
William Langford c1f11855e3 Remove ruby dependency from website build 2019-02-26 11:10:38 -06:00
Muh Muhten 76e72a301d Simplify and optimize SQLish builtins 2019-02-26 11:05:25 -06:00
Muh Muhten a1626adb7e Fix bizarre bsearch/1 behaviour with a stream argument 2019-02-26 11:05:25 -06:00
Muh Muhten d1a07cbdc1 Make tostream much more efficient
(`path(.[])` is a streaming `keys`!)
2019-02-26 11:05:25 -06:00
Muh Muhten 8c1e7175ec Reimplement fromstream/1 more compactly 2019-02-26 11:05:25 -06:00
Muh Muhten fc6df0fdc1 Simplify definition of range/3
New implementation in terms of while/2, and branches immediately on $by
to avoid checking the sign of $by *in* the loop.
2019-02-26 11:05:25 -06:00
Muh Muhten 78271b179a Simplify type-select builtins 2019-02-26 11:05:25 -06:00
Muh Muhten d3abe3a468 Add more tests for any and all 2019-02-26 11:05:25 -06:00
Muh Muhten 41b859325b Redefine isempty/1, and the all and any series
Fixes the bug where all and any evaluate one more item than needed.
2019-02-26 11:05:25 -06:00
Muh Muhten 6a0bdf6063 Remove scalars_or_empty 2019-02-26 11:05:25 -06:00
Muh Muhten 36c250a03d No need to block_drop_unreferenced after builtins
(The correctness of this change is more obvious after the rename.)
2019-02-26 10:49:08 -06:00
Muh Muhten 260879a5c3 Rename block_bind_incremental to block_bind_referenced
block_bind_incremental is block_bind_referenced in a loop backwards. For
an 1-inst block, it does the same thing and isn't too much more
expensive, so it's not really useful to keep both.

Also, block_bind_referenced was a better name for the function.
2019-02-26 10:49:08 -06:00
Muh Muhten 8537b93a43 Fix block flipping in block_drop_unreferenced
Since 605bfb3, block_drop_unreferenced actually reverses the order of
instructions in the block it's run against. This bug was hidden by the
fact that normally it's run *twice* against the main program, flipping
it back, and that order of function definitionss doesn't really matter
after symbol resolution.
2019-02-26 10:49:08 -06:00
Nico Williams 9a0d5be790 Merge pull request #1837 from muhmuhten/limit_0 2019-02-21 08:17:41 -06:00
Muh Muhten 130152a2ac Ensure limit(0; ...) is empty 2019-02-21 04:11:41 -05:00
Muh Muhten 730c730940 Rewrite _assign/2 using $argument syntax 2019-02-20 20:12:52 -06:00
Muh Muhten 85caac4473 Work around fgets()'s lack of length reporting
Stop losing \0s from the end of files because we don't know how much
fgets() read into our buffer. If we prefill the buffer with anything
other than zeroes, we can actually tell the difference between the
terminator and unused space in the buffer.

This is possibly more expensive, but at least it should be correct.

Fixes #1504
2019-02-20 20:12:52 -06:00
Nicolas Williams 048acee39b Fix if-then-else example formatting 2019-02-20 20:03:26 -06:00
Nicolas Williams 8a02b2c9c1 Document optional else clause of if 2019-02-20 20:03:26 -06:00
Chance Zibolski 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
Muh Muhten 1ef90acb38 Bind data imports properly when already resolved 2019-02-20 20:02:41 -06:00
Muh Muhten e843a4fdf9 Make builtin binding fast again by binding only referenced symbols
Avoid doing the internal binding of top-level symbols in the parser,
leaving that work to be done in a post-processing step. For builtins,
this lets us do a reference-aware bind step (block_bind_incremental)
*after* generating builtins/0.

Libraries are a bit trickier since they may be bound multiple times, so
instead of thinking through the implications I added (block_bind_self)
to resolve all internal symbols immediately.
2019-02-20 19:43:13 -06:00
Muh Muhten b2b0bd37a1 Load ~/.jq as a library instead of with builtins
Remove the special code which loads ~/.jq in builtin.c, and instead glue
an optional include which points to the same file onto the main program
in linker.c.

Fixes a minor bug where errors in ~/.jq would be labelled <builtin>.
2019-02-20 19:16:18 -06:00
Muh Muhten 450ade4818 Add import metadata key "optional"
A library marked is imported if found, but silently skipped if missing.
This is the desired semantic for the auto-include at ~/.jq
2019-02-20 19:16:18 -06:00
Muh Muhten c814c4e001 Replace TOP-before-imports special case with assert
The case isn't actually possible afaict.
2019-02-20 19:16:18 -06:00
Muh Muhten 4f4494c770 Catch .. as the first component of a module path
Only the second and subsequent path components were being checked, which
I guess is theoretically security-relevant.

There's no apparent point to reconstructing the path after splitting it
by adding /s back in, either.
2019-02-20 19:16:18 -06:00
Muh Muhten ff014824bc Pass on the error message when rel_path is invalid
"Module path must be a string" is not a useful error message when the
reason the module path isn't a string is because the string it was got
replaced with an invalid with an error message for some other reason.

Also fixes a few memory leaks on early exits.
2019-02-20 19:16:18 -06:00
Muh Muhten 8edf58a95f Simplify definition of block_bind_referenced 2019-02-20 19:16:18 -06:00
Jason Hood 88e1f59ec1 Allow globbing on Windows
The mingw-w64 runtime expands wildcards, which causes a discrepancy
between `main`'s `argv` (multiple file names) and Windows' `wargv` (a
single wildcard).  Use `wmain` to retrieve the wide character args.
2019-02-17 23:58:23 -06:00
Jason Hood 80b064f97b Make UTC time on Windows
Windows has `_mkgmtime` for the UTC equivalent of `mktime`.
2019-02-16 20:42:25 -06:00
Jason Hood 0fc8200ab4 Add ISO 8601-specific strptime
Implement `strptime` for systems lacking it, but only supporting the
ISO 8601 format string.
2019-02-16 20:41:41 -06:00
Jason Hood 87594f81d6 Prevent redirecting to NUL crash
Windows regards the `NUL` device as tty, which causes `WriteFile` to
fail (the bytes written pointer cannot be `NULL` in this case).  Tweak
the color test to ensure tty is accurate.
2019-02-16 20:40:41 -06:00
Jason Hood def42a31ca Possibly enable color output on Windows (#1494)
Windows 10 supports color output, but it must be explicitly enabled;
ANSICON provides support for other versions.  Enable color if either of
those are available.  Resolves #1494.
2019-02-16 20:40:41 -06:00
Muh Muhten 605bfb3577 Reimplement block_drop_unreferenced in linear time 2019-02-16 20:30:20 -06:00
Nico Williams 9fa2e51099 Merge pull request #1818 from muhmuhten/free_in_index 2019-02-09 16:32:20 -06:00
Muh Muhten 3f59bee3e0 Make sure to free in jv_string_indexes 2019-02-09 17:17:59 -05:00
Muh Muhten 88613f5469 Improve linking time by marking subtrees with unbound symbols 2019-02-08 22:41:31 -06:00
Nicolas Williams 2660b04a73 Fix infinite loop in index("") (fix #1815) 2019-02-08 20:40:55 -06:00
Matt Clegg 18ac789d6d FIX if-then-else example
"(.+)" doesn't match new line characters so the link generated for [if-then-else](https://github.com/stedolan/jq/blob/90bc29c1b544c0436ec44246e180fdbb6d6384df/docs/content/3.manual/v1.5/manual.yml#L1804) doesn't work
2019-02-07 11:08:44 -06:00
Muh Muhten 956d40d9dd Define error/1 in terms of error/0
The parser generates a call to error/0 on break. Having that exported
from C directly removes a language dependency on builtin.jq.

In any case, error/0 seems to be the more fundamental operation, seeing
as the old C impementation of error/1 did nothing useful with its input.
2019-02-07 11:05:06 -06:00
Muh Muhten 2fd725209e Export input/0 directly from C, removing _input/0
The distinction between input/0 and _input/0 has been unnecessary since
a9c613..7dc34b, which moved end-of-input handling into C and replaced
the jq definition of input with `def input: _input;`
2019-02-06 12:06:03 -06:00
Derrick Pallas 21be3857b5 builtin/f_match: prevent overruns of input_string
If these values do not match exactly, it is because the UTF-8 is invalid
anyway and we counted codepoints differently than oniguruma did.  Perhaps it
would be better to error out here, but at least one similar loop already
uses < vs != and since we're off the rails anyway this might be OK.  It is
certainly better than overruning the buffer.

Resolves https://github.com/stedolan/jq/issues/1804
2019-02-04 14:12:03 -06:00
Derrick Pallas d29bf5b4fc builtin/f_match: call onig_error_code_to_str with einfo correctly 2019-02-02 16:17:12 -08:00
Muh Muhten 3c5b1419a2 Unify timegm fallbacks into my_mktime
my_timegm was introduced in 1900c7 to add a mktime fallback used in
4a6241, the subsequently removed in c53823. As a result of this code
shuffling, the jq mktime function (f_mktime) wound up using a fallback
even on systems where timegm is available, with incorrect results in
some time zones with DST, e.g.

% TZ=America/New_York jq -n '"2018-08-31T00:00:00Z"|fromdate|todate'
"2018-08-31T01:00:00Z"

This undoes 1900c7 and moves the workaround it added into the #else of
my_mktime.
2019-01-30 22:05:51 -06:00
Muh Muhten 012af2186b Fix build on BSD make
Replace uses of the nonstandard $^ variable by explicitly specifying the
source filenames. This is the only obvious thing preventing the build
from running correctly on non-GNU make.
2019-01-30 09:48:04 -06:00
Muh Muhten 12a628abdc Fix include/import namespace confusion 2019-01-30 09:47:24 -06:00
David Haguenauer 63ba2b1637 Add tests for built-in function contains 2019-01-22 11:00:08 -06:00
Nicolas Williams 61cd6dbb3b contains should handle embedded NULs (fix #1732) 2019-01-18 22:33:46 -06:00
William Langford 4b4fefa254 Merge pull request #1774 from dooglus/patch-1
Fix grammar typo.
2019-01-05 16:04:30 -05:00
Nicolas Williams 0bc77083ba Out-of-srcdir builds: AM_CPPFLAGS=-I${srcdir}/src 2018-12-26 12:53:48 -06:00
Ricardo Constantino b10878fea7 builtin: add missing windows.h include
Follow-up fix to b436156f5 because BOOL and DWORD
are not built-in to mingw64.
2018-12-26 12:53:48 -06:00
Ricardo Constantino 6893284ee5 Makefile.am: add no-undefined for win32
"Undefined symbols are not allowed in x86_64-w64-mingw32 shared libraries"

This was also applied in the official MINGW-packages repo:
Alexpux/MINGW-packages@b5566c58a
2018-12-26 02:45:54 +00:00
HE, Tao b436156f5b Mingw-w64 on windows doesn't have setenv, fix that.
Signed-off-by: HE, Tao <sighingnow@gmail.com>
2018-12-19 09:07:14 -06:00
Eugen fb1c635af6 Make fromstream/1 more efficient 2018-12-18 14:20:35 -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
mail6543210 712330940b Ensure that ${builddir}/src exists 2018-12-18 14:15:04 -06:00
William Langford 9c029f7077 Merge pull request #1779 from gvangool/update-NEWS
Adds the release info for 1.6 to NEWS
2018-12-15 15:20:23 -05:00
Gert Van Gool 2760fd365b Adds the release info for 1.6 to NEWS 2018-12-15 19:51:29 +01:00
Nicolas Williams 8ea4a5584e Allow variable refs as object keys {$key:value}
Users are often surprised by the requirement to parenthesize any
non-trivial object key expressions in object constructors.  E.g.,
{"a"+"b":1}.  This commit adds one more kind of key expression besides
literals and idents: variable references.

A common use case for this is jq programs as JSON templates to fill in
with variables computed from inputs or passed in on the command-line.
E.g., {some_key:$value}.  Now users can also use, e.g., {$key:$value}.

This and the restrictions on key and value expressions in object
constructors are now clarified a bit in the documentation.
2018-12-10 21:54:59 -06:00
Chris Moore 9caa1ba146 Fix grammar typo.
'operator' needs to be plural here.
2018-11-29 05:44:05 -08:00
William Langford bb87e6e30f Merge pull request #1768 from haochenx/readme-add-automake-as-build-dependency-in
add automake as build dependency to README.md
2018-11-20 10:13:47 -05:00
William Langford a1f1231a73 Add missing jv_copy when printing with -ar 2018-11-20 09:58:25 -05:00
Haochen Xie 0ab71031a6 add automake as build dependency to README.md 2018-11-12 16:00:53 -05:00
William Langford 2f2d05b087 Minor website fixes for 1.6 2018-11-02 08:15:18 -04:00
William Langford 2e01ff1fb6 Release jq-1.6 2018-11-01 21:49:29 -04:00
William Langford 3daecb246a Update website with details for jq-1.6 2018-11-01 21:48:34 -04:00
William Langford cd4f61aee6 Fix website whitespace 2018-10-21 23:28:43 -04:00
William Langford 39a3e2c46f Add documentation for destructuring alternation 2018-10-21 23:28:43 -04:00
Alex Ozdemir 0c845aa291 Bugfix: Math function checking
We had config machinery that determined which math functions are
available in libc. If a c math function was missing on the host system,
then the corresponding jq function would be removed from the source,
enabling the build to proceed anyway. The detection machinery was broken
in a subtle way, as was shown after glibc updated to 2.27, dropping the
`pow10` function. This caused compilation to fail.

The essential problem was that we detected whether a math function was
available by compiling and linking a small program evaluating that
function on constants. However, since gcc's optimization machinery has
special knowledge of some math functions (e.g. `pow10`), it can
optimize them away, even if they don't exist in the library and are not
linkable. That is, the following example compiles and links against
glibc 2.27, even though `pow10` has been removed:
```
int main () {
  printf("%f", pow10(0.5));
  return 0;
}
```

What?!
On the other hand, this program does not link:
```

int main () {
  double f;
  printf("%f", &f);
  printf("%f", pow10(f));
  return 0;
}
```

In the first program the call to `pow10` can be optimized away as a
constant expression. This requires GCC to know about `pow10` (which it
does!), but it does not require `pow10` to be in the library (and
actually linkable).

The solution is to use autoconf's machinery for detecting function
presence, instead of our own (buggy) machinery. This has the added
benefit of simplifying the code.

The bug was reported in issue #1659
2018-10-12 16:23:09 -04:00
William Langford 341a5fcab3 Fix osx travis build 2018-08-30 22:03:32 -04:00
William Langford dd4cec664c fix memory leak 2018-08-30 21:09:04 -04:00
William Langford 46d1ce2667 Restore JV_PRINT_COLOUR as an alias
JV_PRINT_COLOUR was part of the public libjq headers and was removed as
part of 2d05b54. While JV_PRINT_COLOR is definitely the preferred
spelling this side of the pond, we shouldn't just remove otherwise
exposed enum values.
2018-08-17 23:23:10 -04:00
William Langford 0673dee1b3 Fix destructuring alternation
Attempting to use the existing FORK_OPT opcode resulted in difficulty
knowing when to pop an error message off the stack and when not to. This
commit makes DESTRUCTURE_ALT a real opcode that is identical to
FORK_OPT, except for never pushing the error message onto the stack when
continuing from an error backtrack.

Some small changes were necessary to the DUP/POP behavior surrounding
destructuring to accomodate this.
2018-08-17 23:15:48 -04:00
William Langford 3dc5f4e948 Create issue template 2018-08-17 09:15:08 -04:00
Roland C. Dowdeswell 90bc29c1b5 jv_file.c: check to see if the file is a directory and fail
Not all stdio implementations disallow one to open a directory with
fopen(3) and so we specifically check for directories as it is also
in the standard search path.
2018-05-11 19:32:25 -05:00
Nicolas Williams 7fd9e86ea6 Make limit/2 more efficient
Contributed by @pkoppstein.
2018-03-06 16:35:33 -06:00
Nicolas Williams e113c67d51 limit/2 evals exp one time too many 2018-03-06 11:29:13 -06:00
rain1 bf88c73c20 src/main.c: fix issue #1587 by using jv_dumpf in the raw-output and ascii-output case. retain fwrite in the raw-output case. 2018-03-01 14:33:47 -06:00
Riley Avron ae11f111a5 Fix "provides" typo 2018-02-23 14:10:47 -06:00
David Fetter 2ce1e323df Change backticks to the more legible $() 2018-02-20 15:54:21 -05:00
Jakub Jirutka 68d0048148 Build static binaries and deploy to GH Releases from Travis 2018-02-20 12:11:28 -05:00
Jakub Jirutka bafb43e589 Build and run tests against musl libc using Alpine Linux on Travis 2018-02-20 12:11:28 -05:00
Jakub Jirutka c163e88af3 Change Travis config to utilize Build Stages
See: https://docs.travis-ci.com/user/build-stages/
2018-02-20 12:11:28 -05:00
Paul Chvostek bd34b8dd2e fix FreeBSD install instructions 2018-01-04 15:50:20 -06:00
Larry Aasen 61edf3fa93 Updated the compile-ios.sh script to fix issues with local oniguruma path. 2017-12-12 18:27:59 -06:00
Nicolas Williams 8eff744eec Update AUTHORS 2017-12-11 12:22:02 -06:00
David Fetter b4742c1257 Added rawfile
In passing, clean remnants of argfile from slurpfile docs.
2017-12-11 12:17:17 -06:00
Nicolas Williams 9a4576e756 Revert "reduce: handle empty updates (fix #1313)"
This reverts commit e24af3c78e.

While the semantics are desirable, there is no way to implement them
efficiently.  The reason is that in order to handle backtracking (empty)
from the state update expression, we have to retain a reference to the
reduction state value in order to restore it upon backtracking.
Retaining a reference to the reduction state kills performance by
causing lots of additional memory allocations and garbage because the
input to the update expression will always have at least two references,
thus no changes to it can be done in-place, and all changes end up being
CoW changes.

Avoiding this is the very reason for the LOADVN instruction (leaving
`null` in the variable loaded from).
2017-12-11 11:20:16 -06:00
Nicolas Williams b5560d8420 Fix import as $data linking 2017-12-10 23:09:35 -06: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
William Langford 0c9eacedaa Actually fix the strptime tests
This has been a complicated issue to fix for a number of reasons.
The core of it is that the behavior is different between different
versions of macOS, some of which set possible-but-incorrect values.

This commit addresses the issue by always using our computation for
tm_wday and tm_yday on macOS. As a side-effect, strptime format
strings that specify %u and %j will no longer work on macOS.
2017-11-29 20:47:56 -05:00
Eric Bréchemier 476b36770d Keep object keys in parsing order in tostream output
As noted by @nicowilliams, `tostream` used `keys`,
which sorts the keys in alphabetical order, instead
of `keys_unsorted`, which preserves the parsing order.

Fixes #1541.
2017-11-29 11:46:08 -06:00
Andrew Speed 239278fd3a Use rvm to install ruby 1.9.3 2017-11-28 08:51:38 -05:00
William Langford 98b36e74b8 Fix strptime tests on macOS 10.12
Dates in 1900 are before the Unix epoch. We shouldn't make any promises
about how well they are supported, especially given that our time
support is a thin wrapper over the libc functions.

This changes the test to use dates after the epoch, which should fit
within both a signed and an unsigned 32-bit time_t.
2017-11-27 22:57:50 -05:00
William Langford c3cbbdd8a2 Fix memory leaks in various c-coded builtins 2017-11-27 20:37:14 -05:00
Nicolas Williams 18879fb993 Fix leak on error in strptime 2017-11-23 01:51:22 -06:00
trantor bdaddcf107 Typo correction
Suppresion -> Suppression
2017-11-22 13:47:35 -05:00
William Langford 7b81a836c3 Merge pull request #1403 from Argoday/master
Use unsorted keys in walk
2017-06-19 10:55:26 -04:00
Nicolas Williams c538237f4e Deal with strptime() on OS X and *BSD (fix #1415)
strptime() on OS X and *BSDs (reputedly) does not set tm_wday and
tm_yday unless corresponding %U and %j format specifiers were used.
That can be... surprising when one parsed year, month, and day anyways.
Glibc's strptime() conveniently sets tm_wday and tm_yday in those cases,
but OS X's does not, ignoring them completely.

This commit makes jq compute those where possible, though the day of
week computation may be wrong for dates before 1900-03-01 or after
2099-12-31.
2017-05-21 16:24:48 -05:00
Nicolas Williams 4a6241be06 Attempt to fix #1415
OS X (and *BSD) strptime() does not set tm_wday nor tm_yday unless
corresponding format options are used.  That means we must call timegm()
to set them.
2017-05-21 01:58:18 -05:00
Nicolas Williams 1900c7bcac Add private my_timegm() 2017-05-21 01:57:55 -05:00
Nicolas Williams 578d536233 Fix HAVE_TM_TM_GMT_OFF usage 2017-05-21 01:53:00 -05:00
Nicolas Williams b0d6d28310 Use AC_CHECK_MATH_FUNC() for all math functions 2017-05-21 01:22:39 -05:00
Nicolas Williams 10d66051ef Fix jv_load_file() assertion (fix #1410) 2017-05-20 18:53:48 -05:00
Daniel Lange cb3d5aff84 Improved git build instructions. 2017-05-11 09:05:56 -04:00
Jonathan Word ca12bd9b5d Use unsorted keys in walk
Preserve key sorting order when executing in walk, if sorted keys is desired `--sort-keys` should be used to explicitly obtain sorted keys.
2017-05-03 15:49:21 -04:00
Nico Williams 6d89e297fe Add JQ_COLORS env var for color config (fix #1252) 2017-04-29 14:00:52 -04:00
Nicolas Williams 32d8f2000a Fix build 2017-04-26 20:55:50 -05:00
Nicolas Williams 0bd7614bd5 Always use jv_mem_*alloc() 2017-04-21 18:41:06 -05:00
pkoppstein 4b4cf789e0 def isempty(g) # Testing 'isempty(empty)' at line number 1364 2017-04-15 16:45:00 -05:00
William Langford 76b1fc18f1 Update oniguruma to fix #1370 2017-04-02 14:58:59 -04:00
William Langford 405071337d Don't require java to build gh-pages 2017-03-31 18:48:28 -04:00
William Langford 151b494382 Add collect example with pipeline 2017-03-31 18:48:05 -04:00
William Langford 12f74b226e Add missing close-backtick in docs 2017-03-30 22:23:47 -04:00
Nicolas Williams 18753cb7a7 Also fix jn/2 and yn/2 2017-03-30 11:46:03 -05:00
Nicolas Williams 71d4ff6ed8 Fix frexp, modf, lgamma_r (fix #1374) 2017-03-29 00:07:42 -05:00
Nicolas Williams 7935d307f0 Allow . as {$a:$b} destructuring 2017-03-26 05:36:23 -05:00
Nicolas Williams 38bfec1594 Add flex/bison outputs 2017-03-26 05:36:23 -05:00
Nicolas Williams 2421dfb843 Add more destructuring tests 2017-03-26 05:36:22 -05:00
William Langford 94035be3fa Add --debug-trace=all for detailed debug output
When tracing execution, print the whole stack, not just the items used by the
current opcode
2017-03-26 05:36:22 -05:00
William Langford c8a2a0acc2 Fix a tripped assertion when generating reduces
A noop body, while useless, should still compile successfully
2017-03-26 05:36:22 -05:00
William Langford 3a8c8f4747 Add alternation destructuring operator ?//
This is a first pass to show the implementation.
It needs tests and evaluation, but doesn't break any existing tests.

NOT READY FOR MERGING
2017-03-26 05:36:22 -05:00
Nicolas Williams b142d484d5 Conditional exprs are not path exprs (fix #1368)
The conditional expression in if-then-elif-else-end cannot contribute to
path expressions because it doesn't change the input to any of the then/
elif/else expressions.  These must be generated via gen_subexp().

See also #1366.
2017-03-15 01:07:37 -05:00
Nicolas Williams 674e9fb7c2 Make and build dist in travis-CI (#1356) 2017-03-04 23:14:36 -06:00
Nicolas Williams 6878123202 Make configure.ac work for shallow clones 2017-03-04 22:57:35 -06:00
Nicolas Williams f7bf9a8e96 Make scripts/version work in shallow clones
Shallow clones don't have tags.  Use git describe --always --dirty in
such cases.

XXX Add branch name.
2017-03-03 14:30:58 -06:00
Nicolas Williams 89809a2d0f Fix make dist 2017-03-01 23:01:08 -06:00
Nicolas Williams 9df19f53e4 Fix off-by-one bug in #1108 fix 2017-03-01 22:45:02 -06:00
Nicolas Williams 65cbaac344 Array slice overflows (fix #1108) 2017-03-01 17:48:45 -06:00
Nicolas Williams 2fcb257168 getpath/1 should be a path expression (fix #1358)
It needs to be possible to do something like

    getpath($paths[]) += 1

meaning: increment all the paths in . that are listed in $paths[].

In order to do this getpath() needs to update the jq->path and
jq->value_at_path as necessary.
2017-02-28 21:54:30 -06:00
William Langford 63791b795a Fix name of builtins in the builtins/0 output 2017-02-26 19:50:10 -05:00
Nicolas Williams ea90b947b0 Fix warning about environ 2017-02-26 18:22:30 -06:00
Nicolas Williams 9a0d796298 Fix --without-oniguruma build 2017-02-26 18:22:23 -06:00
Nicolas Williams 0337027d54 Fix environ Win32 build problem 2017-02-26 18:06:35 -06:00
Nicolas Williams 8ea21a54ad Add halt, halt_error builtins (fix #386) 2017-02-26 16:34:56 -06:00
Nicolas Williams 6bac4ed059 Document stderr 2017-02-26 16:34:56 -06:00
Nicolas Williams a03ae02f44 Fix memory leak 2017-02-26 16:33:50 -06:00
Nicolas Williams 45f126514c Fix Appveyor for non-master branches 2017-02-26 16:13:22 -06:00
Nicolas Williams b279713e47 fixup 2017-02-26 16:12:57 -06:00
Nicolas Williams 3504bd9a2a Add $ENV builtin variable to access environment 2017-02-26 00:39:24 -06:00
Nicolas Williams 1a8a0ae0f5 Fix error message for undefined vars 2017-02-26 00:37:28 -06:00
Nicolas Williams 441b066dd8 Preserve precious vars in configure.ac (fix #795) 2017-02-25 21:49:38 -06:00
Nicolas Williams ef87010059 Document $ARGS and friends 2017-02-25 19:21:06 -06:00
Nicolas Williams 66fb962a66 Add $ARGS, --args and --jsonargs (fix #1345) 2017-02-25 19:13:28 -06:00
Nicolas Williams e8abc0a2f6 jq_compile_args(): allow object args to be object 2017-02-25 19:13:28 -06:00
Nicolas Williams 7b1bd99de6 Add jv_object_has() 2017-02-25 19:13:28 -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 2e1f2db8b5 Improve Appveyor build
Among other things, make TESTS=... breaks when using modules/oniguruma,
so set SUBDIRS= then.
2017-02-25 18:57:38 -06:00
Nicolas Williams ba32b33796 Windows: configure fails to detect missing math
For some reason AC_CHECK_MATH_FUNC() on Windows is not detecting a
handful of math functions as not being supported.  This commit is a bit
of a hack.
2017-02-25 18:51:09 -06:00
Nicolas Williams 6e77b017c5 Make comment consistent with code 2017-02-25 18:51:09 -06:00
Yasuhiro Matsumoto 5d058fa416 Don't call SetConsoleOutputCP
Should use wide-string function instead of SetConsoleOutputCP.

Fixes #1121
2017-02-25 18:51:04 -06:00
Yasuhiro Matsumoto 12c60b2f32 Quiet a compiler warning 2017-02-25 18:49:22 -06:00
Nicolas Williams 9801de6979 Windows: Also use -lshlwapi for jq(1) 2017-02-25 14:49:20 -06:00
Nicolas Williams c695f2cd9c When using builtin Oniguruma, set flags correctly
This should fix the Travis-CI build.
2017-02-25 14:11:42 -06:00
Nicolas Williams 27c29aeb7b Document localtime and strflocaltime 2017-02-23 23:39:24 -06:00
Nicolas Williams 06f20603f6 Add localtime and strflocaltime (fix #1349) 2017-02-23 22:26:53 -06:00
Nicolas Williams 607a9e3912 Improve manual section on assignment forms 2017-02-23 22:17:54 -06:00
Nicolas Williams d3b4ad04f5 Revert e7caf68 for Dockerfile 2017-02-23 22:01:43 -06:00
Nicolas Williams e7caf68edd Attempt to use builtin Oniguruma for CIs 2017-02-23 00:33:08 -06:00
Nicolas Williams c6374b6a1f Allow ./configure --with-oniguruma=builtin
This allows one to force the use of jq's builtin copy of Oniguruma
(builtin as a git submodule).

We still need to fix make dist to include that copy of Oniguruma.
2017-02-23 00:30:13 -06:00
Nicolas Williams 8cde328007 Allow var bindings in path expressions (#1347)
The expression in a variable binding is not and must not be seen as
being part of a path expression in which the variable binding appears.
2017-02-21 18:11:35 -06:00
Erik Brinkman 02bad4b298 Add local oniguruma submodule
Configure should still allow use of prebuilt onigurumas (whether
system-installed or in a special prefix).  If these are not found, and
configure was not called with `--without-oniguruma`, then use the vendored
oniguruma module.  If configure was called with `--without-oniguruma`, then we
do not build regex functionality into jq.
2017-02-18 21:34:26 -05:00
Nicolas Williams 9b2179089b Improve manual 2017-02-15 11:48:39 -06:00
William Langford 1c806b74ea Add builtins builtin 2017-02-13 11:36:20 -05:00
William Langford 8001955fb7 Fix memory leak in libm cfunctions 2017-02-13 11:36:20 -05:00
William Langford e6fa039f3f Merge pull request #1089 from l8nite/base64_decode 2017-02-12 16:25:44 -05:00
Shaun Guth e0b784ac6d Add @base64d for decoding base64 #47 2017-02-12 16:03:59 -05:00
J Phani Mahesh dc679081fa fix truncate_stream to match docs 2017-02-07 21:30:55 -06:00
Nicolas Williams 597c1f6667 Add more missing math functions 2017-02-04 00:11:46 -06:00
Nicolas Williams 125071cf00 Fix handling of unsupported math functions 2017-02-04 00:11:10 -06:00
Nicolas Williams 2fb099e4cf Promote wiki more in README 2017-01-31 16:13:32 -06:00
Nicolas Williams 6f9646a44f Improve docs somewhat, inspired by #1326 2017-01-30 14:11:05 -06:00
Nicolas Williams bd7b48c1b9 Make |= delete LHS when RHS is empty (Fix #1314)
Now that #1313 is fixed, |= no longer outputs null when the RHS update
expression outputs empty.

When a user wants to keep the current value of the LHS they would have
the RHS update expression output `.`, so having `empty` achieve the same
thing would be redundant.  The obvious thing to do is to delete the LHS
when the RHS update outputs `empty` (i.e., doesn't output any values).

It's reasonable to think that existing programs won't be broken by this
change, because reduce and |= not handling empty well is clearly a bug.
(Though it's possible that some programs were using empty to quickly
terminate reduce or |=, it's not likely.  They should use label/break
instead.)

Prior to this change |= would use the _last_ value output by the RHS
update expression.  With this change |= will use the _first_ value
instead.  This change _is_ a minor backwards-incompatible change.  It
may or may not be acceptable; we'll see.  It is a useful change in that
it makes |= faster when the update expression produces multiple values.
2017-01-30 14:11:05 -06:00
Nicolas Williams aac8132f47 recurse (i.e., ..) needs to find leaf nulls 2017-01-30 14:11:05 -06:00
Nicolas Williams 7bdf3a39ad Add SQL-style operators (#1322) 2017-01-30 14:11:05 -06:00
Nicolas Williams 396543191c Make first(g) more efficient: extract only 1 value
first(g) was extracting two values, which, if g is slow, made first(g)
slow.  And if the second extraction were to throw an error, then
first(g) would throw that error, which is clearly not the right thing to
do.  Besides that, first(g) was allocating garbage, which it no longer
does.
2017-01-30 14:11:05 -06:00
Nicolas Williams e24af3c78e reduce: handle empty updates (fix #1313) 2017-01-30 14:11:05 -06:00
Attila Fülöp e82147bbb8 Solaris needs XPG6 for c99 2017-01-28 19:16:23 -06:00
William Langford d2c3cf49e1 Merge pull request #1317 from wtlangford/dont-split-utf8-sequences
Handle cut-off UTF-8 sequences when reading files
2017-01-27 21:45:15 -05:00
William Langford e84d17196c Handle cut-off UTF-8 sequences when reading files
Read additional bytes from the file to complete the UTF-8 sequence so the bytes
in it don't get converted to U+FFFD replacement characters.
2017-01-27 21:04:26 -05:00
W-Mark Kubacki fd4ae8304e Parse no deeper than MAX_PARSING_DEPTH
while true; do printf '{"deeper": '; done | jq .
2017-01-27 09:59:44 -06:00
W-Mark Kubacki 83e2cf607f Skip printing what's below a MAX_PRINT_DEPTH
This addresses #1136, and mitigates a stack exhaustion when printing
a very deeply nested term.
2017-01-27 09:59:44 -06:00
Jakub Wilk 61b75639a7 gen_utf8_tables: remove unused variable 2017-01-26 13:15:59 -06:00
Jan Schulz 19d266b528 Revert "Disable appveyor build for now"
This reverts commit 0b8218515e.

There is a new oniguruma package which previously trashed the build.
2017-01-23 16:28:01 -06:00
Richard Groves 9c4238c2f6 Typo fixed
simply -> simple
2017-01-23 16:21:37 -06:00
Janne Cederberg 114ac72169 Documentation clarification suggestions 2017-01-23 15:48:44 -06:00
James Pearson Hughes a10d7fbb02 Update download instructions for Arch
jq has been in the community repo for [just over a year now][0].

[0]: https://projects.archlinux.org/svntogit/community.git/commit/trunk?h=packages/jq&id=8d5e06065bc92bf56ea651970c9bda07fb545554
2017-01-23 15:46:17 -06:00
Tim McCormack f33af0b16a Typo: s/more/mode/ in --seq 2017-01-23 15:45:07 -06:00
Clément MATHIEU eeba7b3167 Fix input_(line_number|filename) leak memory 2017-01-23 15:18:51 -06:00
Jay Satiro e5c30e6fae Fix cross-compile tmp dir removal
- cd out of the tmp dir before attempting to remove it.
2017-01-23 15:10:57 -06:00
Nicolas Williams 0b8218515e Disable appveyor build for now 2016-03-21 18:59:52 -05:00
David Tolnay 1a8a5ee000 Remove David from maintainers 2016-02-24 00:39:56 -08:00
Nicolas Williams 1740fd036d Travis-CI build for OSX (fix #1083) 2016-01-19 00:19:24 -06:00
Nicolas Williams 6c635998f8 Always test sort_by/group_by post-#1082 2016-01-18 12:17:58 -06:00
Stephen Dolan 7835a724d6 Make jv_sort stable regardless of qsort details. 2016-01-18 10:41:25 -06:00
Stephen Dolan 239c357af0 Add AppVeyor badge to README.md
Thanks @JanSchulz, @nicowilliams!
2016-01-18 10:15:43 +00:00
Nicolas Williams d228490162 Add --enable-ubsan (undefined behavior sanitizer) 2016-01-17 13:06:27 -06:00
Nicolas Williams b92a12cf6c Run failing tests on Windows; ignore failures 2016-01-17 12:46:57 -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 062f86a625 Enable more tests on Windows; move sort_by tests
Use %%FAIL IGNORE MSG for error messages that differ on Windows, and
move the sort_by/group_by tests that fail qhen qsort() is not stable.

Now only tests/sorttest and tests/shtest are disabled on Windows.
2016-01-17 12:45:01 -06:00
Nicolas Williams c3d13260a7 Tweak appveyor.yml; disable failing tests 2016-01-17 01:49:50 -06:00
Jan Schulz e6e07cd2c6 Upload build failure logs
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2016-01-16 17:02:43 -06:00
Jan Schulz ec4dfd32cc Build a html help
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2016-01-16 17:02:43 -06:00
Jan Schulz c0e01452f2 Run tests on appveyor
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2016-01-16 17:02:43 -06:00
Jan Schulz 45260890f2 Add 32bit windows builds on appveyor
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2016-01-16 17:02:43 -06:00
Jan Schulz 4337fc5fe0 Build on windows (mingw) on appveyor
For this to work, one of the core commiter should do:

* enable appveyor in the github project (grant access)
* Make an appveyor account and add the github jq repo as a new project

inspirations from:

appveyor, msys2, use bash environment to build...
* https://github.com/ariscop/elemental-ircd/blob/appveyor/appveyor.yml
* https://github.com/khaledhosny/ots/pull/67/files
* https://github.com/universal-ctags/ctags/blob/master/appveyor.yml
* https://github.com/universal-ctags/ctags/blob/master/win32/appveyor.bat

and with mvsc
* https://github.com/khaledhosny/ots/blob/master/.appveyor.yml

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2016-01-16 17:02:43 -06:00
Nicolas Williams 093d20c3b9 Fix cross-compilation build 2016-01-16 16:51:06 -06:00
Nicolas Williams ec07936888 Fix Windows build (fix #911) 2016-01-16 16:51:01 -06:00
Nicolas Williams 8e4724e16c fixup non-maintainer build 2016-01-15 16:06:18 -06:00
Nicolas Williams 3afdbb7b7d Always build src/builtin.inc (fix #1069) 2016-01-15 11:59:14 -06:00
Nicolas Williams f217fa26ae MultiByteToWideChar() usage bug (fix #1072) 2016-01-15 11:58:41 -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 856a4b2f3f Add note about IEEE754 to help msg 2015-12-15 00:00:03 -06:00
Cameron Sparr 6d76cd0a99 Change usage formatting 2015-12-14 23:58:28 -06:00
Romero Malaquias 6151f20477 Avoiding conditional directives that break statements 2015-12-09 15:29:35 -06:00
pkoppstein ad8d1a8cc8 Two sub bugs fixed; two new gsub tests have been added.
./jq --run-tests < tests/onig.test
has been run successfully:

...
Testing 'gsub("a";"b")' at line number 70
Testing 'gsub( "(.*)"; "";  "x")' at line number 74
...
22 of 22 tests passed (0 malformed)
2015-12-09 15:28:01 -06:00
Nicolas Williams ec583deefa Fix JV_OBJECT() and go up to 18 2015-12-01 23:27:19 -06:00
Nicolas Williams 5fe053671a Assume . if either stdin/on isatty() (fix #1028)
And move the #define of isatty on Windows up.
2015-12-01 23:27:19 -06:00
Mark McKinstry 0d177d240d yum has been replaced with dnf as of f22
https://fedoraproject.org/wiki/Changes/ReplaceYumWithDNF
2015-11-26 10:48:06 -05:00
David Tolnay 18b4b18b41 Support --without-oniguruma 2015-11-21 10:05:37 -08:00
David Tolnay befd192958 Oniguruma hash in dockerfile 2015-11-18 00:30:18 -08:00
Loamhoof 79f9ecd150 Fix manual signature for split (non-regex) 2015-11-15 21:43:38 +01:00
Nicolas Williams 8f115e9eed Add address sanitizer (ASAN) support (fix #1002) 2015-10-27 20:06:21 -05:00
David Tolnay e17ccf2297 Support numbers and boolean in join (fix #930) 2015-10-25 12:40:15 -07:00
Nicolas Williams 8eb1367ca4 Heap buffer overflow in tokenadd() (fix #105)
This was an off-by one: the NUL terminator byte was not allocated on
resize.  This was triggered by JSON-encoded numbers longer than 256
bytes.
2015-10-24 17:27:56 -05:00
David Tolnay 2f79004f85 strptime() on OpenBSD requires _XOPEN_SOURCE_EXTENDED 1 (fix #999)
strptime() is an XPG4v2 function, on OpenBSD the prototype
is not included in time.h unless visibility is set, it needs
either "#define _XOPEN_SOURCE_EXTENDED 1" or _XOPEN_SOURCE
>= 500. Without this the prototype isn't included and
strptime's returned pointer is truncated to an int, causing
SEGV on 64-bit arches when using it.

Thanks @sthen
2015-10-24 11:23:56 -07:00
David Tolnay b7a219a91d mktemp needs 6 or more X's (fix #1000)
mktemp(1) isn't posix specified, but it's reasonable to use
mktemp(3) to implement it which requires 6 trailing X's in
the format

Thanks @sthen
2015-10-24 11:21:18 -07:00
Nicolas Williams aa279ae7ac Fix builtin.o dependency (#992) 2015-10-22 22:33:47 -05:00
Nicolas Williams 4060535f9f Fix linux32 jq-1.5 executable (fix #935) 2015-10-22 22:07:34 -05:00
Nicolas Williams 1847333342 Rename sig/v1.5/jq-linux32.asc (prep for #935) 2015-10-22 22:06:27 -05:00
Nicolas Williams 87c278c8a5 Remove setup.sh (fix #993) 2015-10-22 21:53:53 -05:00
David Tolnay 143e8dc5e4 Move jq-coded builtins to non-C file (fix #424) 2015-10-22 19:26:00 -07:00
David Tolnay b80d58e167 Move docs for map earlier (fix #288) 2015-10-17 23:54:07 -07:00
David Tolnay 6c31850e86 If-then-else documentation for forking conditional (fix #942) 2015-10-17 21:15:24 -07:00
David Tolnay c8dc164566 Support lowercase name in from_entries (fix #990) 2015-10-17 20:50:40 -07:00
David Tolnay 32e5e6af4b Revert "Adjust spacing of section headers to account for nav bar (fix #986)"
This reverts commit 73b8413d10.

The fix for #986 caused #988.
2015-10-13 23:29:57 -07:00
David Tolnay 4a886f831c Autocomplete manual search to first result on submit 2015-10-13 10:48:06 -07:00
David Tolnay e3c36777ab Add background color to typeahead menu 2015-10-12 22:50:03 -07:00
David Tolnay c2395f0278 Sort manual search results shortest to longest 2015-10-12 22:35:37 -07:00
David Tolnay 0791261f07 Remove backticks from manual headers and search strings 2015-10-12 22:30:16 -07:00
David Tolnay 73b8413d10 Adjust spacing of section headers to account for nav bar (fix #986) 2015-10-12 22:12:37 -07:00
David Tolnay 664b8e26f0 Merge typeaheadjs.css into base.scss 2015-10-12 21:03:42 -07:00
David Tolnay 64ade137bc PGP signatures for release binaries (fix #889) 2015-10-12 20:57:53 -07:00
David Tolnay da15e10bd0 Accept only bitwise identical NaN values in jv_identical (fix #978) 2015-10-12 20:47:22 -07:00
David Tolnay 1f7c24fea7 Add signing key and dtolnay's key fingerprints to KEYS 2015-10-12 20:07:24 -07:00
Nicolas Williams 49b8382c5f Remove expired key from KEYS 2015-10-12 19:11:52 -05:00
Nicolas Williams 583ab589dc Add KEYS file 2015-10-12 19:01:02 -05:00
David Tolnay c80c07ab68 Link to BootstrapCDN for Bootstrap and Bootswatch (fix #985) 2015-10-12 12:19:25 -07:00
David Tolnay c5875504da Explicitly use current directory in Rakefile 2015-10-12 10:46:17 -07:00
David Tolnay 05d1c09cc1 Split up Rakefile to minimize dependencies (fix #435) 2015-10-12 10:42:15 -07:00
David Tolnay 9d6e91ea7b Add description for rake tasks
You can see the descriptions by running `rake --tasks`.
2015-10-12 10:21:18 -07:00
David Tolnay 4887cfd951 Remove duplicate yaml import in Rakefile 2015-10-12 10:10:56 -07:00
David Tolnay 9a51696bc0 Remove old Rakefile dist targets
Because binaries no longer go into the repo.
2015-10-12 10:03:18 -07:00
Simon Elsbrock bf271b8062 docs: jq 1.5 is now available in Debian unstable
It may take some time until it bubbles up into Ubuntu repositories.
2015-10-12 10:02:07 +02:00
David Tolnay 2864fb467e Bump fedora and chocolatey available version numbers 2015-10-02 19:19:36 -07:00
David Tolnay 4490d9d1f6 Support NaN in path expressions (fix #962) 2015-09-24 10:33:34 -07:00
Nicolas Williams c4524da3e0 EOF after newline in string mishandled (fix #951) 2015-09-22 20:11:54 -07:00
David Tolnay 58f082d74f Delete negative indices in array (fix #954) 2015-09-21 20:33:06 -07:00
David Tolnay 154d0ee4a8 Fix assert fail if object literal key is not a string (fix #953) 2015-09-21 12:47:06 -07:00
Roman Inflianskas 83ab4e273b Add openSUSE repository 2015-09-20 08:15:15 -07:00
David Tolnay dccda74062 Address comments on PR #950 2015-09-16 10:48:50 -07:00
David Tolnay b52bebfbe8 Improve invalid object key error message 2015-09-16 09:53:42 -07:00
David Tolnay 1758c1ba74 Remove "Requires 1.5" from manuals
No longer necessary now that manuals are versioned.
2015-09-13 18:57:11 -07:00
Joel Nothman 83e8ec587f utf8bytelength: count UTF8 string bytelength
[Builtin name changed, and it only works on string inputs. -Nico]
2015-09-13 01:01:24 -05:00
Steven Penny 63dd033da7 Fix segmentation fault on Windows with long paths (fix #939) 2015-09-10 21:29:34 -07:00
David Tolnay 91f0dcff5c Avoid passing '/bin/bash' as default argument to docker run
Previously:

```
$ docker run dbdc663dabc8
jq: error: syntax error, unexpected '/', expecting $end (Unix shell quoting issues?) at <top-level>, line 1:
/bin/bash
jq: 1 compile error
$ docker run --entrypoint /bin/echo dbdc663dabc8
/bin/bash
```

Now:

```
$ docker run e36393e8c15e
jq - commandline JSON processor [version 1.5rc2-77-g9a3fe9e]
Usage: /usr/local/bin/jq [options] <jq filter> [file...]

	jq is a tool for processing JSON inputs, applying the
...
```
2015-09-05 13:03:01 -07:00
David Tolnay 688bb1993f Get oniguruma from github instead of geocities 2015-09-05 12:40:42 -07:00
David Tolnay 94bda489ce Fix indentation in Dockerfile 2015-09-05 11:54:56 -07:00
David Tolnay c9003e521c Add travis and coveralls badges to readme 2015-08-25 08:48:40 -07:00
Stephen Dolan 8105255be2 No-op commit to trigger first run of Travis. 2015-08-25 15:36:54 +01:00
Nicolas Williams f57743eb37 Remove jq.1.default and related content 2015-08-23 23:08:11 -05:00
David Tolnay 0c93eb3379 Move source files to src/ 2015-08-23 20:36:11 -07:00
David Tolnay 891f28ef5e Copy gitignore in website update script 2015-08-22 17:26:58 -07:00
David Tolnay 371e74a25f Remove obsolete comment in Makefile.am 2015-08-22 16:27:06 -07:00
David Tolnay 9ec27fe362 Sort source file lists in Makefile.am 2015-08-22 16:20:21 -07:00
David Tolnay 75662a4b05 Standardize indentation in Makefile.am
This was being done 5 different way in 5 places:

- indent 3 spaces, then tabs to column 73
- indent 2 spaces, then tabs to column 73
- indent 2 spaces, then a single tab
- indent with spaces up to equal sign, then tabs to column 73
- indent 1 tab, then tabs to column 73

I standardized on 8 spaces, then spaces to column 73. The 8
spaces lines up with common browsers' indentation of the
rest of the makefile, which is indented by single tabs. The
spaces to column 73 make sure the trailing backslashes line
up regardless of the tabstop setting.
2015-08-22 15:31:50 -07:00
David Tolnay 4a993dff29 Add gcov output to gitignore 2015-08-22 14:47:07 -07:00
David Tolnay 516e79151f Include "jv.h" instead of <jv.h> 2015-08-22 13:53:44 -07:00
David Tolnay 6c3934de15 Fix decoding of UTF-8 sequence length (fix #922) 2015-08-22 12:31:36 -07:00
David Tolnay 370833d555 Sort libm functions 2015-08-22 10:54:35 -07:00
David Tolnay 302ae77712 Remove unused libm functions 2015-08-21 09:45:16 -07:00
Frederic Cambus 5d23c240b6 Use 'snprintf' instead of 'sprintf'
This gets rid of a linker warning when compiling on OpenBSD:

    ./.libs/libjq.a(jv_print.o)(.text+0x2fc): In function `jvp_dump_string':
    /root/jq-1.5/jv_print.c:118: warning: sprintf() is often misused, please use snprintf()
2015-08-20 14:48:58 -07:00
David Tolnay 7032228879 Hide manual jqplay button and navigation in print mode 2015-08-20 11:14:14 -07:00
David Tolnay 8932cf719f Hide tutorial "show result" button in print mode 2015-08-20 00:02:09 -07:00
David Tolnay 7668a4f255 Expand all manual examples in print mode 2015-08-19 23:27:10 -07:00
David Tolnay 2c6c521799 Add FreeBSD install instructions (fix #917) 2015-08-18 08:21:57 -07:00
David Tolnay 19577fcefa Link to correct 1.5 source tarball 2015-08-17 18:04:56 -07:00
David Tolnay b8f71d3659 Fix assert fail when delpaths is given non-array (fix #901) 2015-08-16 19:44:16 -07:00
David Tolnay 2d05b5475c Standardize on "color" to match what the flag has always been called 2015-08-16 19:19:29 -07:00
David Tolnay 44a5c4b0b1 Fix "the the" in manuals 2015-08-16 19:04:38 -07:00
David Tolnay a12b9102c7 Fix examples in 1.4 manual 2015-08-16 19:01:32 -07:00
David Tolnay b5f8cb2126 Fix spelling of getpath and setpath in manual 2015-08-16 18:43:12 -07:00
David Tolnay 31be4a0495 Remove duplicate author
They seem to be the same person based on this pull request:
https://github.com/stedolan/jq/pull/80

I am keeping the email tied to his GitHub account.
2015-08-16 18:41:00 -07:00
David Tolnay e785a17a5f Sort authors 2015-08-16 18:41:00 -07:00
Nicolas Williams b6e3657eda Document getpath/setpath 2015-08-16 20:32:01 -05:00
David Tolnay ec7c3cf9a7 Fix -Wzero-length-array 2015-08-16 09:11:23 -07:00
David Tolnay eb2fc1d27e Fix unnecessary use of BLOCK macro 2015-08-16 09:01:35 -07:00
David Tolnay 73b9e8dc99 Fix -Wgnu-zero-variadic-macro-arguments 2015-08-16 09:00:31 -07:00
David Tolnay 490a843947 Add sha1sum for jq-osx-amd64 1.5 2015-08-16 08:46:22 -07:00
David Tolnay 6fa1300d39 Link to 1.5 binary for OS X (fix #912) 2015-08-15 23:44:41 -07:00
David Tolnay ef0fb50c1c Fix 1.5 manual title 2015-08-15 23:19:13 -07:00
David Tolnay 3608341c53 Update website for jq 1.5 (fix #910) 2015-08-15 23:12:31 -07:00
David Tolnay 461f04bd4d Rename header template to navbar
To avoid the confusing similarity between _head and _header.
2015-08-15 14:15:19 -07:00
David Tolnay 161a6fa635 Update gems
I updated some of these gems for a different project, and
suddenly `rake build` was giving very different output
compared to the current gh-pages. This commit makes sure
everyone updating gh-pages is using reasonably similar
versions, so we avoid spurious diffs.
2015-08-15 13:23:19 -07:00
David Tolnay 6d2f917a3a Move footer content into template
This caused problems because liquid >=3.0.0 does not allow a
variable and a template with the same name. Here we had a
variable and a template both called footer.
2015-08-15 13:03:33 -07:00
David Tolnay 8f55d6d4ab Use https where possible 2015-08-15 12:23:16 -07:00
David Tolnay 2306795864 Canonical URL and redirect to https site (fix #908) 2015-08-15 12:23:13 -07:00
David Tolnay e0eb03b96d Update website footer links 2015-08-14 11:29:47 -07:00
David Tolnay b1083ab367 Use entry title without whitespace as section id 2015-08-14 00:33:55 -07:00
David Tolnay e3e7cea177 Fix some w3c validator complaints 2015-08-14 00:01:49 -07:00
David Tolnay d36a85a369 Consistent indentation of shared templates 2015-08-13 23:08:52 -07:00
David Tolnay bd46a5dd52 Move all javascript to end of body 2015-08-13 23:00:54 -07:00
David Tolnay 7f87785002 Group logically related parser rule names 2015-08-13 22:39:31 -07:00
David Tolnay 0f419563ea Remove all trailing whitespace 2015-08-13 22:39:23 -07:00
David Tolnay aff6f49990 Tiny margin on tutorial accordions 2015-08-13 22:18:01 -07:00
David Tolnay 58a053d7de Fix memory leak in non-constant module declaration 2015-08-13 21:42:35 -07:00
David Tolnay 7b5c6a9224 Fix assert fail on invalid import path (fix #899) 2015-08-13 21:42:35 -07:00
David Tolnay 5479d7f2dc Fix assert fail on non-object import metadata (fix #900) 2015-08-13 21:42:35 -07:00
Nicolas Williams a5b2c55a70 Fix streaming docs errors (fix #904) 2015-08-13 23:38:14 -05:00
Nicolas Williams b119853aef Test main.c fix for #817 2015-08-13 09:08:37 -07:00
Nicolas Williams 5d08d54636 Make search path expansion portable (fix #817)
This is part 2 of the fix to #817.  Part 1 is the previous commit.
2015-08-13 09:08:37 -07:00
Nicolas Williams 10df52efed Make all global module paths absolute (fix #817)
This is part 1 of the fix for #817.  The next commit is part 2.
2015-08-13 09:08:37 -07:00
David Tolnay 68f84659f3 Update site from bootstrap 2.1.1 to 3.3.5 2015-08-13 01:10:16 -07:00
David Tolnay 3ef92863f2 Update wording and json bodies in tutorial 2015-08-11 22:02:53 -07:00
pkoppstein dea7868f01 spelling corrections; untabify 2015-08-11 20:54:03 -07:00
pkoppstein 16d0e528aa walk/1 2015-08-11 20:54:03 -07:00
Nicolas Williams c426d494f0 Improve assignment docs (see #897) 2015-08-11 18:05:22 -05:00
Nicolas Williams 9a3f802d20 Fix #896, double-free in setpath 2015-08-11 17:46:15 -05:00
David Tolnay 89897b4bcd Change index page links to github releases 2015-08-08 10:35:18 -07:00
David Tolnay f1d1fea467 Add SHA-1 checksums of release binaries (fix #726) 2015-08-08 01:19:39 -07:00
David Tolnay e404a1a96d Script to update gh-pages from master 2015-08-08 00:29:22 -07:00
David Tolnay b23d07875e Remove obsolete gitignore entry 2015-08-08 00:26:32 -07:00
David Tolnay 9a68905228 Replace jq-1.4 source tarball link 2015-08-07 22:53:48 -07:00
David Tolnay 486c275885 Replace website download links with github releases 2015-08-07 22:23:08 -07:00
David Tolnay a864e848b5 Add jq-1.5rc2 to index page news 2015-08-07 22:11:09 -07:00
David Tolnay a4dc312eff Break long line on index page 2015-08-07 22:09:06 -07:00
David Tolnay 765f9ac74c Clean up download page and fix links 2015-08-07 21:40:19 -07:00
David Tolnay 3fae608b65 Copy over links to 1.5rc2 from gh-pages 2015-08-07 20:35:41 -07:00
David Tolnay a47b32999b Fix range(value;stream) (fix #886) 2015-08-06 23:05:03 -07:00
pkoppstein d66fbd218b Clarify documentation of STRING * INTEGER 2015-08-04 21:40:16 -04:00
Nicolas Williams b5edbf7ffa OS X's mktemp -d requires template (fix #876) 2015-07-28 00:28:54 -05:00
Nicolas Williams 6b55baa00f Add missing files (fix #875) 2015-07-28 00:09:46 -05:00
Nicolas Williams 7f251344b7 Fix make dist (fix #870) 2015-07-26 23:26:30 -05:00
David Tolnay 21309bc6d7 Error on bytecodes longer than 0xFFFF (fix #269)
This lets us use uint16_t for the program counter. JVM
languages have the same limit on method size so it is a
reasonable limit.
2015-07-26 16:19:20 -07:00
David Tolnay 8295baf284 Drop plus from "jq 1.5+" on download page
See https://github.com/stedolan/jq/issues/488#issuecomment-124998113
2015-07-26 09:37:34 -07:00
David Tolnay ec84f28630 News is not THIS important 2015-07-26 01:27:14 -07:00
David Tolnay 701a47c82e Add 1.4 and 1.3 manuals to website (fix #866) 2015-07-26 01:26:13 -07:00
David Tolnay 616f365e5a Suggest --disable-maintainer-mode on download page 2015-07-25 23:44:52 -07:00
David Tolnay ceb2684f2f Update setup.sh script
Adjust what gets cleaned up now that ChangeLog and
config/.gitignore are checked into the repo, and skip
install and distcheck steps.
2015-07-24 23:26:47 -07:00
David Tolnay b9c340a211 Change homepage .com -> .io
The .com redirects to .io, but might as well have the
correct one to begin with.
2015-07-24 22:55:58 -07:00
David Tolnay 3a964e2025 Change AC bug-report parameter to point to GitHub
This affects where `make check` tells you to report failures.
2015-07-24 22:48:03 -07:00
Santiago Lapresta 3d49fc59dd Implement flatten/0 in terms of flatten/1 2015-07-24 21:55:43 -07:00
David Tolnay 16e8d0b1ab detect invalid path expression (fix #862) 2015-07-24 20:23:07 -07:00
pkoppstein 5856a2d2c0 simplify implementation of bsearch to use "until" and avoid "last"; tested 2015-07-24 12:29:20 -07:00
David Tolnay 227f62e013 Rebuild jq.1.prebuilt 2015-07-24 09:01:21 -07:00
Evan Zacks 89244cc3ea fix references to --color-output 2015-07-24 10:18:12 -04:00
Thomas R. Hall 3a43e2ff07 Updated v1.3 filenames
The jq 1.3 filenames for Windows are jq-1.3.exe instead of jq.exe. Updated these so they no longer return a 404.
2015-07-23 22:24:39 -07:00
David Tolnay 81f328f1aa Copy over changes made to gh-pages directly
This includes the following commits from the gh-pages branch:

 - 63e80b8
 - d24a397
 - 9796cd6
 - ee21707
 - ccb0f1d
 - 200e6b3
 - 64134c0
 - 57152d2
 - 8ffbfa3
2015-07-23 21:51:30 -07:00
David Tolnay f5a7bba986 Resolve remaining shift/reduce conflicts involving '?'
By lowering the precedence of rules that should never use
the generic Exp '?' rule.
2015-07-19 09:43:10 -07:00
David Tolnay 66ef8e2c24 Resolve shift/reduce conflict of 'def' vs '|'
This was an important conflict. In the following expression:

    def a: 0; . | a

Bison needs to decide between these two equally valid
parses:

    (def a: 0; .) | a
    def a: 0; (. | a)

For jq we want the second one, because the first results in
"a/0 is not defined". In the current parser the first parse
is a reduce and the second parse is a shift. Since Bison
prefers to shift in shift/reduce conflicts, we accidentally
got the correct behavior.

This commit adds a precedence level FUNCDEF which is lower
precedence than '|', meaning we explicitly choose the
correct parse.

Of course many unit tests already cover this case, but I
added one specifically for it.
2015-07-19 09:42:01 -07:00
David Tolnay 1628bbf95f Clean up trailing whitespace 2015-07-19 09:38:50 -07:00
Nicolas Williams 812703139c Use =, not ==, for shell tests 2015-07-18 21:12:08 -05:00
David Tolnay 54add5ac9a travis has whitelisted libonig-dev
https://github.com/travis-ci/travis-ci/issues/4123
2015-07-10 13:21:00 -07:00
Nicolas Williams f183b57ed5 input_filename should never empty 2015-07-10 12:32:11 -05:00
Nicolas Williams dc4dfdff17 Update AUTHORS 2015-07-10 12:28:21 -05:00
Nicolas Williams f55034d314 Update NEWS 2015-07-10 11:26:29 -05:00
Nicolas Williams 930899e12d Update ChangeLog 2015-07-10 11:12:24 -05:00
Nicolas Williams 579518c78d Use include for import into namespace 2015-07-10 10:19:33 -05:00
Nicolas Williams fa45a5121c Simplify import docs 2015-07-10 10:11:30 -05:00
Nicolas Williams 862566a48f Fix typo in docs 2015-07-10 10:10:28 -05:00
James Andariese f9f4d2d1e5 Dockerfile reorganized
* Remove excess layer creation
  This is an antipattern in Docker.
* Remove build tools once build is complete
  Leaving them around is not necessary and expands the image size 5x
* Make check works with libonig installed
* Compiles statically (needs libonig to be built rather than installed)
* Valgrind doesn't work with the use of TLS in jq so it's disabled -- this
  might be a FIXME situation; I'm not familiar enough with valgrind to
  say whether this is expected
* Make entrypoint be the jq binary so that the image can also be used
  to run jq in environments where you don't want to or can't install
  jq (such as CoreOS).
2015-07-10 07:15:44 -07:00
Mike Fletcher b74379532d Fixing missing D in LIBM_DDD_NO macro name 2015-07-09 14:59:37 -04:00
David Tolnay 1e5e0c9fe2 Make jq.h usable from C++
Previously, with clang++:
jq.h:46:37: error: typedef redefinition with different
      types ('struct jq_util_input_state *' vs 'jq_util_input_state')

With g++:
jq.h:46:37: error: conflicting declaration
      ‘typedef struct jq_util_input_state* jq_util_input_state’

This typedef was added to libjq by commit 0d41447 which was
after the 1.4 release, so although it is a public API, this
is not a backcompat break because it has never been in a
release.

Specifying the "*" at all uses of jq_util_input_state is
slightly tedious, but jq_state already works that way, so at
least it will be consistent.
2015-07-04 15:08:01 -07:00
Nicolas Williams 05899f8b3e Fix Windows build 2015-07-04 13:45:24 -05:00
Nicolas Williams a2a6f2d896 Document math support 2015-07-03 21:19:01 -05:00
Nicolas Williams 1c350c67d7 Remove pow10 for now; CHECK_MATH_FUNC needs work
The CHECK_MATH_FUNC() m4 macro needs work.  It should use
AC_RUN_IFELSE(), not just AC_LINK_IFELSE(), and it should #define
_GNU_SOURCE and/or other such feature macros in the prologue to get
non-standard math functions (alternatvely jq should only support
standard math functions).
2015-07-03 21:13:13 -05:00
David Tolnay 2348b7245e docs and diagram for exec_stack 2015-07-02 23:58:07 -07:00
David Tolnay 6e27de4f74 strftime wrong day-of-week (fix #838) 2015-07-01 20:37:16 -07:00
Nicolas Williams e5dafaea44 Document --run-tests 2015-06-28 13:57:02 -05:00
Nicolas Williams fd4f4f2087 Make --run-tests' jv_test() quiet 2015-06-28 13:39:32 -05:00
Nicolas Williams 6c89186437 Make --run-tests less verbose by default
Adding --debug-trace or --debug-dump-disasm before --run-tests now makes
it verbose.
2015-06-27 23:31:44 -05:00
Nicolas Williams 32c4759e6b Add more basic number tests 2015-06-27 23:15:16 -05:00
Nicolas Williams 6366cfd7a4 Add pow, better libm detection (fix #443) 2015-06-27 23:14:46 -05:00
David Tolnay 9985c01975 gcov exclusions 2015-06-27 14:48:13 -07:00
David Tolnay e6371712ff flag to enable gcov and coveralls 2015-06-27 11:25:01 -07:00
David Tolnay d7e35101c5 add configure option to run tests without valgrind 2015-06-27 11:24:53 -07:00
Nicolas Williams 1defaa7b00 Fix braino in merging the previous commit
There's a mantest that shows how to use `env`.  Well, we need to set the
env var as expected then, else it will fail.
2015-06-27 13:00:41 -05:00
David Tolnay 815b4c9772 get Travis CI working 2015-06-27 12:40:01 -05:00
Nicolas Williams aaf305868c Restore import into caller's namespace 2015-06-26 23:40:37 -05:00
Nicolas Williams 8cc31f0f49 Slight re-phrasing of module docs 2015-06-26 23:38:24 -05:00
Nicolas Williams a011ac6392 Use set -u in tests/setup 2015-06-26 23:36:34 -05:00
Nicolas Williams 505e23124f Fix #830 2015-06-26 21:24:01 -05:00
Nicolas Williams e7f6d1e6d0 Update Adavanced section of manual 2015-06-26 21:19:29 -05:00
Nicolas Williams a220482de6 Document {$var} 2015-06-26 21:18:58 -05:00
Nicolas Williams e16bd17571 Add {$var} . as {$var} syntax (fix #831) 2015-06-26 20:45:14 -05:00
Nicolas Williams 25d47ca08e Add streaming utilities (fix #827) 2015-06-26 20:45:06 -05:00
Nicolas Williams 5108a451ca Alternative implementation of tovalues 2015-06-26 20:17:02 -05:00
Santiago Lapresta ec7647c4ab Add combinations/0 and combinations/1 2015-06-23 10:59:58 -05:00
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
Nicolas Williams ef12efbf8c Fix README 2015-05-02 17:36:37 -05:00
Nicolas Williams adb9b9b8a7 README: send questions to SO and Freenode 2015-05-02 17:34:59 -05:00
Nicolas Williams 07f94f82a2 usage() should check fprintf() result (fix #771) 2015-04-28 10:39:34 -05:00
Nicolas Williams 215b4c0fe1 Use jv_mem_alloc() in compile.c (fix #771) 2015-04-28 10:37:37 -05:00
Nicolas Williams 89963e1370 Fix header guards (fix #770) 2015-04-28 10:36:21 -05:00
Nicolas Williams 5d40f3a7c0 --raw-input wrongly adds NULs (fix #761) 2015-04-24 10:42:19 -05:00
Nicolas Williams 5e0e7a7ebd With inputs builtin, -n and -R can now coexist 2015-04-23 23:43:44 -05:00
Nicolas Williams dad6e42934 --raw-input ought to read NULs (partial fix #760)
We can't know how many bytes fgets() read when we reach EOF and fgets()
didn't see a newline; we can only assume that at least strlen(buf) bytes
were read.  This is quite obnoxious if one wants to use NULs in raw
input, but at least we can make reading "a\0b\0c\0" with no newline
yield "a\0b\0c", losing only the final sequence of NULs.

We can't use getline() either, since it will want to allocate a buffer
big enough for an entire line, and we might not have any newlines in our
input.  A complete fix will have to use getc() or read(), preferably the
latter.
2015-04-23 23:43:44 -05:00
Nicolas Williams 7d938487dd --slurp --raw-input is broken (fix #761) 2015-04-23 18:26:57 -05:00
Nicolas Williams fcfacb932d from_entries is broken (fix #767) 2015-04-23 18:25:32 -05:00
Assaf Gordon 6906d291c5 regex functions: report informative error if not available.
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-22 16:57:03 -05:00
Andrew O'Brien 943090846f Fixes manual generation with psych
When running `make` I ran into a couple of problems building the manual. While
I'm not entirely sure that this is the root cause, it appears to have been
related to the fact that ruby 2.0 dropped syck completely in favor of psych
(which was introduced in 1.9.2) for YAML processing. I'm currently using ruby
2.1.0p0.

I'm assuming that the fact that the YAML engine was explicitly set to syck in
the Rakefile was an attempt to work around some incompatibility between the two
libraries, so I looked into what would be necessary to get it to work with the
newer one. The changes to `manual.yml` ended up being pretty minor: I ran it
through `iconv` to convert some ISO-8859-1 characters to UTF-8 and added some
quotes in places (apparently you can't start a string value with '`').
2015-04-22 11:01:39 -05:00
Assaf Gordon 2dc8621d05 Handle NUL in escaped-string output
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-20 16:51:48 -04:00
tal@whatexit.org b6cc00fa71 manual.yml: Clarify how to specify keys with ":" and special chars.
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2015-04-16 11:09:49 -05:00
Assaf Gordon 9e2d9b6419 docs: expand @tsv section - add escape sequences. 2015-04-15 23:24:24 -04:00
Assaf Gordon 3210b29bba @tsv: escape \r, \n, \\
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-04-15 16:11:58 -04:00
Nicolas Williams ddad9618dc Test fix for mktime 2015-03-31 10:03:35 -05:00
Nicolas Williams 24005287f4 Add $__loc__ (fix #740) 2015-03-30 22:36:04 -05:00
Nicolas Williams 1dcfc2f547 Include filename and lineno in error messages 2015-03-30 15:56:29 -05:00
Nicolas Williams 7d6d4066dd Tweak fix for #719 2015-03-24 15:05:06 -05:00
Assaf Gordon 4c22bda09b detect and report output writing errors
Detect output errors when the program exits.

Currently:
    $ echo '{}' | jq . > /dev/full && echo ok
    ok

with the patch:
    $ echo '{}' | jq . > /dev/full && echo ok
    Error: writing output failed: No space left on device

also apply to hardware/network/other I/O errors.

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2015-03-24 15:01:32 -05:00
Santiago Lapresta 9d62c6fd0c Adds Dockerfile
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2015-03-24 14:59:29 -05:00
Assaf Gordon 5e0db6dd65 partial handling of input errors
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2015-03-24 14:56:46 -05:00
Assaf Gordon 551d875be1 always propagate input errors to exit code
Improve robustness in automated system when using exit code in shell scripts,
by exiting with code 2 if there was any input error (even overriding other
possible error exit codes).
Exit code 2 is already used to indicate system errors.

Without the patch:
   $ jq . no-such-file ; echo $?
   jq: no-such-file: No such file or directory
   0

With the patch:
   $ jq . no-such-file ; echo $?
   jq: no-such-file: No such file or directory
   2

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2015-03-24 14:55:14 -05:00
Nicolas Williams 4f8567476d Better argfile fix (#705, fix #736) 2015-03-24 14:53:35 -05:00
Nicolas Williams ffa2832e33 Drop name-less label/break for now
See #734 and #658.
2015-03-24 01:21:17 -05:00
William Langford 0f7759f831 Fix #735 2015-03-23 22:11:55 -04:00
Nicolas Williams ccfba00178 Add more date builtins 2015-03-09 11:27:58 -05:00
Nico Williams 3e8183fcd5 Merge pull request #720 from agordon/exit-code-5-exceptions
exit with non-zero code on runtime exceptions
2015-03-08 17:09:07 -05:00
Nicolas Williams 0df387f6b5 Automake: jq depends on version.h (fix #721) 2015-03-08 16:52:08 -05:00
Assaf Gordon 4104c4fa1c exit with non-zero code on runtime exceptions
With this change, runtime exceptions are propagated to non-zero exit
code of 'jq', allow better scripting and automation. The new exit code
value is 5.

This allows using the shell's and/or operations ('&&' and '||') to
detect input runtime exceptions.

Before:
runtime exceptions are printed to STDERR, but not reported as non-zero exit-code:
    $ echo '"hello"' | jq '.|tonumber' ; echo $?
    jq: error: Invalid numeric literal at EOF at line 1, column 5 (while parsing 'hello')
    0

After:
    $ echo '"hello"' | ./jq '.|tonumber' ;  echo $?
    jq: error: Invalid numeric literal at EOF at line 1, column 5 (while parsing 'hello')
    5

Note that there's a subtle interplay when using "-e" option.
The value of the non-zero exit code changes from 4 to 5, but it still
indicates a 'failure' or non-true value.

Before:
    $ echo '"hello"' | jq -e '.|tonumber' ;  echo $?
    jq: error: Invalid numeric literal at EOF at line 1, column 5 (while parsing 'hello')
    4

After:
    $ echo '"hello"' | ./jq -e '.|tonumber' ;  echo $?
    jq: error: Invalid numeric literal at EOF at line 1, column 5 (while parsing 'hello')
    5
2015-03-06 18:50:58 -05:00
Nicolas Williams 33a85679b9 Fix #718 2015-03-06 00:18:45 -06:00
Nicolas Williams a4b9552c82 Add date builtins (fix #364)
Windows support for strptime() is missing.  We can add a copy of one
from a BSD later.
2015-03-06 00:14:15 -06:00
Nicolas Williams b82c231900 Remove -i option (#704)
In-place editing should be implemented with builtins for file I/O.
2015-03-05 21:52:02 -06:00
Nicolas Williams 3d2ab93b11 Fix #705 (--argfile weirdness) 2015-02-18 18:38:11 -06:00
Nicolas Williams c86ef36769 Test in-place functionality; fix #704 2015-02-18 18:01:12 -06:00
Nicolas Williams 3b8d08177f Fix #702 2015-02-18 10:21:21 -06:00
Nico Williams 0164ff0bbc Merge pull request #701 from sseemayer/master
Correct automake and autoconf version requirements
2015-02-18 10:00:23 -06:00
Stefan Seemayer a4baac2256 Correct automake and autoconf version requirements 2015-02-18 13:15:44 +01:00
Nicolas Williams 1e5e9f3ef8 Mention --disable-maintainer-mode in bison error 2015-02-17 11:00:07 -06:00
Nico Williams d58d85af9e Merge pull request #699 from hroptatyr/oniguruma-detection
Fix oniguruma detection logic
2015-02-16 10:54:33 -06:00
Sebastian Freundt 10e8d34fd3 Fix oniguruma detection logic
At the moment, a failed oniguruma header check would leave
HAVE_ONIGURUMA set to 1 still, resulting in a compiler error
in builtin.c.
2015-02-16 09:01:08 +00:00
Nicolas Williams ebc090ad15 README tweaks 2015-02-15 18:34:44 -06:00
Nicolas Williams 8cef5a37ab Add --disable-maintainer-mode; make bison optional
Also flex is now optional.

The outputs of flex and bison are now committed.  By default they get
built, but users who want to build from git can now

    ./configure --disable-maintainer-mode

to turn off the dependency on bison and flex.

Maintainers must, of course, commit the bison and/or flex outputs when
they make changes to parser.y and/or lexer.l, respectively.
2015-02-15 18:34:44 -06:00
Nicolas Williams 8afdeee785 Make Oniguruma/regexp optional
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-15 18:32:01 -06:00
Nicolas Williams a83a9e0bc2 Reduce number of msg callback typedefs 2015-02-13 15:58:02 -06:00
Nicolas Williams 0d414471bb Refactor moar: move parts of main.c into libjq
This adds utility functions for reading and parsing files that should be
easy to use by other apps, together with jq_start()/jq_next().
2015-02-13 15:58:02 -06:00
Nicolas Williams 91fb3df495 Refactor handling of inputs in main() (fix #667)
Much of this could be in libjq.  Eventually all of the work of reading
from files and looping over `jq_next()` should move into libjq, with
`main()` mostly doing all the command-line option processing.
2015-02-13 15:55:31 -06:00
Nico Williams 373ef71feb Merge pull request #692 from kim-toms/enhance-from_entries
Enhance from_entries to better deal with Amazon AWS Tags
2015-02-10 10:49:35 -06:00
Kim Toms ca78a746e6 Enhance from_entries to better deal with Amazon AWS Tags 2015-02-10 08:33:56 -05:00
Nicolas Williams 1e13e1e06e Fix sequence warnings (fix #686) 2015-01-30 17:21:50 -06:00
Nicolas Williams 42ff8a6959 Usage message for -h should go to stdout 2015-01-30 10:27:46 -06:00
William Langford 2e92c3e568 Merge pull request #678 from isomorphisms/patch-1
readability
2015-01-27 14:15:07 -05:00
i 5389fdb651 readability
Easier to read dashes than hyphens imho.
2015-01-27 13:32:15 -05:00
Nicolas Williams 7a295b30e0 Fix --raw-input 2015-01-20 00:22:24 -06:00
Nico Williams cca3e92854 Merge pull request #669 from joelpurra/join-empty-array-668
Empty arrays join/1 to an empty string, fixes #668 bug introduced by 9760245
2015-01-14 15:50:15 -06:00
Joel Purra 4d05dc55a3 Empty arrays join/1 to an empty string, fixes #668 bug introduced by 9760245 2015-01-14 12:27:55 +01:00
Nicolas Williams aeb52e29d6 Add debug and stderr builtins
And refactor setup of jv dump flags.
2015-01-14 01:39:13 -06:00
Nicolas Williams 97602456e3 join/1: respect empty strings (fix #668) 2015-01-14 01:32:25 -06:00
Nicolas Williams 8b5ff40402 Split on empty sep: fix #552 moar 2015-01-14 01:32:11 -06:00
Nicolas Williams d630597e87 Fix docs for split/0 2015-01-12 10:47:43 -06:00
Nicolas Williams 60d1ecb58a Fix #552 2015-01-12 10:44:44 -06:00
Nicolas Williams d927a2c185 Fix --run-tests arg handling 2015-01-12 10:43:06 -06:00
Nicolas Williams 6e7cf81d74 Look for jq/main.jq for imports 2015-01-02 19:16:43 -06:00
Nicolas Williams 736f1751ee Add comments to tests/run 2015-01-02 19:15:57 -06:00
Nicolas Williams 28aab9ca79 Fix tests/run in from-tar-ball case
Drop useless use of scripts/version
2015-01-02 19:15:11 -06:00
Nicolas Williams 972c048149 Add static build instructions (fix #294) 2015-01-01 16:26:55 -06:00
Nicolas Williams 902aa39fce Fix warning in util.c 2015-01-01 15:15:10 -06:00
Nicolas Williams 22f55aa585 Include missing EXTRA_DIST items; fix #661 2015-01-01 15:14:49 -06:00
Nicolas Williams 157c95b988 Add mkstemp() for mingw build 2015-01-01 03:14:55 -06:00
Nicolas Williams 426913f127 Fix memleak introduced run-tests enhancement 2015-01-01 02:12:08 -06:00
Nicolas Williams c4cc62a053 Add more missing test files 2015-01-01 01:49:40 -06:00
Nicolas Williams 862696a778 Add missing test file 2015-01-01 01:39:50 -06:00
Nicolas Williams 86bc662bd2 Move some module tests into all.test 2014-12-31 20:09:53 -06:00
Nicolas Williams ae7f8d6ab9 Further module system revamp (fix #659)
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-31 20:09:53 -06:00
Nicolas Williams 7dc34b92af Add label $name | EXP; fix break
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-30 11:42:45 -06:00
Nicolas Williams cbfc0d6130 Remove string indexing by string (fix #454)
This turns out to have been a bad idea:

    "foo"|.["o"]

it interacts badly with `path()`.

See #454 for the gory details.
2014-12-30 11:31:52 -06:00
Nicolas Williams c308b2881f Fix parser leak (fuzzing) 2014-12-30 11:31:52 -06:00
Nicolas Williams c959d1fca1 Fix lineno counting in jq_test.c 2014-12-30 11:28:50 -06:00
Nicolas Williams 63511a874f Add support for testing erroneous programs
This will allow moving tests of some tests from tests/run to
tests/all.test.  It will also be useful for more extensive testing of
language features where we want nice error messages, or errors at all,
to be produced, particularly language features where the errors arise at
compile-, codegen-, or link-time rather than parse-time.

This does not check for run-time errors though -- those we can already
check for with try/catch.

    $ jq --run-tests
    %%FAIL
    break
    jq: error: break used outside labeled control structure
    ^D
    1 of 1 tests passed (0 malformed)
    $
2014-12-30 10:55:30 -06:00
Nicolas Williams 90c705f138 Make --run-tests more informative
Print the line number and program text on the same output line where a
failure is reported, for all failures that were already reported on
lines starting with '***'.  This makes poring over test logs with
failures much easier.
2014-12-30 10:55:30 -06:00
Nicolas Williams b67bad82cb Allow resetting of jq err callback
This will be useful for the upcoming test-erroneous-programs improvement
to --run-tests, so we can switch between the default error reporting
method (print to stderr) to a method internal to --run-tests, and back.

The idea is that when testing programs that are expected to compile (and
link), it'd be nice if errors continue going to stderr, while when
testing programs that must fail to compile (or link), the error has to
be captured so it can be compared to the error expected by the test.
2014-12-30 10:52:38 -06:00
Nicolas Williams 6981b46338 Fix streaming bug (fuzzing) 2014-12-30 01:35:22 -06:00
pkoppstein 752e00bc66 transpose/0 for possibly jagged matrices 2014-12-27 18:52:36 -06:00
pkoppstein 00f018a054 bsearch(x) (binary search): builtin.c (tested), with documentation and test case. Always yields an integer (even if input is unsorted); returns (-1 - ix) if x is not in input array. 2014-12-27 18:44:20 -06:00
pkoppstein 56344670f4 ascii_upcase/0 and ascii_downcase/0 2014-12-27 18:38:52 -06:00
Nicolas Williams 5df20f4954 Add debug builtin
And refactor setup of jv dump flags.
2014-12-27 18:25:34 -06:00
Nicolas Williams a9c613e87d Don't force C API users to set input cb 2014-12-27 18:15:10 -06:00
Nicolas Williams 7538ef34be Make jq --run-tests show test line numbers 2014-12-27 18:15:10 -06:00
Nicolas Williams 5c62a4b805 Fix uninitialized struct field 2014-12-27 18:09:28 -06:00
Nicolas Williams 559863ca68 Streaming parser torture tests 2014-12-26 23:18:07 -06:00
Nicolas Williams 845ad5e969 Fuzz JSON parser 2014-12-26 23:05:57 -06:00
Nicolas Williams 243b1f8e5e Better quoting in tests/run 2014-12-26 23:05:56 -06:00
Nicolas Williams 5bfb9781f7 Add Streaming parser (--stream)
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
    $
2014-12-26 23:05:56 -06:00
Nicolas Williams 906d2537b9 Allow C-coded functions to empty
Just return a jv_invalid() without a message.
2014-12-26 23:05:56 -06:00
Nicolas Williams bbb287f54b Add BLOCK_8() macro 2014-12-26 23:05:56 -06:00
Nicolas Williams e51e916e31 Fix foreach non-progation of errors
Errors were being re-propagated as "break".

Also add `error/0` builtin, which made this fix easier.
2014-12-26 23:05:20 -06:00
Nicolas Williams 46e3125e26 Allow zero-length buffers in jv_parser_set_buf()
If the caller is at EOF and has no more bytes to feed the parser, how is
the parser to be told about the EOF condition?  A small fix to allow
zero-length buffers in jv_parser_set_buf() fixes this problem (it also
makes it easier to deal with async I/O: feed the parser whatever is
available, including nothing).
2014-12-26 22:56:48 -06:00
Nicolas Williams c02fcc8fef Fix in and inside 2014-12-26 22:56:48 -06:00
Nico Williams 25d4cbd1b3 Merge pull request #624 from Janrain-Colin/patch-1
Doc correction
2014-12-26 22:14:17 -06:00
Nico Williams 3234a7681e Merge pull request #366 from slapresta/inversed-contains
Added `in` command
2014-12-26 22:00:41 -06:00
Nico Williams 36077da66a Merge pull request #628 from slapresta/map-on-objects
Modify map\1 so that it works on objects
2014-12-26 21:50:11 -06:00
Nicolas Williams 9e1fd8cf4d Fix infinite loop in read_more() (fix #656) 2014-12-24 16:49:55 -06:00
Nicolas Williams a55085b662 Fix EOF handling; fix #656 2014-12-24 16:07:36 -06:00
Nico Williams e0f9b6a5cd Merge pull request #651 from eiiches/fix-examples
Fix several errors in the manual
2014-12-24 11:29:29 -06:00
Nicolas Williams 0053aa868c Add @tsv; fix #645 2014-12-24 11:21:18 -06:00
Nico Williams fab2048648 Merge pull request #653 from msabramo/patch-1
.travis.yml: Set sudo false; use containers
2014-12-24 11:20:47 -06:00
Nicolas Williams 56ae88d9d5 Module search revamp for pkg managers
The search path listed in an import directive can now be an array.  The
top-level search path is appended.  Null and empty strings in the path
terminate any search.  The "." in "." and "./*" is replaced with the
directory containing the file doing the import (for command-line
programs this is the current directory, though that may be a bad idea).

No version numbers or anything of the sort are gratuitously added to the
search paths.

All this makes external package managers possible by allowing
dependencies to be installed local to dependents.
2014-12-24 02:31:51 -06:00
Nicolas Williams 1cdcff1c01 Fix bug caused by 8ca07a0 2014-12-24 02:25:11 -06:00
Nicolas Williams 8ca07a08c3 Fix #348: reject unescaped control chars 2014-12-24 00:01:43 -06:00
Nico Williams 2775b90b20 Merge pull request #601 from slapresta/redefine-any-all
Define {any,all}/0,1 in terms of {any,all}/2
2014-12-23 23:37:25 -06:00
Nicolas Williams ae312bd7fe Use __attribute__ __printf__ with GCC 2014-12-23 23:22:57 -06:00
Nicolas Williams 9017b83d4e Make values faster (fix #652) 2014-12-23 23:22:57 -06:00
Nicolas Williams 02cf1831e9 Fix #649 2014-12-23 18:16:21 -06:00
Marc Abramowitz d237de7b30 .travis.yml: Set sudo false; use containers
This is the way to enable Travis's fancy new containers, which should result in faster builds.
2014-12-22 21:37:23 -08:00
Santiago Lapresta 84d3203dd1 Define map_values 2014-12-22 23:05:35 +01:00
Santiago Lapresta a3234034b5 in is now inside, added in as inverse of has 2014-12-22 22:17:53 +01:00
Santiago Lapresta b748eae035 Added in command 2014-12-22 22:14:06 +01:00
Eiichi Sato a6656edc7c Fix examples in manual 2014-12-21 03:26:04 +09:00
Eiichi Sato b4a9ea56ae Fix indents in manual.yml 2014-12-21 03:24:45 +09:00
Eiichi Sato fdbc91e3c4 HTML-escape jq programs in manual 2014-12-21 03:24:41 +09:00
Eiichi Sato bd67bb8273 Fix examples in manual 2014-12-21 03:24:38 +09:00
Nico Williams 54a0470c42 Merge pull request #611 from StevenMaude/tutorial-typo-fixes
Fix typos in tutorial
2014-12-12 17:46:17 -06:00
Nico Williams 3dd790c408 Merge pull request #616 from ianmiell/ianmiell_requirements
Requirements made slightly more complete
2014-12-12 17:45:17 -06:00
Nicolas Williams be11b2768f Add until(cond; next); fix #639 2014-12-12 17:35:59 -06:00
Nicolas Williams 2075bec60f Fix #647, but caused by 89791a0 2014-12-12 17:05:16 -06:00
Nicolas Williams 44c2382402 Add --argjson, fix #648 2014-12-12 16:40:07 -06:00
Nico Williams fd041c2064 Merge pull request #642 from Janrain-Colin/patch-3
fix typo in manual
2014-12-12 16:03:18 -06:00
Colin von Heuring c6495f6632 fix typo in manual 2014-12-06 16:27:43 -08:00
Nicolas Williams 7243989c52 Fix refcount leak, fix #618 2014-11-29 15:24:43 -06:00
Nicolas Williams 46613af64c STOREV/LOADV* should also print refcnts 2014-11-28 20:52:22 -06:00
Nicolas Williams 79000644c6 Enable printing of stack val refcnts 2014-11-28 19:35:29 -06:00
Nicolas Williams b349e7d9a8 Print stack value refcounts when tracing (#636) 2014-11-28 19:26:41 -06:00
Colin von Heuring 6c8882caf3 Doc correction 2014-11-23 11:37:50 -08:00
William Langford 30e00820a7 Fix #600. Add regression test 2014-11-12 20:46:34 -05:00
Ian Miell 0f81e1bcd0 Requirements made slightly more complete: cf https://github.com/ianmiell/shutit/blob/master/library/jq/jq.py 2014-11-11 23:02:31 +00:00
Steven Maude cb376b27f8 Fix typos in tutorial
parrent > parent, url > URL
2014-11-05 10:47:37 +00:00
Santiago Lapresta dc5e77ef8e Define {any,all}/2 independently from {any,all}/0 2014-10-21 13:00:38 +02:00
Santiago Lapresta 72735167f9 Define {any,all}/{0,1} in terms of {any,all}/2 2014-10-20 22:01:25 +02:00
Nicolas Williams 89791a000b Add support for JSON sequence MIME type
Per draft-ietf-json-text-sequence-07 (which soon will be published as an
RFC).
2014-10-12 08:44:40 -05:00
William Langford 3411167c03 Properly call onig_error_code_to_str
Fix #585
2014-10-06 21:48:56 -04:00
pkoppstein 85f0e30c81 fix sub (#586); add gsub/3; add transpose/0.
Signed-off-by: William Langford <wlangfor@gmail.com>
2014-10-06 21:32:07 -04:00
Nicolas Williams 1796a716ea Restore split/1; don't use regexp (fix #576) 2014-10-03 17:58:45 -05:00
Nicolas Williams 07d8d5c5ef Update docs about sort/group/min/max/unique 2014-10-03 17:58:44 -05:00
Nicolas Williams 0b29b44cab from-entries should work with EC2 (fix #592) 2014-10-03 17:47:13 -05:00
Nicolas Williams a0a350f468 Remove sort/1 and group/1
Reserve these for sorting with jq-coded comparators.
2014-10-03 17:47:13 -05:00
Nicolas Williams 4a57b84db0 to_entries should not sort keys (fix #561) 2014-09-30 21:52:30 -05:00
William Langford f7a2af7052 Properly handle when objects cannot be folded
Fix #579.
2014-09-22 20:14:46 -04:00
Nicolas Williams 456bafa82f Drop the jq version directory from search path 2014-08-30 00:58:24 -05:00
Nicolas Williams 7a8e3c759e Never close stdin; allow multiple - arguments 2014-08-30 00:40:03 -05:00
Nicolas Williams b70bea8d34 Handle invalid inputs in argument files (fix #562) 2014-08-30 00:40:03 -05:00
William Langford d177944b75 Properly handle incomplete json when input is file
Fix #562
2014-08-28 21:52:45 -04:00
Nicolas Williams 9bd55487ea C-coded builtins should not assert (fix #553) 2014-08-21 00:12:29 -05:00
Nicolas Williams 23e2e2eab3 Quiet warning about freopen() of stdout 2014-08-20 20:49:30 -05:00
Nicolas Williams 8d2d5e37e5 Drop "any/" in module search; use 1.x-master 2014-08-20 20:48:48 -05:00
Nicolas Williams 287e2c96ed BSD sed lacks -r; fix #551 2014-08-14 03:31:25 -05:00
Nicolas Williams f8d9478517 Document module system
Fix #511.
2014-08-14 03:26:28 -05:00
Nicolas Williams 1ba8c2cfa6 Add module directive, modulemeta builtin
Fix #425.
2014-08-14 03:26:26 -05:00
Nicolas Williams d654724fef Add JV_OBJECT() macro 2014-08-14 03:21:38 -05:00
Nicolas Williams 3375089013 Add JV_ARRAY() macro 2014-08-14 03:21:38 -05:00
Nicolas Williams 9f13afa20f Add jq_report_error() function; use it
Put a stop to fprintf(stderr, ...) where we shouldn't.
2014-08-14 03:21:35 -05:00
Nicolas Williams 908c10928b Fix #549 2014-08-11 14:58:44 -05:00
Nicolas Williams c321c3b86b Constant fold objects 2014-08-09 20:47:03 -05:00
Nicolas Williams f87521183f Fold constant arrays 2014-08-09 20:27:08 -05:00
Nicolas Williams 8a561120c4 More constant folding: null, true, and false
A step towards doing constant folding for arrays and objects.
2014-08-09 19:15:50 -05:00
Nicolas Williams 20ca21cb0d Out of bounds negative array indices should raise 2014-08-09 19:15:50 -05:00
Nicolas Williams 2d1a75f550 .foo[-1] = ... trips assertion (fix #490) 2014-08-09 13:10:41 -05:00
Nicolas Williams 8cddb7c681 Allow any number of jq-coded function arguments 2014-08-09 12:42:39 -05:00
Nicolas Williams 4249bbf0d5 Make nwise private 2014-08-08 19:36:43 -05:00
Nicolas Williams 8a57c27e92 Make regexp builtins and range/3 use #524 too 2014-08-08 19:31:11 -05:00
Nicolas Williams 8706b6b16a Use def f($a): ...; syntax for builtins 2014-08-08 19:23:46 -05:00
Nicolas Williams 32c08d48f3 Add def f($arg): syntax (fix #524) 2014-08-08 19:16:01 -05:00
Nicolas Williams fc52e78ed4 Fix tests for #432 2014-08-08 18:17:58 -05:00
Nicolas Williams eb12f0358e Fix docs YAML (introduced in #432) 2014-08-08 18:01:42 -05:00
pkoppstein a696c6b551 regex filters (#432): scan, splits, split, sub, gsub 2014-08-08 17:00:14 -05:00
Nicolas Williams 0d437e25de Better error msg for bad shell quoting (fix #538) 2014-08-06 17:51:53 -05:00
William Langford 6744664ff4 Actually check version for bison.
Clean up oniguruma checks.
2014-08-06 12:26:34 -04:00
William Langford ef5bd5a6de Merge pull request #532 from wtlangford/top-removal
Remove duplicate TOP insertions, drop unused defs.
2014-08-05 13:41:59 -04:00
Nicolas Williams 2159f9f5e0 Document TCO a bit more 2014-08-05 01:15:33 -05:00
Nicolas Williams 2518b3a34f Fix docs (missing backquotes) 2014-08-05 01:15:33 -05:00
William Langford c3d6d5fd37 Merge pull request #523 from eproxus/patch-1
Add example of selecting object with keys
2014-08-05 00:50:21 -04:00
William Langford a25950a58c Remove duplicate TOP insertions, drop unused defs. 2014-08-05 00:46:10 -04:00
pkoppstein f8fed0f0bc Apply TCO to recurse/1, add recurse/2; tweak docs
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-08-04 21:11:01 -05:00
Adam Lindberg 89545ea9d0 Add example of selecting object with keys
It is not very straight forward how to select objects by their attributes from an array. This example provides the basic use case of how to select some objects based key values.
2014-08-01 12:13:35 +02:00
Nicolas Williams a2f99d43c3 Some builtins are unnecessarily special (fix #521) 2014-08-01 00:20:30 -05:00
Nicolas Williams a7878a8d1a Correct @wtlangford's address 2014-07-30 13:19:46 -05:00
Nicolas Williams c73ad74be0 Add @wtlangford to the AUTHORS list 2014-07-30 13:02:34 -05:00
pkoppstein 53993a9942 Add capture; document regular expression filters
Fix #493.
2014-07-28 19:41:21 -05:00
Nicolas Williams e1b20b48f0 Add first, nth, last (fix #510) 2014-07-28 13:18:58 -05:00
William Langford 14bc1f6526 Fixing crash when a library's dependency could not be loaded.
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-07-27 17:51:48 -05:00
Nicolas Williams 2e2538ccb8 Fold constants (fix #504) 2014-07-27 17:48:49 -05:00
Nicolas Williams ae27178352 Fix #499, #500 2014-07-27 17:41:40 -05:00
William Langford 0f89270d08 Changing color codes to fix #495 2014-07-22 23:05:43 -05:00
Nicolas Williams 10f5a3448d Do fix remaining bison warning (fix #433) 2014-07-22 22:51:11 -05:00
Nicolas Williams 50b85c2911 Rename jq_memmem() to _jq_memmem() 2014-07-22 22:51:11 -05:00
William Langford 38b939688a Added library system with -l, -L, and JQ_LIBRARY_PATH
Created util.[ch] to hold common utilities.
2014-07-22 22:51:11 -05:00
Nicolas Williams 01fc8168e9 Add -i option to edit files in place (fix #105) 2014-07-20 00:11:23 -05:00
Nicolas Williams 3362fb3406 Add -n to short usage msg; fix --arg msg 2014-07-20 00:04:24 -05:00
Nicolas Williams 8c3d503d54 Fix bison empty rule warnings (#433, partial fix) 2014-07-14 16:41:48 -05:00
Nicolas Williams 2bb9fc5dda Fix #484, try/catch syntax has conflicts 2014-07-14 16:41:48 -05:00
Nico Williams ea3e947b50 Merge pull request #483 from else/master
jq 1.4 is in Debian
2014-07-14 09:16:01 -05:00
Simon Elsbrock 538e012e85 jq 1.4 is in Debian
jq 1.4 is in Debian, please see https://tracker.debian.org/pkg/jq
2014-07-14 11:24:47 +02:00
Nico Williams 918ada06dc Merge pull request #482 from mbruggmann/manual-fixes
Fix manual example for `endswith`.
2014-07-13 19:01:57 -05:00
Nicolas Williams cb2737a433 Add regression test for #479 2014-07-13 19:00:37 -05:00
Nicolas Williams c38e5b1b2c Lib defs don't bind to each other; fix #479 again 2014-07-13 18:36:27 -05:00
Marc Bruggmann 089041b090 Fix manual example for endswith. 2014-07-13 19:02:21 +02:00
Nicolas Williams cadf8c3cb0 Revert "Library defs don't bind to each other; fix #479"
This reverts commit 6b6e3f4262.  It was
the wrong fix.
2014-07-13 02:04:27 -05:00
Nicolas Williams 6b6e3f4262 Library defs don't bind to each other; fix #479 2014-07-12 18:38:55 -05:00
Nicolas Williams 6e88d419ba Fix #478 assertion failure 2014-07-10 19:23:02 -05:00
Nico Williams ab4bf05300 Merge pull request #475 from qqshfox/patch-1
Fix examples for `del` in manual
2014-07-09 10:09:28 -05:00
Hanfei Shen ecac7bd3a1 Fix examples for del in manual 2014-07-09 16:37:17 +08:00
Zhiming Wang 1d620c0de3 Fix invalid YAML in manual.yml
Grave accent "`" is a reserved indicator in YAML per
http://www.yaml.org/spec/1.2/spec.html#id2774228, so it can't start a
plain scalar. This commit applies quoting to titles beginning with
grave accents.

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-07-09 01:12:23 -05:00
Zhiming Wang f68815d5ad Add tests/all.trs to .gitignore
tests/all.trs is auto generated during make check.

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-07-09 01:11:41 -05:00
Nicolas Williams 666aeda82c Better document path()'s power; also |= 2014-07-09 01:05:06 -05:00
Nicolas Williams 5be80b81eb Add foreach EXP as $var (INIT; UPDATE) form 2014-07-09 00:43:06 -05:00
Nicolas Williams 10477fc2d4 Make while() handle break 2014-07-09 00:39:25 -05:00
Nicolas Williams d8672e1b2a Make C-coded built-ins take jq_state * argument 2014-07-07 23:37:42 -05:00
Nicolas Williams a68958e5dc error(x) should not tostring its arg; fix #466 2014-07-07 22:26:53 -05:00
Nicolas Williams 824f7df404 limit should use break 2014-07-07 22:26:07 -05:00
Nicolas Williams 4bcff40828 Make any/2 and all/2 efficient using foreach 2014-07-07 22:25:34 -05:00
Nicolas Williams 80a9937e48 exec_stack.h was not using jv_mem_realloc() 2014-07-07 19:33:19 -05:00
Nicolas Williams b963ebaf1d jv_invalid() shouldn't allocate
jv_invalid() should behave like jv_invalid_with_msg(jv_null()), and
neither should allocate memory, because neither ought to need to.
2014-07-07 19:33:18 -05:00
Nicolas Williams eb45372414 jv_show() should be able to display invalid values 2014-07-07 19:33:18 -05:00
Nicolas Williams 539dccae90 Add break builtin for foreach 2014-07-07 19:33:17 -05:00
Nicolas Williams 6458910ba3 Explain foreach's powers a bit more 2014-07-07 17:22:53 -05:00
Nicolas Williams ef9b591215 Document path(path_expression) builtin 2014-07-07 17:13:51 -05:00
Nicolas Williams f845808813 Add missing backtick in manual 2014-07-07 17:13:48 -05:00
Nicolas Williams 25719b5596 $var["foo"]=1 can't work as expected; doc fix #236 2014-07-07 16:56:14 -05:00
Nicolas Williams 8780bc0b8e Better check for lib has only functions (fix #138) 2014-07-07 16:03:32 -05:00
Nicolas Williams 821cd31e67 Add any/N and all/N x N in (1, 2) (fix #455)
Contributed by @pkoppstein.
2014-07-06 20:08:06 -05:00
Nicolas Williams 5a863bf010 Add foreach and limit 2014-07-06 19:40:05 -05:00
William Langford d0ca11d665 Add support for negative indices for .[]; fix #462
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-07-06 01:40:22 -05:00
Nicolas Williams 7d3a44a1e2 Add general ? operator 2014-07-06 01:29:43 -05:00
Nicolas Williams 7fce34292e Add try EXP catch EXP 2014-07-06 01:29:42 -05:00
Nicolas Williams 9113282c27 Document error/1 2014-07-06 00:27:05 -05:00
Nicolas Williams 78a8419428 Add while(cond; update) (fix #314) 2014-07-02 22:05:33 -05:00
Nicolas Williams ff9a61ead2 Add range(init;upto;by) (fix #317) 2014-07-02 22:05:33 -05:00
Nicolas Williams 3a647d3e47 Multi-arity needs better errors (fix #438) 2014-07-02 02:18:10 -05:00
Nicolas Williams 1f17ef3623 Descrive generators, range() with by to manual 2014-07-01 23:32:44 -05:00
Nicolas Williams a6030ab374 Fix typo in manual 2014-07-01 23:32:40 -05:00
William Langford 9f4d7e2fb8 Fixed base64 issue with UTF-8 strings
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-07-01 22:56:13 -05:00
Nicolas Williams ba1acbe961 Teach disassembler about TAIL_CALL_JQ 2014-07-01 22:49:25 -05:00
Nicolas Williams 9deee38dc8 Fix off-by-one in TCO
Now we have the ability to define a generator in jq:

        def for(cond; update):
            def _for:
                if cond then ., (update | _for) else . end;
            _for;

        for(. < 10; . + 1) # generates numbers between `.` and 10

    Running this by hand with --debug-dump-disasm (with a fix for that
    coming up next) we can see that the call to _for is optimized:

        _for:0:
          0000 DUP
          0001 CALL_JQ cond:0^1
          0005 JUMP_F 0022
          0007 POP
          0008 FORK 0012
          0010 JUMP 0020
          0012 CALL_JQ update:1^1
          0016 TAIL_CALL_JQ _for:0^1
          0020 JUMP 0023
          0022 POP
          0023 RET

    And timing this with 1000, 10000, 100000 iterations shows that
    indeed we must be applying TCO; otherwise, without TCO, this gets
    very slow very quickly.
2014-07-01 22:40:40 -05:00
Nicolas Williams 436941d48b TCO to the max!
Close #446.

    Currently tested by disassembling and tracing various recursive jq
    programs by hand under valgrind.  An improved test framework that
    can test for errors and specific bytecode patterns is in
    development.
2014-06-30 23:41:20 -05:00
William Langford e1c5a2f575 Added cross-compilation script to build libjq for iOS.
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-06-30 20:02:19 -05:00
Zhiming Wang a5e9086676 Let @uri produce uppercase hexadecimal digits...
instead of lowercase ones.

According to RFC 3986,

   The uppercase hexadecimal digits 'A' through 'F' are equivalent to
   the lowercase digits 'a' through 'f', respectively.  If two URIs
   differ only in the case of hexadecimal digits used in percent-encoded
   octets, they are equivalent.  For consistency, URI producers and
   normalizers should use uppercase hexadecimal digits for all percent-
   encodings.

See https://github.com/stedolan/jq/issues/451 for details.

Test suite and manual are also updated to reflect this change.

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-06-30 19:52:42 -05:00
Nicolas Williams 1204e328df Add much commentary about CALL_JQ and call frames 2014-06-30 19:40:56 -05:00
Nicolas Williams 3e1baf5916 Get "Try Online" button working (fix #440) 2014-06-24 00:39:00 -05:00
Nicolas Williams beb0d081bb Improve TCO
Instead of checking for self-recursion check that the thing we're
calling is a function and not a closure, therefore the new frame will
have the same env as the current frame.
2014-06-23 19:59:00 -05:00
Nicolas Williams 4b7c701fdd Tail call optimization (close #437) 2014-06-22 00:24:02 -05:00
Nicolas Williams 233e32208c Fix option stacking bug 2014-06-21 18:01:00 -05:00
Nicolas Williams 63e31c2a35 Remove stray fprintf() from last commit 2014-06-20 23:29:53 -05:00
Nicolas Williams f9349becab Allow stacking of short options (fix #346) 2014-06-20 23:26:54 -05:00
Nicolas Williams ff5cf0abc7 Remove extra free of testmode
I added a jv_free() too many while rebasing @wtlangford's contribution.
It could only be triggered by calling `_match_impl` directly.
2014-06-18 21:11:06 -05:00
William Langford 8ff935c01a Added regex support as per issue #164.
jq now depends on oniguruma for regex support.
Modified configure.ac accordingly.

Added valgrind suppression file for oniguruma to prevent one-time and bounded
leaks from causing tests to fail.

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-06-18 21:02:47 -05:00
Nicolas Williams 5d9d1b1020 Partial revamp of scripts/crosscompile
Fix #430.
2014-06-18 16:29:37 -05:00
Nicolas Williams 8725d9fa3e Minor style cleanup in main.c 2014-06-17 19:04:55 -05:00
Nicolas Williams 9ae2d66d21 Remove remnants of --online-input option 2014-06-17 19:02:23 -05:00
Nicolas Williams 0c762925b2 Add -j / --join-output option, similar to -r
Fix #215.
2014-06-17 18:59:35 -05:00
David Haguenauer ad52026550 Fixed typo.
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-06-17 18:47:27 -05:00
Nicolas Williams cf7895876b Rebuild jq.1.prebuilt 2014-06-17 18:17:50 -05:00
Nicolas Williams f902d5fae6 Remove trailing whitespace from manual.yml 2014-06-17 18:17:50 -05:00
Nicolas Williams 98e3ebc378 Use new style in manual for defs with args 2014-06-17 18:17:50 -05:00
Santiago Lapresta dde43f796e Simplified standard library
Close #426.

Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-06-17 18:17:50 -05:00
Nicolas Williams 7ee3b724d1 Fix #419, improve Cannot index message (sortof)
jv_get() doesn't know if it's being called in the context of a jq
program or not, so it can't produce a very useful error message when the
types of the to-be-indexed value and the key don't agree.  For now,
including the key (when it is a short string) in the error message is as
significant an improvement as is easy to make.
2014-06-17 17:00:23 -05:00
Nicolas Williams e151a300d0 Fix #266; make help message more useful 2014-06-17 16:47:12 -05:00
Nicolas Williams f58f771660 Fix #280: from_entries of [] is null, should be {} 2014-06-16 22:40:44 -05:00
Nicolas Williams ea63d5d3c2 No args default w/ tty stdout, not tty stdin #220 2014-06-16 22:34:50 -05:00
Nicolas Williams ea0ffe24f8 Don't declare environ on WIN32 2014-06-16 22:34:37 -05:00
Santiago Lapresta 061a604a2a Added flatten and flatten(x) functions
Fix #415.
2014-06-16 17:03:05 -05:00
Nicolas Williams f741074267 Remove download 1.3 button; reposition try online 2014-06-16 17:01:09 -05:00
Nicolas Williams de5952d67e Add ChangeLog and NEWS files 2014-06-16 15:29:48 -05:00
Nicolas Williams a03f4802ef Add missing contributors to AUTHORS 2014-06-16 15:29:31 -05:00
Nicolas Williams 778ba9f7ab Update AUTHORS 2014-06-16 13:25:50 -05:00
Nicolas Williams 676e0ce38e Fix Win64 jq.exe link on main page 2014-06-16 11:13:55 -05:00
Nicolas Williams 088a42fc53 Allow multiple functions with different arities 2014-06-16 00:05:30 -05:00
Nicolas Williams 63dbac28ad Fix typo; rename jq.1-prebuit to jq.1.prebuilt 2014-06-13 19:04:06 -05:00
Nicolas Williams e9a1de47b4 Add env builtin 2014-06-13 17:51:41 -05:00
Nicolas Williams d14fca0cc6 Document the lambda nature of function args #391 2014-06-13 17:22:43 -05:00
Nicolas Williams bb83813f51 Automatically update jq.1.prebuilt 2014-06-13 17:22:17 -05:00
Nicolas Williams 8225d4e0c5 Add jqplay link to the site 2014-06-13 17:21:56 -05:00
Jingwen Owen Ou d45195ab5c jqplay has a domain now 2014-06-12 18:17:39 -07:00
Nicolas Williams 73bd347fcf Add links to Solaris 11+ executables 2014-06-12 19:26:05 -05:00
Nicolas Williams c9dbe090c5 Include links to 1.3 executables in gh-pages 2014-06-12 17:30:30 -05:00
Nicolas Williams 61cc0d4fb1 Make a better jq.1 when Ruby deps missing 2014-06-12 17:30:09 -05:00
Nico Williams 15c4a7f95f Merge pull request #400 from kdeme/master
Heuristic IEEE754 endianness autoconf detection

Use AC_C_BIGENDIAN, though it's not really the correct approach.  Autoconf ought to have provided a test specifically for IEEE754 endianness, since it can differ from integer/pointer endianness!
2014-06-12 15:55:41 -05:00
Kim De Mey 20e629284f Detect endianness at configuration with Autoconf AC_C_BIGENDIAN feature 2014-06-11 10:37:32 +02:00
Nicolas Williams e73951f3d1 Add lib.h to dist file list 2014-06-09 18:58:46 -05:00
Nicolas Williams fdf843c08b Make the note about shell quoting appear on site 2014-06-09 17:43:17 -05:00
Nicolas Williams cf145ec65e Add note about cmd.exe quoting 2014-06-09 10:22:55 -05:00
Nicolas Williams 4889844d0c Building docs fails on powerpc (#349)
Thanks @shym!!
2014-06-09 09:39:02 -05:00
Nicolas Williams dc7857c585 Update site news 2014-06-08 20:45:06 -05:00
Nicolas Williams d65dbf89c9 Also fix configure.ac to use git describe --tags 2014-06-08 19:36:06 -05:00
Nicolas Williams ed2b3e26fb Fix scripts/version: use git describe --tags ...
After tagging as 1.4 scripts/version was still producing jq-1.3-....
2014-06-08 19:31:21 -05:00
Nicolas Williams 46436bd870 Add test of indices with short input 2014-06-08 02:27:27 -05:00
Nicolas Williams 1dbe9317bc Add indices(s), improve index(s), rindex(s)
Now these deal with arrays as input and `s` being an array or a scalar.
2014-06-08 02:01:44 -05:00
Nicolas Williams ef4f3a54fe Improve index and rindex examples 2014-06-08 02:01:21 -05:00
Nicolas Williams 9af03c2562 Remove reference to getpath from docs 2014-06-08 01:35:03 -05:00
Nicolas Williams c10e5f4e73 Document index and rindex (#389) 2014-06-08 00:00:17 -05:00
Santiago Lapresta 01f676041d Added join function
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-06-07 21:53:03 -05:00
Nicolas Williams 6856ab8a69 String * number should be commutative 2014-06-07 21:43:30 -05:00
Nicolas Williams 8212750fe9 Add cross-compilation notes to README
A detailed set of instruction as to how to setup a cross-compilation
environment for OS X and Win32/64 would be nice.
2014-06-04 18:36:30 -05:00
Nicolas Williams 35b6b949e3 Add -j option to scripts/crosscompile 2014-06-04 18:36:30 -05:00
Nicolas Williams d1ea3ab89d Add flags argument to jv_parser_new()
For extensibility.  We might add streaming parser options, even binary
JSON encoding options.
2014-06-04 18:35:30 -05:00
Nicolas Williams ae625d0de7 Revert "Add -I / --online-input for huge top-level arrays"
This reverts commit 77936a594d.

There are too many odd bugs in this mode, and it turns out to be a bad
idea anyways.  Instead, in the future a better option will be to pursue
alternative parsers, such as:

 - streaming parser that outputs only when a new leaf value is added or
   an array/object is opened/closed; options here include whether to
   include a path in each output;

 - parsers for binary JSON encodings (there's a variety of them).

Then one might run jq with a streaming parser and use `reduce` to
coalesce inputs from some depth down (instead of from one level down as
the reverted commit had intended).

Besides, a fully streaming parser is desirable in some cases, therefore
we should have such a thing as an option.

I've explored modifying the current parser to support a streaming
option, but it only makes the code very difficult to follow, which is
one reason that alternate parsers makes sense.  At any rate, this is all
for the future.  For now there's no streaming of individual texts, just
text sequences.
2014-06-04 18:15:58 -05:00
Nicolas Williams 5fb82d1018 Fix tests failures on Windows
And Solaris 8 and 9 too, no doubt.  The problem was that non-standard
vsnprintf()s that return -1 when the buffer is too small were not
properly supported.
2014-06-02 00:56:01 -05:00
Nicolas Williams f9d1b94496 Update .gitignore and config/.gitignore 2014-06-01 22:32:53 -05:00
Nico Williams 854ff5643a Merge pull request #367 from slapresta/del-docs
Documented `del` command
2014-05-20 22:11:01 -05:00
Santiago Lapresta 072ebb911b Documented del command 2014-05-21 01:23:28 +02:00
Nico Williams d46f5d29fa Merge pull request #360 from slapresta/275-unique-by
unique_by(.foo) function
2014-05-12 00:30:55 -05:00
Santiago Lapresta 69aa0003af Added texts/examples to unique_by function 2014-05-12 01:44:53 +02:00
Santiago Lapresta 41a093c1f2 Added unique_by function 2014-05-12 01:37:27 +02:00
Nicolas Williams 022a418894 Make pthread tls configurable for Mingw build
For the Mingw build we don't want to pull in the pthread DLL just
because we can autodetect pthread support.  That would make the jq.exe
binary not self-contained.
2014-04-17 20:17:06 -05:00
Nicolas Williams d056668f4f Add autoconf checks for pthreads; fix #340 2014-04-16 18:42:36 -05:00
Nico Williams 917334d18a Merge pull request #332 from jingweno/master
Add link to jq playground
2014-03-20 23:47:40 -05:00
Jingwen Owen Ou 7a83f1c416 Add link to jqplay 2014-03-20 15:49:59 -07:00
Nico Williams 6f0a9521e1 Merge pull request #176 from pearkes/new-tutorial
Docs: Update the tutorial to use GitHub's API
2014-03-13 00:57:54 -05:00
Nicolas Williams aee5c3ecb0 Fix for #303 in the sources 2014-03-13 00:57:33 -05:00
Nico Williams da0d575649 Merge pull request #278 from polyester/master
work with newer versions of automake
2014-03-13 00:52:58 -05:00
Nicolas Williams 74d2216da2 Test arrays and friend filters 2014-03-13 00:29:53 -05:00
Nicolas Williams 769314a8a2 Document scalars 2014-03-13 00:29:53 -05:00
Nicolas Williams 831be04027 Also add scalars 2014-03-13 00:29:53 -05:00
Nicolas Williams 1a1adf73e8 Document arrays, objects, ... 2014-03-13 00:29:53 -05:00
Santiago Lapresta 68f41097b9 Added arrays and other filters
Arrays, objects, numbers, strings, booleans, nulls, values (non-nulls)
-- these builtins filter out those inputs that don't match the name of
the builtin.

This fixes #322 and #324.
2014-03-13 00:27:56 -05:00
Nicolas Williams 4402c6d806 One more recursive merge test 2014-03-12 23:44:21 -05:00
Filippo Valsorda 2aa8a43c5b Add a recursive object merge strategy and bind it to *
This commit adds a jv_object_merge_recursive function, that performs
recursive object merging, and binds it to multiply when applied to
two objects.

Added docs and tests.

Closes #320
2014-03-08 03:56:05 +01:00
Nicolas Williams 219bb9ecb7 Make libm tests more portable 2014-03-06 21:38:10 -06:00
Nico Williams 88fd2ee4f2 Merge pull request #310 from arodland/master
Make jq --raw-output --unbuffered work
2014-03-03 13:46:38 -06:00
Andrew Rodland 6c3683dfe9 Repair jv_show 2014-02-26 01:43:00 -06:00
Andrew Rodland 36e495da1e Make jq --raw-output --unbuffered work
--unbuffered was only affecting the normal output case, not the --raw-output case. Make the two of them play together.

This also makes sure that the output is flushed *after* printing the newline, so a consumer doesn't lag a line behind.
2014-02-26 01:42:29 -06:00
Nicolas Williams 15faf9dc3b Add cbrt (cube root) 2014-02-21 10:51:16 -06:00
Nicolas Williams 59302fd208 Add missing trig functions and barebones test 2014-02-21 10:49:21 -06:00
Nicolas Williams 24202d1ecf Remove non-standard exp10() 2014-02-21 10:49:10 -06:00
Mike McCabe 336f4e27e6 Initial add of math functions. 2014-02-21 08:46:56 +00:00
Nicolas Williams fe29d3d3fa Add ?, .[]?, and .. operators
Make XPath-like `//a/b` recursive structure traversal easier in jq,
which then becomes:

    ..|.a?.b?

The `?` operator suppresses errors about . not being an array or object.
The `..` operator is equivalent to calling the new `recurse_down`
built-in, which in turn is equivalent to

    recurse(.[]?)

Note that `..a` is not supported; neither is `...a`.  That could be add
added, but it doesn't seem worth the trouble of saving the need to type
a '|'.
2014-02-20 15:33:07 -06:00
Nico Williams 3d33412e9a Merge pull request #300 from lcd047/master
Fix building of the manual
2014-02-19 11:21:04 -06:00
LCD 47 fb9196021e manual.yml: fix indent for the new any and all commands. 2014-02-19 15:10:32 +02:00
Nico Williams b23fae9ee3 Merge pull request #296 from slapresta/all-any
Added `all` and `any` builtins
2014-02-16 22:45:49 -06:00
Santiago Lapresta 8b41415b07 Added all and any builtins 2014-02-17 04:01:32 +01:00
Nicolas Williams 1fa55a3fae Fix cut-n-paste in leaf_paths; doc and test 'em 2014-02-05 23:14:05 -06:00
Nicolas Williams a45c937f80 #285 add and builtins 2014-02-05 15:23:32 -06:00
polyester 6ed3adb091 work with newer versions of automake
when using a newer automake, the autoreconf step fails with warnings:
"linking libtool libraries using a non-POSIX archiver requires 'AM_PROG_AR' in 'configure.ac' "

This happens for instance on ubuntu 13.10. 
Doing just that, adding 'AM_PROG_AR' to configure.ac fixes the problem.
2014-01-25 18:55:58 +01:00
Nicolas Williams 106fdf5114 Fix #201; check that bison accepts --warnings 2014-01-01 23:10:00 -06:00
Nicolas Williams 99f170adc3 Fix version for make dist on master
- Re-remove VERSION file and all traces of it
 - Pass a decent version indicator to AC_INIT (using git describe)

When we tag 1.4 this will produce 1.4 as the version string when
building on the HEAD of that tag.
2013-12-31 17:19:40 -06:00
Joe Littlejohn f60d83c15f Fix rpm build (make rpm)
* Re-add VERSION as it's required for `./setup superclean`
  and `make rpm`.
* Add *.rpm to git ignore, we never want them under version control.
2013-12-27 13:01:14 -06:00
Filippo Giunchedi 36a47bae56 include additional files in jq.spec
this will probably need changing upon SONAME bump
2013-12-27 12:49:15 -06:00
Filippo Giunchedi dc8528af0f fix rpm Makefile target and prerequisites
depend on dist and the specfile, plus use automake's variables
2013-12-27 12:49:15 -06:00
Nicolas Williams e12d0ffd1e Document --version 2013-12-26 18:48:51 -06:00
Nicolas Williams a71138a43a Add jv_dumpf() and jv_show()
jv_dumpf() takes a FILE *.

jv_show() is intended for use in debuggers, so it dumps the jv to stderr
and it does not jv_free() the jv, so it's safe to
"call jv_show(some_jv, -1)" in a debugger.  If flags == -1 then the jv
will be shown pretty-printed and in color.
2013-12-26 18:40:34 -06:00
Nicolas Williams cb976b9a50 Document .foo.bar in manual 2013-12-26 18:25:31 -06:00
Nicolas Williams 060eb39bf9 Document exit numbers 2013-12-26 12:54:07 -06:00
Nicolas Williams ab363e9e50 Normalize errors for -e 2013-12-26 12:54:03 -06:00
Nicolas Williams 41a8ae7557 Fix doc typos (.[foo] wanted to be .["foo"]) 2013-12-25 17:09:27 -06:00
Nicolas Williams 1956abbedf Add note to jq.1 about shell quoting 2013-12-25 17:05:32 -06:00
Stephen Dolan 2003a0440f Merge pull request #251 from phihag/fix-uri-in-manual
Fix @uri example
2013-12-21 11:47:24 -08:00
Stephen Dolan a0274cc46e Merge pull request #252 from phihag/ignore-config-test-driver
Ignore the config/test-driver file
2013-12-21 11:46:53 -08:00
Philipp Hagemeister 3b384740b9 Ignore the config/test-driver file
This file is automatically generated and does not need to be committed.
2013-12-20 11:36:52 +01:00
Philipp Hagemeister 4d40a47eab Fix @uri example
Previously, the @uri example didn't match the actual behavior of the current jq, as exclamation marks do not need to be encoded in URIs.
Replace the example with an input that needs encoding, and is encoded by jq.
2013-12-20 11:32:53 +01:00
Stephen Dolan 18e828f17c Allow negated object values without parens. Fixes #247 2013-12-17 22:28:31 +00:00
Nicolas Williams 0966230ba8 Fix memmem() error 2013-12-17 08:40:03 -06:00
Stephen Dolan 669f4ab4c3 Merge pull request #242 from sieben/travis-ci
Adding a .travis.yml file to use the travis-ci.org
2013-12-15 12:54:17 -08:00
Rémy Léone 3455714410 Adding a .travis.yml file to use the travis-ci.org
From wikipedia:

Travis CI is a hosted, distributed continuous integration service used
to build and test projects hosted at GitHub.

Travis CI is configured by adding a file named .travis.yml, which is a
YAML format text file, to the root directory of the GitHub repository.

Travis CI automatically detects when a commit has been made and pushed
to a GitHub repository that is using Travis CI, and each time this
happens, it will try to build the project and run tests. This includes
commits to all branches, not just to the master branch. When that
process has completed, it will notify a developer in the way it has been
configured to do so — for example, by sending an email containing the
test results (showing success or failure), or by posting a message on an
IRC channel. It can be configured to run the tests on a range of
different machines, with different software installed (such as older
versions of a programming language, to test for compatibility).
2013-12-13 17:14:37 +01:00
Stephen Dolan 32ea50d336 Make the testsuite run on machines without valgrind 2013-12-13 15:22:17 +00:00
Stephen Dolan 5ac6a460fa Format more integers as integers, not scientific notation.
jq is now willing to put up to 15 zeros after an integer before
moving to scientific notation.
2013-12-13 15:22:17 +00:00
Stephen Dolan f147b7fae5 Merge pull request #239 from DRMacIver/overflows
Avoid undefined behaviour with large array indices
2013-12-12 16:38:14 -08:00
Nicolas Williams 474386a1d9 Complete more-arity feature not complete
And test
2013-12-11 14:14:26 -06:00
Stephen Dolan 7fd2c2d08b Merge pull request #235 from DRMacIver/prototypes
some functions were missing proper prototypes
2013-12-10 03:56:02 -08:00
David R. MacIver 5412f3f1c1 convert range bounds to integers in a way that avoids undefined behaviour 2013-12-10 09:20:13 +00:00
David R. MacIver 014b45b4a9 add checking of numeric indices to an array to see if they can reasonably be considered integers. Avoid undefined behaviour if out of bounds 2013-12-10 09:20:12 +00:00
David R. MacIver 30ea390b77 some functions were missing prototypes. Add them 2013-12-10 00:07:08 +00:00
Stephen Dolan 00f244385b Merge pull request #232 from DRMacIver/teardown_on_error
consistent use of goto out in main
2013-12-08 16:41:16 -08:00
David R. MacIver 7b671b95d2 don't need to check for NULL there 2013-12-08 23:52:07 +00:00
Stephen Dolan 1535f23455 Merge pull request #233 from DRMacIver/printf
Fix warnings about vprintf
2013-12-08 15:44:33 -08:00
Stephen Dolan 4ba0c8baef Merge pull request #231 from DRMacIver/fix_mem_leak_in_compile
args to jq_compile_args were not getting freed when there were errors in the compile
2013-12-08 15:17:20 -08:00
Stephen Dolan a7dd3ab793 Clean up string/object interactions in jv. 2013-12-08 22:49:28 +00:00
David R. MacIver f6f7d4d973 These vfprintfs are being used as if they were printfs. Fix that 2013-12-08 20:08:04 +00:00
David R. MacIver f4ae5c883b consistent use of goto out in main 2013-12-08 19:22:18 +00:00
Stephen Dolan 74a14f5de7 Refactor jv structure.
New structure layout is simpler and also faster.  In particular, it's
now small enough to be passed in registers on amd64.
2013-12-08 17:46:23 +00:00
Stephen Dolan fee21c959a Make testsuite not leak when compiled with -DNDEBUG. 2013-12-08 17:44:54 +00:00
David R. MacIver 4b48054f41 test for losing memory on compile errors 2013-12-08 16:19:12 +00:00
David R. MacIver 17a319d120 args to jq_compile_args were not getting freed when there were errors in the compile 2013-12-08 15:28:29 +00:00
Nicolas Williams 3a1dab5396 Fix double-free typo in print_error() 2013-12-06 23:25:06 -06:00
Nicolas Williams dac081e183 Fix manual.yml 2013-12-06 11:58:55 -06:00
Stephen Dolan 489fcdc089 Merge pull request #224 from nicowilliams/features
Features: more arity, string ops
2013-12-04 17:36:08 -08:00
Nicolas Williams 3ba7c97b2a Add self to AUTHORS 2013-12-04 18:21:42 -06:00
Nicolas Williams 54635000c5 Conditionally #define _GNU_SOURCE in compile.c 2013-12-04 18:21:42 -06:00
Nicolas Williams 426edff09c Add tests for string index by string and builtins 2013-12-04 18:21:42 -06:00
Nicolas Williams b37ce20c2a Add index and rindex builtins 2013-12-04 18:21:42 -06:00
Nicolas Williams cac14a531d Add index strings by string; return string indexes
% jq '.[","]'
    "a,bc,def,ghij,klmno"
    [1,4,8,13]
    %
2013-12-04 18:21:42 -06:00
Nicolas Williams ae7a042876 Make length return abs value of numeric inputs 2013-12-04 18:21:42 -06:00
Nicolas Williams eb165459aa Add callback interface for errors
Printing to stderr is not the right answer for a library.
2013-12-04 18:21:41 -06:00
Nicolas Williams 04bc2ef7cf Add jv_string_vfmt() 2013-12-04 18:21:41 -06:00
Nicolas Williams 09104ce531 Document ltrimstr and rtrimstr 2013-12-04 18:21:41 -06:00
Nicolas Williams 9fa2173825 Test ltrimstr and rtrimstr functions 2013-12-04 18:21:41 -06:00
Nicolas Williams 346da34432 Add ltrimstr and rtrimstr functions 2013-12-04 18:21:41 -06:00
Nicolas Williams fa316ac430 Document -u / --unslurp option 2013-12-04 18:21:41 -06:00
Nicolas Williams 77936a594d Add -I / --online-input for huge top-level arrays 2013-12-04 18:21:41 -06:00
Nicolas Williams 4e07eac356 Document -e / --exit-status argument 2013-12-04 18:21:40 -06:00
Nicolas Williams d018e43ddc Add -e | --exit-status CLI option 2013-12-04 18:21:40 -06:00
Nicolas Williams 8cee66e609 Document tojson and fromjson builtins 2013-12-04 18:21:40 -06:00
Nicolas Williams 3c4248192d Test tojson and fromjson 2013-12-04 18:21:40 -06:00
Nicolas Williams 255f8ef5be Add tojson and fromjson builtins 2013-12-04 18:21:40 -06:00
Nicolas Williams 20b32db5af Document split function 2013-12-04 18:21:40 -06:00
Nicolas Williams b634722c8a Document string multiplication and division 2013-12-04 18:21:40 -06:00
Nicolas Williams c9e8581f45 Document string functions and slicing 2013-12-04 18:21:39 -06:00
Nicolas Williams da129f6664 Test string slicing 2013-12-04 18:21:39 -06:00
Nicolas Williams 884e6c7d8b Add string slicing 2013-12-04 18:21:39 -06:00
Nicolas Williams 5aadaa79eb Add tests for string division/splitting 2013-12-04 18:21:39 -06:00
Nicolas Williams cf562961b7 Add string division by string (split on separator) 2013-12-04 18:21:39 -06:00
Nicolas Williams 63bed9bdf1 Test starts/endswith and string multiplication 2013-12-04 18:21:39 -06:00
Nicolas Williams 5989dbdfcf Add string multiplication by number 2013-12-04 18:21:39 -06:00
Nicolas Williams db19a11399 Add startswith/endswith 2013-12-04 18:21:38 -06:00
Nicolas Williams 6c734cb609 Add explode/implode jq functions to match jv API 2013-12-04 18:21:38 -06:00
Nicolas Williams ef41d1cb57 Use uint32_t for codepoint in jv_string_append_codepoint() 2013-12-04 18:21:38 -06:00
Nicolas Williams 08b4a34a8e Add jv string utility functions
jv_string_empty()
        -> return an empty string with given allocated length (for fast
           appends)
    jv_string_append_codepoint
        -> append a single codepoint (int) to the given string
    jv_string_explode
        -> return an array of codepoints making up a string
    jv_string_implode
        -> return the UTF-8 encoding of an array of codepoint numbers
2013-12-04 18:21:38 -06:00
Nicolas Williams 1fc5656762 Support more arguments for defs 2013-12-04 18:21:38 -06:00
Stephen Dolan 91cfc34ae4 Preserve insertion order in objects. Closes #169. 2013-12-04 22:30:39 +00:00
Nicolas Pouillard a0b942a7f5 Add a few more test cases (from the man page)
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2013-11-30 00:55:26 -06:00
Stephen Dolan 6a401c8262 Add a --unbuffered option. Closes #206 2013-11-08 12:21:45 +00:00
Stephen Dolan d235f32bc9 Merge pull request #210 from Habbie/patch-1
count should be length
2013-11-08 03:43:57 -08:00
Peter van Dijk bdbfa7e32c count should be length
Example refers to a count function, which does not exist. Replacing it with length works.
2013-11-07 16:39:44 +01:00
Stephen Dolan 78976b3504 Merge pull request #193 from ryo1kato/fix-docs
Docs: add description of --from-file option
2013-11-07 04:41:01 -08:00
Stephen Dolan 8d4748c8df Fix a crash on group_by of empty list. Fixes #208. 2013-11-07 12:18:48 +00:00
Ryoichi KATO da723d3e11 Docs: add description of --from-file option 2013-10-16 21:42:29 +09:00
Stephen Dolan 0feeb7d0d4 Merge pull request #188 from Juanxo/patch-1
Fix typo on error message
2013-10-07 06:59:50 -07:00
Juan Guerrero 9e53f36a74 Fix typo on error message 2013-10-06 17:52:04 +02:00
Stephen Dolan 7e7c08da47 Merge pull request #185 from qoelet/master
Add missing -i flag in build instructions
2013-09-20 06:05:42 -07:00
Kenny Shen 2f6b89ef70 Add missing -i flag in build instructions 2013-09-20 10:34:57 +08:00
Stephen Dolan 4e3024cb61 Merge pull request #182 from mdaines/sqrt-builtin
Add builtin for calculating square root
2013-09-14 16:34:52 -07:00
Michael Daines c427bf6a94 Add test showing calculation of standard deviation 2013-09-14 17:48:19 -04:00
Stephen Dolan dae2422fd1 Merge branch 'libjq'
Conflicts:
	Makefile.am
	configure.ac
2013-09-14 19:30:39 +01:00
Stephen Dolan f98e3e6c26 Merge pull request #181 from mdaines/patch-1
Fix typo
2013-09-13 15:24:22 -07:00
Mike Daines fe99532f8b Fix typo 2013-09-13 12:15:52 -04:00
Stephen Dolan 41a4968c90 Merge pull request #171 from joelittlejohn/fix-makefile
Fix Makefile after refactoring of stacks in 05d90517b0
2013-09-13 09:02:42 -07:00
Stephen Dolan 1cdaabf2dd Merge pull request #175 from lipidity/fix-build
Call AM_INIT_AUTOMAKE once only
2013-09-13 09:02:24 -07:00
Michael Daines 82d8253c19 Add sqrt operator 2013-09-11 20:24:41 -04:00
Jack Pearkes c1717d6e12 docs: update the tutorial to use GitHub's API 2013-09-04 11:42:40 +02:00
Ankur f0d1c39b5b Call AM_INIT_AUTOMAKE once only
Fixes build with automake-1.14
2013-09-01 18:58:26 +10:00
Joe Littlejohn 111aea3f0a Fix Makefile after refactoring of stacks in 05d90517b0 2013-08-19 13:40:08 +01:00
Stephen Dolan 37cfc912c1 Remove #includes from jv.h 2013-06-23 14:23:07 +01:00
Stephen Dolan 8c2e228c74 Fix the jv_parser interface. 2013-06-23 12:26:49 +01:00
Stephen Dolan 8630fb02bb Use libtool's built-in symbol exporting rather than a mapfile. 2013-06-23 12:10:58 +01:00
Stephen Dolan 5052ab4e2b Move gen_utf8_tables to scripts 2013-06-23 12:08:22 +01:00
Stephen Dolan a44f739356 Move libtool m4 junk to config/ and delete some autogenerated files. 2013-06-23 12:01:58 +01:00
Stephen Dolan f44ecf3872 Remove Autoconf-generated config.h. 2013-06-23 12:01:58 +01:00
Stephen Dolan 1c9e03f800 Merge branch 'header-cleanup' into libjq
Conflicts:
	Makefile.am
2013-06-22 23:27:16 +01:00
Stephen Dolan 5d9ec83805 Build libjq only once, and link it statically to ./jq
This means ./jq is a real binary rather than a libtool turd.
2013-06-22 20:53:28 +01:00
Stephen Dolan 3a295c659b Fix distcheck.
Update list of files to be distributed.
2013-06-22 20:53:03 +01:00
Stephen Dolan d253414783 Merge pull request #162 from stedolan/utf8-fixes
Utf8 fixes. Closes #161
2013-06-22 09:30:59 -07:00
Stephen Dolan 8b1b503609 Reject all overlong UTF8 sequences. 2013-06-22 13:43:46 +01:00
Stephen Dolan ff48bd6ec5 Fix various UTF8 parsing bugs.
In particular, parse bad UTF8 by replacing the broken bits with U+FFFD
and resychronise correctly after broken sequences.
2013-06-22 13:34:24 +01:00
Stephen Dolan 54b9c9bdb2 Fix example in manual for floor. See #155. 2013-06-22 12:17:28 +01:00
Nicolas Williams 3dcdc582ea Document floor 2013-06-21 15:27:34 -05:00
Nicolas Williams 7c4171d414 Add floor operator 2013-06-21 15:27:34 -05:00
Nicolas Williams 1d839ff9df Document mod 2013-06-21 15:27:34 -05:00
Nicolas Williams 3403d07912 Add mod (and setmod) operators 2013-06-21 15:27:34 -05:00
Nicolas Williams e8643787cf Update .gitignore 2013-06-21 12:41:57 -05:00
Nicolas Williams 298b2a6033 Add libjq autoconf goo 2013-06-21 11:57:12 -05:00
Nicolas Williams c791428905 Quiet setup.sh re: tmp dir 2013-06-21 11:57:11 -05:00
Stephen Dolan dc2fe63e42 Merge pull request #157 from nicowilliams/argfile-fixes
Argfile fixes
2013-06-21 09:40:32 -07:00
Stephen Dolan 7af88962ee Move cfunction invocation code to the interpreter loop. 2013-06-21 12:06:28 +01:00
Nicolas Williams 3216d7683a Fix serious bug in handling of --argfile 2013-06-18 19:05:52 -05:00
Nicolas Williams e4094c8664 Fix leaks in jv_load_file() 2013-06-18 19:05:52 -05:00
Stephen Dolan b49d65a276 Fold opcode.{c,h} into bytecode.{c,h} 2013-06-18 01:36:18 +01:00
Stephen Dolan 824ce76cec Simplify block functions for variables 2013-06-18 01:07:18 +01:00
Stephen Dolan 2a18f97d12 Saner build instructions in README.md
Closes #144
2013-06-18 00:29:05 +01:00
Stephen Dolan 8c4d29ee38 Remove some initialise-to-zero code.
This lets valgrind find more bugs - if a field isn't given a
well-defined value valgrind will now find it instead of seeing it
set to zero with memset.
2013-06-18 00:17:20 +01:00
Stephen Dolan 2c13f4fe72 Merge branch 'stack-refactor-merge' 2013-06-18 00:13:44 +01:00
Stephen Dolan 94931040a8 Merge branch 'stack-refactor'
Conflicts:
	execute.c
2013-06-18 00:06:00 +01:00
Stephen Dolan b78a4cdc93 Merge pull request #154 from nicowilliams/no-fopen-re
Remove accidentally introduced use of fopen "e"
2013-06-17 15:34:01 -07:00
Nicolas Williams da09544bb0 Remove accidentally introduced use of fopen "e" 2013-06-17 17:27:25 -05:00
Stephen Dolan ce17b6bd53 Merge pull request #114 from nicowilliams/nomem_handler
Add jv_nomem_handler()
2013-06-16 06:20:27 -07:00
Nicolas Williams fe03bea191 Remove last remnant of main.h 2013-06-16 08:06:52 -05:00
Nicolas Williams 0ed6347d47 Allow --run-tests to take a file argument 2013-06-15 17:37:15 -05:00
Nicolas Williams 3f86e97f70 Fixup API to get closer to a libjq 2013-06-15 17:37:15 -05:00
Stephen Dolan 69fa279e3c Merge pull request #150 from nicowilliams/jv_load_file
Move slurp_file() into library as jv_load_file()
2013-06-15 05:29:17 -07:00
Nicolas Williams bbf4e05fde Move slurp_file() into library as jv_load_file()
Needed as part of creating a libjq.
2013-06-15 00:08:59 -05:00
Stephen Dolan 05d90517b0 Clean up lots of stack and frame logic.
Move frame defs to execute.c
2013-06-14 22:08:18 +01:00
Stephen Dolan 5f5c1dc5a6 Simplify frame logic. 2013-06-14 01:20:24 +01:00
Stephen Dolan e0524644f8 Unify all stacks. Passes tests, but needs cleanup. 2013-06-13 21:50:32 +01:00
Stephen Dolan 81e2336ace Support ."foo" syntax for accessing fields. See #141. 2013-06-11 22:26:39 +01:00
Stephen Dolan 25bf1a0169 Unify frame and data stacks 2013-06-10 01:17:58 +01:00
Stephen Dolan c8ab67be27 Speed up cached configure (./configure -C) 2013-06-05 16:40:01 +01:00
Stephen Dolan 6c34288ebf Clean up flex lines in build 2013-06-05 13:43:23 +01:00
Stephen Dolan 2ffbb9d6b7 Lex and parse .foo better.
'.as' is now valid, '. foo' is now invalid. See #141.
2013-06-05 13:41:56 +01:00
Stephen Dolan dad608d5c0 Merge pull request #142 from lanthaler/master
Update README.md
2013-06-04 04:13:24 -07:00
Markus Lanthaler 04b939625b Update README.md
Update the link to the documentation. All GitHub pages are now using the github.io domain.
2013-06-04 13:04:42 +02:00
Stephen Dolan 5dac485458 Make jq --version print to stdout, not stderr 2013-06-03 23:22:59 +01:00
Stephen Dolan 2c4ccd122e Better error handling for .foo case in parser. See #141. 2013-06-03 23:12:31 +01:00
Stephen Dolan b90ae078b8 Let the parser rather than the lexer handle invalid characters. 2013-06-03 23:12:31 +01:00
Stephen Dolan cc8761dbde Add command-line option to sort object keys.
Closes #79.
2013-06-03 23:12:31 +01:00
Stephen Dolan 08cc591884 Clean up Makefile.am (distcheck, rebuild version.h less often) 2013-06-03 23:12:31 +01:00
Stephen Dolan 1bc4d04f43 Merge pull request #139 from 13ren/stopwarning
Stop warning on fgets, jq_test.c:42
2013-06-01 07:30:15 -07:00
Brendan Macmillan d4018192a9 Stop warning on fgets, simple version 2013-06-01 11:12:28 +10:00
Brendan Macmillan 19ddbfeca9 Stop warning on fgets, complex version 2013-06-01 11:03:15 +10:00
Stephen Dolan 4fed6763fc Squash a warning on some GCC versions 2013-05-31 12:15:58 +01:00
Stephen Dolan 73446a9cce Support for printing object keys in sorted order.
No command-line option to enable this yet. See #79.
2013-05-29 11:47:12 +01:00
Stephen Dolan dcf1ac0d1f Merge pull request #135 from 13ren/locfile_bugfix
Locfile bugfix
2013-05-29 03:38:15 -07:00
Stephen Dolan 364c58d13f Merge pull request #130 from 13ren/libload_2
libload_2 (update to pull request #126, for issue  #112)
2013-05-29 03:37:36 -07:00
Brendan Macmillan 8cfe11e4e2 Bugfix multiline off-by-one (locfile.c) 2013-05-29 15:23:08 +10:00
Brendan Macmillan 40378a18f7 locfile.h -> locfile.h + locfile.c
clean up includes of a few files
2013-05-29 15:17:01 +10:00
Brendan Macmillan 7fb5d8c973 Hack bugfix for multiline off-by-one (locfile.c) 2013-05-29 15:16:45 +10:00
Brendan Macmillan 6e373942e5 Load library from ~/.jq 2013-05-29 15:05:40 +10:00
Stephen Dolan f0b982795c Make jq --version report an actual git revision.
Closes #129.
2013-05-24 23:35:38 +01:00
Stephen Dolan cbd422d56e Merge pull request #133 from nicowilliams/option_argfile-rebase0
Add --argfile variant of --arg (issue #117)
2013-05-24 04:13:45 -07:00
Nicolas Williams 03598bb5d6 Add --argfile variant of --arg (issue #117)
This is useful when one has a database (in JSON form) to query using jq
input data.

    % echo '{"a":1, "c":5}' > db.json
    % echo '"c"'|./jq --argfile f /tmp/a '$f[.]'
    5
    % echo '"a"'|./jq --argfile f /tmp/a '$f[.]'
    1
    % echo '"b"'|./jq --argfile f /tmp/a '$f[.]'
    null
    %
2013-05-23 13:52:06 -05:00
Stephen Dolan 983a53a643 'make clean' won't delete jq.1 if it can't be rebuilt.
See #131
2013-05-23 19:20:19 +01:00
495 changed files with 85846 additions and 18350 deletions

No files matched your search

+10
View File
@@ -1,2 +1,12 @@
.gitattributes export-ignore
.gitignore export-ignore
* text=auto eol=lf
vendor/** linguist-vendored
# generated files
src/lexer.[ch] linguist-generated=true
src/parser.[ch] linguist-generated=true
tests/man.test linguist-generated=true
tests/manonig.test linguist-generated=true
jq.1.prebuilt linguist-generated=true
docs/Pipfile.lock linguist-generated=true
+30
View File
@@ -0,0 +1,30 @@
---
name: Bug report
about: Create a report to help us improve
---
<!--
READ THIS FIRST!
If you have a usage question, please ask us on [Stack Overflow](https://stackoverflow.com/questions/tagged/jq), in the [#jq channel](https://web.libera.chat/#jq) on [Libera.Chat](https://libera.chat/), or in our [Discord server](https://discord.gg/yg6yjNmgAC).
-->
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Provide a minimal test case to reproduce the behavior.
If the input is large, either attach it as a file, or [create a gist](https://gist.github.com) and link to it here.
**Expected behavior**
A clear and concise description of what you expected to happen.
**Environment (please complete the following information):**
- OS and Version: [e.g. macOS, Windows, Linux (please specify distro)]
- jq version [e.g. 1.5]
**Additional context**
Add any other context about the problem here.
+15
View File
@@ -0,0 +1,15 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "docs/"
schedule:
interval: "monthly"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
official-actions:
patterns: ["actions/*"]
docker-actions:
patterns: ["docker/*"]
+86
View File
@@ -0,0 +1,86 @@
name: BSD
on:
push:
branches:
- master
tags:
- "jq-*"
pull_request:
jobs:
freebsd:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Clone repository
uses: actions/checkout@v7
with:
submodules: true
- name: Build and test
uses: vmactions/freebsd-vm@v1
with:
usesh: true
cache-after-prepare: true
prepare: |
pkg install -y autoconf automake libtool gmake git
run: |
set -e
# The VM runs as root over a checkout owned by another uid, so git
# rejects the repository and scripts/version -- which AC_INIT calls
# through m4_esyscmd_s -- exits 128, leaving JQ_VERSION undefined.
git config --global --add safe.directory "$PWD"
git config --global --add safe.directory "$PWD/vendor/oniguruma"
autoreconf -i
./configure --disable-docs --with-oniguruma=builtin --enable-static
gmake -j"$(sysctl -n hw.ncpu)"
gmake check VERBOSE=yes
- name: Upload Test Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: test-logs-freebsd
retention-days: 7
path: |
test-suite.log
tests/*.log
netbsd:
runs-on: ubuntu-latest
timeout-minutes: 60
steps:
- name: Clone repository
uses: actions/checkout@v7
with:
submodules: true
- name: Build and test
uses: vmactions/netbsd-vm@v1
with:
usesh: true
cache-after-prepare: true
prepare: |
# The image's default PKG_PATH falls back to a 9.0 package set;
# point it at the running release instead.
PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/$(uname -m)/$(uname -r)/All/"
export PKG_PATH
pkg_add autoconf automake libtool gmake git
run: |
set -e
# The VM runs as root over a checkout owned by another uid, so git
# rejects the repository and scripts/version -- which AC_INIT calls
# through m4_esyscmd_s -- exits 128, leaving JQ_VERSION undefined.
git config --global --add safe.directory "$PWD"
git config --global --add safe.directory "$PWD/vendor/oniguruma"
autoreconf -i
./configure --disable-docs --with-oniguruma=builtin --enable-static
gmake -j"$(sysctl -n hw.ncpu)"
gmake check VERBOSE=yes
- name: Upload Test Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: test-logs-netbsd
retention-days: 7
path: |
test-suite.log
tests/*.log
+431
View File
@@ -0,0 +1,431 @@
name: CI
on:
push:
branches:
- master
tags:
- "jq-*"
pull_request:
jobs:
linux:
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
- armel
- armhf
- i386
- mips
- mips64
- mips64el
- mips64r6
- mips64r6el
- mipsel
- mipsr6
- mipsr6el
- powerpc
- ppc64el
- riscv64
- s390x
include:
- arch: amd64
CC: x86_64-linux-gnu
- arch: arm64
CC: aarch64-linux-gnu
- arch: armel
CC: arm-linux-gnueabi
- arch: armhf
CC: arm-linux-gnueabihf
- arch: i386
CC: i686-linux-gnu
- arch: mips
CC: mips-linux-gnu
- arch: mips64
CC: mips64-linux-gnuabi64
- arch: mips64el
CC: mips64el-linux-gnuabi64
- arch: mips64r6
CC: mipsisa64r6-linux-gnuabi64
- arch: mips64r6el
CC: mipsisa64r6el-linux-gnuabi64
- arch: mipsel
CC: mipsel-linux-gnu
- arch: mipsr6
CC: mipsisa32r6-linux-gnu
- arch: mipsr6el
CC: mipsisa32r6el-linux-gnu
- arch: powerpc
CC: powerpc-linux-gnu
- arch: ppc64el
CC: powerpc64le-linux-gnu
- arch: riscv64
CC: riscv64-linux-gnu
- arch: s390x
CC: s390x-linux-gnu
runs-on: ${{ matrix.arch == 'i386' && 'ubuntu-22.04' || 'ubuntu-24.04' }}
env:
AR: ${{ matrix.CC }}-ar
CHOST: ${{ matrix.CC }}
CC: ${{ matrix.CC }}-gcc
CPP: ${{ matrix.CC }}-cpp
LDFLAGS: -s
SUFFIX: linux-${{ matrix.arch }}
steps:
- name: Clone repository
uses: actions/checkout@v7
with:
submodules: true
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y automake autoconf libtool crossbuild-essential-${{ matrix.arch }}
- name: Build
run: |
autoreconf -i
./configure \
--host=${{ matrix.CC }} \
--disable-docs \
--with-oniguruma=builtin \
--enable-static \
--enable-all-static \
CFLAGS="-O2 -pthread -fstack-protector-all"
make -j"$(nproc)"
file ./jq
cp ./jq jq-${{ env.SUFFIX }}
- name: Test
# Only run tests for amd64 matching the CI machine arch
if: ${{ matrix.arch == 'amd64' }}
run: |
make check VERBOSE=yes
git diff --exit-code
- name: Upload Test Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: test-logs-${{ env.SUFFIX }}
retention-days: 7
path: |
test-suite.log
tests/*.log
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: jq-${{ env.SUFFIX }}
path: jq-${{ env.SUFFIX }}
if-no-files-found: error
retention-days: 7
macos:
strategy:
fail-fast: false
matrix:
arch:
- amd64
- arm64
include:
- arch: amd64
target: x86_64-apple-darwin
- arch: arm64
target: arm64-apple-darwin
runs-on: macos-14
env:
LDFLAGS: -dead_strip
SUFFIX: macos-${{ matrix.arch }}
steps:
- name: Clone repository
uses: actions/checkout@v7
with:
submodules: true
- name: Install packages
run: |
# brew update sometimes fails with "Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!"
brew update || brew update-reset
brew install autoconf automake libtool
- name: Set CC
run: |
echo "CC=clang -target ${{ matrix.target }}$(uname -r)" >> "$GITHUB_ENV"
- name: Build
run: |
autoreconf -i
./configure \
--host="${{ matrix.target }}$(uname -r)" \
--disable-docs \
--with-oniguruma=builtin \
--disable-shared \
--enable-static \
--enable-all-static \
CFLAGS="-O2 -pthread -fstack-protector-all"
make -j"$(sysctl -n hw.logicalcpu)"
strip ./jq
file ./jq
cp ./jq jq-${{ env.SUFFIX }}
- name: Test
run: |
make check VERBOSE=yes
git diff --exit-code
- name: Upload Test Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: test-logs-${{ env.SUFFIX }}
retention-days: 7
path: |
test-suite.log
tests/*.log
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: jq-${{ env.SUFFIX }}
path: jq-${{ env.SUFFIX }}
if-no-files-found: error
retention-days: 7
windows:
strategy:
fail-fast: false
matrix:
arch:
- amd64
- i386
- arm64
include:
- arch: amd64
msystem: UCRT64
os: windows-2022
- arch: i386
msystem: MINGW32
os: windows-2022
- arch: arm64
msystem: CLANGARM64
os: windows-11-arm
runs-on: ${{ matrix.os }}
env:
LDFLAGS: -s
SUFFIX: windows-${{ matrix.arch }}
defaults:
run:
shell: msys2 {0}
steps:
- name: Prepare git config
run: git config --system core.autocrlf false
shell: bash
- name: Clone repository
uses: actions/checkout@v7
with:
submodules: true
- uses: msys2/setup-msys2@v2
with:
update: true
msystem: ${{ matrix.msystem }}
install: >-
base-devel
git
autoconf
automake
libtool
pacboy: >-
toolchain:p
- name: Build
run: |
autoreconf -i
./configure \
--disable-docs \
--with-oniguruma=builtin \
--disable-shared \
--enable-static \
--enable-all-static \
CFLAGS="-O2 -pthread -fstack-protector-all -Wl,--stack,8388608"
make -j$(nproc)
file ./jq.exe
cp ./jq.exe jq-${{ env.SUFFIX }}.exe
- name: Test
run: |
make check VERBOSE=yes
git diff --exit-code
- name: Upload Test Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: test-logs-${{ env.SUFFIX }}
retention-days: 7
path: |
test-suite.log
tests/*.log
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: jq-${{ env.SUFFIX }}
path: jq-${{ env.SUFFIX }}.exe
if-no-files-found: error
retention-days: 7
dist:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v7
with:
submodules: true
- name: Install packages
run: |
sudo apt-get update -qq
sudo apt-get install -y automake autoconf
- name: Create dist
run: |
autoreconf -i
./configure \
--disable-docs \
--with-oniguruma=builtin
make distcheck
make dist dist-zip
git diff --exit-code
- name: Upload artifacts
uses: actions/upload-artifact@v7
with:
name: jq-dist
if-no-files-found: error
retention-days: 7
path: |
jq-*.tar.gz
jq-*.zip
docker:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
attestations: write
artifact-metadata: write
packages: write
needs: linux
steps:
- name: Clone repository
uses: actions/checkout@v7
- name: Download executables
uses: actions/download-artifact@v8
with:
pattern: jq-linux-*
merge-multiple: true
- name: Move executables
run: |
mkdir -p linux/{386,amd64,arm64,arm/v7,mips64le,ppc64le,riscv64,s390x}
chmod +x jq-linux-*
mv jq-linux-i386 linux/386/jq
mv jq-linux-amd64 linux/amd64/jq
mv jq-linux-arm64 linux/arm64/jq
mv jq-linux-armhf linux/arm/v7/jq
mv jq-linux-mips64el linux/mips64le/jq
mv jq-linux-ppc64el linux/ppc64le/jq
mv jq-linux-riscv64 linux/riscv64/jq
mv jq-linux-s390x linux/s390x/jq
- name: Create Dockerfile
run: |
cat <<'EOF' >Dockerfile
FROM scratch
ARG TARGETPLATFORM
COPY AUTHORS COPYING $TARGETPLATFORM/jq /
RUN ["/jq", "--version"]
ENTRYPOINT ["/jq"]
EOF
- name: Docker metadata
uses: docker/metadata-action@v6
id: metadata
with:
images: ghcr.io/${{ github.repository }}
tags: >
${{ startsWith(github.ref, 'refs/tags/jq-')
&& format('type=match,pattern=jq-(.*),group=1,value={0}', github.ref_name)
|| 'type=sha,format=long' }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and release Docker image
uses: docker/build-push-action@v7
id: build-push
with:
context: .
push: ${{ startsWith(github.ref, 'refs/tags/jq-') }}
provenance: false
platforms: linux/386,linux/amd64,linux/arm64,linux/arm/v7,linux/mips64le,linux/ppc64le,linux/riscv64,linux/s390x
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
- name: Generate signed attestations
if: startsWith(github.ref, 'refs/tags/jq-')
uses: actions/attest@v4
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.build-push.outputs.digest }}
push-to-registry: true
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
attestations: write
artifact-metadata: write
pull-requests: write
environment: release
needs: [linux, macos, windows, dist, docker]
if: startsWith(github.ref, 'refs/tags/jq-')
steps:
- name: Clone repository
uses: actions/checkout@v7
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: jq-*
merge-multiple: true
- name: Prepare release artifacts
run: |
cp jq-linux-amd64 jq-linux64
cp jq-macos-amd64 jq-osx-amd64
cp jq-windows-amd64.exe jq-win64.exe
- name: Generate signed attestations
id: attest
uses: actions/attest@v4
with:
subject-path: jq-*
- name: Upload release
env:
TAG_NAME: ${{ github.ref_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mv "${{ steps.attest.outputs.bundle-path }}" jq-attestation.json
sha256sum jq-* > sha256sum.txt
gh release create "$TAG_NAME" --draft --title "jq ${TAG_NAME#jq-}" --generate-notes
gh release upload "$TAG_NAME" --clobber jq-* sha256sum.txt
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v7
with:
gpg_private_key: ${{ secrets.JQ_RELEASE_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.JQ_RELEASE_GPG_PASSPHRASE }}
- name: Update signatures
env:
TAG_NAME: ${{ github.ref_name }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
sig_dir="sig/v${TAG_NAME#jq-}"
mkdir -p "$sig_dir"
mv sha256sum.txt "$sig_dir"
for file in jq-*; do
gpg --detach-sign --armor --batch --output "${sig_dir}/${file#*/}.asc" "$file"
done
git add sig
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
title="Update signatures of ${TAG_NAME#jq-}"
git commit -m "$title"
branch="update-signatures-${TAG_NAME#jq-}"
git push origin "HEAD:refs/heads/$branch"
gh pr create --title "$title" --body "" --head "$branch"
+42
View File
@@ -0,0 +1,42 @@
name: decnum
on:
push:
branches:
- master
pull_request:
jobs:
disabled:
runs-on: ubuntu-24.04
steps:
- name: Clone repository
uses: actions/checkout@v7
with:
submodules: true
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y automake autoconf libtool
- name: Build
run: |
autoreconf -i
./configure \
--disable-docs \
--disable-maintainer-mode \
--disable-decnum
make -j"$(nproc)"
file ./jq
- name: Test
run: |
diff <(echo 100000000000000000000 | ./jq) <(echo 1e+20)
make check VERBOSE=yes
git diff --exit-code
- name: Upload Test Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: test-logs-decnum-disabled
retention-days: 7
path: |
test-suite.log
tests/*.log
+49
View File
@@ -0,0 +1,49 @@
name: Building man page, man.test, manonig.test
on:
push:
branches:
- master
paths:
- '.github/workflows/manpage.yml'
- 'docs/**'
- 'tests/man.test'
- 'tests/manonig.test'
- 'jq.1.prebuilt'
pull_request:
paths:
- '.github/workflows/manpage.yml'
- 'docs/**'
- 'tests/man.test'
- 'tests/manonig.test'
- 'jq.1.prebuilt'
jobs:
manpages:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.11'
cache: pipenv
- name: Install pipenv
run: pip install pipenv
- name: Install dependencies
run: pipenv sync
working-directory: docs
- name: Validate manual schema
run: pipenv run python3 validate_manual_schema.py content/manual/**/*.yml
working-directory: docs
- name: Configure
run: |
autoreconf -i
./configure --enable-docs
- name: Build man page, man.test, manonig.test
run: |
rm -f jq.1.prebuilt tests/man.test tests/manonig.test
make jq.1.prebuilt tests/man.test tests/manonig.test
- name: Make sure that jq.1.prebuilt, man.test, manonig.test are up to date
run: |
git diff --exit-code jq.1.prebuilt tests/man.test tests/manonig.test
+75
View File
@@ -0,0 +1,75 @@
name: oniguruma
on:
push:
branches:
- master
pull_request:
# Since builtin oniguruma is tested in the CI workflow,
# we test other options for --with-oniguruma here.
jobs:
installed:
runs-on: ubuntu-24.04
steps:
- name: Clone repository
uses: actions/checkout@v7
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y automake autoconf libtool valgrind libonig-dev
- name: Build
run: |
autoreconf -i
./configure \
--disable-docs \
--enable-valgrind \
--with-oniguruma=yes
make -j"$(nproc)"
file ./jq
- name: Test
run: |
./jq -n '"" | test("")'
make check VERBOSE=yes
git diff --exit-code
- name: Upload Test Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: test-logs-oniguruma-installed
retention-days: 7
path: |
test-suite.log
tests/*.log
disabled:
runs-on: ubuntu-24.04
steps:
- name: Clone repository
uses: actions/checkout@v7
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y automake autoconf libtool valgrind
- name: Build
run: |
autoreconf -i
./configure \
--disable-docs \
--enable-valgrind \
--with-oniguruma=no
make -j"$(nproc)"
file ./jq
- name: Test
run: |
! ./jq -n '"" | test("")'
make check VERBOSE=yes
git diff --exit-code
- name: Upload Test Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: test-logs-oniguruma-disabled
retention-days: 7
path: |
test-suite.log
tests/*.log
+47
View File
@@ -0,0 +1,47 @@
name: Clang scan-build Static Analyzer Build
on:
push:
branches:
- master
jobs:
scan-build:
runs-on: ubuntu-latest
steps:
- name: Clone repository
uses: actions/checkout@v7
with:
submodules: true
- name: Install packages
run: |
sudo apt-get update -qq
sudo apt-get install -y automake autoconf gdb valgrind clang clang-tools
echo "CC=clang" >> "$GITHUB_ENV"
- name: Build
run: |
autoreconf -i
./configure --enable-valgrind CFLAGS="-g -O0"
scan-build --keep-going --exclude vendor/ make -j"$(nproc)"
- name: Test
run: |
ulimit -c unlimited
scan-build --keep-going --exclude vendor/ make -j"$(nproc)" check
- name: Core dump stacks
run: |
if [[ -f core ]]; then
gdb -batch -ex "thread apply all bt" \
"$(file core | sed "s/^[^']*'//; s/[ '].*$//")" core
exit 1
fi
- name: Test logs
if: ${{ failure() }}
run: |
cat test-suite.log tests/*.log
- name: Upload Logs
uses: actions/upload-artifact@v7
with:
name: Scan-Build Reports
path: /tmp/scan-build*
if-no-files-found: ignore
retention-days: 7
+41
View File
@@ -0,0 +1,41 @@
name: valgrind
on:
push:
branches:
- master
pull_request:
jobs:
linux:
runs-on: ubuntu-24.04
steps:
- name: Clone repository
uses: actions/checkout@v7
with:
submodules: true
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install -y automake autoconf libtool valgrind
- name: Build
run: |
autoreconf -i
./configure \
--disable-docs \
--enable-valgrind \
--with-oniguruma=builtin
make -j"$(nproc)"
file ./jq
- name: Test
run: |
make check VERBOSE=yes
git diff --exit-code
- name: Upload Test Logs
if: ${{ failure() }}
uses: actions/upload-artifact@v7
with:
name: test-logs-valgrind-linux
retention-days: 7
path: |
test-suite.log
tests/*.log
+47
View File
@@ -0,0 +1,47 @@
name: Update website
on:
push:
branches:
- master
paths:
- 'docs/**'
concurrency: website
jobs:
build:
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- name: Checkout code
uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v7
with:
python-version: '3.11'
cache: pipenv
- name: Install pipenv
run: pip install pipenv
- name: Install dependencies
run: pipenv sync
- name: Build website
run: pipenv run python3 build_website.py
- name: Upload pages artifact
uses: actions/upload-pages-artifact@v5
with:
path: docs/output/
deploy:
needs: build
permissions:
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
uses: actions/deploy-pages@v5
id: deployment
+41 -9
View File
@@ -1,28 +1,60 @@
*.o
*.a
*.lo
*.la
*.lai
*.so
*.so.*
*.gcda
*.gcno
*.gcov
*~
.*.sw[a-p]
tags
jq
!tests/modules/lib/jq/
jq.1
# Something delightfully recursive happens otherwise
docs/content/2.download/source/*
# Autogenerated
lexer.c
lexer.h
parser.c
parser.h
# Generated source
src/builtin.inc
src/config_opts.inc
*.pc
# Autotools junk
.libs
.deps
.dirstamp
libtool
*.log
stamp-h1
config.log
config.status
autom4te.cache
config.h
confdefs.h
conftest*
INSTALL
Makefile
jq-*.tar.gz
jq-*.zip
configure
aclocal.m4
Makefile.in
version.h
.remake-version-h
config.cache
*.rpm
m4/libtool.m4
m4/ltoptions.m4
m4/ltsugar.m4
m4/ltversion.m4
m4/lt~obsolete.m4
tests/*.trs
# Docs output
docs/output
cscope.in.out
cscope.out
cscope.po.out
jq.dSYM
+3
View File
@@ -0,0 +1,3 @@
[submodule "vendor/oniguruma"]
path = vendor/oniguruma
url = https://github.com/kkos/oniguruma.git
+250 -3
View File
@@ -1,6 +1,253 @@
Created By:
Stephen Dolan <mu@netsoc.tcd.ie>
Contributions by
Anthony Shortland <anthony.shortland@me.com> - rpmbuild target
Lee Thompson <stagr.lee@gmail.com> - autoconf stuff
Maintained by:
David Tolnay <dtolnay@gmail.com>
Emanuele Torre <torreemanuele6@gmail.com>
Leonid S. Usov <leonid@practi.net>
Mattias Wadman <mattias.wadman@gmail.com>
Muh Muhten <muh.muhten@gmail.com>
Nicolas Williams <nico@cryptonector.com>
Owen Ou <o@owenou.com>
William Langford <wlangfor@gmail.com>
itchyny <itchyny@cybozu.co.jp>
pkoppstein <pkoppstein@gmail.com>
Contributions by:
13ren <melbourne.research@gmail.com>
A4-Tacks <wdsjxhno1001@163.com>
AJ Jordan <alex@strugee.net>
Aaron Peschel <apeschel@zendesk.com>
Adam Lindberg <hello@alind.io>
Alanscut <wp_scut@163.com>
Aleksey Tsalolikhin <atsalolikhin@spokeo.com>
Alex Chamberlain <alex@alexchamberlain.co.uk>
Alex Jurkiewicz <alex@jurkiewi.cz>
Alex Ozdemir <aozdemir@hmc.edu>
Alex Wilson <gpg@probablyfine.co.uk>
Alexandre Jasmin <ajasmin@transtex-llc.com>
Allan Clark <allanc@chickenandporn.com>
Alyssa Ross <hi@alyssa.is>
Andreas Heiduk <asheiduk@users.noreply.github.com>
Andrew O'Brien <obrien.andrew@gmail.com>
Andrew Rodland <andrew@cleverdomain.org>
Andrew Speed <andrew.cspeed@gmail.com>
Andy Lester <andy@petdance.com>
Ankur <ankz.kothari@gmail.com>
Anthony Shortland <anthony@dtosolutions.com>
Anthony Sottile <asottile@umich.edu>
Assaf Gordon <assafgordon@gmail.com>
Attila Fülöp <attila@fueloep.org>
Benjamin Wuethrich <benjamin@koho.ca>
Benoit de Chezelles <bew@users.noreply.github.com>
Bernard Niset <bernard.niset@gmail.com>
Bhargava Mummadireddy <kishoreinvits@gmail.com>
Binbin Qian <qianbinbin@hotmail.com>
Bradley Skaggs <bskaggs@acm.org>
Brahm Lower <bplower@gmail.com>
Brendan Macmillan <melbourne.research@gmail.com>
Cameron Sparr <cameronsparr@gmail.com>
Chance Zibolski <czibolsk@redhat.com>
Charles Merriam <charles.merriam@gmail.com>
Chris LaRose <cjlarose@gmail.com>
Chris Moore <dooglus@gmail.com>
Christoph Anton Mitterer <calestyo@scientia.org>
Christopher Degawa <ccom@randomderp.com>
Ciaran McNamara <1372986+ciaranmcnamara@users.noreply.github.com>
Clément MATHIEU <clement@unportant.info>
Colin Leroy-Mira <colin@colino.net>
Colin von Heuring <colin@janrain.com>
Dag-Erling Smørgrav <des@des.no>
Damian Gryski <damian@gryski.com>
Dan Church <h3xx@users.noreply.github.com>
Daniel Lange <DLange@git.local>
David Biesack <David.Biesack@apiture.com>
David Fetter <david@fetter.org>
David Haguenauer <ml@kurokatta.org>
David Korczynski <david@adalogics.com>
David R. MacIver <david@drmaciver.com>
DavidKorczynski <david@adalogics.com>
Dawid Ferenczy Rogožan <ferenczy@users.noreply.github.com>
Dennis Ameling <dennis@dennisameling.com>
Derrick Pallas <derrick@pallas.us>
Doug Luce <doug@github.con.com>
Eiichi Sato <sato.eiichi@gmail.com>
Eli Schwartz <eschwartz@archlinux.org>
Eloy Coto <eloy.coto@gmail.com>
Eric Bréchemier <eric@egull.co>
Erik Brinkman <erik.brinkman@gmail.com>
Eugen <EugenGez@gmail.com>
Evan Zacks <zackse@gmail.com>
Fabian Dellwing <fabian.dellwing@mbconnectline.de>
Fabian Fleischer <50590395+fab1ano@users.noreply.github.com>
Felix Wolfsteller <felix.wolfsteller@gmail.com>
Filippo Giunchedi <fgiunchedi@gmail.com>
Filippo Valsorda <filippo.valsorda@gmail.com>
Florian Weimer <fweimer@redhat.com>
Frederic Cambus <fcambus@users.sourceforge.net>
Gabriel Marin <gbrlmarn@gmail.com>
Gaelan Steele <gbs@canishe.com>
George Hopkins <george-hopkins@null.net>
Gert Van Gool <gertvangool@gmail.com>
Gijs Kunze <gwkunze@gmail.com>
Gustav <gustav@invoke.se>
HE, Tao <sighingnow@gmail.com>
Han Jiang <jhcarl0814@gmail.com>
Hanfei Shen <qqshfox@gmail.com>
Hanson Char <hanson.char@gmail.com>
Haochen Xie <haochenx@acm.org>
Helmut K. C. Tessarek <tessarek@evermeet.cx>
Henré Botha <henrebotha@gmail.com>
Ian Miell <ian.miell@gmail.com>
Ikko Ashimine <eltociear@gmail.com>
Ish Nagy <50555716+ishnagy@users.noreply.github.com>
J Phani Mahesh <github@phanimahesh.me>
J. B. Rainsberger <me@jbrains.ca>
Jack Pearkes <jackpearkes@gmail.com>
Jakub Jirutka <jakub@jirutka.cz>
Jakub Wilk <jwilk@jwilk.net>
James Andariese <james.andariese@locationlabs.com>
James Pearson Hughes <xiong.chiamiov@gmail.com>
Jan Schulz <jasc@gmx.net>
Jan-Piet Mens <jp@mens.de>
Janne Cederberg <janne.cederberg@gmail.com>
Jason Hood <jadoxa@yahoo.com.au>
Jay Satiro <raysatiro@yahoo.com>
Jesper Rønn-Jensen <jesperrr@gmail.com>
Jingwen Owen Ou <jingweno@gmail.com>
Joe Littlejohn <joe.littlejohn@nokia.com>
Joel Nothman <joel.nothman@gmail.com>
Joel Purra <code+github@joelpurra.com>
Jonathan Chan Kwan Yin <sofe2038@gmail.com>
Jonathan Word <argoday@argoday.com>
Josh Soref <2119212+jsoref@users.noreply.github.com>
José Joaquín Atria <jjatria@gmail.com>
Juan Guerrero <juan.guerrero.lozano@gmail.com>
Kamontat Chantrachirathumrong <14089557+kamontat@users.noreply.github.com>
Kartik Shah <krtk.6160@gmail.com>
Kenny Shen <kenny.shen@zalora.com>
Kim De Mey <kim.demey@gmail.com>
Kim Toms <kim.toms@bplglobal.net>
Kirk McKelvey <kirkoman@gmail.com>
Klemens Nanni <kn@openbsd.org>
LCD 47 <lcd047@gmail.com>
Larry Aasen <larryaasen@gmail.com>
Lee Thompson <stagr.lee@gmail.com>
Loamhoof <soeren.medard@gmail.com>
Lucas Trzesniewski <lucas.trzesniewski@gmail.com>
Lukas Lansky <lukas.lansky@suse.com>
MCApollo <34170230+MCApollo@users.noreply.github.com>
Marc Abramowitz <marc@marc-abramowitz.com>
Marc Bruggmann <marcbr@spotify.com>
Marcin Kłopotek <marcin.klopotek@gmail.com>
Marcin Serwin <marcin@serwin.dev>
Mark Feit <mfeit@internet2.edu>
Mark McKinstry <mmckinst@umich.edu>
Markus Lanthaler <mark_lanthaler@gmx.net>
Matt Clegg <m@cle.gg>
Matt Meyers <matt@mattmeyers.dev>
Matti Åstrand <mattiastr@gmail.com>
Mattias Hansson <hansson.mattias@gmail.com>
Maxime Biais <maxime.biais@gmail.com>
Maximilian Roos <5635139+max-sixty@users.noreply.github.com>
McSinyx <cnx@loang.net>
Michael Daines <michael@mdaines.com>
Michael Färber <01mf02@gmail.com>
Mike Daines <mdaines@users.noreply.github.com>
Mike Fletcher <john.m.fletcher@bankofamerica.com>
Mike McCabe <mccabe@archive.org>
Nathan Baulch <nathan.baulch@gmail.com>
Naïm Favier <n@monade.li>
Nicolas Pouillard <nicolas.pouillard@gmail.com>
Nicole Wren <nicole@wren.systems>
Paul Chvostek <paul+gitkraken@it.ca>
Paul Wise <pabs3@bonedaddy.net>
Peter Kjellerstedt <peter.kjellerstedt@gmail.com>
Peter van Dijk <peter@7bits.nl>
Philipp Hagemeister <phihag@phihag.de>
Ricardo Constantino <wiiaboo@gmail.com>
Richard Groves <richard@noodlfroot.com>
Richard H Lee <richard@webdezign.co.uk>
Riley Avron <riley.avron@gmail.com>
Rob Wills <rob.wills@gmail.com>
Robert Aboukhalil <robert.aboukhalil@gmail.com>
Rohan Santhosh Kumar <181558744+Rohan5commit@users.noreply.github.com>
Roland C. Dowdeswell <roland.dowdeswell@twosigma.com>
Roman Inflianskas <rominf@users.noreply.github.com>
Romero Malaquias <romero.malaquias@gmail.com>
Ryoichi KATO <ryo1kato@gmail.com>
Rémy Léone <remy.leone@gmail.com>
SArpnt <sarpnt@ficial.net>
Samar Sunkaria <sameesunkaria@me.com>
Santiago Lapresta <santiago.lapresta@gmail.com>
Scott Seal <seal.scottm@gmail.com>
Sean Wei <me@sean.taipei>
Sebastian Freundt <freundt@ga-group.nl>
Shaun Guth <sguth@practicefusion.com>
Shay Elkin <shay@everything.me>
Simon Elsbrock <simon@iodev.org>
Stefan <stefan.haubenthal@gmail.com>
Stefan Seemayer <stefan@seemayer.de>
Stephen Roantree <stroantree@gmail.com>
Stephen Shaw <stesh@netsoc.tcd.ie>
Steven Ihde <sihde@hamachi.us>
Steven Maude <StevenMaude@users.noreply.github.com>
Steven Penny <svnpenn@gmail.com>
Sudhakar Verma <10460978+sudhackar@users.noreply.github.com>
Thalia Archibald <thalia@archibald.dev>
TheOdd <owenhines@protonmail.com>
Thomas Bozeman th026106 <thomas.bozeman@digitalglobe.com>
Thomas R. Hall <trhall@trhall.org>
Thomas Sibley <tom@zulutango.org>
Tim McCormack <cortex@brainonfire.net>
Timothy John Perisho Eccleston <combinatorist@users.noreply.github.com>
Tom Wolf <github@incognitox.org>
Tomas Halman <thalman@redhat.com>
Travis Gockel <travis@gockelhut.com>
Tyler Rockwood <rockwotj@users.noreply.github.com>
Ulrich Eckhardt <ulrich.eckhardt@base-42.de>
Vladimír Marek <vlmarek13@gmail.com>
W-Mark Kubacki <wmark@hurrikane.de>
William Chargin <wchargin@gmail.com>
Yasuhiro Matsumoto <mattn.jp@gmail.com>
Yeikel <email@yeikel.com>
Yoichi Nakayama <yoichi.nakayama@gmail.com>
Yu-Fu Fu <yufu@yfu.tw>
Ze Sheng <108382772+OwenSanzas@users.noreply.github.com>
Zhaohui Mei <mzh.whut@gmail.com>
Zhiming Wang <zmwangx@gmail.com>
bigmoonbit <bigmoonbit@outlook.com>
calpeconsulting <61429736+calpeconsulting@users.noreply.github.com>
cdnbacon <mike@busbud.com>
dak180 <dak180@users.sf.net>
davkor <david@adalogics.com>
dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
eitsupi <50911393+eitsupi@users.noreply.github.com>
fletcher gornick <fletcher@gornick.dev>
github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
goodactive <167312449+goodactive@users.noreply.github.com>
i <isomorphisms@sdf.org>
jkleint <jkleint@gmail.com>
lectrical <14344693+lectrical@users.noreply.github.com>
liviubobocu <liviu.bobocu@uipath.com>
maflcko <6399679+maflcko@users.noreply.github.com>
mail6543210 <mail6543210@yahoo.com.tw>
mjarosie <mjarosie@users.noreply.github.com>
myaaaaaaaaa <103326468+myaaaaaaaaa@users.noreply.github.com>
nmulcahey <nmulcahey@gmail.com>
orbea <orbea@riseup.net>
polyester <paul@cleanclothes.org>
rain1 <rain1@airmail.cc>
riastradh <campbell+github@mumble.net>
sachint <32639496+sachintu47@users.noreply.github.com>
sheepster <omer531998@gmail.com>
tal@whatexit.org <tal@whatexit.org>
taoky <taoky99@outlook.com>
theyoucheng <daniel1988xyz@gmail.com>
tlsbollei <170938166+tlsbollei@users.noreply.github.com>
trantor <trantorvega@gmail.com>
wellweek <148746285+wellweek@users.noreply.github.com>
wllm-rbnt <william.robinet@conostix.com>
zstadler <zeev.stadler@gmail.com>
наб <nabijaczleweli@nabijaczleweli.xyz>
엄태용 <lg65438805@gmail.com>
+110 -4
View File
@@ -25,14 +25,14 @@ jq's documentation (everything found under the docs/ subdirectory in
the source tree) is licensed under the Creative Commons CC BY 3.0
license, which can be found at:
http://creativecommons.org/licenses/by/3.0/
https://creativecommons.org/licenses/by/3.0/
The documentation website includes a copy of Twitter's Boostrap and
The documentation website includes a copy of Twitter's Bootstrap and
relies on Bonsai, Liquid templates and various other projects, look
them up for detailed licensing conditions.
jq incorporates David M. Gay's dtoa.c and g_fmt.c, which bear the
following notices:
@@ -68,3 +68,109 @@ WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY
REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY
OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE.
jq uses parts of the open source C library "decNumber", which is distributed
under the following license:
ICU License - ICU 1.8.1 and later
COPYRIGHT AND PERMISSION NOTICE
Copyright (c) 1995-2005 International Business Machines Corporation and others
All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, and/or sell copies of the Software, and to permit persons
to whom the Software is furnished to do so, provided that the above
copyright notice(s) and this permission notice appear in all copies of
the Software and that both the above copyright notice(s) and this
permission notice appear in supporting documentation.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Except as contained in this notice, the name of a copyright holder
shall not be used in advertising or otherwise to promote the sale, use
or other dealings in this Software without prior written authorization
of the copyright holder.
--------------------------------------------------------------------------------
All trademarks and registered trademarks mentioned herein are the property of their respective owners.
jv_thread.h is copied from Heimdal's lib/base/heimbase.h and some code
in jv.c is copied from Heimdal's lib/base/dll.c:
Portions Copyright (c) 2016 Kungliga Tekniska Högskolan
(Royal Institute of Technology, Stockholm, Sweden).
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
jq uses a modified version of NetBSD implementation strptime(),
which is distributed under the following license:
Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
All rights reserved.
This code was contributed to The NetBSD Foundation by Klaus Klein.
Heavily optimised by David Laight
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
+1349
View File
File diff suppressed because it is too large. Load diff
+34
View File
@@ -0,0 +1,34 @@
FROM debian:12-slim AS builder
ENV DEBIAN_FRONTEND=noninteractive \
DEBCONF_NONINTERACTIVE_SEEN=true \
LC_ALL=C.UTF-8 \
LANG=C.UTF-8
RUN apt-get update \
&& apt-get install -y \
build-essential \
autoconf \
libtool \
git \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY . /app
RUN autoreconf -i \
&& ./configure \
--disable-docs \
--with-oniguruma=builtin \
--enable-static \
--enable-all-static \
--prefix=/usr/local \
&& make -j$(nproc) \
&& make check VERBOSE=yes \
&& make install-strip
FROM scratch
COPY --from=builder /app/AUTHORS /app/COPYING /usr/local/bin/jq /
RUN ["/jq", "--version"]
ENTRYPOINT ["/jq"]
+8
View File
@@ -0,0 +1,8 @@
pub 4096R/71523402 2015-10-11
Key fingerprint = 4FD7 01D6 FA9B 3D2D F5AC 935D AF19 040C 7152 3402
uid jq Release Signing Key <jq@stedolan.github.io>
pub 2048R/D15684DB 2015-10-12 [expires: 2017-10-11]
Key fingerprint = 7F6C 7BD3 0412 AFD5 8C1A 5007 EB26 A4F8 D156 84DB
uid Nicolas Williams <nico@cryptonector.com>
sub 2048R/9C9CCD6A 2015-10-12 [expires: 2017-10-11]
+224 -74
View File
@@ -1,123 +1,273 @@
### C source files to be built and distributed.
JQ_INCS = jq_parser.h builtin.h bytecode.h compile.h execute.h \
forkable_stack.h frame_layout.h jv.h jv_alloc.h jv_aux.h jv_dtoa.h \
jv_parse.h jv_unicode.h locfile.h opcode.h opcode_list.h parser.y \
jv_utf8_tables.h lexer.l
JQ_SRC = opcode.c bytecode.c compile.c execute.c builtin.c jv.c \
jv_parse.c jv_print.c jv_dtoa.c jv_unicode.c jv_aux.c jv_alloc.c \
jq_test.c ${JQ_INCS}
LIBJQ_INCS = src/builtin.h src/bytecode.h src/compile.h \
src/exec_stack.h src/jq_parser.h src/jv_alloc.h src/jv_dtoa.h \
src/jv_unicode.h src/jv_utf8_tables.h src/lexer.l src/libm.h \
src/linker.h src/locfile.h src/opcode_list.h src/parser.y \
src/util.h src/iso8601.h \
src/jv_dtoa_tsd.h src/jv_thread.h src/jv_private.h \
vendor/decNumber/decContext.h vendor/decNumber/decNumber.h \
vendor/decNumber/decNumberLocal.h
LIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c \
src/jq_test.c src/jv.c src/jv_alloc.c src/jv_aux.c \
src/jv_dtoa.c src/jv_file.c src/jv_parse.c src/jv_print.c \
src/jv_unicode.c src/linker.c src/locfile.c src/util.c \
src/iso8601.c src/jv_dtoa_tsd.c \
vendor/decNumber/decContext.c vendor/decNumber/decNumber.c \
${LIBJQ_INCS}
### C build options
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
-Wno-unused-parameter -Wno-unused-function
AM_CFLAGS = -Wextra -Wall -Wno-unused-parameter -Wno-unused-function \
-Woverlength-strings -Wstrict-prototypes
if WIN32
AM_CFLAGS += -municode
endif
ACLOCAL_AMFLAGS = -I config/m4
### Generating the lexer and parser
# While there is some autoconf macro support for lex/flex, it doesn't support
# header file creation so we'll use good old make
BUILT_SOURCES = lexer.h lexer.c parser.h parser.c
lexer.c: lexer.l
flex -o lexer.c --header-file=lexer.h $<
lexer.h: lexer.c
if MAINTAINER_MODE
BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \
src/builtin.inc src/config_opts.inc src/version.h
src/lexer.c: src/lexer.l
$(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $<
src/lexer.h: src/lexer.c
else
BUILT_SOURCES = src/builtin.inc src/config_opts.inc src/version.h
.y.c:
$(AM_V_YACC) [ "$(<D)" = "$(@D)" ] || cp $(<D)/$(@F) $@
$(AM_V_YACC) [ "$(<D)" = "$(@D)" ] || cp $(<D)/$(*F).h $*.h
$(AM_V_YACC) touch $@ $*.h
# Tell YACC (bison) autoconf macros that you want a header file created.
# If the --warnings=all fails, you probably have an old version of bison
# OSX ships an old bison, so update with homebrew or macports
AM_YFLAGS = --warnings=all -d
.l.c:
$(AM_V_LEX) [ "$(<D)" = "$(@D)" ] || cp $(<D)/$(@F) $@
$(AM_V_LEX) [ "$(<D)" = "$(@D)" ] || cp $(<D)/$(*F).h $*.h
$(AM_V_LEX) touch $@ $*.h
endif
# Tell YACC (Bison) autoconf macros that you want a header file created.
# If the --warnings=all fails, you probably have an old version of Bison
# macOS ships an old Bison, so update with Homebrew or MacPorts.
AM_YFLAGS = --warnings=all -Wno-yacc -d
### libjq
lib_LTLIBRARIES = libjq.la
libjq_la_SOURCES = ${LIBJQ_SRC}
libjq_la_LIBADD = -lm
libjq_la_LDFLAGS = $(onig_LDFLAGS) -export-symbols-regex '^j[qv]_' -version-info 1:4:0
if WIN32
libjq_la_LIBADD += -lshlwapi
libjq_la_LDFLAGS += -no-undefined
endif
include_HEADERS = src/jv.h src/jq.h
AM_CPPFLAGS = -I$(srcdir)/src -I$(srcdir)/vendor
### Address sanitizer (ASan)
if ENABLE_ASAN
AM_CFLAGS += -fsanitize=address
endif
### Undefined Behavior Sanitizer
if ENABLE_UBSAN
AM_CFLAGS += -fsanitize=undefined
endif
### Code coverage with gcov
if ENABLE_GCOV
AM_CFLAGS += --coverage --no-inline
endif
### Error injection for testing
if ENABLE_ERROR_INJECTION
lib_LTLIBRARIES += libinject_errors.la
libinject_errors_la_SOURCES = src/inject_errors.c
libinject_errors_la_LIBADD = -ldl
libinject_errors_la_LDFLAGS = -module
endif
### Building the jq binary
main.c: config.h
# Remake the version.h header file if, and only if, the git ID has changed
.PHONY: .FORCE
.FORCE:
generate_ver = ver="`{ $(srcdir)/scripts/version || echo '$(VERSION)' ; } | xargs printf '\043define JQ_VERSION \"%s\"\n'`"
.remake-version-h: .FORCE
@ $(generate_ver); test "x`cat src/version.h 2>/dev/null`" = "x$$ver" || touch .remake-version-h
src/version.h: .remake-version-h
mkdir -p src
$(AM_V_GEN) $(generate_ver); echo "$$ver" > $@
src/config_opts.inc:
mkdir -p src
$(AM_V_GEN) if test -x ./config.status; then \
./config.status --config; \
else echo "(unknown)"; \
fi | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/"/' -e 's/^/#define JQ_CONFIG /' > $@
src/main.c: src/version.h src/config_opts.inc
src/builtin.inc: $(srcdir)/src/builtin.jq
mkdir -p src
$(AM_V_GEN) od -v -A n -t o1 -- $< | \
sed -e 's/$$/ /' \
-e 's/\([0123456789]\) /\1, /g' \
-e 's/ $$//' \
-e 's/ 0/ 0/g' \
-e 's/ \([123456789]\)/ 0\1/g' > $@
src/builtin.o: src/builtin.inc
CLEANFILES = src/version.h .remake-version-h src/builtin.inc src/config_opts.inc
bin_PROGRAMS = jq
jq_SOURCES = ${JQ_SRC} main.c
jq_SOURCES = src/main.c
jq_LDADD = libjq.la -lm
if ENABLE_ALL_STATIC
jq_LDFLAGS = -all-static
endif
### Tests (make check)
TESTS = tests/all.test
TEST_LOG_COMPILER = ${srcdir}/tests/run
TESTS = tests/mantest tests/jqtest tests/shtest tests/utf8test tests/base64test tests/uritest
if !WIN32
TESTS += tests/optionaltest
endif
AM_TESTS_ENVIRONMENT = JQ=$(abs_builddir)/jq
if ENABLE_VALGRIND
AM_TESTS_ENVIRONMENT += ENABLE_VALGRIND=1
endif
# This is a magic make variable that causes it to treat tests/man.test as a
# DATA-type dependency for the check target. As a result, it will attempt to
# run any defined targets for tests/man.test as a dependency for check. This
# allows us to ensure that the tests are up-to-date if the manual has been updated
check_DATA = tests/man.test
### Building the man tests
# We use the examples in the manual as additional tests, to ensure they always work.
# As a result, we need to rebuild the tests if the manual has been updated.
# Making changes to the manpage without having the python deps means your
# tests won't run. If you aren't making changes to the examples, you probably
# don't care. But if you are, then you need to run the tests anyway.
tests/man.test tests/manonig.test: $(srcdir)/docs/content/manual/dev/manual.yml
if ENABLE_DOCS
$(AM_V_GEN) ( cd ${abs_srcdir}/docs && \
$(PIPENV) run python validate_manual_schema.py content/manual/dev/manual.yml && \
$(PIPENV) run python build_mantests.py )
else
@echo Changes to the manual.yml require docs to be enabled to update the manual test.
@echo As a result, the manual test is out of date.
endif
### Building the manpage
# If ENABLE_DOCS is not set, just copy jq.1.default to jq.1
# The real_docs target succeeds (possibly after building jq.1) only if ENABLE_DOCS is set
# Thus, making "dist" depend on "real_docs" ensures that we never build a tarball with
# a stub manpage.
# We build the docs from the manpage yml. If no changes have been made to the
# manpage, then we'll end up using the cached version. Otherwise, we need to
# rebuild it.
man_MANS = jq.1
.PHONY: real_docs
jq.1.prebuilt: $(srcdir)/docs/content/manual/dev/manual.yml
if ENABLE_DOCS
jq.1: $(srcdir)/docs/content/3.manual/manual.yml
( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage ) > $@ || { rm -f $@; false; }
jq.1.default: $(srcdir)/docs/default_manpage.md
( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage_default ) > $@ || { rm -f $@; false; }
real_docs: jq.1
if cmp jq.1 $(srcdir)/jq.1.default > /dev/null; then\
rm -f jq.1; $(MAKE) $(AM_MAKEFLAGS) jq.1;\
fi
$(AM_V_GEN) ( cd ${abs_srcdir}/docs && \
$(PIPENV) run python validate_manual_schema.py content/manual/dev/manual.yml && \
$(PIPENV) run python build_manpage.py ) > $@
else
jq.1: $(srcdir)/jq.1.default
cp $^ $@
real_docs:
@echo "Ruby dependencies not found, cannot build manpage." > /dev/stderr
@echo "Follow the instructions in docs/README.md to install them" > /dev/stderr
@echo "and then rerun ./configure" > /dev/stderr
false
@echo Changes to the manual.yml require docs to be enabled to update the manpage.
@echo As a result, the manpage is out of date.
endif
# The committed manpage has no date to avoid merge conflicts. Stamp the date
# of the last commit when building in a git repository, including on make
# dist, so that release tarballs ship a dated jq.1. Respect SOURCE_DATE_EPOCH
# so that distribution builds can pin the date.
jq.1: jq.1.prebuilt
$(AM_V_GEN) date=`if test -n "$$SOURCE_DATE_EPOCH"; then \
date -u -d "@$$SOURCE_DATE_EPOCH" +%F 2>/dev/null || \
date -u -r "$$SOURCE_DATE_EPOCH" +%F 2>/dev/null; \
elif test -e $(srcdir)/.git; then \
cd $(srcdir) && git log -1 --format=%cd --date=short 2>/dev/null; \
fi`; \
sed 's/^\.TH "JQ" "1" ""/.TH "JQ" "1" "'"$$date"'"/' $(srcdir)/jq.1.prebuilt > $@
CLEANFILES += jq.1
### Build oniguruma
if BUILD_ONIGURUMA
libjq_la_LIBADD += vendor/oniguruma/src/.libs/libonig.la
jq_LDADD += vendor/oniguruma/src/.libs/libonig.la
SUBDIRS = vendor/oniguruma
endif
AM_CFLAGS += $(onig_CFLAGS)
if WITH_ONIGURUMA
TESTS += tests/onigtest tests/manonigtest
endif
### Packaging
docs/site.yml: configure.ac
sed 's/^jq_version: .*/jq_version: "$(VERSION)"/' $@ > $@.new
mv $@.new $@
install-binaries: $(BUILT_SOURCES)
$(MAKE) $(AM_MAKEFLAGS) install-exec
# Ensure "make dist" fails when we can't build the real manpage
dist-hook: real_docs
DOC_FILES = docs/content docs/public docs/templates \
docs/Pipfile docs/Pipfile.lock docs/build_manpage.py \
docs/build_mantests.py docs/build_website.py docs/README.md \
docs/validate_manual_schema.py docs/manual_schema.yml
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
docs/Gemfile docs/Gemfile.lock docs/Rakefile docs/README.md \
docs/default_manpage.md jq.1.default
EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \
jq.1.prebuilt jq.spec src/lexer.c src/lexer.h src/parser.c \
src/parser.h src/version.h src/builtin.jq scripts/version \
libjq.pc \
tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \
tests/modules/c/d.jq tests/modules/data.json \
tests/modules/deep1.jq tests/modules/deep2a.jq \
tests/modules/deep2b.jq tests/modules/deep3.jq \
tests/modules/home1/.jq tests/modules/home2/.jq/g.jq \
tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \
tests/modules/shadow1.jq tests/modules/shadow2.jq \
tests/modules/syntaxerror/syntaxerror.jq \
tests/modules/test_bind_order.jq \
tests/modules/test_bind_order0.jq \
tests/modules/test_bind_order1.jq \
tests/modules/test_bind_order2.jq \
tests/modules/cycle_a.jq tests/modules/cycle_b.jq \
tests/modules/cycle_self.jq \
tests/onig.supp tests/local.supp \
tests/setup tests/torture/input0.json \
tests/optional.test tests/man.test tests/manonig.test \
tests/jq.test tests/onig.test tests/base64.test tests/uri.test \
tests/jq-f-test.sh \
tests/no-main-program.jq tests/yes-main-program.jq
# setup is only used by distribution developers, not package developers.
# Still, as a matter of allowing patching, its not a bad idea to distribute
# the developer setup script in the tarball.
EXTRA_DIST = config.h.in $(BUILT_SOURCES) $(man_MANS) $(TESTS) \
$(TEST_LOG_COMPILER) gen_utf8_tables.py jq.spec \
$(DOC_FILES)
AM_DISTCHECK_CONFIGURE_FLAGS=--with-oniguruma=builtin
# README.md is expected in Github projects, good stuff in it, so we'll
# README.md is expected in GitHub projects, good stuff in it, so we'll
# distribute it and install it with the package in the doc directory.
docdir = ${datadir}/doc/${PACKAGE}
dist_doc_DATA = README.md COPYING AUTHORS README
dist_doc_DATA = README.md NEWS.md COPYING AUTHORS
releasetag:
git tag -s "jq-$$(cat VERSION)" -m "jq release $$(cat VERSION)"
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libjq.pc
RELEASE ?= 1
rpm: jq
rpm: dist jq.spec
@echo "Packaging jq as an RPM ..."
mkdir -p rpm/SOURCES rpm/BUILD rpm/BUILDROOT rpm/RPMS rpm/SPECS
cp jq-$$(cat VERSION).tar.gz rpm/SOURCES/
rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "myver $$(cat VERSION)" --define "myrel ${RELEASE}" rpm/SOURCES/jq-$$(cat VERSION).tar.gz
cp jq-$(VERSION).tar.gz rpm/SOURCES/
rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "myver $(VERSION)" --define "myrel ${RELEASE}" rpm/SOURCES/jq-$(VERSION).tar.gz
find rpm/RPMS/ -name "*.rpm" -exec mv {} ./ \;
rm -rf rpm
dist-clean-local:
rm -f ${BUILT_SOURCES}
# Not sure why this doesn't get cleaned up automatically, guess
# automake used to man pages which are hand coded?
clean-local:
rm -f jq.1
+768
View File
@@ -0,0 +1,768 @@
# 1.8.2
This is a patch release with security fixes and bug fixes since 1.8.1, along with new builds for Windows arm64 and Docker arm/v7.
Full commit log can be found at <https://github.com/jqlang/jq/compare/jq-1.8.1...jq-1.8.2>.
## Security fixes
- CVE-2026-32316: Fix heap buffer overflow in `jvp_string_append` and `jvp_string_copy_replace_bad`.
@itchyny e47e56d226519635768e6aab2f38f0ab037c09e5
- CVE-2026-33947: Limit path depth to prevent stack overflow in `jv_setpath`, `jv_getpath`, `jv_delpaths`.
@itchyny fb59f1491058d58bdc3e8dd28f1773d1ac690a1f
- CVE-2026-33948: Fix NUL truncation in the JSON parser.
@itchyny 6374ae0bcdfe33a18eb0ae6db28493b1f34a0a5b
- CVE-2026-39956: Fix `_strindices` missing runtime type checks.
@tlsbollei fdf8ef0f0810e3d365cdd5160de43db46f57ed03
- CVE-2026-39979: Fix out-of-bounds read in `jv_parse_sized()`.
@wader 2f09060afab23fe9390cce7cb860b10416e1bf5f
- CVE-2026-40164: Randomize hash seed to mitigate hash collision DoS attacks.
@AsafMeizner @itchyny 0c7d133c3c7e37c00b6d46b658a02244fdd3c784
- CVE-2026-40612: Limit containment check depth to prevent stack overflow in `contains`.
@itchyny d1a12569d91641135976a8536776a4a329c02cc2
- CVE-2026-41256: Fix NUL truncation in program files loaded with `-f`.
@itchyny 5a015deae35d19e3ebbc65db6c157a80e76df738
- CVE-2026-41257: Fix signed-int overflow in `stack_reallocate`.
@itchyny 01b3cded76daacbfddb7f8763700b0803bcb5c6f
- CVE-2026-43894: Reject numeric literals longer than `DEC_MAX_DIGITS` (999999999).
@itchyny 9761ceb7d6cc48c16b25f0ab1baaef0e701927e4
- CVE-2026-43895: Reject embedded NUL bytes in module import paths.
@itchyny 9d223f153c3632a207fa071caaa6292da33ae361
- CVE-2026-43896: Limit recursive object merge depth to prevent stack overflow.
@itchyny 532ccea6080ed6758f39fe9f6208a44b665023d2
- CVE-2026-44777: Detect circular module imports to prevent stack overflow.
@itchyny f58787c41835d9b17795730cb04925fdba25c71c
- CVE-2026-47770: Guard deep structural equality and comparison recursion.
@fuyu0425 7122866869960b55cea3646bc91334ef55787831
- CVE-2026-49839: Fix heap-buffer-overflow in raw file loading.
@itchyny e987df0d463d85fd70825e042a082427e8275b86
- CVE-2026-54679: Tighten string length bounds and propagate invalid jv in implode.
@itchyny 46d1da30944ce93dd671ac72b6513fc0eb747837
- GHSA-gf4g-95wj-4q4r: Fix use-after-free in `args2obj()` array argument path. @sseal #3498
- GHSA-hj52-j2c9-r8r4: Fix signed-int overflow in `tokenadd` to prevent buffer overflow.
@itchyny 63751f8a9f94dc6d3370084ad0d60826c58b955d
- Limit the number of function parameters and definitions to prevent SEGV. @OwenSanzas #3460
- Pre-allocate `tokenbuf` for string parser to avoid undefined behavior. @fab1ano #3485
- Avoid stack overflow when freeing deeply nested values.
@itchyny 33d7bce3218ec718139342e5b48b475c4dea715f
- Fix memory leaks and double frees. @itchyny #3487
## Releasing
- Add builds for Windows arm64. @dennisameling #3376
- Support arm/v7 architecture in Docker images. @itchyny #3463
- Update GPG signing key. @itchyny 0ff997f7c4c07660ffc6ad2506d5f56b8136208b
- Add `artifact-metadata` permission for actions/attest. @itchyny #3530
- Upload attestation bundle as a release artifact, allowing unauthenticated
verification via `gh attestation verify --bundle jq-attestation.json`.
@itchyny #3563
## CLI changes
- Improve error message truncation with closing delimiters. @itchyny #3478
- Remove extra space from `die` function output. @krtk6160 #3391
- Fix raw input flag not to corrupt multi-byte characters. @itchyny #3421
- Fix crash when importing a module with errors twice. @itchyny #3497
- Increase the maximum printing depth from 256 to 10000. @ishnagy #3414
## Changes to existing functions
- Fix `rtrimstr("")` always outputting `""`. @A4-Tacks #3415
- Fix infinite loop and undefined behavior in `del(.[nan])`. @itchyny #3490
- Refactor `@uri` and `@urid` to fix multi-byte UTF-8 corruption. @itchyny #3495
- Fix `tonumber` and `toboolean` to reject strings with embedded null bytes. @itchyny #3496
- Fix undefined behavior in modulo operator. @fab1ano #3486
- Fix reversed pointer subtraction in `f_env` bounds check. @itchyny #3465
- Fix missing validity check in `f_strflocaltime` after `f_localtime`. @itchyny #3491
- Fix year 2038 problem on 32-bit platforms. @itchyny #3407
- Use `//` instead of `//=` in `from_entries` definition. @itchyny #3516
## Build and test changes
- Drop `strptime` test using non-portable `%F`. @alyssais #3365
- Limit oniguruma depth to 1024 in `jq_fuzz_execute`. @sudhackar #3377
- Fix localization test for time formatting functions. @itchyny #3409
- Fix expected value assertion. @itchyny #3431 #3408
- Fix typo in tests/jq.test. @bigmoonbit #3441
- Refactor `tm2jv` to handle fractional seconds. @itchyny #3489
- Fix `jq_fuzz_parse_stream`: use iterative parser API for streaming mode. @OwenSanzas #3499
- Fix crashes and resource leaks in `jq_testsuite`. @itchyny #3509
- Support building with `--disable-maintainer-mode` and source != build dir. @Saur2000 #3518
- Add Solaris support. @vlmarek #3515
- Respect `SOURCE_DATE_EPOCH` while generating man page. @McSinyx #3514
- Fix undefined pointer arithmetic in UTF-8 helpers. @theyoucheng df924eae91af10cc236a907cdadd97813827aa1f
- Fix one-byte over-read in `BASE64_DECODE_TABLE`. @itchyny #3547
## Documentation changes
- Add wiki link to navigation bar. @wader #3424
- Add missing word in manual for rawfile. @jpmens #3434
- Fix typo "stder" to "stderr". @jjatria #3446
- Fix buttons in tutorial to toggle labels when clicked on. @itchyny #3493
- Fix "happened" spelling in tutorial changelog entries. @Rohan5commit #3525
# 1.8.1
This is a patch release to fix security, performance, and build issues found in 1.8.0.
Full commit log can be found at <https://github.com/jqlang/jq/compare/jq-1.8.0...jq-1.8.1>.
## Security fixes
- CVE-2025-49014: Fix heap use after free in `f_strftime`, `f_strflocaltime`.
@wader 499c91bca9d4d027833bc62787d1bb075c03680e
- GHSA-f946-j5j2-4w5m: Fix stack overflow in `node_min_byte_len` of oniguruma.
@wader 5e159b34b179417e3e0404108190a2ac7d65611c
## CLI changes
- Fix assertion failure when syntax error happens at the end of the query. @itchyny #3350
## Changes to existing functions
- Fix portability of `strptime/1` especially for Windows. @itchyny #3342
## Language changes
- Revert the change of `reduce`/`foreach` state variable in 1.8.0 (#3205).
This change was reverted due to serious performance regression. @itchyny #3349
## Documentation changes
- Add LICENSE notice of NetBSD's `strptime()` to COPYING. @itchyny #3344
## Build improvements
- Fix build on old Mac with old sed. @qianbinbin #3336
# 1.8.0
We are pleased to announce the release of version 1.8.0.
This release includes a number of improvements since the last version.
Note that some changes may introduce breaking changes to existing scripts,
so be sure to read the following information carefully.
Full commit log can be found at <https://github.com/jqlang/jq/compare/jq-1.7.1...jq-1.8.0>.
## Releasing
- Change the version number pattern to `1.X.Y` (`1.8.0` instead of `1.8`). @itchyny #2999
- Generate provenance attestations for release artifacts and docker image. @lectrical #3225
```sh
gh attestation verify --repo jqlang/jq jq-linux-amd64
gh attestation verify --repo jqlang/jq oci://ghcr.io/jqlang/jq:1.8.0
```
## Security fixes
- CVE-2024-23337: Fix signed integer overflow in `jvp_array_write` and `jvp_object_rehash`.
@itchyny de21386681c0df0104a99d9d09db23a9b2a78b1e
- The fix for this issue now limits the maximum size of arrays and objects to 536870912 (`2^29`) elements.
- CVE-2024-53427: Reject NaN with payload while parsing JSON.
@itchyny a09a4dfd55e6c24d04b35062ccfe4509748b1dd3
- The fix for this issue now drops support for NaN with payload in JSON (like `NaN123`).
Other JSON extensions like `NaN` and `Infinity` are still supported.
- CVE-2025-48060: Fix heap buffer overflow in `jv_string_vfmt`.
@itchyny c6e041699d8cd31b97375a2596217aff2cfca85b
- Fix use of uninitialized value in `check_literal`. @itchyny #3324
- Fix segmentation fault on `strftime/1`, `strflocaltime/1`. @itchyny #3271
- Fix unhandled overflow in `@base64d`. @emanuele6 #3080
## CLI changes
- Fix `--indent 0` implicitly enabling `--compact-output`. @amarshall @gbrlmarn @itchyny #3232
```sh
$ jq --indent 0 . <<< '{ "foo": ["hello", "world"] }'
{
"foo": [
"hello",
"world"
]
}
# Previously, this implied --compact-output, but now outputs with new lines.
```
- Improve error messages to show problematic position in the filter. @itchyny #3292
```sh
$ jq -n '1 + $foo + 2'
jq: error: $foo is not defined at <top-level>, line 1, column 5:
1 + $foo + 2
^^^^
jq: 1 compile error
```
- Include column number in parser and compiler error messages. @liviubobocu #3257
- Fix error message for string literal beginning with single quote. @mattmeyers #2964
```sh
$ jq .foo <<< "{'foo':'bar'}"
jq: parse error: Invalid string literal; expected ", but got ' at line 1, column 7
# Previously, the error message was Invalid numeric literal at line 1, column 7.
```
- Improve `JQ_COLORS` environment variable to support larger escapes like truecolor. @SArpnt #3282
```sh
JQ_COLORS="38;2;255;173;173:38;2;255;214;165:38;2;253;255;182:38;2;202;255;191:38;2;155;246;255:38;2;160;196;255:38;2;189;178;255:38;2;255;198;255" jq -nc '[null,false,true,42,{"a":"bc"}]'
```
- Add `--library-path` long option for `-L`. @thaliaarchi #3194
- Fix `--slurp --stream` when input has no trailing newline character. @itchyny #3279
- Fix `--indent` option to error for malformed values. @thaliaarchi #3195
- Fix option parsing of `--binary` on non-Windows platforms. @calestyo #3131
- Fix issue with `~/.jq` on Windows where `$HOME` is not set. @kirkoman #3114
- Fix broken non-Latin output in the command help on Windows. @itchyny #3299
- Increase the maximum parsing depth for JSON to 10000. @itchyny #3328
- Parse short options in order given. @thaliaarchi #3194
- Consistently reset color formatting. @thaliaarchi #3034
## New functions
- Add `trim/0`, `ltrim/0` and `rtrim/0` to trim leading and trailing white spaces. @wader #3056
```sh
$ jq -n '" hello " | trim, ltrim, rtrim'
"hello"
"hello "
" hello"
```
- Add `trimstr/1` to trim string from both ends. @gbrlmarn #3319
```sh
$ jq -n '"foobarfoo" | trimstr("foo")'
"bar"
```
- Add `add/1`. Generator variant of `add/0`. @myaaaaaaaaa #3144
```sh
$ jq -c '.sum = add(.xs[])' <<< '{"xs":[1,2,3]}'
{"xs":[1,2,3],"sum":6}
```
- Add `skip/2` as the counterpart to `limit/2`. @itchyny #3181
```sh
$ jq -nc '[1,2,3,4,5] | [skip(2; .[])]'
[3,4,5]
```
- Add `toboolean/0` to convert strings to booleans. @brahmlower @itchyny #2098
```sh
$ jq -n '"true", "false" | toboolean'
true
false
```
- Add `@urid` format. Reverse of `@uri`. @fmgornick #3161
```sh
$ jq -Rr '@urid' <<< '%6a%71'
jq
```
## Changes to existing functions
- Use code point index for `indices/1`, `index/1` and `rindex/1`. @wader #3065
- This is a breaking change. Use `utf8bytelength/0` to get byte index.
- Improve `tonumber/0` performance and rejects numbers with leading or trailing
white spaces. @itchyny @thaliaarchi #3055 #3195
- This is a breaking change. Use `trim/0` to remove leading and trailing white spaces.
- Populate timezone data when formatting time. This fixes timezone name in
`strftime/1`, `strflocaltime/1` for DST. @marcin-serwin @sihde #3203 #3264 #3323
- Preserve numerical precision on unary negation, `abs/0`, `length/0`. @itchyny #3242 #3275
- Make `last(empty)` yield no output values like `first(empty)`. @itchyny #3179
- Make `ltrimstr/1` and `rtrimstr/1` error for non-string inputs. @emanuele6 #2969
- Make `limit/2` error for negative count. @itchyny #3181
- Fix `mktime/0` overflow and allow fewer elements in date-time representation array. @emanuele6 #3070 #3162
- Fix non-matched optional capture group. @wader #3238
- Provide `strptime/1` on all systems. @george-hopkins @fdellwing #3008 #3094
- Fix `_WIN32` port of `strptime`. @emanuele6 #3071
- Improve `bsearch/1` performance by implementing in C. @eloycoto #2945
- Improve `unique/0` and `unique_by/1` performance. @itchyny @emanuele6 #3254 #3304
- Fix error messages including long string literal not to break Unicode characters. @itchyny #3249
- Remove `pow10/0` as it has been deprecated in glibc 2.27. Use `exp10/0` instead. @itchyny #3059
- Remove private (and undocumented) `_nwise` filter. @itchyny #3260
## Language changes
- Fix precedence of binding syntax against unary and binary operators.
Also, allow some expressions as object values. @itchyny #3053 #3326
- This is a breaking change that may change the output of filters with binding syntax as follows.
```sh
$ jq -nc '[-1 as $x | 1,$x]'
[1,-1] # previously, [-1,-1]
$ jq -nc '1 | . + 2 as $x | -$x'
-3 # previously, -1
$ jq -nc '{x: 1 + 2, y: false or true, z: null // 3}'
{"x":3,"y":true,"z":3} # previously, syntax error
```
- Support Tcl-style multiline comments. @emanuele6 #2989
```sh
#!/bin/sh --
# Can be use to do shebang scripts.
# Next line will be seen as a comment be of the trailing backslash. \
exec jq ...
# this jq expression will result in [1]
[
1,
# \
2
]
```
- Fix `foreach` not to break init backtracking with `DUPN`. @kanwren #3266
```sh
$ jq -n '[1, 2] | foreach .[] as $x (0, 1; . + $x)'
1
3
2
4
```
- Fix `reduce`/`foreach` state variable should not be reset each iteration. @itchyny #3205
```sh
$ jq -n 'reduce range(5) as $x (0; .+$x | select($x!=2))'
8
$ jq -nc '[foreach range(5) as $x (0; .+$x | select($x!=2); [$x,.])]'
[[0,0],[1,1],[3,4],[4,8]]
```
- Support CRLF line breaks in filters. @itchyny #3274
- Improve performance of repeating strings. @itchyny #3272
## Documentation changes
- Switch the homepage to custom domain [jqlang.org](https://jqlang.org). @itchyny @owenthereal #3243
- Make latest release instead of development version the default manual. @wader #3130
- Add opengraph meta tags. @wader #3247
- Replace jqplay.org with play.jqlang.org @owenthereal #3265
- Add missing line from decNumber's licence to `COPYING`. @emanuele6 #3106
- Various document improvements. @tsibley #3322, @itchyny #3240, @jhcarl0814 #3239,
@01mf02 #3184, @thaliaarchi #3199, @NathanBaulch #3173, @cjlarose #3164,
@sheepster1 #3105, #3103, @kishoreinvits #3042, @jbrains #3035, @thalman #3033,
@SOF3 #3017, @wader #3015, @wllm-rbnt #3002
## Build improvements
- Fix build with GCC 15 (C23). @emanuele6 #3209
- Fix build with `-Woverlength-strings` @emanuele6 #3019
- Fix compiler warning `type-limits` in `found_string`. @itchyny #3263
- Fix compiler error in `jv_dtoa.c` and `builtin.c`. @UlrichEckhardt #3036
- Fix warning: a function definition without a prototype is deprecated. @itchyny #3259
- Define `_BSD_SOURCE` in `builtin.c` for OpenBSD support. @itchyny #3278
- Define empty `JV_{,V}PRINTF_LIKE` macros if `__GNUC__` is not defined. @emanuele6 #3160
- Avoid `ctype.h` abuse: cast `char` to `unsigned char` first. @riastradh #3152
- Remove multiple calls to free when successively calling `jq_reset`. @Sameesunkaria #3134
- Enable IBM z/OS support. @sachintu47 #3277
- Fix insecure `RUNPATH`. @orbea #3212
- Avoid zero-length `calloc`. @itchyny #3280
- Move oniguruma and decNumber to vendor directory. @itchyny #3234
## Test improvements
- Run tests in C locale. @emanuele6 #3039
- Improve reliability of `NO_COLOR` tests. @dag-erling #3188
- Improve `shtest` not to fail if `JQ_COLORS` and `NO_COLOR` are already set. @SArpnt #3283
- Refactor constant folding tests. @itchyny #3233
- Make tests pass when `--disable-decnum`. @nicowilliams 6d02d53f515bf1314d644eee93ba30b0d11c7d2b
- Disable Valgrind by default during testing. @itchyny #3269
# 1.7.1
## Security
- CVE-2023-50246: Fix heap buffer overflow in jvp\_literal\_number\_literal
- CVE-2023-50268: fix stack-buffer-overflow if comparing nan with payload
## CLI changes
- Make the default background color more suitable for bright backgrounds. @mjarosie @taoky @nicowilliams @itchyny #2904
- Allow passing the inline jq script after `--`. @emanuele6 #2919
- Restrict systems operations on OpenBSD and remove unused `mkstemp`. @klemensn #2934
- Fix possible uninitialised value dereference if `jq_init()` fails. @emanuele6 @nicowilliams #2935
## Language changes
- Simplify `paths/0` and `paths/1`. @asheiduk @emanuele6 #2946
- Reject `U+001F` in string literals. @torsten-schenk @itchyny @wader #2911
- Remove unused nref accumulator in `block_bind_library`. @emanuele6 #2914
- Remove a bunch of unused variables, and useless assignments. @emanuele6 #2914
- main.c: Remove unused EXIT\_STATUS\_EXACT option. @emanuele6 #2915
- Actually use the number correctly casted from double to int as index. @emanuele6 #2916
- src/builtin.c: remove unnecessary jv\_copy-s in type\_error/type\_error2. @emanuele6 #2937
- Remove undefined behavior caught by LLVM 10 UBSAN. @Gaelan @emanuele6 #2926
- Convert decnum to binary64 (double) instead of decimal64. This makes jq behave like the JSON specification suggests and more similar to other languages. @wader @leonid-s-usov #2949
- Fix memory leaks on invalid input for `ltrimstr/1` and `rtrimstr/1`. @emanuele6 #2977
- Fix memory leak on failed get for `setpath/2`. @emanuele6 #2970
- Fix nan from json parsing also for nans with payload that start with 'n'. @emanuele6 #2985
- Allow carriage return characters in comments. @emanuele6 #2942 #2984
## Documentation changes
- Generate links in the man page. @emanuele6 #2931
- Standardize arch types to AMD64 & ARM64 from index page download dropdown. @owenthereal #2884
## libjq
- Add extern C for C++. @rockwotj #2953
## Build and test changes
- Fix incorrect syntax for checksum file. @kamontat @wader #2899
- Remove `-dirty` version suffix for windows release build. @itchyny #2888
- Make use of `od` in tests more compatible. @nabijaczleweli @emanuele6 @nicowilliams #2922
- Add dependabot. @yeikel #2889
- Extend fuzzing setup to fuzz parser and JSON serializer. @DavidKorczynski @emanuele6 #2952
- Keep releasing executables with legacy names. @itchyny #2951
# 1.7
After a five year hiatus we're back with a GitHub organization, with new admins and new maintainers who have brought a great deal of energy to make a long-awaited and long-needed new release. We're very grateful for all the new owners, admins, and maintainers. Special thanks go to Owen Ou (@owenthereal) for pushing to set up a new GitHub organization for jq, Stephen Dolan (@stedolan) for transferring the jq repository to the new organization, @itchyny for doing a great deal of work to get the release done, Mattias Wadman (@wader) and Emanuele Torre (@emanuele6) for many PRs and code reviews. Many others also contributed PRs, issues, and code reviews as well, and you can find their contributions in the Git log and on the [closed issues and PRs page](https://github.com/jqlang/jq/issues?q=is%3Aclosed+sort%3Aupdated-desc).
Since the last stable release many things have happened:
- jq now lives at <https://github.com/jqlang>
- New maintainers, admins, and owners have been recruited.
- A list of [current maintainers](https://github.com/jqlang/jq/blob/jq-1.7/AUTHORS#L4-L14)
- NEWS file is replaced by NEWS.md with Markdown format. @wader #2599
- CI, scan builds, release, website builds etc now use GitHub actions. @owenthereal @wader @itchyny #2596 #2603 #2620 #2723
- Lots of documentation improvements and fixes.
- Website updated with new section search box, better section ids for linking, dark mode, etc. @itchyny #2628
- Release builds for:
- Linux `amd64`, `arm64`, `armel`, `armhf`, `i386`, `mips`, `mips64`, `mips64el`, `mips64r6`, `mips64r6el`, `mipsel`, `mipsr6`, `mipsr6el`, `powerpc`, `ppc64el`, `riscv64` and `s390x`
- macOS `amd64` and `arm64`
- Windows `i386` and `amd64`
- Docker `linux/386`, `linux/amd64`, `linux/arm64`, `linux/mips64le`, `linux/ppc64le`, `linux/riscv64` and `linux/s390x`
- More details see @owenthereal #2665
- Docker images are now available from `ghcr.io/jqlang/jq` instead of Docker Hub. @itchyny #2652 #2686
- OSS-fuzz. @DavidKorczynski #2760 #2762
Full commit log can be found at <https://github.com/jqlang/jq/compare/jq-1.6...jq-1.7> but here are some highlights:
## CLI changes
- Make object key color configurable using `JQ_COLORS` environment variable. @itchyny @haguenau @ericpruitt #2703
```sh
# this would make "field" bold yellow (`1;33`, the last value)
$ JQ_COLORS="0;90:0;37:0;37:0;37:0;32:1;37:1;37:1;33" ./jq -n '{field: 123}'
{
"field": 123
}
```
- Change the default color of null to Bright Black. @itchyny #2824
- Respect `NO_COLOR` environment variable to disable color output. See <https://no-color.org> for details. @itchyny #2728
- Improved `--help` output. Now mentions all options and nicer order. @itchyny @wader #2747 #2766 #2799
- Fix multiple issues of exit code using `--exit-code`/`-e` option. @ryo1kato #1697
```sh
# true-ish last output value exits with zero
$ jq -ne true ; echo $?
true
0
# false-ish last output value (false and null) exits with 1
$ jq -ne false ; echo $?
false
1
# no output value exists with 4
$ jq -ne empty ; echo $?
4
```
- Add `--binary`/`-b` on Windows for binary output. To get `\n` instead of `\r\n` line endings. @nicowilliams 0dab2b1
- Add `--raw-output0` for NUL (zero byte) separated output. @asottile @pabs3 @itchyny #1990 #2235 #2684
```sh
# will output a zero byte after each output
$ jq -n --raw-output0 '1,2,3' | xxd
00000000: 3100 3200 3300 1.2.3.
# can be used with xargs -0
$ jq -n --raw-output0 '"a","b","c"' | xargs -0 -n1
a
b
c
$ jq -n --raw-output0 '"a b c", "d\ne\nf"' | xargs -0 printf '[%s]\n'
[a b c]
[d
e
f]
# can be used with read -d ''
$ while IFS= read -r -d '' json; do
> jq '.name' <<< "$json"
> done < <(jq -n --raw-output0 '{name:"a b c"},{name:"d\ne\nf"}')
"a b c"
"d\ne\nf"
# also it's an error to output a string containing a NUL when using NUL separator
$ jq -n --raw-output0 '"\u0000"'
jq: error (at <unknown>): Cannot dump a string containing NUL with --raw-output0 option
```
- Fix assert crash and validate JSON for `--jsonarg`. @wader #2658
- Remove deprecated `--argfile` option. @itchyny #2768
- Enable stack protection. @nicowilliams #2801
## Language changes
- Use decimal number literals to preserve precision. Comparison operations respects precision but arithmetic operations might truncate. @leonid-s-usov #1752
```sh
# precision is preserved
$ echo '100000000000000000' | jq .
100000000000000000
# comparison respects precision (this is false in JavaScript)
$ jq -n '100000000000000000 < 100000000000000001'
true
# sort/0 works
$ jq -n -c '[100000000000000001, 100000000000000003, 100000000000000004, 100000000000000002] | sort'
[100000000000000001,100000000000000002,100000000000000003,100000000000000004]
# arithmetic operations might truncate (same as JavaScript)
$ jq -n '100000000000000000 + 10'
100000000000000020
```
- Adds new builtin `pick(stream)` to emit a projection of the input object or array. @pkoppstein #2656 #2779
```sh
$ jq -n '{"a": 1, "b": {"c": 2, "d": 3}, "e": 4} | pick(.a, .b.c, .x)'
{
"a": 1,
"b": {
"c": 2
},
"x": null
}
```
- Adds new builtin `debug(msgs)` that works like `debug` but applies a filter on the input before writing to stderr. @pkoppstein #2710
```sh
$ jq -n '1 as $x | 2 | debug("Entering function foo with $x == \($x)", .) | (.+1)'
["DEBUG:","Entering function foo with $x == 1"]
["DEBUG:",2]
3
$ jq -n '{a: 1, b: 2, c: 3} | debug({a, b, sum: (.a+.b)})'
["DEBUG:",{"a":1,"b":2,"sum":3}]
{
"a": 1,
"b": 2,
"c": 3
}
```
- Adds new builtin `scan($re; $flags)`. Was documented but not implemented. @itchyny #1961
```sh
# look for pattern "ab" in "abAB" ignoring casing
$ jq -n '"abAB" | scan("ab"; "i")'
"ab"
"AB"
```
- Adds new builtin `abs` to get absolute value. This potentially allows the literal value of numbers to be preserved as `length` and `fabs` convert to float. @pkoppstein #2767
- Allow `if` without `else`-branch. When skipped the `else`-branch will be `.` (identity). @chancez @wader #1825 #2481
```sh
# convert 1 to "one" otherwise keep as is
$ jq -n '1,2 | if . == 1 then "one" end'
"one"
2
# behaves the same as
$ jq -n '1,2 | if . == 1 then "one" else . end'
"one"
2
# also works with elif
$ jq -n '1,2,3 | if . == 1 then "one" elif . == 2 then "two" end
"one"
"two"
3
```
- Allow use of `$binding` as key in object literals. @nicowilliams 8ea4a55
```sh
$ jq -n '"a" as $key | {$key: 123}'
{
"a": 123
}
# previously parentheses were needed
$ jq -n '"a" as $key | {($key): 123}'
{
"a": 123
}
```
- Allow dot between chained indexes when using `.["index"]` @nicowilliams #1168
```sh
$ jq -n '{"a": {"b": 123}} | .a["b"]'
123
# now this also works
$ jq -n '{"a": {"b": 123}} | .a.["b"]'
123
```
- Allow dot for chained value iterator `.[]`, `.[]?` @wader #2650
```sh
$ jq -n '{"a": [123]} | .a[]'
123
# now this also works
$ jq -n '{"a": [123]} | .a.[]'
123
```
- Fix try/catch catches more than it should. @nicowilliams #2750
- Speed up and refactor some builtins, also remove `scalars_or_empty/0`. @muhmuhten #1845
- Now `halt` and `halt_error` exit immediately instead of continuing to the next input. @emanuele6 #2667
- Fix issue converting string to number after previous convert error. @thalman #2400
- Fix issue representing large numbers on some platforms causing invalid JSON output. @itchyny #2661
- Fix deletion using assigning empty against arrays. @itchyny #2133
```sh
# now this works as expected, filter out all values over 2 by assigning empty
$ jq -c '(.[] | select(. >= 2)) |= empty' <<< '[1,5,3,0,7]'
[1,0]
```
- Allow keywords to be used as binding name in more places. @emanuele6 #2681
- Allow using `nan` as NaN in JSON. @emanuele6 #2712
- Expose a module's function names in `modulemeta`. @mrwilson #2837
- Fix `contains/1` to handle strings with NUL. @nicowilliams 61cd6db
- Fix `stderr/0` to output raw text without any decoration. @itchyny #2751
- Fix `nth/2` to emit empty on index out of range. @itchyny #2674
- Fix `implode` to not assert and instead replace invalid Unicode codepoints. @wader #2646
- Fix `indices/1` and `rindex/1` in case of overlapping matches in strings. @emanuele6 #2718
- Fix `sub/3` to resolve issues involving global search-and-replace (gsub) operations. @pkoppstein #2641
- Fix `significand/0`, `gamma/0` and `drem/2` to be available on macOS. @itchyny #2756 #2775
- Fix empty regular expression matches. @itchyny #2677
- Fix overflow exception of the modulo operator. @itchyny #2629
- Fix string multiplication by 0 (and less than 1) to emit empty string. @itchyny #2142
- Fix segfault when using libjq and threads. @thalman #2546
- Fix constant folding of division and reminder with zero divisor. @itchyny #2797
- Fix `error/0`, `error/1` to throw null error. @emanuele6 #2823
- Simpler and faster `transpose`. @pkoppstein #2758
- Simple and efficient implementation of `walk/1`. @pkoppstein #2795
- Remove deprecated filters `leaf_paths`, `recurse_down`. @itchyny #2666
# Previous releases
Release history
- jq version 1.6 was released on Fri Nov 2 2018
- jq version 1.5 was released on Sat Aug 15 2015
- jq version 1.4 was released on Mon Jun 9 2014
- jq version 1.3 was released on Sun May 19 2013
- jq version 1.2 was released on Thu Dec 20 2012
- jq version 1.1 was released on Sun Oct 21 2012
- jq version 1.0 was released on Sun Oct 21 2012
New features in 1.6 since 1.5:
- Destructuring Alternation
- New Builtins:
- builtins/0
- stderr/0
- halt/0, halt_error/1
- isempty/1
- walk/1
- utf8bytelength/1
- localtime/0, strflocaltime/1
- SQL-style builtins
- and more!
- Add support for ASAN and UBSAN
- Make it easier to use jq with shebangs (8f6f28c)
- Add $ENV builtin variable to access environment
- Add JQ_COLORS env var for configuring the output colors
New features in 1.5 since 1.4:
- regular expressions (with Oniguruma)
- a library/module system
- many new builtins
- datetime builtins
- math builtins
- regexp-related builtins
- stream-related builtins (e.g., all/1, any/1)
- minimal I/O builtins (`inputs`, `debug`)
- new syntactic features, including:
- destructuring (`. as [$first, $second] | ...`)
- try/catch, generalized `?` operator, and label/break
- `foreach`
- multiple definitions of a function with different numbers of
arguments
- command-line arguments
- --join-lines / -j for raw output
- --argjson and --slurpfile
- --tab and --indent
- --stream (streaming JSON parser)
- --seq (RFC7464 JSON text sequence)
- --run-tests improvements
- optimizations:
- tail-call optimization
- reduce and foreach no longer leak a reference to .
New features in 1.4 since 1.3:
- command-line arguments
- jq --arg-file variable file
- jq --unbuffered
- jq -e / --exit-status (set exit status based on outputs)
- jq -S / --sort-keys (now jq no longer sorts object keys by
default
- syntax
- .. -> like // in XPath (recursive traversal)
- question mark (e.g., .a?) to suppress errors
- ."foo" syntax (equivalent to .["foo"])
- better error handling for .foo
- added % operator (modulo)
- allow negation without requiring extra parenthesis
- more function arguments (up to six)
- filters:
- any, all
- iterables, arrays, objects, scalars, nulls, booleans, numbers,
strings, values
- string built-ins:
- split
- join (join an array of strings with a given separator string)
- ltrimstr, rtrimstr
- startswith, endswith
- explode, implode
- fromjson, tojson
- index, rindex, indices
- math functions
- floor, sqrt, cbrt, etcetera (depends on what's available from libm)
- libjq -- a C API interface to jq's JSON representation and for
running jq programs from C applications
-1
View File
@@ -1 +0,0 @@
README.md
+75 -16
View File
@@ -1,23 +1,82 @@
jq
==
# jq
jq is a command-line JSON processor.
`jq` is a lightweight and flexible command-line JSON processor akin to `sed`,`awk`,`grep`, and friends for JSON data. It's written in portable C and has zero runtime dependencies, allowing you to easily slice, filter, map, and transform structured data.
If you want to learn to use jq, read the documentation at
[http://stedolan.github.com/jq](http://stedolan.github.com/jq). This
documentation is generated from the docs/ folder of this repository.
## Documentation
If you want to hack on jq, feel free, but be warned that its internals
are not well-documented at the moment. Bring a hard hat and a
shovel. Also, read the wiki: http://github.com/stedolan/jq/wiki
- **Official Documentation**: [jqlang.org](https://jqlang.org)
- **Try jq Online**: [play.jqlang.org](https://play.jqlang.org)
To build jq, run
## Installation
./configure
make
sudo make install (optionally)
### Prebuilt Binaries
If you've just checked out the latest version from git (rather than
using a released source tarball) then you'll need to run this first:
Download the latest releases from the [GitHub release page](https://github.com/jqlang/jq/releases).
The platform-specific assets are standalone executables, not archives. On macOS and Linux,
rename the downloaded file to `jq` and make it executable with `chmod +x jq`.
autoreconf
### Docker Image
Pull the [jq image](https://github.com/jqlang/jq/pkgs/container/jq) to start quickly with Docker.
#### Run with Docker
##### Example: Extracting the version from a `package.json` file
```bash
docker run --rm -i ghcr.io/jqlang/jq:latest < package.json '.version'
```
##### Example: Extracting the version from a `package.json` file with a mounted volume
```bash
docker run --rm -i -v "$PWD:$PWD" -w "$PWD" ghcr.io/jqlang/jq:latest '.version' package.json
```
### Building from source
#### Dependencies
- libtool
- make
- automake
- autoconf
#### Instructions
```console
git submodule update --init # if building from git to get oniguruma
autoreconf -i # if building from git
./configure --with-oniguruma=builtin
make clean # if upgrading from a version previously built from source
make -j8
make check
sudo make install
sudo ldconfig # on Linux, if jq cannot find libjq.so
```
Build a statically linked version:
```console
make clean
make LDFLAGS=-all-static
```
If you're not using the latest git version but instead building a released tarball (available on the release page), skip the `autoreconf` step, and flex or bison won't be needed.
##### Cross-Compilation
For details on cross-compilation, check out the [GitHub Actions file](.github/workflows/ci.yml) and the [cross-compilation wiki page](https://github.com/jqlang/jq/wiki/Cross-compilation).
## Community & Support
- Questions & Help: [Stack Overflow (jq tag)](https://stackoverflow.com/questions/tagged/jq)
- Chat & Community: [Join us on Discord](https://discord.gg/yg6yjNmgAC)
- Wiki & Advanced Topics: [Explore the Wiki](https://github.com/jqlang/jq/wiki)
## License
`jq` is released under the [MIT License](COPYING). `jq`'s documentation is
licensed under the [Creative Commons CC BY 3.0](COPYING).
`jq` uses parts of the open source C library "decNumber", which is distributed
under [ICU License](COPYING)
+7
View File
@@ -0,0 +1,7 @@
# How to report security vulnerabilities in `jq`
GitHub has a [mechanism for private disclosure of vulnerabilities](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability) to repository owners and authorized persons such as maintainers. The `jqlang/jq` repository now has this feature enabled.
## Reporting a Vulnerability
See [Privately Reporting a Security Vulnerability](https://docs.github.com/en/code-security/security-advisories/guidance-on-reporting-and-writing/privately-reporting-a-security-vulnerability). Click on [`jqlang/jq`](https://github.com/jqlang/jq)'s [Security page](https://github.com/jqlang/jq/security) and click on [Report a vulnerability](https://github.com/jqlang/jq/security/advisories/new). This will notify the owners and maintainers. After submitting you'll get an option to start a private clone of `jqlang/jq` for collaboration with the maintainers.
-581
View File
@@ -1,581 +0,0 @@
#include <string.h>
#include "builtin.h"
#include "compile.h"
#include "jq_parser.h"
#include "locfile.h"
#include "jv_aux.h"
#include "jv_unicode.h"
typedef jv (*func_1)(jv);
typedef jv (*func_2)(jv,jv);
typedef jv (*func_3)(jv,jv,jv);
typedef jv (*func_4)(jv,jv,jv,jv);
typedef jv (*func_5)(jv,jv,jv,jv,jv);
jv cfunction_invoke(struct cfunction* function, jv input[]) {
switch (function->nargs) {
case 1: return ((func_1)function->fptr)(input[0]);
case 2: return ((func_2)function->fptr)(input[0], input[1]);
case 3: return ((func_3)function->fptr)(input[0], input[1], input[2]);
case 4: return ((func_4)function->fptr)(input[0], input[1], input[2], input[3]);
case 5: return ((func_5)function->fptr)(input[0], input[1], input[2], input[3], input[4]);
default: return jv_invalid_with_msg(jv_string("Function takes too many arguments"));
}
}
static jv type_error(jv bad, const char* msg) {
jv err = jv_invalid_with_msg(jv_string_fmt("%s %s",
jv_kind_name(jv_get_kind(bad)),
msg));
jv_free(bad);
return err;
}
static jv type_error2(jv bad1, jv bad2, const char* msg) {
jv err = jv_invalid_with_msg(jv_string_fmt("%s and %s %s",
jv_kind_name(jv_get_kind(bad1)),
jv_kind_name(jv_get_kind(bad2)),
msg));
jv_free(bad1);
jv_free(bad2);
return err;
}
static jv f_plus(jv input, jv a, jv b) {
jv_free(input);
if (jv_get_kind(a) == JV_KIND_NULL) {
jv_free(a);
return b;
} else if (jv_get_kind(b) == JV_KIND_NULL) {
jv_free(b);
return a;
} else if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
return jv_number(jv_number_value(a) +
jv_number_value(b));
} else if (jv_get_kind(a) == JV_KIND_STRING && jv_get_kind(b) == JV_KIND_STRING) {
return jv_string_concat(a, b);
} else if (jv_get_kind(a) == JV_KIND_ARRAY && jv_get_kind(b) == JV_KIND_ARRAY) {
return jv_array_concat(a, b);
} else if (jv_get_kind(a) == JV_KIND_OBJECT && jv_get_kind(b) == JV_KIND_OBJECT) {
return jv_object_merge(a, b);
} else {
return type_error2(a, b, "cannot be added");
}
}
static jv f_negate(jv input) {
if (jv_get_kind(input) != JV_KIND_NUMBER) {
return type_error(input, "cannot be negated");
}
jv ret = jv_number(-jv_number_value(input));
jv_free(input);
return ret;
}
static jv f_minus(jv input, jv a, jv b) {
jv_free(input);
if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
return jv_number(jv_number_value(a) - jv_number_value(b));
} else if (jv_get_kind(a) == JV_KIND_ARRAY && jv_get_kind(b) == JV_KIND_ARRAY) {
jv out = jv_array();
jv_array_foreach(a, i, x) {
int include = 1;
jv_array_foreach(b, j, y) {
if (jv_equal(jv_copy(x), y)) {
include = 0;
break;
}
}
if (include)
out = jv_array_append(out, jv_copy(x));
jv_free(x);
}
jv_free(a);
jv_free(b);
return out;
} else {
return type_error2(a, b, "cannot be subtracted");
}
}
static jv f_multiply(jv input, jv a, jv b) {
jv_free(input);
if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
return jv_number(jv_number_value(a) * jv_number_value(b));
} else {
return type_error2(a, b, "cannot be multiplied");
}
}
static jv f_divide(jv input, jv a, jv b) {
jv_free(input);
if (jv_get_kind(a) == JV_KIND_NUMBER && jv_get_kind(b) == JV_KIND_NUMBER) {
return jv_number(jv_number_value(a) / jv_number_value(b));
} else {
return type_error2(a, b, "cannot be divided");
}
}
static jv f_equal(jv input, jv a, jv b) {
jv_free(input);
return jv_bool(jv_equal(a, b));
}
static jv f_notequal(jv input, jv a, jv b) {
jv_free(input);
return jv_bool(!jv_equal(a, b));
}
enum cmp_op {
CMP_OP_LESS,
CMP_OP_GREATER,
CMP_OP_LESSEQ,
CMP_OP_GREATEREQ
};
static jv order_cmp(jv input, jv a, jv b, enum cmp_op op) {
jv_free(input);
int r = jv_cmp(a, b);
return jv_bool((op == CMP_OP_LESS && r < 0) ||
(op == CMP_OP_LESSEQ && r <= 0) ||
(op == CMP_OP_GREATEREQ && r >= 0) ||
(op == CMP_OP_GREATER && r > 0));
}
static jv f_less(jv input, jv a, jv b) {
return order_cmp(input, a, b, CMP_OP_LESS);
}
static jv f_greater(jv input, jv a, jv b) {
return order_cmp(input, a, b, CMP_OP_GREATER);
}
static jv f_lesseq(jv input, jv a, jv b) {
return order_cmp(input, a, b, CMP_OP_LESSEQ);
}
static jv f_greatereq(jv input, jv a, jv b) {
return order_cmp(input, a, b, CMP_OP_GREATEREQ);
}
static jv f_contains(jv a, jv b) {
if (jv_get_kind(a) == jv_get_kind(b)) {
return jv_bool(jv_contains(a, b));
} else {
return type_error2(a, b, "cannot have their containment checked");
}
}
static jv f_tonumber(jv input) {
if (jv_get_kind(input) == JV_KIND_NUMBER) {
return input;
}
if (jv_get_kind(input) == JV_KIND_STRING) {
jv parsed = jv_parse(jv_string_value(input));
if (!jv_is_valid(parsed) || jv_get_kind(parsed) == JV_KIND_NUMBER) {
jv_free(input);
return parsed;
}
}
return type_error(input, "cannot be parsed as a number");
}
static jv f_length(jv input) {
if (jv_get_kind(input) == JV_KIND_ARRAY) {
return jv_number(jv_array_length(input));
} else if (jv_get_kind(input) == JV_KIND_OBJECT) {
return jv_number(jv_object_length(input));
} else if (jv_get_kind(input) == JV_KIND_STRING) {
return jv_number(jv_string_length_codepoints(input));
} else if (jv_get_kind(input) == JV_KIND_NULL) {
jv_free(input);
return jv_number(0);
} else {
return type_error(input, "has no length");
}
}
static jv f_tostring(jv input) {
if (jv_get_kind(input) == JV_KIND_STRING) {
return input;
} else {
return jv_dump_string(input, 0);
}
}
#define CHARS_ALPHANUM "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
static jv escape_string(jv input, const char* escapings) {
assert(jv_get_kind(input) == JV_KIND_STRING);
const char* lookup[128] = {0};
const char* p = escapings;
while (*p) {
lookup[(int)*p] = p+1;
p++;
p += strlen(p);
p++;
}
jv ret = jv_string("");
const char* i = jv_string_value(input);
const char* end = i + jv_string_length_bytes(jv_copy(input));
const char* cstart;
int c = 0;
while ((i = jvp_utf8_next((cstart = i), end, &c))) {
assert(c != -1);
if (c < 128 && lookup[c]) {
ret = jv_string_append_str(ret, lookup[c]);
} else {
ret = jv_string_append_buf(ret, cstart, i - cstart);
}
}
jv_free(input);
return ret;
}
static jv f_format(jv input, jv fmt) {
if (jv_get_kind(fmt) != JV_KIND_STRING) {
jv_free(input);
return type_error(fmt, "is not a valid format");
}
const char* fmt_s = jv_string_value(fmt);
if (!strcmp(fmt_s, "json")) {
jv_free(fmt);
return jv_dump_string(input, 0);
} else if (!strcmp(fmt_s, "text")) {
jv_free(fmt);
return f_tostring(input);
} else if (!strcmp(fmt_s, "csv")) {
jv_free(fmt);
if (jv_get_kind(input) != JV_KIND_ARRAY)
return type_error(input, "cannot be csv-formatted, only array");
jv line = jv_string("");
jv_array_foreach(input, i, x) {
if (i) line = jv_string_append_str(line, ",");
switch (jv_get_kind(x)) {
case JV_KIND_NULL:
/* null rendered as empty string */
jv_free(x);
break;
case JV_KIND_TRUE:
case JV_KIND_FALSE:
line = jv_string_concat(line, jv_dump_string(x, 0));
break;
case JV_KIND_NUMBER:
if (jv_number_value(x) != jv_number_value(x)) {
/* NaN, render as empty string */
jv_free(x);
} else {
line = jv_string_concat(line, jv_dump_string(x, 0));
}
break;
case JV_KIND_STRING: {
line = jv_string_append_str(line, "\"");
line = jv_string_concat(line, escape_string(x, "\"\"\"\0"));
line = jv_string_append_str(line, "\"");
break;
}
default:
jv_free(input);
jv_free(line);
return type_error(x, "is not valid in a csv row");
}
}
jv_free(input);
return line;
} else if (!strcmp(fmt_s, "html")) {
jv_free(fmt);
return escape_string(f_tostring(input), "&&amp;\0<&lt;\0>&gt;\0'&apos;\0\"&quot;\0");
} else if (!strcmp(fmt_s, "uri")) {
jv_free(fmt);
input = f_tostring(input);
int unreserved[128] = {0};
const char* p = CHARS_ALPHANUM "-_.!~*'()";
while (*p) unreserved[(int)*p++] = 1;
jv line = jv_string("");
const char* s = jv_string_value(input);
for (int i=0; i<jv_string_length_bytes(jv_copy(input)); i++) {
unsigned ch = (unsigned)(unsigned char)*s;
if (ch < 128 && unreserved[ch]) {
line = jv_string_append_buf(line, s, 1);
} else {
line = jv_string_concat(line, jv_string_fmt("%%%02x", ch));
}
s++;
}
jv_free(input);
return line;
} else if (!strcmp(fmt_s, "sh")) {
jv_free(fmt);
if (jv_get_kind(input) != JV_KIND_ARRAY)
input = jv_array_set(jv_array(), 0, input);
jv line = jv_string("");
jv_array_foreach(input, i, x) {
if (i) line = jv_string_append_str(line, " ");
switch (jv_get_kind(x)) {
case JV_KIND_NULL:
case JV_KIND_TRUE:
case JV_KIND_FALSE:
case JV_KIND_NUMBER:
line = jv_string_concat(line, jv_dump_string(x, 0));
break;
case JV_KIND_STRING: {
line = jv_string_append_str(line, "'");
line = jv_string_concat(line, escape_string(x, "''\\''\0"));
line = jv_string_append_str(line, "'");
break;
}
default:
jv_free(input);
jv_free(line);
return type_error(x, "can not be escaped for shell");
}
}
jv_free(input);
return line;
} else if (!strcmp(fmt_s, "base64")) {
jv_free(fmt);
input = f_tostring(input);
jv line = jv_string("");
const char b64[64 + 1] = CHARS_ALPHANUM "+/";
const char* data = jv_string_value(input);
int len = jv_string_length_bytes(jv_copy(input));
for (int i=0; i<len; i+=3) {
uint32_t code = 0;
int n = len - i >= 3 ? 3 : len-i;
for (int j=0; j<3; j++) {
code <<= 8;
code |= j < n ? (unsigned)data[i+j] : 0;
}
char buf[4];
for (int j=0; j<4; j++) {
buf[j] = b64[(code >> (18 - j*6)) & 0x3f];
}
if (n < 3) buf[3] = '=';
if (n < 2) buf[2] = '=';
line = jv_string_append_buf(line, buf, sizeof(buf));
}
jv_free(input);
return line;
} else {
jv_free(input);
return jv_invalid_with_msg(jv_string_concat(fmt, jv_string(" is not a valid format")));
}
}
static jv f_keys(jv input) {
if (jv_get_kind(input) == JV_KIND_OBJECT || jv_get_kind(input) == JV_KIND_ARRAY) {
return jv_keys(input);
} else {
return type_error(input, "has no keys");
}
}
static jv f_sort(jv input){
if (jv_get_kind(input) == JV_KIND_ARRAY) {
return jv_sort(input, jv_copy(input));
} else {
return type_error(input, "cannot be sorted, as it is not an array");
}
}
static jv f_sort_by_impl(jv input, jv keys) {
if (jv_get_kind(input) == JV_KIND_ARRAY &&
jv_get_kind(keys) == JV_KIND_ARRAY &&
jv_array_length(jv_copy(input)) == jv_array_length(jv_copy(keys))) {
return jv_sort(input, keys);
} else {
return type_error2(input, keys, "cannot be sorted, as they are not both arrays");
}
}
static jv f_group_by_impl(jv input, jv keys) {
if (jv_get_kind(input) == JV_KIND_ARRAY &&
jv_get_kind(keys) == JV_KIND_ARRAY &&
jv_array_length(jv_copy(input)) == jv_array_length(jv_copy(keys))) {
return jv_group(input, keys);
} else {
return type_error2(input, keys, "cannot be sorted, as they are not both arrays");
}
}
static jv minmax_by(jv values, jv keys, int is_min) {
if (jv_get_kind(values) != JV_KIND_ARRAY)
return type_error2(values, keys, "cannot be iterated over");
if (jv_get_kind(keys) != JV_KIND_ARRAY)
return type_error2(values, keys, "cannot be iterated over");
if (jv_array_length(jv_copy(values)) != jv_array_length(jv_copy(keys)))
return type_error2(values, keys, "have wrong length");
if (jv_array_length(jv_copy(values)) == 0) {
jv_free(values);
jv_free(keys);
return jv_null();
}
jv ret = jv_array_get(jv_copy(values), 0);
jv retkey = jv_array_get(jv_copy(keys), 0);
for (int i=1; i<jv_array_length(jv_copy(values)); i++) {
jv item = jv_array_get(jv_copy(keys), i);
int cmp = jv_cmp(jv_copy(item), jv_copy(retkey));
if ((cmp < 0) == (is_min == 1)) {
jv_free(retkey);
retkey = item;
jv_free(ret);
ret = jv_array_get(jv_copy(values), i);
} else {
jv_free(item);
}
}
jv_free(values);
jv_free(keys);
jv_free(retkey);
return ret;
}
static jv f_min(jv x) {
return minmax_by(x, jv_copy(x), 1);
}
static jv f_max(jv x) {
return minmax_by(x, jv_copy(x), 0);
}
static jv f_min_by_impl(jv x, jv y) {
return minmax_by(x, y, 1);
}
static jv f_max_by_impl(jv x, jv y) {
return minmax_by(x, y, 0);
}
static jv f_type(jv input) {
jv out = jv_string(jv_kind_name(jv_get_kind(input)));
jv_free(input);
return out;
}
static jv f_error(jv input, jv msg) {
jv_free(input);
msg = f_tostring(msg);
return jv_invalid_with_msg(msg);
}
static const struct cfunction function_list[] = {
{(cfunction_ptr)f_plus, "_plus", 3},
{(cfunction_ptr)f_negate, "_negate", 1},
{(cfunction_ptr)f_minus, "_minus", 3},
{(cfunction_ptr)f_multiply, "_multiply", 3},
{(cfunction_ptr)f_divide, "_divide", 3},
{(cfunction_ptr)f_tonumber, "tonumber", 1},
{(cfunction_ptr)f_tostring, "tostring", 1},
{(cfunction_ptr)f_keys, "keys", 1},
{(cfunction_ptr)jv_setpath, "setpath", 3}, // FIXME typechecking
{(cfunction_ptr)jv_getpath, "getpath", 2},
{(cfunction_ptr)jv_delpaths, "delpaths", 2},
{(cfunction_ptr)jv_has, "has", 2},
{(cfunction_ptr)f_equal, "_equal", 3},
{(cfunction_ptr)f_notequal, "_notequal", 3},
{(cfunction_ptr)f_less, "_less", 3},
{(cfunction_ptr)f_greater, "_greater", 3},
{(cfunction_ptr)f_lesseq, "_lesseq", 3},
{(cfunction_ptr)f_greatereq, "_greatereq", 3},
{(cfunction_ptr)f_contains, "contains", 2},
{(cfunction_ptr)f_length, "length", 1},
{(cfunction_ptr)f_type, "type", 1},
{(cfunction_ptr)f_sort, "sort", 1},
{(cfunction_ptr)f_sort_by_impl, "_sort_by_impl", 2},
{(cfunction_ptr)f_group_by_impl, "_group_by_impl", 2},
{(cfunction_ptr)f_min, "min", 1},
{(cfunction_ptr)f_max, "max", 1},
{(cfunction_ptr)f_min_by_impl, "_min_by_impl", 2},
{(cfunction_ptr)f_max_by_impl, "_max_by_impl", 2},
{(cfunction_ptr)f_error, "error", 2},
{(cfunction_ptr)f_format, "format", 2},
};
struct bytecoded_builtin { const char* name; block code; };
static block bind_bytecoded_builtins(block b) {
block builtins = gen_noop();
{
struct bytecoded_builtin builtin_defs[] = {
{"empty", gen_op_simple(BACKTRACK)},
{"false", gen_const(jv_false())},
{"true", gen_const(jv_true())},
{"null", gen_const(jv_null())},
{"not", gen_condbranch(gen_const(jv_false()),
gen_const(jv_true()))}
};
for (unsigned i=0; i<sizeof(builtin_defs)/sizeof(builtin_defs[0]); i++) {
builtins = BLOCK(builtins, gen_function(builtin_defs[i].name, gen_noop(),
builtin_defs[i].code));
}
}
{
struct bytecoded_builtin builtin_def_1arg[] = {
{"path", BLOCK(gen_op_simple(PATH_BEGIN),
gen_call("arg", gen_noop()),
gen_op_simple(PATH_END))},
};
for (unsigned i=0; i<sizeof(builtin_def_1arg)/sizeof(builtin_def_1arg[0]); i++) {
builtins = BLOCK(builtins, gen_function(builtin_def_1arg[i].name,
gen_op_block_unbound(CLOSURE_PARAM, "arg"),
builtin_def_1arg[i].code));
}
}
{
block rangevar = block_bind(gen_op_var_unbound(STOREV, "rangevar"),
gen_noop(), OP_HAS_VARIABLE);
block init = BLOCK(gen_op_simple(DUP), gen_call("start", gen_noop()), rangevar);
block range = BLOCK(init,
gen_call("end", gen_noop()),
gen_op_var_bound(RANGE, rangevar));
builtins = BLOCK(builtins, gen_function("range",
BLOCK(gen_op_block_unbound(CLOSURE_PARAM, "start"),
gen_op_block_unbound(CLOSURE_PARAM, "end")),
range));
}
return block_bind_referenced(builtins, b, OP_IS_CALL_PSEUDO);
}
static const char* const jq_builtins[] = {
"def map(f): [.[] | f];",
"def select(f): if f then . else empty end;",
"def sort_by(f): _sort_by_impl(map([f]));",
"def group_by(f): _group_by_impl(map([f]));",
"def unique: group_by(.) | map(.[0]);",
"def max_by(f): _max_by_impl(map([f]));",
"def min_by(f): _min_by_impl(map([f]));",
"def add: reduce .[] as $x (null; . + $x);",
"def del(f): delpaths([path(f)]);",
"def _assign(paths; value): value as $v | reduce path(paths) as $p (.; setpath($p; $v));",
"def _modify(paths; update): reduce path(paths) as $p (.; setpath($p; getpath($p) | update));",
"def recurse(f): ., (f | select(. != null) | recurse(f));",
"def to_entries: [keys[] as $k | {key: $k, value: .[$k]}];",
"def from_entries: map({(.key): .value}) | add;",
"def with_entries(f): to_entries | map(f) | from_entries;",
"def reverse: [.[length - 1 - range(0;length)]];",
};
block builtins_bind(block b) {
for (int i=(int)(sizeof(jq_builtins)/sizeof(jq_builtins[0]))-1; i>=0; i--) {
struct locfile src;
locfile_init(&src, jq_builtins[i], strlen(jq_builtins[i]));
block funcs;
int nerrors = jq_parse_library(&src, &funcs);
assert(!nerrors);
b = block_bind_referenced(funcs, b, OP_IS_CALL_PSEUDO);
locfile_free(&src);
}
b = bind_bytecoded_builtins(b);
return gen_cbinding(function_list, sizeof(function_list)/sizeof(function_list[0]), b);
}
-21
View File
@@ -1,21 +0,0 @@
#ifndef BUILTIN_H
#define BUILTIN_H
#include "compile.h"
block builtins_bind(block);
typedef void (*cfunction_ptr)(void);
struct cfunction {
cfunction_ptr fptr;
const char* name;
int nargs;
};
jv cfunction_invoke(struct cfunction* function, jv input[]);
#endif
-48
View File
@@ -1,48 +0,0 @@
#ifndef BYTECODE_H
#define BYTECODE_H
#include <stdint.h>
#include "jv.h"
#include "opcode.h"
#include "builtin.h"
#define MAX_CFUNCTION_ARGS 10
struct symbol_table {
struct cfunction* cfunctions;
int ncfunctions;
jv cfunc_names;
};
// The bytecode format matters in:
// execute.c - interpreter
// compile.c - compiler
// bytecode.c - disassembler
#define ARG_NEWCLOSURE 0x1000
struct bytecode {
uint16_t* code;
int codelen;
int nlocals;
int nclosures;
jv constants; // JSON array of constants
struct symbol_table* globals;
struct bytecode** subfunctions;
int nsubfunctions;
struct bytecode* parent;
jv debuginfo;
};
void dump_disassembly(int, struct bytecode* code);
void dump_code(int, struct bytecode* code);
void dump_operation(struct bytecode* bc, uint16_t* op);
void symbol_table_free(struct symbol_table* syms);
void bytecode_free(struct bytecode* bc);
#endif
Executable
+106
View File
@@ -0,0 +1,106 @@
#!/usr/bin/env bash
# Mac C. compile-ios.sh for JQ.
# Defaults
set -e
oniguruma='6.9.10'
unset CFLAGS
unset CXXFLAGS
unset LDFLAGS
# Parse args.
usage(){
cat << EOF
${0##*/}: usage
Description:
This simple script builds oniguruma and jq for all *-apple-darwin devices.
Arguments:
--extra-cflags <arg>: Pass defines or includes to clang.
--extra-ldflags <arg>: Pass libs or includes to ld64.
--with-oniguruma <arg>: Change default version of onigurma from ${oniguruma}.
EOF
exit 1
}
while (( $# )); do
case "$1" in
--with-oniguruma) shift; oniguruma="${1}" ;;
--extra-cflags) shift; export CFLAGS_="${1}" ;;
--extra-ldflags) shift; export LDFLAGS_="${1}" ;;
--help) usage ;;
*) echo -e "Unknown option: ${1}\n"; usage ;;
esac
shift
done
# Start building.
echo "Building..."
MAKEJOBS="$(sysctl -n hw.ncpu || echo 1)"
CC_="$(xcrun -f clang || echo clang)"
onig_url="https://github.com/kkos/oniguruma/releases/download/v${oniguruma}/onig-${oniguruma}.tar.gz"
builddir="${TMPDIR:-/tmp}/${RANDOM:-'xxxxx'}-compile-ios-build"
cwd="$(realpath ${PWD} 2>/dev/null || echo ${PWD})"
t_exit() {
cat << EOF
A error as occurred.
oniguruma location: ${builddir}/onig/onig-${oniguruma}
jq location: ${cwd}
Provide config.log and console logs when posting a issue.
EOF
}
trap t_exit ERR
# Onig.
mkdir -p "${builddir}/onig"
cd "${builddir}/"
curl -L ${onig_url} | tar xz
for arch in i386 x86_64 armv7 armv7s arm64; do
if [[ "$arch" = "i386" || "$arch" = "x86_64" ]]; then
SYSROOT=$(xcrun -f --sdk iphonesimulator --show-sdk-path)
else
SYSROOT=$(xcrun -f --sdk iphoneos --show-sdk-path)
fi
HOST="${arch}-apple-darwin"
[[ "${arch}" = "arm64" ]] && HOST="aarch64-apple-darwin"
CFLAGS="-arch ${arch} -miphoneos-version-min=9.0 -isysroot ${SYSROOT} ${CFLAGS_} -D_REENTRANT"
LDFLAGS="-arch ${arch} -miphoneos-version-min=9.0 -isysroot ${SYSROOT} ${LDFLAGS_}"
CC="${CC_} ${CFLAGS}"
# ./configure; make install
cd "${builddir}/onig-${oniguruma}"
CC=${CC} LDFLAGS=${LDFLAGS} \
./configure --host=${HOST} --build=$(./config.guess) --enable-shared=no --enable-static=yes --prefix=/
make -j${MAKEJOBS} install DESTDIR="${cwd}/ios/onig/${arch}"
make clean
# Jump back to JQ.
cd ${cwd}
[[ ! -f ./configure ]] && autoreconf -ivf
CC=${CC} LDFLAGS=${LDFLAGS} \
./configure --host=${HOST} --build=$(./config/config.guess) --enable-docs=no --enable-shared=no --enable-static=yes --prefix=/ --with-oniguruma=${cwd}/ios/onig/${arch} $(test -z ${BISON+x} || echo '--enable-maintainer-mode')
make -j${MAKEJOBS} install DESTDIR="${cwd}/ios/jq/${arch}"
make clean
done
mkdir -p "${cwd}/ios/dest/lib"
# lipo, make a static lib.
lipo -create -output ${cwd}/ios/dest/lib/libonig.a ${cwd}/ios/onig/{i386,x86_64,armv7,armv7s,arm64}/lib/libonig.a
lipo -create -output ${cwd}/ios/dest/lib/libjq.a ${cwd}/ios/jq/{i386,x86_64,armv7,armv7s,arm64}/lib/libjq.a
# Take the arm64 headers- the most common target.
cp -r ${cwd}/ios/jq/arm64/include ${cwd}/ios/dest/
rm -rf ${cwd}/build/ios/{i386,x86_64,armv7,armv7s,arm64}
echo "Output to ${cwd}/ios/dest"
-678
View File
@@ -1,678 +0,0 @@
#define _GNU_SOURCE // for strdup
#include <assert.h>
#include <string.h>
#include <stdlib.h>
#include "opcode.h"
#include "compile.h"
#include "bytecode.h"
#include "locfile.h"
#include "jv_alloc.h"
/*
The intermediate representation for jq filters is as a sequence of
struct inst, which form a doubly-linked list via the next and prev
pointers.
A "block" represents a sequence of "struct inst", which may be
empty.
Blocks are generated by the parser bottom-up, so may have free
variables (refer to things not defined). See inst.bound_by and
inst.symbol.
*/
struct inst {
struct inst* next;
struct inst* prev;
opcode op;
struct {
uint16_t intval;
struct inst* target;
jv constant;
const struct cfunction* cfunc;
} imm;
location source;
// Binding
// An instruction requiring binding (for parameters/variables/functions)
// is in one of three states:
// inst->bound_by = NULL - Unbound free variable
// inst->bound_by = inst - This instruction binds a variable
// inst->bound_by = other - Uses variable bound by other instruction
// Unbound instructions (references to other things that may or may not
// exist) are created by "gen_foo_unbound", and bindings are created by
// block_bind(definition, body), which binds all instructions in
// body which are unboudn and refer to "definition" by name.
struct inst* bound_by;
char* symbol;
block subfn; // used by CLOSURE_CREATE (body of function)
block arglist; // used by CLOSURE_CREATE (formals) and CALL_JQ (arguments)
// This instruction is compiled as part of which function?
// (only used during block_compile)
struct bytecode* compiled;
int bytecode_pos; // position just after this insn
};
static inst* inst_new(opcode op) {
inst* i = jv_mem_alloc(sizeof(inst));
i->next = i->prev = 0;
i->op = op;
i->bytecode_pos = -1;
i->bound_by = 0;
i->symbol = 0;
i->subfn = gen_noop();
i->arglist = gen_noop();
i->source = UNKNOWN_LOCATION;
return i;
}
static void inst_free(struct inst* i) {
jv_mem_free(i->symbol);
block_free(i->subfn);
block_free(i->arglist);
if (opcode_describe(i->op)->flags & OP_HAS_CONSTANT) {
jv_free(i->imm.constant);
}
jv_mem_free(i);
}
static block inst_block(inst* i) {
block b = {i,i};
return b;
}
static int block_is_single(block b) {
return b.first && b.first == b.last;
}
static inst* block_take(block* b) {
if (b->first == 0) return 0;
inst* i = b->first;
if (i->next) {
i->next->prev = 0;
b->first = i->next;
i->next = 0;
} else {
b->first = 0;
b->last = 0;
}
return i;
}
block gen_location(location loc, block b) {
for (inst* i = b.first; i; i = i->next) {
if (i->source.start == UNKNOWN_LOCATION.start &&
i->source.end == UNKNOWN_LOCATION.end) {
i->source = loc;
}
}
return b;
}
block gen_noop() {
block b = {0,0};
return b;
}
block gen_op_simple(opcode op) {
assert(opcode_describe(op)->length == 1);
return inst_block(inst_new(op));
}
block gen_const(jv constant) {
assert(opcode_describe(LOADK)->flags & OP_HAS_CONSTANT);
inst* i = inst_new(LOADK);
i->imm.constant = constant;
return inst_block(i);
}
block gen_op_target(opcode op, block target) {
assert(opcode_describe(op)->flags & OP_HAS_BRANCH);
assert(target.last);
inst* i = inst_new(op);
i->imm.target = target.last;
return inst_block(i);
}
block gen_op_targetlater(opcode op) {
assert(opcode_describe(op)->flags & OP_HAS_BRANCH);
inst* i = inst_new(op);
i->imm.target = 0;
return inst_block(i);
}
void inst_set_target(block b, block target) {
assert(block_is_single(b));
assert(opcode_describe(b.first->op)->flags & OP_HAS_BRANCH);
assert(target.last);
b.first->imm.target = target.last;
}
block gen_op_var_unbound(opcode op, const char* name) {
assert(opcode_describe(op)->flags & OP_HAS_VARIABLE);
inst* i = inst_new(op);
i->symbol = strdup(name);
return inst_block(i);
}
block gen_op_var_bound(opcode op, block binder) {
assert(block_is_single(binder));
block b = gen_op_var_unbound(op, binder.first->symbol);
b.first->bound_by = binder.first;
return b;
}
block gen_op_block_unbound(opcode op, const char* name) {
assert(opcode_describe(op)->flags & OP_IS_CALL_PSEUDO);
inst* i = inst_new(op);
i->symbol = strdup(name);
return inst_block(i);
}
block gen_op_block_bound(opcode op, block binder) {
assert(block_is_single(binder));
block b = gen_op_block_unbound(op, binder.first->symbol);
b.first->bound_by = binder.first;
return b;
}
static void inst_join(inst* a, inst* b) {
assert(a && b);
assert(!a->next);
assert(!b->prev);
a->next = b;
b->prev = a;
}
void block_append(block* b, block b2) {
if (b2.first) {
if (b->last) {
inst_join(b->last, b2.first);
} else {
b->first = b2.first;
}
b->last = b2.last;
}
}
block block_join(block a, block b) {
block c = a;
block_append(&c, b);
return c;
}
int block_has_only_binders(block binders, int bindflags) {
bindflags |= OP_HAS_BINDING;
for (inst* curr = binders.first; curr; curr = curr->next) {
if ((opcode_describe(curr->op)->flags & bindflags) != bindflags) {
return 0;
}
}
return 1;
}
static int block_bind_subblock(block binder, block body, int bindflags) {
assert(block_is_single(binder));
assert((opcode_describe(binder.first->op)->flags & bindflags) == bindflags);
assert(binder.first->symbol);
assert(binder.first->bound_by == 0 || binder.first->bound_by == binder.first);
binder.first->bound_by = binder.first;
int nrefs = 0;
for (inst* i = body.first; i; i = i->next) {
int flags = opcode_describe(i->op)->flags;
if ((flags & bindflags) == bindflags &&
i->bound_by == 0 &&
!strcmp(i->symbol, binder.first->symbol)) {
// bind this instruction
i->bound_by = binder.first;
nrefs++;
}
// binding recurses into closures
nrefs += block_bind_subblock(binder, i->subfn, bindflags);
// binding recurses into argument list
nrefs += block_bind_subblock(binder, i->arglist, bindflags);
}
return nrefs;
}
static void block_bind_each(block binder, block body, int bindflags) {
assert(block_has_only_binders(binder, bindflags));
bindflags |= OP_HAS_BINDING;
for (inst* curr = binder.first; curr; curr = curr->next) {
block_bind_subblock(inst_block(curr), body, bindflags);
}
}
block block_bind(block binder, block body, int bindflags) {
block_bind_each(binder, body, bindflags);
return block_join(binder, body);
}
block block_bind_referenced(block binder, block body, int bindflags) {
assert(block_has_only_binders(binder, bindflags));
bindflags |= OP_HAS_BINDING;
block refd = gen_noop();
for (inst* curr; (curr = block_take(&binder));) {
block b = inst_block(curr);
if (block_bind_subblock(b, body, bindflags)) {
refd = BLOCK(refd, b);
} else {
block_free(b);
}
}
return block_join(refd, body);
}
block gen_function(const char* name, block formals, block body) {
block_bind_each(formals, body, OP_IS_CALL_PSEUDO);
inst* i = inst_new(CLOSURE_CREATE);
i->subfn = body;
i->symbol = strdup(name);
i->arglist = formals;
block b = inst_block(i);
block_bind_subblock(b, b, OP_IS_CALL_PSEUDO | OP_HAS_BINDING);
return b;
}
block gen_lambda(block body) {
return gen_function("@lambda", gen_noop(), body);
}
block gen_call(const char* name, block args) {
block b = gen_op_block_unbound(CALL_JQ, name);
b.first->arglist = args;
return b;
}
block gen_subexp(block a) {
return BLOCK(gen_op_simple(SUBEXP_BEGIN), a, gen_op_simple(SUBEXP_END));
}
block gen_both(block a, block b) {
block jump = gen_op_targetlater(JUMP);
block fork = gen_op_target(FORK, jump);
block c = BLOCK(fork, a, jump, b);
inst_set_target(jump, c);
return c;
}
block gen_collect(block expr) {
block array_var = block_bind(gen_op_var_unbound(STOREV, "collect"),
gen_noop(), OP_HAS_VARIABLE);
block c = BLOCK(gen_op_simple(DUP), gen_const(jv_array()), array_var);
block tail = BLOCK(gen_op_var_bound(APPEND, array_var),
gen_op_simple(BACKTRACK));
return BLOCK(c,
gen_op_target(FORK, tail),
expr,
tail,
gen_op_var_bound(LOADVN, array_var));
}
block gen_reduce(const char* varname, block source, block init, block body) {
block res_var = block_bind(gen_op_var_unbound(STOREV, "reduce"),
gen_noop(), OP_HAS_VARIABLE);
block loop = BLOCK(gen_op_simple(DUP),
source,
block_bind(gen_op_var_unbound(STOREV, varname),
BLOCK(gen_op_var_bound(LOADVN, res_var),
body,
gen_op_var_bound(STOREV, res_var)),
OP_HAS_VARIABLE),
gen_op_simple(BACKTRACK));
return BLOCK(gen_op_simple(DUP),
init,
res_var,
gen_op_target(FORK, loop),
loop,
gen_op_var_bound(LOADVN, res_var));
}
block gen_definedor(block a, block b) {
// var found := false
block found_var = block_bind(gen_op_var_unbound(STOREV, "found"),
gen_noop(), OP_HAS_VARIABLE);
block init = BLOCK(gen_op_simple(DUP), gen_const(jv_false()), found_var);
// if found, backtrack. Otherwise execute b
block backtrack = gen_op_simple(BACKTRACK);
block tail = BLOCK(gen_op_simple(DUP),
gen_op_var_bound(LOADV, found_var),
gen_op_target(JUMP_F, backtrack),
backtrack,
gen_op_simple(POP),
b);
// try again
block if_notfound = gen_op_simple(BACKTRACK);
// found := true, produce result
block if_found = BLOCK(gen_op_simple(DUP),
gen_const(jv_true()),
gen_op_var_bound(STOREV, found_var),
gen_op_target(JUMP, tail));
return BLOCK(init,
gen_op_target(FORK, if_notfound),
a,
gen_op_target(JUMP_F, if_found),
if_found,
if_notfound,
tail);
}
block gen_condbranch(block iftrue, block iffalse) {
iftrue = BLOCK(iftrue, gen_op_target(JUMP, iffalse));
return BLOCK(gen_op_target(JUMP_F, iftrue), iftrue, iffalse);
}
block gen_and(block a, block b) {
// a and b = if a then (if b then true else false) else false
return BLOCK(gen_op_simple(DUP), a,
gen_condbranch(BLOCK(gen_op_simple(POP),
b,
gen_condbranch(gen_const(jv_true()),
gen_const(jv_false()))),
BLOCK(gen_op_simple(POP), gen_const(jv_false()))));
}
block gen_or(block a, block b) {
// a or b = if a then true else (if b then true else false)
return BLOCK(gen_op_simple(DUP), a,
gen_condbranch(BLOCK(gen_op_simple(POP), gen_const(jv_true())),
BLOCK(gen_op_simple(POP),
b,
gen_condbranch(gen_const(jv_true()),
gen_const(jv_false())))));
}
block gen_var_binding(block var, const char* name, block body) {
return BLOCK(gen_op_simple(DUP), var,
block_bind(gen_op_var_unbound(STOREV, name),
body, OP_HAS_VARIABLE));
}
block gen_cond(block cond, block iftrue, block iffalse) {
return BLOCK(gen_op_simple(DUP), cond,
gen_condbranch(BLOCK(gen_op_simple(POP), iftrue),
BLOCK(gen_op_simple(POP), iffalse)));
}
block gen_cbinding(const struct cfunction* cfunctions, int ncfunctions, block code) {
for (int cfunc=0; cfunc<ncfunctions; cfunc++) {
inst* i = inst_new(CLOSURE_CREATE_C);
i->imm.cfunc = &cfunctions[cfunc];
i->symbol = strdup(i->imm.cfunc->name);
code = block_bind(inst_block(i), code, OP_IS_CALL_PSEUDO);
}
return code;
}
static uint16_t nesting_level(struct bytecode* bc, inst* target) {
uint16_t level = 0;
assert(bc && target->compiled);
while (bc && target->compiled != bc) {
level++;
bc = bc->parent;
}
assert(bc && bc == target->compiled);
return level;
}
static int count_cfunctions(block b) {
int n = 0;
for (inst* i = b.first; i; i = i->next) {
if (i->op == CLOSURE_CREATE_C) n++;
n += count_cfunctions(i->subfn);
}
return n;
}
// Expands call instructions into a calling sequence
static int expand_call_arglist(struct locfile* locations, block* b) {
int errors = 0;
block ret = gen_noop();
for (inst* curr; (curr = block_take(b));) {
if (opcode_describe(curr->op)->flags & OP_HAS_BINDING) {
if (!curr->bound_by) {
locfile_locate(locations, curr->source, "error: %s is not defined", curr->symbol);
errors++;
// don't process this instruction if it's not well-defined
ret = BLOCK(ret, inst_block(curr));
continue;
}
}
block prelude = gen_noop();
if (curr->op == CALL_JQ) {
int actual_args = 0, desired_args = 0;
// We expand the argument list as a series of instructions
switch (curr->bound_by->op) {
default: assert(0 && "Unknown function type"); break;
case CLOSURE_CREATE:
case CLOSURE_PARAM: {
block callargs = gen_noop();
for (inst* i; (i = block_take(&curr->arglist));) {
assert(opcode_describe(i->op)->flags & OP_IS_CALL_PSEUDO);
block b = inst_block(i);
switch (i->op) {
default: assert(0 && "Unknown type of parameter"); break;
case CLOSURE_REF:
block_append(&callargs, b);
break;
case CLOSURE_CREATE:
block_append(&prelude, b);
block_append(&callargs, gen_op_block_bound(CLOSURE_REF, b));
break;
}
actual_args++;
}
curr->imm.intval = actual_args;
curr->arglist = callargs;
if (curr->bound_by->op == CLOSURE_CREATE) {
for (inst* i = curr->bound_by->arglist.first; i; i = i->next) {
assert(i->op == CLOSURE_PARAM);
desired_args++;
}
}
break;
}
case CLOSURE_CREATE_C: {
for (inst* i; (i = block_take(&curr->arglist)); ) {
assert(i->op == CLOSURE_CREATE); // FIXME
block body = i->subfn;
i->subfn = gen_noop();
inst_free(i);
// arguments should be pushed in reverse order, prepend them to prelude
errors += expand_call_arglist(locations, &body);
prelude = BLOCK(gen_subexp(body), prelude);
actual_args++;
}
assert(curr->op == CALL_JQ);
curr->op = CALL_BUILTIN;
curr->imm.intval = actual_args + 1 /* include the implicit input in arg count */;
assert(curr->bound_by->op == CLOSURE_CREATE_C);
desired_args = curr->bound_by->imm.cfunc->nargs - 1;
assert(!curr->arglist.first);
break;
}
}
if (actual_args != desired_args) {
locfile_locate(locations, curr->source,
"error: %s arguments to %s (expected %d but got %d)",
actual_args > desired_args ? "too many" : "too few",
curr->symbol, desired_args, actual_args);
errors++;
}
}
ret = BLOCK(ret, prelude, inst_block(curr));
}
*b = ret;
return errors;
}
static int compile(struct locfile* locations, struct bytecode* bc, block b) {
int errors = 0;
int pos = 0;
int var_frame_idx = 0;
bc->nsubfunctions = 0;
errors += expand_call_arglist(locations, &b);
b = BLOCK(b, gen_op_simple(RET));
jv localnames = jv_array();
for (inst* curr = b.first; curr; curr = curr->next) {
if (!curr->next) assert(curr == b.last);
int length = opcode_describe(curr->op)->length;
if (curr->op == CALL_JQ) {
for (inst* arg = curr->arglist.first; arg; arg = arg->next) {
length += 2;
}
}
pos += length;
curr->bytecode_pos = pos;
curr->compiled = bc;
assert(curr->op != CLOSURE_REF && curr->op != CLOSURE_PARAM);
if ((opcode_describe(curr->op)->flags & OP_HAS_VARIABLE) &&
curr->bound_by == curr) {
curr->imm.intval = var_frame_idx++;
localnames = jv_array_append(localnames, jv_string(curr->symbol));
}
if (curr->op == CLOSURE_CREATE) {
assert(curr->bound_by == curr);
curr->imm.intval = bc->nsubfunctions++;
}
if (curr->op == CLOSURE_CREATE_C) {
assert(curr->bound_by == curr);
int idx = bc->globals->ncfunctions++;
bc->globals->cfunc_names = jv_array_append(bc->globals->cfunc_names,
jv_string(curr->symbol));
bc->globals->cfunctions[idx] = *curr->imm.cfunc;
curr->imm.intval = idx;
}
}
bc->debuginfo = jv_object_set(bc->debuginfo, jv_string("locals"), localnames);
if (bc->nsubfunctions) {
bc->subfunctions = jv_mem_alloc(sizeof(struct bytecode*) * bc->nsubfunctions);
for (inst* curr = b.first; curr; curr = curr->next) {
if (curr->op == CLOSURE_CREATE) {
struct bytecode* subfn = jv_mem_alloc(sizeof(struct bytecode));
bc->subfunctions[curr->imm.intval] = subfn;
subfn->globals = bc->globals;
subfn->parent = bc;
subfn->nclosures = 0;
subfn->debuginfo = jv_object_set(jv_object(), jv_string("name"), jv_string(curr->symbol));
jv params = jv_array();
for (inst* param = curr->arglist.first; param; param = param->next) {
assert(param->op == CLOSURE_PARAM);
assert(param->bound_by == param);
param->imm.intval = subfn->nclosures++;
param->compiled = subfn;
params = jv_array_append(params, jv_string(param->symbol));
}
subfn->debuginfo = jv_object_set(subfn->debuginfo, jv_string("params"), params);
errors += compile(locations, subfn, curr->subfn);
curr->subfn = gen_noop();
}
}
} else {
bc->subfunctions = 0;
}
bc->codelen = pos;
uint16_t* code = jv_mem_alloc(sizeof(uint16_t) * bc->codelen);
bc->code = code;
pos = 0;
jv constant_pool = jv_array();
int maxvar = -1;
if (!errors) for (inst* curr = b.first; curr; curr = curr->next) {
const struct opcode_description* op = opcode_describe(curr->op);
if (op->length == 0)
continue;
code[pos++] = curr->op;
assert(curr->op != CLOSURE_REF && curr->op != CLOSURE_PARAM);
if (curr->op == CALL_BUILTIN) {
assert(curr->bound_by->op == CLOSURE_CREATE_C);
assert(!curr->arglist.first);
code[pos++] = (uint16_t)curr->imm.intval;
code[pos++] = curr->bound_by->imm.intval;
} else if (curr->op == CALL_JQ) {
assert(curr->bound_by->op == CLOSURE_CREATE ||
curr->bound_by->op == CLOSURE_PARAM);
code[pos++] = (uint16_t)curr->imm.intval;
code[pos++] = nesting_level(bc, curr->bound_by);
code[pos++] = curr->bound_by->imm.intval |
(curr->bound_by->op == CLOSURE_CREATE ? ARG_NEWCLOSURE : 0);
for (inst* arg = curr->arglist.first; arg; arg = arg->next) {
assert(arg->op == CLOSURE_REF && arg->bound_by->op == CLOSURE_CREATE);
code[pos++] = nesting_level(bc, arg->bound_by);
code[pos++] = arg->bound_by->imm.intval | ARG_NEWCLOSURE;
}
} else if (op->flags & OP_HAS_CONSTANT) {
code[pos++] = jv_array_length(jv_copy(constant_pool));
constant_pool = jv_array_append(constant_pool, jv_copy(curr->imm.constant));
} else if (op->flags & OP_HAS_VARIABLE) {
code[pos++] = nesting_level(bc, curr->bound_by);
uint16_t var = (uint16_t)curr->bound_by->imm.intval;
code[pos++] = var;
if (var > maxvar) maxvar = var;
} else if (op->flags & OP_HAS_BRANCH) {
assert(curr->imm.target->bytecode_pos != -1);
assert(curr->imm.target->bytecode_pos > pos); // only forward branches
code[pos] = curr->imm.target->bytecode_pos - (pos + 1);
pos++;
} else if (op->length > 1) {
assert(0 && "codegen not implemented for this operation");
}
}
bc->constants = constant_pool;
bc->nlocals = maxvar + 2; // FIXME: frames of size zero?
block_free(b);
return errors;
}
int block_compile(block b, struct locfile* locations, struct bytecode** out) {
struct bytecode* bc = jv_mem_alloc(sizeof(struct bytecode));
bc->parent = 0;
bc->nclosures = 0;
bc->globals = jv_mem_alloc(sizeof(struct symbol_table));
int ncfunc = count_cfunctions(b);
bc->globals->ncfunctions = 0;
bc->globals->cfunctions = jv_mem_alloc(sizeof(struct cfunction) * ncfunc);
bc->globals->cfunc_names = jv_array();
bc->debuginfo = jv_object_set(jv_object(), jv_string("name"), jv_null());
int nerrors = compile(locations, bc, b);
assert(bc->globals->ncfunctions == ncfunc);
if (nerrors > 0) {
bytecode_free(bc);
*out = 0;
} else {
*out = bc;
}
return nerrors;
}
void block_free(block b) {
struct inst* next;
for (struct inst* curr = b.first; curr; curr = next) {
next = curr->next;
inst_free(curr);
}
}
-77
View File
@@ -1,77 +0,0 @@
#ifndef COMPILE_H
#define COMPILE_H
#include <stdint.h>
#include "jv.h"
#include "opcode.h"
#include "locfile.h"
struct bytecode;
struct symbol_table;
struct cfunction;
struct inst;
typedef struct inst inst;
typedef struct block {
inst* first;
inst* last;
} block;
block gen_location(location, block);
block gen_noop();
block gen_op_simple(opcode op);
block gen_const(jv constant);
block gen_op_target(opcode op, block target);
block gen_op_var_unbound(opcode op, const char* name);
block gen_op_var_bound(opcode op, block binder);
block gen_op_block_unbound(opcode op, const char* name);
block gen_function(const char* name, block formals, block body);
block gen_lambda(block body);
block gen_call(const char* name, block body);
block gen_subexp(block a);
block gen_both(block a, block b);
block gen_collect(block expr);
block gen_reduce(const char* varname, block source, block init, block body);
block gen_definedor(block a, block b);
block gen_condbranch(block iftrue, block iffalse);
block gen_and(block a, block b);
block gen_or(block a, block b);
block gen_var_binding(block var, const char* name, block body);
block gen_cond(block cond, block iftrue, block iffalse);
block gen_cbinding(const struct cfunction* functions, int nfunctions, block b);
void block_append(block* b, block b2);
block block_join(block a, block b);
int block_has_only_binders(block, int bindflags);
block block_bind(block binder, block body, int bindflags);
block block_bind_referenced(block binder, block body, int bindflags);
int block_compile(block, struct locfile*, struct bytecode**);
void block_free(block);
// Here's some horrible preprocessor gunk so that code
// sequences can be contructed as BLOCK(block1, block2, block3)
#define BLOCK_1(b1) (b1)
#define BLOCK_2(b1,b2) (block_join((b1),(b2)))
#define BLOCK_3(b1,b2,b3) (block_join(BLOCK_2(b1,b2),(b3)))
#define BLOCK_4(b1,b2,b3,b4) (block_join(BLOCK_3(b1,b2,b3),(b4)))
#define BLOCK_5(b1,b2,b3,b4,b5) (block_join(BLOCK_4(b1,b2,b3,b4),(b5)))
#define BLOCK_6(b1,b2,b3,b4,b5,b6) (block_join(BLOCK_5(b1,b2,b3,b4,b5),(b6)))
#define BLOCK_7(b1,b2,b3,b4,b5,b6,b7) (block_join(BLOCK_6(b1,b2,b3,b4,b5,b6),(b7)))
#define BLOCK_IDX(_1,_2,_3,_4,_5,_6,_7,NAME,...) NAME
#define BLOCK(...) \
BLOCK_IDX(__VA_ARGS__, BLOCK_7, BLOCK_6, BLOCK_5, BLOCK_4, BLOCK_3, BLOCK_2, BLOCK_1)(__VA_ARGS__)
#endif
-32
View File
@@ -1,32 +0,0 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* Version number of package */
#undef VERSION
/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
`char[]'. */
#undef YYTEXT_POINTER
+10
View File
@@ -0,0 +1,10 @@
config.guess
config.sub
compile
depcomp
install-sh
ltmain.sh
missing
ylwrap
test-driver
ar-lib
-343
View File
@@ -1,343 +0,0 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-03-05.13; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free
# Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
nl='
'
# We need space, tab and new line, in precisely that order. Quoting is
# there to prevent tools from complaining about whitespace usage.
IFS=" "" $nl"
file_conv=
# func_file_conv build_file lazy
# Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will
# take place.
func_file_conv ()
{
file=$1
case $file in
/ | /[!/]*) # absolute file, and not a UNC file
if test -z "$file_conv"; then
# lazily determine how to convert abs files
case `uname -s` in
MINGW*)
file_conv=mingw
;;
CYGWIN*)
file_conv=cygwin
;;
*)
file_conv=wine
;;
esac
fi
case $file_conv/,$2, in
*,$file_conv,*)
;;
mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;;
cygwin/*)
file=`cygpath -m "$file" || echo "$file"`
;;
wine/*)
file=`winepath -w "$file" || echo "$file"`
;;
esac
;;
esac
}
# func_cl_dashL linkdir
# Make cl look for libraries in LINKDIR
func_cl_dashL ()
{
func_file_conv "$1"
if test -z "$lib_path"; then
lib_path=$file
else
lib_path="$lib_path;$file"
fi
linker_opts="$linker_opts -LIBPATH:$file"
}
# func_cl_dashl library
# Do a library search-path lookup for cl
func_cl_dashl ()
{
lib=$1
found=no
save_IFS=$IFS
IFS=';'
for dir in $lib_path $LIB
do
IFS=$save_IFS
if $shared && test -f "$dir/$lib.dll.lib"; then
found=yes
lib=$dir/$lib.dll.lib
break
fi
if test -f "$dir/$lib.lib"; then
found=yes
lib=$dir/$lib.lib
break
fi
done
IFS=$save_IFS
if test "$found" != yes; then
lib=$lib.lib
fi
}
# func_cl_wrapper cl arg...
# Adjust compile command to suit cl
func_cl_wrapper ()
{
# Assume a capable shell
lib_path=
shared=:
linker_opts=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
eat=1
case $2 in
*.o | *.[oO][bB][jJ])
func_file_conv "$2"
set x "$@" -Fo"$file"
shift
;;
*)
func_file_conv "$2"
set x "$@" -Fe"$file"
shift
;;
esac
;;
-I)
eat=1
func_file_conv "$2" mingw
set x "$@" -I"$file"
shift
;;
-I*)
func_file_conv "${1#-I}" mingw
set x "$@" -I"$file"
shift
;;
-l)
eat=1
func_cl_dashl "$2"
set x "$@" "$lib"
shift
;;
-l*)
func_cl_dashl "${1#-l}"
set x "$@" "$lib"
shift
;;
-L)
eat=1
func_cl_dashL "$2"
;;
-L*)
func_cl_dashL "${1#-L}"
;;
-static)
shared=false
;;
-Wl,*)
arg=${1#-Wl,}
save_ifs="$IFS"; IFS=','
for flag in $arg; do
IFS="$save_ifs"
linker_opts="$linker_opts $flag"
done
IFS="$save_ifs"
;;
-Xlinker)
eat=1
linker_opts="$linker_opts $2"
;;
-*)
set x "$@" "$1"
shift
;;
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
func_file_conv "$1"
set x "$@" -Tp"$file"
shift
;;
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
func_file_conv "$1" mingw
set x "$@" "$file"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -n "$linker_opts"; then
linker_opts="-link$linker_opts"
fi
exec "$@" $linker_opts
exit 1
}
eat=
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: compile [--help] [--version] PROGRAM [ARGS]
Wrapper for compilers which do not understand '-c -o'.
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
arguments, and rename the output as expected.
If you are trying to build a whole package this is not the
right script to run: please start by reading the file 'INSTALL'.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
ofile=
cfile=
for arg
do
if test -n "$eat"; then
eat=
else
case $1 in
-o)
# configure might choose to run compile as 'compile cc -o foo foo.c'.
# So we strip '-o arg' only if arg is an object.
eat=1
case $2 in
*.o | *.obj)
ofile=$2
;;
*)
set x "$@" -o "$2"
shift
;;
esac
;;
*.c)
cfile=$1
set x "$@" "$1"
shift
;;
*)
set x "$@" "$1"
shift
;;
esac
fi
shift
done
if test -z "$ofile" || test -z "$cfile"; then
# If no '-o' option was seen then we might have been invoked from a
# pattern rule where we don't need one. That is ok -- this is a
# normal compilation that the losing compiler can handle. If no
# '.c' file was seen then we are probably linking. That is also
# ok.
exec "$@"
fi
# Name of file we expect compiler to create.
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
# Create the lock directory.
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
# that we are using for the .o file. Also, base the name on the expected
# object file name, since that is what matters with a parallel build.
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
while true; do
if mkdir "$lockdir" >/dev/null 2>&1; then
break
fi
sleep 1
done
# FIXME: race condition here if user kills between mkdir and trap.
trap "rmdir '$lockdir'; exit 1" 1 2 15
# Run the compile.
"$@"
ret=$?
if test -f "$cofile"; then
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
elif test -f "${cofile}bj"; then
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
fi
rmdir "$lockdir"
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
-708
View File
@@ -1,708 +0,0 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2012-03-27.16; # UTC
# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
# 2011, 2012 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try '$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by 'PROGRAMS ARGS'.
object Object file output by 'PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputting dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
# A tabulation character.
tab=' '
# A newline character.
nl='
'
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
cygpath_u="cygpath -u -f -"
if test "$depmode" = msvcmsys; then
# This is just like msvisualcpp but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvisualcpp
fi
if test "$depmode" = msvc7msys; then
# This is just like msvc7 but w/o cygpath translation.
# Just convert the backslash-escaped backslashes to single forward
# slashes to satisfy depend.m4
cygpath_u='sed s,\\\\,/,g'
depmode=msvc7
fi
if test "$depmode" = xlc; then
# IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
gccflag=-qmakedep=gcc,-MF
depmode=gcc
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
## Unfortunately, FreeBSD c89 acceptance of flags depends upon
## the command line argument order; so add the flags where they
## appear in depend2.am. Note that the slowdown incurred here
## affects only configure: in makefiles, %FASTDEP% shortcuts this.
for arg
do
case $arg in
-c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
*) set fnord "$@" "$arg" ;;
esac
shift # fnord
shift # $arg
done
"$@"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the "deleted header file" problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' "$nl" < "$tmpdepfile" |
## Some versions of gcc put a space before the ':'. On the theory
## that the space means something, we add a space to the output as
## well. hp depmode also adds that space, but also prefixes the VPATH
## to the object. Take care to not repeat it in the output.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \
| sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like '#:fec' to the end of the
# dependency line.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr "$nl" ' ' >> "$depfile"
echo >> "$depfile"
# The second pass generates a dummy entry for each header file.
tr ' ' "$nl" < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
xlc)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts '$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.u
tmpdepfile2=$base.u
tmpdepfile3=$dir.libs/$base.u
"$@" -Wc,-M
else
tmpdepfile1=$dir$base.u
tmpdepfile2=$dir$base.u
tmpdepfile3=$dir$base.u
"$@" -M
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
# Each line is of the form 'foo.o: dependent.h'.
# Do two passes, one to just change these to
# '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'.
# However on
# $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using '\':
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
# tcc 0.9.26 (FIXME still under development at the moment of writing)
# will emit a similar output, but also prepend the continuation lines
# with horizontal tabulation characters.
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form 'foo.o: dependent.h',
# or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'.
# Do two passes, one to just change these to
# '$object: dependent.h' and one to simply 'dependent.h:'.
sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \
< "$tmpdepfile" > "$depfile"
sed '
s/[ '"$tab"'][ '"$tab"']*/ /g
s/^ *//
s/ *\\*$//
s/^[^:]*: *//
/^$/d
/:$/d
s/$/ :/
' < "$tmpdepfile" >> "$depfile"
rm -f "$tmpdepfile"
;;
hp2)
# The "hp" stanza above does not work with aCC (C++) and HP's ia64
# compilers, which have integrated preprocessors. The correct option
# to use with these is +Maked; it writes dependencies to a file named
# 'foo.d', which lands next to the object file, wherever that
# happens to be.
# Much of this is similar to the tru64 case; see comments there.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir.libs/$base.d
"$@" -Wc,+Maked
else
tmpdepfile1=$dir$base.d
tmpdepfile2=$dir$base.d
"$@" +Maked
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
# Add 'dependent.h:' lines.
sed -ne '2,${
s/^ *//
s/ \\*$//
s/$/:/
p
}' "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile" "$tmpdepfile2"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in 'foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mechanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
msvc7)
if test "$libtool" = yes; then
showIncludes=-Wc,-showIncludes
else
showIncludes=-showIncludes
fi
"$@" $showIncludes > "$tmpdepfile"
stat=$?
grep -v '^Note: including file: ' "$tmpdepfile"
if test "$stat" = 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
# The first sed program below extracts the file names and escapes
# backslashes for cygpath. The second sed program outputs the file
# name when reading, but also accumulates all include files in the
# hold buffer in order to output them again at the end. This only
# works with sed implementations that can handle large buffers.
sed < "$tmpdepfile" -n '
/^Note: including file: *\(.*\)/ {
s//\1/
s/\\/\\\\/g
p
}' | $cygpath_u | sort -u | sed -n '
s/ /\\ /g
s/\(.*\)/'"$tab"'\1 \\/p
s/.\(.*\) \\/\1:/
H
$ {
s/.*/'"$tab"'/
G
p
}' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvc7msys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for ':'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise.
"$@" $dashmflag |
sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' "$nl" < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no eat=no
for arg
do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
if test $eat = yes; then
eat=no
continue
fi
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-arch)
eat=yes ;;
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix=`echo "$object" | sed 's/^.*\././'`
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
# makedepend may prepend the VPATH from the source file name to the object.
# No need to regex-escape $object, excess matching of '.' is harmless.
sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
# Remove '-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
-e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test "X$1" != 'X--mode=compile'; do
shift
done
shift
fi
IFS=" "
for arg
do
case "$arg" in
-o)
shift
;;
$object)
shift
;;
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E 2>/dev/null |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile"
echo "$tab" >> "$depfile"
sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvcmsys)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
-527
View File
@@ -1,527 +0,0 @@
#!/bin/sh
# install - install a program, script, or datafile
scriptversion=2011-01-19.21; # UTC
# This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the
# following copyright and license.
#
# Copyright (C) 1994 X Consortium
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
# Except as contained in this notice, the name of the X Consortium shall not
# be used in advertising or otherwise to promote the sale, use or other deal-
# ings in this Software without prior written authorization from the X Consor-
# tium.
#
#
# FSF changes to this file are in the public domain.
#
# Calling this script install-sh is preferred over install.sh, to prevent
# `make' implicit rules from creating a file called install from it
# when there is no Makefile.
#
# This script is compatible with the BSD install script, but was written
# from scratch.
nl='
'
IFS=" "" $nl"
# set DOITPROG to echo to test this script
# Don't use :- since 4.3BSD and earlier shells don't like it.
doit=${DOITPROG-}
if test -z "$doit"; then
doit_exec=exec
else
doit_exec=$doit
fi
# Put in absolute file names if you don't have them in your path;
# or use environment vars.
chgrpprog=${CHGRPPROG-chgrp}
chmodprog=${CHMODPROG-chmod}
chownprog=${CHOWNPROG-chown}
cmpprog=${CMPPROG-cmp}
cpprog=${CPPROG-cp}
mkdirprog=${MKDIRPROG-mkdir}
mvprog=${MVPROG-mv}
rmprog=${RMPROG-rm}
stripprog=${STRIPPROG-strip}
posix_glob='?'
initialize_posix_glob='
test "$posix_glob" != "?" || {
if (set -f) 2>/dev/null; then
posix_glob=
else
posix_glob=:
fi
}
'
posix_mkdir=
# Desired mode of installed file.
mode=0755
chgrpcmd=
chmodcmd=$chmodprog
chowncmd=
mvcmd=$mvprog
rmcmd="$rmprog -f"
stripcmd=
src=
dst=
dir_arg=
dst_arg=
copy_on_change=false
no_target_directory=
usage="\
Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
or: $0 [OPTION]... SRCFILES... DIRECTORY
or: $0 [OPTION]... -t DIRECTORY SRCFILES...
or: $0 [OPTION]... -d DIRECTORIES...
In the 1st form, copy SRCFILE to DSTFILE.
In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
In the 4th, create DIRECTORIES.
Options:
--help display this help and exit.
--version display version info and exit.
-c (ignored)
-C install only if different (preserve the last data modification time)
-d create directories instead of installing files.
-g GROUP $chgrpprog installed files to GROUP.
-m MODE $chmodprog installed files to MODE.
-o USER $chownprog installed files to USER.
-s $stripprog installed files.
-t DIRECTORY install into DIRECTORY.
-T report an error if DSTFILE is a directory.
Environment variables override the default commands:
CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
RMPROG STRIPPROG
"
while test $# -ne 0; do
case $1 in
-c) ;;
-C) copy_on_change=true;;
-d) dir_arg=true;;
-g) chgrpcmd="$chgrpprog $2"
shift;;
--help) echo "$usage"; exit $?;;
-m) mode=$2
case $mode in
*' '* | *' '* | *'
'* | *'*'* | *'?'* | *'['*)
echo "$0: invalid mode: $mode" >&2
exit 1;;
esac
shift;;
-o) chowncmd="$chownprog $2"
shift;;
-s) stripcmd=$stripprog;;
-t) dst_arg=$2
# Protect names problematic for `test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
shift;;
-T) no_target_directory=true;;
--version) echo "$0 $scriptversion"; exit $?;;
--) shift
break;;
-*) echo "$0: invalid option: $1" >&2
exit 1;;
*) break;;
esac
shift
done
if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
# When -d is used, all remaining arguments are directories to create.
# When -t is used, the destination is already specified.
# Otherwise, the last argument is the destination. Remove it from $@.
for arg
do
if test -n "$dst_arg"; then
# $@ is not empty: it contains at least $arg.
set fnord "$@" "$dst_arg"
shift # fnord
fi
shift # arg
dst_arg=$arg
# Protect names problematic for `test' and other utilities.
case $dst_arg in
-* | [=\(\)!]) dst_arg=./$dst_arg;;
esac
done
fi
if test $# -eq 0; then
if test -z "$dir_arg"; then
echo "$0: no input file specified." >&2
exit 1
fi
# It's OK to call `install-sh -d' without argument.
# This can happen when creating conditional directories.
exit 0
fi
if test -z "$dir_arg"; then
do_exit='(exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
# Set umask so as not to create temps with too-generous modes.
# However, 'strip' requires both read and write access to temps.
case $mode in
# Optimize common cases.
*644) cp_umask=133;;
*755) cp_umask=22;;
*[0-7])
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw='% 200'
fi
cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
*)
if test -z "$stripcmd"; then
u_plus_rw=
else
u_plus_rw=,u+rw
fi
cp_umask=$mode$u_plus_rw;;
esac
fi
for src
do
# Protect names problematic for `test' and other utilities.
case $src in
-* | [=\(\)!]) src=./$src;;
esac
if test -n "$dir_arg"; then
dst=$src
dstdir=$dst
test -d "$dstdir"
dstdir_status=$?
else
# Waiting for this to be detected by the "$cpprog $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if test ! -f "$src" && test ! -d "$src"; then
echo "$0: $src does not exist." >&2
exit 1
fi
if test -z "$dst_arg"; then
echo "$0: no destination specified." >&2
exit 1
fi
dst=$dst_arg
# If destination is a directory, append the input filename; won't work
# if double slashes aren't ignored.
if test -d "$dst"; then
if test -n "$no_target_directory"; then
echo "$0: $dst_arg: Is a directory" >&2
exit 1
fi
dstdir=$dst
dst=$dstdir/`basename "$src"`
dstdir_status=0
else
# Prefer dirname, but fall back on a substitute if dirname fails.
dstdir=`
(dirname "$dst") 2>/dev/null ||
expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
X"$dst" : 'X\(//\)[^/]' \| \
X"$dst" : 'X\(//\)$' \| \
X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
echo X"$dst" |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
s//\1/
q
}
/^X\(\/\/\)[^/].*/{
s//\1/
q
}
/^X\(\/\/\)$/{
s//\1/
q
}
/^X\(\/\).*/{
s//\1/
q
}
s/.*/./; q'
`
test -d "$dstdir"
dstdir_status=$?
fi
fi
obsolete_mkdir_used=false
if test $dstdir_status != 0; then
case $posix_mkdir in
'')
# Create intermediate dirs using mode 755 as modified by the umask.
# This is like FreeBSD 'install' as of 1997-10-28.
umask=`umask`
case $stripcmd.$umask in
# Optimize common cases.
*[2367][2367]) mkdir_umask=$umask;;
.*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
*[0-7])
mkdir_umask=`expr $umask + 22 \
- $umask % 100 % 40 + $umask % 20 \
- $umask % 10 % 4 + $umask % 2
`;;
*) mkdir_umask=$umask,go-w;;
esac
# With -d, create the new directory with the user-specified mode.
# Otherwise, rely on $mkdir_umask.
if test -n "$dir_arg"; then
mkdir_mode=-m$mode
else
mkdir_mode=
fi
posix_mkdir=false
case $umask in
*[123567][0-7][0-7])
# POSIX mkdir -p sets u+wx bits regardless of umask, which
# is incompatible with FreeBSD 'install' when (umask & 300) != 0.
;;
*)
tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
if (umask $mkdir_umask &&
exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
then
if test -z "$dir_arg" || {
# Check for POSIX incompatibilities with -m.
# HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
# other-writeable bit of parent directory when it shouldn't.
# FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
ls_ld_tmpdir=`ls -ld "$tmpdir"`
case $ls_ld_tmpdir in
d????-?r-*) different_mode=700;;
d????-?--*) different_mode=755;;
*) false;;
esac &&
$mkdirprog -m$different_mode -p -- "$tmpdir" && {
ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
}
}
then posix_mkdir=:
fi
rmdir "$tmpdir/d" "$tmpdir"
else
# Remove any dirs left behind by ancient mkdir implementations.
rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
fi
trap '' 0;;
esac;;
esac
if
$posix_mkdir && (
umask $mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
)
then :
else
# The umask is ridiculous, or mkdir does not conform to POSIX,
# or it failed possibly due to a race condition. Create the
# directory the slow way, step by step, checking for races as we go.
case $dstdir in
/*) prefix='/';;
[-=\(\)!]*) prefix='./';;
*) prefix='';;
esac
eval "$initialize_posix_glob"
oIFS=$IFS
IFS=/
$posix_glob set -f
set fnord $dstdir
shift
$posix_glob set +f
IFS=$oIFS
prefixes=
for d
do
test X"$d" = X && continue
prefix=$prefix$d
if test -d "$prefix"; then
prefixes=
else
if $posix_mkdir; then
(umask=$mkdir_umask &&
$doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
# Don't fail if two instances are running concurrently.
test -d "$prefix" || exit 1
else
case $prefix in
*\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
*) qprefix=$prefix;;
esac
prefixes="$prefixes '$qprefix'"
fi
fi
prefix=$prefix/
done
if test -n "$prefixes"; then
# Don't fail if two instances are running concurrently.
(umask $mkdir_umask &&
eval "\$doit_exec \$mkdirprog $prefixes") ||
test -d "$dstdir" || exit 1
obsolete_mkdir_used=true
fi
fi
fi
if test -n "$dir_arg"; then
{ test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
{ test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
else
# Make a couple of temp file names in the proper directory.
dsttmp=$dstdir/_inst.$$_
rmtmp=$dstdir/_rm.$$_
# Trap to clean up those temp files at exit.
trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
# Copy the file name to the temp name.
(umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
# and set any options; do chmod last to preserve setuid bits.
#
# If any of these fail, we abort the whole thing. If we want to
# ignore errors from any of these, just make sure not to ignore
# errors from the above "$doit $cpprog $src $dsttmp" command.
#
{ test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
{ test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
{ test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
{ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
# If -C, don't bother to copy if it wouldn't change the file.
if $copy_on_change &&
old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
eval "$initialize_posix_glob" &&
$posix_glob set -f &&
set X $old && old=:$2:$4:$5:$6 &&
set X $new && new=:$2:$4:$5:$6 &&
$posix_glob set +f &&
test "$old" = "$new" &&
$cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
then
rm -f "$dsttmp"
else
# Rename the file to the real destination.
$doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
# The rename failed, perhaps because mv can't rename something else
# to itself, or perhaps because mv is so ancient that it does not
# support -f.
{
# Now remove or move aside any old file at destination location.
# We try this two ways since rm can't unlink itself on some
# systems and the destination file might be busy for other
# reasons. In this case, the final cleanup might fail but the new
# file should still install successfully.
{
test ! -f "$dst" ||
$doit $rmcmd -f "$dst" 2>/dev/null ||
{ $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
{ $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
} ||
{ echo "$0: cannot unlink or rename $dst" >&2
(exit 1); exit 1
}
} &&
# Now rename the file to the real destination.
$doit $mvcmd "$dsttmp" "$dst"
}
fi || exit 1
trap '' 0
fi
done
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
+2
View File
@@ -0,0 +1,2 @@
libtool.m4
lt*.m4
+9
View File
@@ -0,0 +1,9 @@
dnl AC_CHECK_MATH_FUNC(func)
AC_DEFUN([AC_CHECK_MATH_FUNC], [
AC_LANG(C)
AC_CHECK_LIB([m],[$1],[
m4_define([ac_tr_func], [HAVE_]m4_toupper($1))
AC_DEFINE(ac_tr_func, 1, [Define if you have the $1 math function.])
],[
])
])
+8
View File
@@ -0,0 +1,8 @@
dnl Shamelessly stolen from Heimdal
dnl
dnl Look for function in any of the specified libraries
dnl
dnl AC_FIND_FUNC_NO_LIBS(func, libraries, includes, arguments, extra libs, extra args)
AC_DEFUN([AC_FIND_FUNC_NO_LIBS], [
AC_FIND_FUNC_NO_LIBS2([$1], ["" $2], [$3], [$4], [$5], [$6])])
+62
View File
@@ -0,0 +1,62 @@
dnl Shamelessly stolen from Heimdal
dnl
dnl Look for function in any of the specified libraries
dnl
dnl AC_FIND_FUNC_NO_LIBS2(func, libraries, includes, arguments, extra libs, extra args)
AC_DEFUN([AC_FIND_FUNC_NO_LIBS2], [
AC_MSG_CHECKING([for $1])
AC_CACHE_VAL(ac_cv_funclib_$1,
[
if eval "test \"\$ac_cv_func_$1\" != yes" ; then
ac_save_LIBS="$LIBS"
for ac_lib in $2; do
case "$ac_lib" in
"") ;;
yes) ac_lib="" ;;
no) continue ;;
-l*) ;;
*) ac_lib="-l$ac_lib" ;;
esac
LIBS="$6 $ac_lib $5 $ac_save_LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[$3]],[[$1($4)]])],[eval "if test -n \"$ac_lib\";then ac_cv_funclib_$1=$ac_lib; else ac_cv_funclib_$1=yes; fi";break])
done
eval "ac_cv_funclib_$1=\${ac_cv_funclib_$1-no}"
LIBS="$ac_save_LIBS"
fi
])
eval "ac_res=\$ac_cv_funclib_$1"
if false; then
AC_CHECK_FUNCS($1)
dnl AC_CHECK_LIBS($2, foo)
fi
# $1
eval "ac_tr_func=HAVE_[]upcase($1)"
eval "ac_tr_lib=HAVE_LIB[]upcase($ac_res | sed -e 's/-l//')"
eval "LIB_$1=$ac_res"
case "$ac_res" in
yes)
eval "ac_cv_func_$1=yes"
eval "LIB_$1="
AC_DEFINE_UNQUOTED($ac_tr_func, 1, [Define if the $1 function is available.])
AC_MSG_RESULT([yes])
;;
no)
eval "ac_cv_func_$1=no"
eval "LIB_$1="
AC_MSG_RESULT([no])
;;
*)
eval "ac_cv_func_$1=yes"
eval "ac_cv_lib_`echo "$ac_res" | sed 's/-l//'`=yes"
AC_DEFINE_UNQUOTED($ac_tr_func, 1, [Define if you have the $1 function.])
AC_DEFINE_UNQUOTED($ac_tr_lib, 1, [Define if you have the $2 library.])
AC_MSG_RESULT([yes, in $ac_res])
;;
esac
AC_SUBST(LIB_$1)
])
+9
View File
@@ -0,0 +1,9 @@
dnl Shamelessly stolen from Heimdal
dnl
dnl AC_FIND_FUNC(func, libraries, includes, arguments)
AC_DEFUN([AC_FIND_FUNC], [
AC_FIND_FUNC_NO_LIBS([$1], [$2], [$3], [$4])
if test -n "$LIB_$1"; then
LIBS="$LIB_$1 $LIBS"
fi
])
+3
View File
@@ -0,0 +1,3 @@
dnl Shamelessly stolen from Heimdal
AC_DEFUN([upcase],[`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`])dnl
-331
View File
@@ -1,331 +0,0 @@
#! /bin/sh
# Common stub for a few missing GNU programs while installing.
scriptversion=2012-01-06.13; # UTC
# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
if test $# -eq 0; then
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
fi
run=:
sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
# In the cases where this matters, `missing' is being run in the
# srcdir already.
if test -f configure.ac; then
configure_ac=configure.ac
else
configure_ac=configure.in
fi
msg="missing on your system"
case $1 in
--run)
# Try to run requested program, and just exit if it succeeds.
run=
shift
"$@" && exit 0
# Exit code 63 means version mismatch. This often happens
# when the user try to use an ancient version of a tool on
# a file that requires a minimum version. In this case we
# we should proceed has if the program had been absent, or
# if --run hadn't been passed.
if test $? = 63; then
run=:
msg="probably too old"
fi
;;
-h|--h|--he|--hel|--help)
echo "\
$0 [OPTION]... PROGRAM [ARGUMENT]...
Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
error status if there is no known handling for PROGRAM.
Options:
-h, --help display this help and exit
-v, --version output version information and exit
--run try to run the given command, and emulate it if it fails
Supported PROGRAM values:
aclocal touch file \`aclocal.m4'
autoconf touch file \`configure'
autoheader touch file \`config.h.in'
autom4te touch the output file, or create a stub one
automake touch all \`Makefile.in' files
bison create \`y.tab.[ch]', if possible, from existing .[ch]
flex create \`lex.yy.c', if possible, from existing .c
help2man touch the output file
lex create \`lex.yy.c', if possible, from existing .c
makeinfo touch the output file
yacc create \`y.tab.[ch]', if possible, from existing .[ch]
Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and
\`g' are ignored when checking the name.
Send bug reports to <bug-automake@gnu.org>."
exit $?
;;
-v|--v|--ve|--ver|--vers|--versi|--versio|--version)
echo "missing $scriptversion (GNU Automake)"
exit $?
;;
-*)
echo 1>&2 "$0: Unknown \`$1' option"
echo 1>&2 "Try \`$0 --help' for more information"
exit 1
;;
esac
# normalize program name to check for.
program=`echo "$1" | sed '
s/^gnu-//; t
s/^gnu//; t
s/^g//; t'`
# Now exit if we have it, but it failed. Also exit now if we
# don't have it and --version was passed (most likely to detect
# the program). This is about non-GNU programs, so use $1 not
# $program.
case $1 in
lex*|yacc*)
# Not GNU programs, they don't have --version.
;;
*)
if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
# We have it, but it failed.
exit 1
elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
# Could not run --version or --help. This is probably someone
# running `$TOOL --version' or `$TOOL --help' to check whether
# $TOOL exists and not knowing $TOOL uses missing.
exit 1
fi
;;
esac
# If it does not exist, or fails to run (possibly an outdated version),
# try to emulate it.
case $program in
aclocal*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acinclude.m4' or \`${configure_ac}'. You might want
to install the \`Automake' and \`Perl' packages. Grab them from
any GNU archive site."
touch aclocal.m4
;;
autoconf*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`${configure_ac}'. You might want to install the
\`Autoconf' and \`GNU m4' packages. Grab them from any GNU
archive site."
touch configure
;;
autoheader*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`acconfig.h' or \`${configure_ac}'. You might want
to install the \`Autoconf' and \`GNU m4' packages. Grab them
from any GNU archive site."
files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
test -z "$files" && files="config.h"
touch_files=
for f in $files; do
case $f in
*:*) touch_files="$touch_files "`echo "$f" |
sed -e 's/^[^:]*://' -e 's/:.*//'`;;
*) touch_files="$touch_files $f.in";;
esac
done
touch $touch_files
;;
automake*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
You might want to install the \`Automake' and \`Perl' packages.
Grab them from any GNU archive site."
find . -type f -name Makefile.am -print |
sed 's/\.am$/.in/' |
while read f; do touch "$f"; done
;;
autom4te*)
echo 1>&2 "\
WARNING: \`$1' is needed, but is $msg.
You might have modified some files without having the
proper tools for further handling them.
You can get \`$1' as part of \`Autoconf' from any GNU
archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo "#! /bin/sh"
echo "# Created by GNU Automake missing as a replacement of"
echo "# $ $@"
echo "exit 0"
chmod +x $file
exit 1
fi
;;
bison*|yacc*)
echo 1>&2 "\
WARNING: \`$1' $msg. You should only need it if
you modified a \`.y' file. You may need the \`Bison' package
in order for those modifications to take effect. You can get
\`Bison' from any GNU archive site."
rm -f y.tab.c y.tab.h
if test $# -ne 1; then
eval LASTARG=\${$#}
case $LASTARG in
*.y)
SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.c
fi
SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" y.tab.h
fi
;;
esac
fi
if test ! -f y.tab.h; then
echo >y.tab.h
fi
if test ! -f y.tab.c; then
echo 'main() { return 0; }' >y.tab.c
fi
;;
lex*|flex*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.l' file. You may need the \`Flex' package
in order for those modifications to take effect. You can get
\`Flex' from any GNU archive site."
rm -f lex.yy.c
if test $# -ne 1; then
eval LASTARG=\${$#}
case $LASTARG in
*.l)
SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
if test -f "$SRCFILE"; then
cp "$SRCFILE" lex.yy.c
fi
;;
esac
fi
if test ! -f lex.yy.c; then
echo 'main() { return 0; }' >lex.yy.c
fi
;;
help2man*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a dependency of a manual page. You may need the
\`Help2man' package in order for those modifications to take
effect. You can get \`Help2man' from any GNU archive site."
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -f "$file"; then
touch $file
else
test -z "$file" || exec >$file
echo ".ab help2man is required to generate this page"
exit $?
fi
;;
makeinfo*)
echo 1>&2 "\
WARNING: \`$1' is $msg. You should only need it if
you modified a \`.texi' or \`.texinfo' file, or any other file
indirectly affecting the aspect of the manual. The spurious
call might also be the consequence of using a buggy \`make' (AIX,
DU, IRIX). You might want to install the \`Texinfo' package or
the \`GNU make' package. Grab either from any GNU archive site."
# The file to touch is that specified with -o ...
file=`echo "$*" | sed -n "$sed_output"`
test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
if test -z "$file"; then
# ... or it is the one specified with @setfilename ...
infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
file=`sed -n '
/^@setfilename/{
s/.* \([^ ]*\) *$/\1/
p
q
}' $infile`
# ... or it is derived from the source name (dir/f.texi becomes f.info)
test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
fi
# If the file does not exist, the user really needs makeinfo;
# let's fail without touching anything.
test -f $file || exit 1
touch $file
;;
*)
echo 1>&2 "\
WARNING: \`$1' is needed, and is $msg.
You might have modified some files without having the
proper tools for further handling them. Check the \`README' file,
it often tells you about the needed prerequisites for installing
this package. You may also peek at any GNU archive site, in case
some other package would contain this missing \`$1' program."
exit 1
;;
esac
exit 0
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
-226
View File
@@ -1,226 +0,0 @@
#! /bin/sh
# ylwrap - wrapper for lex/yacc invocations.
scriptversion=2011-08-25.18; # UTC
# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005,
# 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
#
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
case "$1" in
'')
echo "$0: No files given. Try \`$0 --help' for more information." 1>&2
exit 1
;;
--basedir)
basedir=$2
shift 2
;;
-h|--h*)
cat <<\EOF
Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]...
Wrapper for lex/yacc invocations, renaming files as desired.
INPUT is the input file
OUTPUT is one file PROG generates
DESIRED is the file we actually want instead of OUTPUT
PROGRAM is program to run
ARGS are passed to PROG
Any number of OUTPUT,DESIRED pairs may be used.
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v|--v*)
echo "ylwrap $scriptversion"
exit $?
;;
esac
# The input.
input="$1"
shift
case "$input" in
[\\/]* | ?:[\\/]*)
# Absolute path; do nothing.
;;
*)
# Relative path. Make it absolute.
input="`pwd`/$input"
;;
esac
pairlist=
while test "$#" -ne 0; do
if test "$1" = "--"; then
shift
break
fi
pairlist="$pairlist $1"
shift
done
# The program to run.
prog="$1"
shift
# Make any relative path in $prog absolute.
case "$prog" in
[\\/]* | ?:[\\/]*) ;;
*[\\/]*) prog="`pwd`/$prog" ;;
esac
# FIXME: add hostname here for parallel makes that run commands on
# other machines. But that might take us over the 14-char limit.
dirname=ylwrap$$
do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret'
trap "ret=129; $do_exit" 1
trap "ret=130; $do_exit" 2
trap "ret=141; $do_exit" 13
trap "ret=143; $do_exit" 15
mkdir $dirname || exit 1
cd $dirname
case $# in
0) "$prog" "$input" ;;
*) "$prog" "$@" "$input" ;;
esac
ret=$?
if test $ret -eq 0; then
set X $pairlist
shift
first=yes
# Since DOS filename conventions don't allow two dots,
# the DOS version of Bison writes out y_tab.c instead of y.tab.c
# and y_tab.h instead of y.tab.h. Test to see if this is the case.
y_tab_nodot="no"
if test -f y_tab.c || test -f y_tab.h; then
y_tab_nodot="yes"
fi
# The directory holding the input.
input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'`
# Quote $INPUT_DIR so we can use it in a regexp.
# FIXME: really we should care about more than `.' and `\'.
input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'`
while test "$#" -ne 0; do
from="$1"
# Handle y_tab.c and y_tab.h output by DOS
if test $y_tab_nodot = "yes"; then
if test $from = "y.tab.c"; then
from="y_tab.c"
else
if test $from = "y.tab.h"; then
from="y_tab.h"
fi
fi
fi
if test -f "$from"; then
# If $2 is an absolute path name, then just use that,
# otherwise prepend `../'.
case "$2" in
[\\/]* | ?:[\\/]*) target="$2";;
*) target="../$2";;
esac
# We do not want to overwrite a header file if it hasn't
# changed. This avoid useless recompilations. However the
# parser itself (the first file) should always be updated,
# because it is the destination of the .y.c rule in the
# Makefile. Divert the output of all other files to a temporary
# file so we can compare them to existing versions.
if test $first = no; then
realtarget="$target"
target="tmp-`echo $target | sed s/.*[\\/]//g`"
fi
# Edit out `#line' or `#' directives.
#
# We don't want the resulting debug information to point at
# an absolute srcdir; it is better for it to just mention the
# .y file with no path.
#
# We want to use the real output file name, not yy.lex.c for
# instance.
#
# We want the include guards to be adjusted too.
FROM=`echo "$from" | sed \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
TARGET=`echo "$2" | sed \
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`
sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \
-e "s,$FROM,$TARGET," "$from" >"$target" || ret=$?
# Check whether header files must be updated.
if test $first = no; then
if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then
echo "$2" is unchanged
rm -f "$target"
else
echo updating "$2"
mv -f "$target" "$realtarget"
fi
fi
else
# A missing file is only an error for the first file. This
# is a blatant hack to let us support using "yacc -d". If -d
# is not specified, we don't want an error when the header
# file is "missing".
if test $first = yes; then
ret=1
fi
fi
shift
shift
first=no
done
else
ret=$?
fi
# Remove the directory.
cd ..
rm -rf $dirname
exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-end: "; # UTC"
# End:
+275 -36
View File
@@ -1,66 +1,305 @@
AC_INIT([jq], [1.3], [mu@netsoc.tcd.ie],
[jq], [http://stedolan.github.com/jq/])
m4_define([jq_version], m4_esyscmd_s([scripts/version])))
AC_INIT([jq],[jq_version],[https://github.com/jqlang/jq/issues],[jq],[https://jqlang.org])
dnl Created autoconf implementation thompson@dtosolutions, 26NOV12
AC_PREREQ([2.61])
AC_PREREQ([2.65])
AC_CONFIG_AUX_DIR([config])
AM_INIT_AUTOMAKE([parallel-tests foreign])
AC_USE_SYSTEM_EXTENSIONS
dnl Prefer GNU make on Solaris where /usr/bin/make is not suitable
AS_IF([test -z "$MAKE"], [
AS_CASE(["`uname -s`"], [SunOS], [MAKE=/usr/gnu/bin/make])
])
AM_INIT_AUTOMAKE([1.11.2 subdir-objects parallel-tests foreign -Wall])
AM_SILENT_RULES([yes])
AM_PROG_AR
AM_MAINTAINER_MODE([disable])
AC_PROG_CC
AC_PROG_CC_STDC
m4_version_prereq([2.70], [], [AC_PROG_CC_STDC])
AC_PROG_CPP_WERROR
AC_PROG_YACC
AC_OBJEXT
AC_EXEEXT
LT_INIT([shared static win32-dll])
AM_PROG_CC_C_O
AC_SYS_LARGEFILE # issue 2167
dnl couldn't use AM_PROG_LEX as it doesn't support header files like the
dnl AC_PROG_YACC macros...
dnl
dnl these program checks should probably be deleted
dnl
dnl check bison version
AC_PROG_LEX
if test "x$LEX" != xflex; then
LEX="$SHELL $missing_dir/missing flex"
if test "$USE_MAINTAINER_MODE" = yes; then
if test "$YACC" != "bison -y"; then
AC_MSG_CHECKING([bison version])
AC_MSG_RESULT([not bison])
else
AX_PROG_BISON_VERSION([3],
[],
[AC_MSG_ERROR([You need bison version 3.0 or greater])])
fi
AC_CHECK_PROGS(LEX, flex lex)
fi
AC_CHECK_FUNCS(memmem)
dnl Check for valgrind
AC_CHECK_PROGS(valgrind_cmd, valgrind)
if test "x$valgrind_cmd" = "x" ; then
AC_MSG_WARN([valgrind is required to test jq.])
fi
AC_CHECK_HEADER("sys/cygwin.h", [have_cygwin=1;])
AC_CHECK_HEADER("shlwapi.h",[have_shlwapi=1;])
AM_CONDITIONAL([WIN32], [test "x$have_shlwapi" = x1 && test ! "x$have_cygwin" = x1])
dnl Running tests with Valgrind is slow. It is faster to iterate on
dnl code without Valgrind until tests pass, then enable Valgrind and
dnl fix leaks.
AC_ARG_ENABLE([valgrind],
AS_HELP_STRING([--enable-valgrind],[enable Valgrind during testing]))
dnl Don't attempt to build docs if there's no Ruby lying around
dnl Address sanitizer (ASan)
AC_ARG_ENABLE([asan],
AS_HELP_STRING([--enable-asan],[enable address sanitizer]))
dnl Undefined Behavior Sanitizer
AC_ARG_ENABLE([ubsan],
AS_HELP_STRING([--enable-ubsan],[enable undefined behavior sanitizer]))
dnl Code coverage
AC_ARG_ENABLE([gcov],
AS_HELP_STRING([--enable-gcov],[enable gcov code coverage tool]))
dnl Don't attempt to build docs if python deps aren't installed
AC_ARG_ENABLE([docs],
AC_HELP_STRING([--disable-docs], [don't build docs]))
AS_HELP_STRING([--disable-docs],[do not build docs]), [], [enable_docs=yes])
dnl Don't attempt to build the error injection object (if there is no LD_PRELOAD support)
AC_ARG_ENABLE([error-injection],
AS_HELP_STRING([--enable-error-injection],[build and test with error injection]))
dnl Enable building all static
AC_ARG_ENABLE([all-static],
AS_HELP_STRING([--enable-all-static],[link jq with static libraries only]))
dnl find pipenv
AC_ARG_VAR([PIPENV], [pipenv command])
AC_CHECK_PROGS([PIPENV], pipenv)
AS_IF([test "x$enable_docs" != "xno"],[
AC_CHECK_PROGS(bundle_cmd, bundle)
AS_IF([test "x$bundle_cmd" = "x" || \
! ( cd ${srcdir}/docs; "$bundle_cmd" check 2>/dev/null )],[
AC_MSG_WARN([no bundler])
cat <<EOF
AC_CACHE_CHECK([for Python dependencies], [jq_cv_python_deps],[
jq_cv_python_deps=yes
AS_IF([test "x$PIPENV" = "x" || \
! bmsg="`cd ${srcdir}/docs; LC_ALL=$LANG "$PIPENV" --venv`"],[
jq_cv_python_deps=no
])
])
AS_IF([test "x$jq_cv_python_deps" != "xyes"], [
AC_MSG_WARN([Error checking python dependencies: $bmsg
*****************************************************************
* Ruby dependencies for building jq documentation not found. *
* Python dependencies for building jq documentation not found. *
* You can still build, install and hack on jq, but the manpage *
* will not be rebuilt and some of the tests won't run. *
* will not be rebuilt and new manpage tests will not be run. *
* See docs/README.md for how to install the docs dependencies. *
*****************************************************************
EOF
enable_docs=no
*****************************************************************])
enable_docs=no
])
])
AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno])
AC_SUBST([BUNDLER], ["$bundle_cmd"])
dnl Disable decNumber support
AC_ARG_ENABLE([decnum],
AS_HELP_STRING([--disable-decnum],[disable decnum support]))
dnl AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS(config.h)
AM_INIT_AUTOMAKE([-Wall])
AC_CONFIG_FILES([Makefile])
AS_IF([test "x$enable_decnum" != "xno"],[
AC_DEFINE([USE_DECNUM], 1, [Define to enable decnum support.])
])
AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" = xyes])
AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = xyes])
AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = xyes])
AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" = xyes])
AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno])
AM_CONDITIONAL([ENABLE_ERROR_INJECTION], [test "x$enable_error_injection" = xyes])
AM_CONDITIONAL([ENABLE_ALL_STATIC], [test "x$enable_all_static" = xyes])
dnl Find pthread, if we have it. We do this first because we may set -pthread on CFLAGS
dnl which can cause various macros to be defined (__REENTRANT on Darwin, for example)
AX_PTHREAD([
AC_DEFINE([HAVE_PTHREAD], [1], [Define to enable POSIX threads support.])
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
])
AC_FUNC_ALLOCA
AC_FIND_FUNC([isatty], [c], [#include <unistd.h>], [0])
AC_FIND_FUNC([_isatty], [c], [#include <io.h>], [0])
AC_FIND_FUNC([strptime], [c], [#include <time.h>], [0, 0, 0])
AC_FIND_FUNC([strftime], [c], [#include <time.h>], [0, 0, 0, 0])
AC_FIND_FUNC([setenv], [c], [#include <stdlib.h>], [0, 0, 0])
AC_FIND_FUNC([timegm], [c], [#include <time.h>], [0])
AC_FIND_FUNC([gmtime_r], [c], [#include <time.h>], [0, 0])
AC_FIND_FUNC([gmtime], [c], [#include <time.h>], [0])
AC_FIND_FUNC([localtime_r], [c], [#include <time.h>], [0, 0])
AC_FIND_FUNC([localtime], [c], [#include <time.h>], [0])
AC_FIND_FUNC([gettimeofday], [c], [#include <sys/time.h>], [0, 0])
AC_CHECK_MEMBER([struct tm.tm_gmtoff], [AC_DEFINE([HAVE_TM_TM_GMT_OFF],1,[Define to 1 if the system has the tm_gmt_off field in struct tm])],
[], [[#include <time.h>]])
AC_CHECK_MEMBER([struct tm.__tm_gmtoff], [AC_DEFINE([HAVE_TM___TM_GMT_OFF],1,[Define to 1 if the system has the __tm_gmt_off field in struct tm])],
[], [[#include <time.h>]])
AC_FIND_FUNC([setlocale], [c], [#include <locale.h>], [0,0])
AC_FIND_FUNC([arc4random], [c], [#include <stdlib.h>], [])
AC_FIND_FUNC([getentropy], [c], [#include <unistd.h>], [0, 0])
dnl Figure out if we have the pthread functions we actually need
AC_FIND_FUNC_NO_LIBS([pthread_key_create], [], [#include <pthread.h>], [NULL, NULL])
AC_FIND_FUNC_NO_LIBS([pthread_once], [], [#include <pthread.h>], [NULL, NULL])
AC_FIND_FUNC_NO_LIBS([atexit], [], [#include <stdlib.h>], [NULL])
dnl libm math.h functions
AC_CHECK_MATH_FUNC(acos)
AC_CHECK_MATH_FUNC(acosh)
AC_CHECK_MATH_FUNC(asin)
AC_CHECK_MATH_FUNC(asinh)
AC_CHECK_MATH_FUNC(atan2)
AC_CHECK_MATH_FUNC(atan)
AC_CHECK_MATH_FUNC(atanh)
AC_CHECK_MATH_FUNC(cbrt)
AC_CHECK_MATH_FUNC(ceil)
AC_CHECK_MATH_FUNC(copysign)
AC_CHECK_MATH_FUNC(cos)
AC_CHECK_MATH_FUNC(cosh)
AC_CHECK_MATH_FUNC(drem)
AC_CHECK_MATH_FUNC(erf)
AC_CHECK_MATH_FUNC(erfc)
AC_CHECK_MATH_FUNC(exp10)
AC_CHECK_MATH_FUNC(__exp10) dnl macOS has an __exp10
AC_CHECK_MATH_FUNC(exp2)
AC_CHECK_MATH_FUNC(exp)
AC_CHECK_MATH_FUNC(expm1)
AC_CHECK_MATH_FUNC(fabs)
AC_CHECK_MATH_FUNC(fdim)
AC_CHECK_MATH_FUNC(floor)
AC_CHECK_MATH_FUNC(fma)
AC_CHECK_MATH_FUNC(fmax)
AC_CHECK_MATH_FUNC(fmin)
AC_CHECK_MATH_FUNC(fmod)
AC_CHECK_MATH_FUNC(frexp)
AC_CHECK_MATH_FUNC(gamma)
AC_CHECK_MATH_FUNC(hypot)
AC_CHECK_MATH_FUNC(j0)
AC_CHECK_MATH_FUNC(j1)
AC_CHECK_MATH_FUNC(jn)
AC_CHECK_MATH_FUNC(ldexp)
AC_CHECK_MATH_FUNC(lgamma)
AC_CHECK_MATH_FUNC(log10)
AC_CHECK_MATH_FUNC(log1p)
AC_CHECK_MATH_FUNC(log2)
AC_CHECK_MATH_FUNC(log)
AC_CHECK_MATH_FUNC(logb)
AC_CHECK_MATH_FUNC(modf)
AC_CHECK_MATH_FUNC(lgamma_r)
AC_CHECK_MATH_FUNC(nearbyint)
AC_CHECK_MATH_FUNC(nextafter)
AC_CHECK_MATH_FUNC(nexttoward)
AC_CHECK_MATH_FUNC(pow)
AC_CHECK_MATH_FUNC(remainder)
AC_CHECK_MATH_FUNC(rint)
AC_CHECK_MATH_FUNC(round)
AC_CHECK_MATH_FUNC(scalb)
AC_CHECK_MATH_FUNC(scalbln)
AC_CHECK_MATH_FUNC(significand)
dnl scalbn and ilogb are used on macos to replace significand if we don't have frexp
AC_CHECK_MATH_FUNC(scalbn)
AC_CHECK_MATH_FUNC(ilogb)
AC_CHECK_MATH_FUNC(sin)
AC_CHECK_MATH_FUNC(sinh)
AC_CHECK_MATH_FUNC(sqrt)
AC_CHECK_MATH_FUNC(tan)
AC_CHECK_MATH_FUNC(tanh)
AC_CHECK_MATH_FUNC(tgamma)
AC_CHECK_MATH_FUNC(trunc)
AC_CHECK_MATH_FUNC(y0)
AC_CHECK_MATH_FUNC(y1)
AC_CHECK_MATH_FUNC(yn)
dnl Thread local storage
have___thread=no
AC_MSG_CHECKING(for thread-local storage)
AC_LINK_IFELSE([AC_LANG_SOURCE([
static __thread int x ;
int main () { x = 123; return x; }
])], have___thread=yes)
if test $have___thread = yes; then
AC_DEFINE([HAVE___THREAD],1,[Define to 1 if the system supports __thread])
fi
AC_MSG_RESULT($have___thread)
AC_C_BIGENDIAN(
AC_DEFINE([IEEE_MC68k], 1, [machine is bigendian]),
AC_DEFINE([IEEE_8087], 1, [machine is littleendian]),
AC_MSG_ERROR(unknown endianness),
AC_MSG_ERROR(universal endianness not supported)
)
dnl Oniguruma
AC_ARG_WITH([oniguruma],
[AS_HELP_STRING([--with-oniguruma=prefix],
[try this for a non-standard install prefix of the oniguruma library])], ,
[with_oniguruma=yes])
onig_CFLAGS=
onig_LDFLAGS=
build_oniguruma=no
AS_IF([test "x$with_oniguruma" != xno], [
save_CFLAGS="$CFLAGS"
save_LDFLAGS="$LDFLAGS"
AS_IF([test "x$with_oniguruma" != xyes], [
AS_IF([test "x$with_oniguruma" = xbuiltin], [
build_oniguruma=yes
], [
onig_CFLAGS="-I${with_oniguruma}/include"
onig_LDFLAGS="-L${with_oniguruma}/lib"
])
])
AS_IF([test "x$build_oniguruma" = xno], [
# check for ONIGURUMA library, either in /usr or where requested
CFLAGS="$CFLAGS $onig_CFLAGS"
LDFLAGS="$LDFLAGS $onig_LDFLAGS"
AC_CHECK_HEADER("oniguruma.h",
AC_CHECK_LIB([onig],[onig_version]))
# handle check results
AS_IF([test "x$ac_cv_lib_onig_onig_version" != "xyes"], [
build_oniguruma=yes
AC_MSG_NOTICE([Oniguruma was not found. Will use the packaged oniguruma.])
])
])
AS_IF([test "x$build_oniguruma" = xyes && test -f "${srcdir}/vendor/oniguruma/configure.ac" ], [
onig_CFLAGS="-I${srcdir}/vendor/oniguruma/src"
onig_LDFLAGS="-L${srcdir}/vendor/oniguruma/src -Wl,-rpath,${libdir}"
AC_CONFIG_SUBDIRS([vendor/oniguruma])
AC_DEFINE([HAVE_LIBONIG],1,[Define to 1 if the system includes libonig])
])
CFLAGS="$save_CFLAGS"
LDFLAGS="$save_LDFLAGS"
])
AC_SUBST(onig_CFLAGS)
AC_SUBST(onig_LDFLAGS)
AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes])
AM_CONDITIONAL([WITH_ONIGURUMA], [test "x$with_oniguruma" != xno])
dnl On Solaris, strptime clears the tm structure before parsing. This breaks the
dnl sentinel logic in builtin.c, which then incorrectly assumes that strptime set
dnl tm_wday and tm_yday. Defining _STRPTIME_DONTZERO disables that behavior.
AS_IF([test "x`uname -s 2>/dev/null`" = "xSunOS"], [
CPPFLAGS="$CPPFLAGS -D_STRPTIME_DONTZERO"
])
AC_CONFIG_MACRO_DIRS([config/m4 m4])
AC_CONFIG_FILES([Makefile libjq.pc])
AC_OUTPUT
-6
View File
@@ -1,6 +0,0 @@
.DS_Store
.sass-cache
output/*
# Autogenerated from public/css/base.scss
public/css/base.css
-6
View File
@@ -1,6 +0,0 @@
source "https://rubygems.org"
gem "rake"
gem "bonsai"
gem "maruku"
gem "ronn"
-63
View File
@@ -1,63 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
POpen4 (0.1.4)
Platform (>= 0.4.0)
open4
Platform (0.4.0)
activesupport (3.2.12)
i18n (~> 0.6)
multi_json (~> 1.0)
addressable (2.3.4)
bonsai (1.4.8)
activesupport (>= 3.0.3)
builder (>= 3.0.0)
i18n (>= 0.5.0)
launchy (>= 0.3.7)
liquid (>= 2.2.2)
maruku (>= 0.6.0)
rack
sass
sinatra (>= 1.0)
tilt (>= 1.3)
watch (>= 0.1.0)
yui-compressor
builder (3.2.0)
hpricot (0.8.6)
i18n (0.6.4)
launchy (2.3.0)
addressable (~> 2.3)
liquid (2.5.0)
maruku (0.6.1)
syntax (>= 1.0.0)
multi_json (1.7.3)
mustache (0.99.4)
open4 (1.3.0)
rack (1.5.2)
rack-protection (1.5.0)
rack
rake (10.0.3)
rdiscount (2.0.7.2)
ronn (0.7.3)
hpricot (>= 0.8.2)
mustache (>= 0.7.0)
rdiscount (>= 1.5.8)
sass (3.2.8)
sinatra (1.4.2)
rack (~> 1.5, >= 1.5.2)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
syntax (1.0.0)
tilt (1.4.0)
watch (0.1.0)
yui-compressor (0.9.6)
POpen4 (>= 0.1.4)
PLATFORMS
ruby
DEPENDENCIES
bonsai
maruku
rake
ronn
+14
View File
@@ -0,0 +1,14 @@
[[source]]
name = "pypi"
url = "https://pypi.org/simple"
verify_ssl = true
[dev-packages]
[packages]
jinja2 = "*"
pyyaml = "*"
markdown = "*"
lxml = "*"
jsonschema = "*"
importlib_resources = "*"
+561
View File
@@ -0,0 +1,561 @@
{
"_meta": {
"hash": {
"sha256": "14036c3c9f103c52a0c5a53346ef33c2fbef409697f9eb314da51ccdd3aa9fb2"
},
"pipfile-spec": 6,
"requires": {},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"attrs": {
"hashes": [
"sha256:16d5969b87f0859ef33a48b35d55ac1be6e42ae49d5e853b597db70c35c57e11",
"sha256:adcf7e2a1fb3b36ac48d97835bb6d8ade15b8dcce26aba8bf1d14847b57a3373"
],
"markers": "python_version >= '3.9'",
"version": "==25.4.0"
},
"importlib-metadata": {
"hashes": [
"sha256:d13b81ad223b890aa16c5471f2ac3056cf76c5f10f82d6f9292f0b415f389000",
"sha256:e5dd1551894c77868a30651cef00984d50e1002d06942a7101d34870c5f02afd"
],
"markers": "python_version >= '3.9'",
"version": "==8.7.0"
},
"importlib-resources": {
"hashes": [
"sha256:4cf94875a8368bd89531a756df9a9ebe1f150e0f885030b461237bc7f2d905f2",
"sha256:d952faee11004c045f785bb5636e8f885bed30dc3c940d5d42798a2a4541c185"
],
"index": "pypi",
"version": "==6.0.0"
},
"jinja2": {
"hashes": [
"sha256:0137fb05990d35f1275a587e9aee6d56da821fc83491a0fb838183be43f66d6d",
"sha256:85ece4451f492d0c13c5dd7c13a64681a86afae63a5f347908daf103ce6d2f67"
],
"index": "pypi",
"markers": "python_version >= '3.7'",
"version": "==3.1.6"
},
"jsonschema": {
"hashes": [
"sha256:0c26707e2efad8aa1bfc5b7ce170f3fccc2e4918ff85989ba9ffa9facb2be326",
"sha256:d489f15263b8d200f8387e64b4c3a75f06629559fb73deb8fdfb525f2dab50ce"
],
"index": "pypi",
"markers": "python_version >= '3.10'",
"version": "==4.26.0"
},
"jsonschema-specifications": {
"hashes": [
"sha256:98802fee3a11ee76ecaca44429fda8a41bff98b00a0f2838151b113f210cc6fe",
"sha256:b540987f239e745613c7a9176f3edb72b832a4ac465cf02712288397832b5e8d"
],
"markers": "python_version >= '3.9'",
"version": "==2025.9.1"
},
"lxml": {
"hashes": [
"sha256:032a0a97eed428bd143c75a11118238546424ceb2fa311cca5f073aa44658dc4",
"sha256:05f5bce9af14fd1506997594bd81cee6d9c6b58ea80a39c058327aa6371ed9e9",
"sha256:0794e04ba343852c6d78e996c58ef4b8e579b4ecc72f8df0d4058bf843b4c96e",
"sha256:0ab2467e405e748d93495fb5568e74044802b8d3ff2b2a1607c3f78c6e982de5",
"sha256:0bf5a3e397df2ec4258eb5eea4c1ac6cf013ca1abd04a176903bff20a70021fe",
"sha256:0c0710ac085a157b593c38fbcacd950f15c4afa8e2057527185875ab302752bc",
"sha256:0dee106e9aa97fb00541b1ed7827070564d0549c3d3fba8920e6b20fd980f748",
"sha256:0f17d83c48ee9dfd96abae3ac3e2108c76d2fc86ce96355e37b8da9f7f4ecc08",
"sha256:0feebef8d0521188d0157f758356072e840173aa61ca45b8b3f87959ac283dd5",
"sha256:13a620a3fcc20023f9e6ed5c383e00e826f1c2d5db554df2f67240760f9118e8",
"sha256:13d22c0d57355366b393936acf6b98a5e0edeadddd3fccbc6a846c50a76b8741",
"sha256:160fcf381f76c3aeac28a756bec44f48942a8f7245a87aa28e3a523b4d90cd87",
"sha256:16148acd77ed1d8836a56db883af2f5eed720f9723088110b16a0d08582130a6",
"sha256:170773d8a3cdc76259065523ddd978c44f9806e28605f08812e8f86783e44ac6",
"sha256:18293f8a8d8b6a8e71ef37706b659e3846a4261232158167b1ddf35f6994f633",
"sha256:18a4db52b5a7b53a3540b0b0f4123319334621ee8083d496de314d0bf06ff59a",
"sha256:1a635e837b50a1819bebfedaac5916498ea024120969da8790500148fb0a894d",
"sha256:1aeca87830c4fe649dcf93fe2b059525b71c72587f21be4ae4af7103082a79fa",
"sha256:1b7c37339d7e75cab9a123a04248e243cefefb302ad6db566ea0c77cbcde421e",
"sha256:1beb0f9909b26cee938df9ba56b15252a84429b1fc30ce6fca161390b9789a70",
"sha256:20384c2bbcbf87180c8c61eb60869699c1ec0cd09b62cfd13804022d860b0867",
"sha256:20428910dae17a1a93152a3ff2c0441d2f4932992c0797d65651dd0561f1792f",
"sha256:207dfc3d47cf0e575e643bbc140dacc8863b39abaa1e5307cd64c7f2365b8a12",
"sha256:209c3ccbfe35a04ac6d24f0611f9d1cbf8025d49991b14acd935236234d6c156",
"sha256:2123e5aa075ac20d23c7af489255efd129cbfe190dbe88fd42598cc9df3199b6",
"sha256:21402998e4b78e7cce237d2788841aaa21ac9a4d1574d04dc2d12ee41ae807b5",
"sha256:2221e88679d1351e9a40aaee54bc65679b9795bbd0160bc3d5e36b163344eb75",
"sha256:22eec57e26c418cde02c051ce9914a365e52a7f135a565c6f0480242aeebab48",
"sha256:23c366231259cd75ad06495174701afb3fcb36a92917fa47de2d1f1bd9d95739",
"sha256:25f4118c438f96bb466e83108506d03d5c31b1bd2387e83e5b070bda6ded9c37",
"sha256:28a23fefdb345b2d4d0ff2860571b5ff9a89a28b6a120f720e8fb0324d346626",
"sha256:290f66b97ede0e552e1cb44a0fd8a74f9753ee635b50830a0b122fb72788d015",
"sha256:2b9b1325ca1c2a9a2dbb6eb913ae563313f2082ae60b03210f7e83ee80712274",
"sha256:2bec13085dc8ef48a3fe62f7dfcacfeda2c785cdf19cc8eeda2bb9ed081da165",
"sha256:2cae5d5c90a62d9139c512a0cb1aad1d182b022b5740daea2617eb5bf7fc658e",
"sha256:2e01125896585139453cab8cb235893644d8815d7509520da95ae3ee8d1c1f79",
"sha256:2e62c569ec7531b679b184cbfe335c501c1d13c4b363560013019962eb630e6d",
"sha256:2f5b2a2b9811b853b39bfa41367c6d78747b8e3e80e07fc5a24aae295c1a4d7d",
"sha256:302f72413251c03f671e063c9414bed5dc8c927069e5abb69245521e51a4e81b",
"sha256:32a409be3190b088f960ac92bfedfbef2f86c49ff940765e1548177592d20026",
"sha256:33cadd956b667997e4de1635fce9541f2e8ede2038fcde8cf55aa14d571d1bad",
"sha256:379f8a75cf6eb7eef0af074b55f49ab73b868388a98de14646abcdfa4564bb11",
"sha256:3847e71a78cbbc1aff955dbbbaf2fff12153f611d3162c5beaa3395636cbc2f9",
"sha256:38fc4e4e4e084e0bd491949482527d406788045c546d4f8789e93fc527b91385",
"sha256:3a27ac6c780c8b8a1cd231b58407634cafc1c4cc28cd6c7141362df0f36351e7",
"sha256:3a48093cdb058a93af842ede9703520e810b05dcd0fc6d7190a06376c3bfb6bd",
"sha256:3e42265103fb385d8642a78672edf376c6f7e1d3598a7a4f9cb1278f2f6b5f6f",
"sha256:3e9a00d1c2c30936f7add097c41afc5da6556c580909104aafd382cac92a855c",
"sha256:40983eabefd13da003e68170928c7acc011f0d095eefce5871a3c71c9385fb9a",
"sha256:40bcbd9f94166ffe925811e730607385cec959f42fb1bb7dad83748680465221",
"sha256:41096ec0740a58dad03d3ae0c7486d306d20becefb13ceb1649835ab3eb64167",
"sha256:415e3a115c0d510e329020012834d1c0aa1c581ee53a218603e38abbc1dea70a",
"sha256:41e2d428110b408e963b6fb18f9bbf1f5c027b56bd4b498d54556476c0aeb1c3",
"sha256:424aa5657141d306ba9ad1baab4b2c0a0719040075ee6c66aee9bb2dea2b5054",
"sha256:42632b4024ab24a6b488f559ac851312509888b6b80ae2aa11cf29a646a0d245",
"sha256:45222d94ddd511536f3b2f7d9deae3b2339b4ce0f075f1ca25703b07cad9dd21",
"sha256:4736e6c87e603146d8949d8501da621ad20c31015060d3fcf95ace2859f3e3e6",
"sha256:48542c9acba9ff9450bd18d871d2c2c8787fdb283572b623d206f1b927cd7d9e",
"sha256:49fbc2682a9306135b7ec49e93f97f9c26689b9b7f96ed2742d8d6497e994d13",
"sha256:4a579dfb9c835f8ab47f4b8ed33440cbc75b806b73297208e6ec2a33e903740b",
"sha256:4b061064b4a2fe8598a466d723d43dbcd5a610a5d5cfe02fb6226f5c17349f75",
"sha256:4e11e885e0704be185867fcf71b904d8f65d7d6877bc121f69870b0d0479ba7b",
"sha256:4f4db7c7e954d289d71878938348b3d91b904a3e8210a11939359fb758a58e7d",
"sha256:527195c188d7d0af748cd48d220ab8cdc5cb99be3d49ac4d9be7324d8abf9bc0",
"sha256:53258656846f5c48996b882fb4b135885e088a3ad3d96b4bc0530f95124d1f69",
"sha256:545ccc14fb05485f48b4439ec35beb16d5b5280eb6c81c658bd4707a2a119414",
"sha256:5609efdb0d3c95499c00046bc53648b3482ec2175b5503d6e611b3f0555dc71d",
"sha256:5929d9df5e7e3379183be0e21f7d559618a5b61cb63280df6164019242e337ed",
"sha256:5a143e6207579de8baeded4eaac9134413200359f1969d636f0bfb98ee8c3c8f",
"sha256:5a721a98c649855963811b59b55755b30566e7f7fc40bdc9803d66dee9f811cf",
"sha256:5cffe18571ccc51d742cd08cbb3f8b756de9311d18c7ea98f5d92f37b8fb60c2",
"sha256:5d12669a2c419b0e8dc423d23dea24bb82f6f9cb829f32e04674b0ba40322a7c",
"sha256:5d582042c69857c364e8153de6e18e0da9b7b515a6a8113caf69a6ec8e0520f2",
"sha256:61116cec57ed69aebc70f37a545eec095339bb829efbdabcfb97c51e9536e158",
"sha256:611a51e61c92f62345a50b0035df6fc0d678f9299f33728826d831598862f59d",
"sha256:623c8799c17128753c65699f1c3aa32402657393a9ad6db09ed8b98ddf76611d",
"sha256:6374e9e382e5a98c9c5e66d41b357b470da1c54bce30f17f9dc4bcc58436cc1c",
"sha256:66299564c046bc7e0cc5de5106601eae907e9fa5904cd68a323380a8502f7861",
"sha256:69cafd61aea04ebb3502c93c2aaa568b12931ca0802231e0b5de76bf8b6e74bd",
"sha256:6a406d0b3cb207b0fa460ed4dc93e866f44f105da0169361cb18ff998a44c7f0",
"sha256:6ba4fe5bfbef6811a8e49b3719cde373ad399006c0c1ac184b7297116ecbba5d",
"sha256:6cd11e7550d89e551a87dcec30f04b1fca32e86b68708aa01a4daa455d8605e5",
"sha256:6e1eb8a4cbffd5553680ad96be6680e364710656eced73d1dc90ec489df599a3",
"sha256:6ea2f13dce778ca072ccee598bca46a092ce192e8fd907b6c1f0e52c800529a0",
"sha256:71532ebf30be0048a45559b4fab15333fbaaf9042f658e878d918ecd0cf09805",
"sha256:73fc05988ed20809450474ba760a87c8ad4e455fc09783c02195e56ec634b41a",
"sha256:75cc6569e86be5785b6188ef1642670c6adbc984e81ec35e224842ecd9eefcc8",
"sha256:773062aec2f2e56b2b22d37054123f0de8a22a4688a0c3376c3fe42685f975cf",
"sha256:7ae4949f212a53b007dbc355884fda122545c5764a54256c9217e419a62a6559",
"sha256:7b2bb7d703bed7ac893bf7f40d97b5d9279d35d2ce460624ca28929eab0d5a3d",
"sha256:7d0f5976aa2701996f759b30172925829867547bb073af0ae67d1307a0f0262c",
"sha256:7d5a748d12dd9b535e0a130f60dae9ddf0adafbabe61e7864f55c7436c84547a",
"sha256:7dd624c1eaa629ad44b59a1a0145fdf2d67895592dce94c9358b938b3d075e65",
"sha256:7f75b9b9fec2a9c6b18095c81865580e795b1441c429e42d22fcc82a77f40039",
"sha256:83e3a51e7933db700a0da0db31849db3a24022d9970da9bb73001e1d0326fd92",
"sha256:8499d464de86fab0f102313cce32a9bed9ab1f06ec813cf025cb790964fbb765",
"sha256:869dfcd4d381cb0ea87085cc4f011b9171b494ef21e76ad8665f6d5e2d1dc8a1",
"sha256:8753b8d51dbc86fd335ee31fcf7f3658e9f5c016d4edfb23f76ad295f4b8c9d0",
"sha256:887c021d9a977cff89cb273047c1352997b772a8908a25c21836861f69b92be1",
"sha256:88e719b9437f148f7e1465df845c758dd1598618cbea3a2fd1e61a715542f2b2",
"sha256:8a330c0ee5fa318c7b5cbbaad882baeca3f570357e7eb25ab34bf31008150758",
"sha256:8db38ff3fb7aee7d6a82ae4da2eef1178656fe1216841fbd24870062a9d60473",
"sha256:8e49a646acfab83c68974f4aa1d0a2acca9e88d7d627ae0fc13201b14b76d310",
"sha256:909f4e927bb051f7740d6367285fc60cdcfdaf0258c2dba4ff5ba7eadadc250c",
"sha256:90f709b9accab6b2e4d14f5c8718203877a0486bcb3afd74d8b539ecd1e961d4",
"sha256:92d96586376fb79a33474797186bf993250152ee5c32650b67db78d54b92e6f3",
"sha256:93476b6514b373fc6ca67d26c442784f7807c86f00635bfe79f935c3eab2af17",
"sha256:97acecb11cbc411473f15b8d780df06d7a9f3a2aad9aca78364f56640c8fb70e",
"sha256:97ce49699d87ebf8aad631b55d65b33219a4f1bfefbbf5bff19dc9af160aeaf9",
"sha256:9bde9ae026a55b9a192078dfa6e27dd0ca4a050171ab6272e92f97b757dfdf48",
"sha256:9e67324961ac9bbe616cce5100514d2e34d88665aeb07071e8b16eac55d06d94",
"sha256:9efe56a68179f3adc4de41861c9358931db03837c48dd5e1c78077b84dd07f3a",
"sha256:a1932d7ce78a561367512c594fe66eac2b2ec9b9264cfd9b5f950622f4a116e2",
"sha256:a1cec0f99b9b914d39176347a93b7610dc09324491aee1cbc57cd291a41a1d55",
"sha256:a2e3f70673a1d5b82f38255f777d26cd855bf2092b1436c4867464a7892f9238",
"sha256:a43b3bdf11e477dc7770609d3477316f974354dfc8425d596f64f471cc8daf6e",
"sha256:a5c18810318303ce9afb3f95e2ddb54834f96fa699a8600433fd5a93dcf44c56",
"sha256:a7eb78ba28b187e1e9203a55c60fcf70df2d22cb205fe6d51b9383d6097419f0",
"sha256:aa633613ff907ea91b9b0489a1f0da1b8725d8c6ccec6b77e8a1c9c235044bb0",
"sha256:aa9fd1ee2a5dacfc41039ed49ffeeacfa75bafbd255b69f3b578e11897a0e623",
"sha256:ace1d2c83b2bd24db5940600541140e87a325e119cb32d5fa9ad720d7e76648e",
"sha256:b1cc980905221a5d8b3c476330730b3adb40ff80add71ffbdb6215ba055656f1",
"sha256:b37772102d44bb6628186accca3a121b1fa3a6b3d97518a8c29a5229ca4c0d0a",
"sha256:b3ff39654f0ce6ebd4db154211136dbe7e8157bcc3bed2344c87f32c7c6ecb6c",
"sha256:b477912f42c5c33405a10c759d22f80cf5af043ae02d95b9d8e5e5bc555739ed",
"sha256:b49638355ea3bebba70da783ccbc630fd72afa16bc46c54474bfa1f9a915bbc6",
"sha256:b4fc6b03b9d9d90557274f571ab30e7fbbfc527955536935d96f98b6817a86e4",
"sha256:b50343241eb69fd85f7791cf8bcc7b1c4729826b7d59ba2f6b27db29638fa745",
"sha256:bc8dd3d9c93e70c3df974a201ac2958b6d77b465d813c51d1f15fa8e645763ae",
"sha256:be5346653c0b0e34be96869ff9dbeba23860156f89a2896a64c64fb419260cb6",
"sha256:c00e26288784460885fe76e4d4b293573e0f791f52e6d60e27b42edf005922eb",
"sha256:c1b50797ac246bb2942a04b6c0f69af0667aba7cf7535f39bbb1b3208fd5d128",
"sha256:c34ca1dc41bd86d9ff830d5bdf4e4a752bba6c54f7d2707027ce0eabd36084c9",
"sha256:c55e71a9b1db1f107efb60da49c093689b74c5c31a708e5379e2fd9439d4fbb5",
"sha256:c581b1d68b3845fb86c6b2983e755b29bf001461c59fa411d2c26a911b6559a9",
"sha256:c59e4265608da6a041f54646ecc0c9ecdbb19aaf14c4c684bb6c2114998cc415",
"sha256:c5e7ce578aa8a80910a72a8ca0bbea3baae10100827249001999726a788456d8",
"sha256:c66f858b82497173f73366795fc6ee8171620e75a338506d6b2e7bc16f5fca11",
"sha256:c6c0c13128a32eb04a51357e56a094e13aa8e6d3d1884de2e9ae923f6915e1a8",
"sha256:c9389b3784b56c58d933b5e0aecdf28f901b073ff385358d8a7d40907f6e14b2",
"sha256:ca0ec532ad2f5ba1e5ec120ac157769c57f01855b3d8bf37213f5d88abd9ba0a",
"sha256:cad7617727a96d189bd6f979d0fadf765198c7934e85f4edaba9bf3ad919a300",
"sha256:cae82b5ca24b0c2beedb269f6e2a96f466acd926879ab00ae19f1a65cbf9ffb0",
"sha256:cc669256d28736f7f3a149df5c380c50ace2692ba3e62203d10656fade4a2145",
"sha256:ce1f220114959941170e22b8ad44279f6dee2dcef7591814d01ae805dc058889",
"sha256:cfb398886a7eb4c719161c3efcff2a1248febc53a4d8e5072d2d8a87fed84ac9",
"sha256:d077f21f4b16f0471353883748f126f62038760397c107bb9fad2ca94dc0dfb7",
"sha256:d0c5c362bc94f1929dc7e96e715bbe7bd17037f802e6d8f0d1545df9133c0559",
"sha256:d2765c18ce303149ee804b1f3dad11232726dd0a702d73a15cf19179ac8cc962",
"sha256:d44442effeb8781f392340c5dc8c6716fba41dbeacb82fd4c0f09026fb5ff682",
"sha256:d85dfab42dd672f87a7f76e9de7172962aee69fa12044f0d6e1a23cbd53fb80e",
"sha256:d97c5227621af74b111882a290b10f371780a38eef9d9e730408fba2259b52fb",
"sha256:d9a0d12846d6ce434fb3857918eef4315ec9b4769deb020c75828798614bfcfd",
"sha256:d9b3e7d71bf6acff341233417abbdface29c647e3113892d9aaedc02eb4aa2bc",
"sha256:da707f14ea3c35ee463d50acd596d6488e4b2b4ae7cf77a5bf93f55c023d63e8",
"sha256:da85db328e507da922d586c3c7416ec360ec22e9cd9e0700691afacde0c81f53",
"sha256:dc205732d593118cf701d986f40e9de7801bb2e371cb189ddbda9b7348f4d97e",
"sha256:dc3a44689eea43eab836e5c98a8ab015dc2419987d1ea6eafc7c590cdff86bed",
"sha256:dd5e90f34cffcfed97f36cf066325773d2b6021c60c29942e53a18b028501b1d",
"sha256:ddcf547bea2aee967d6a77779376a45e77e610e8465147a1f3d7e20d539d6e32",
"sha256:e477aca0bc0d19f3b4ae9e4f2a1cfd687c31bf772d78734910658186b40b2477",
"sha256:e8b17e23df3e827a69d25af70990ca2420e92668aaffaeeb3cd2351d7916a023",
"sha256:e99e09ab7741f1281e2677f4c0058c7f5267d182530b09c87e4f6aa26adf3887",
"sha256:ea2c01cdb16dc12156e455007c406dfaaece0c89aa4ba0e3b47586779f951d41",
"sha256:ea6b1e9105b4b24a34c722432d9fb578f9ed83af21fa1abda639011e0f22bbb6",
"sha256:ebd054ad1737a68fb7c5c073d405cef2b88bb824e294de3b4a4e995b47f0e376",
"sha256:ec295280f4b37769256da025acf5890370355ac589c27e89caae0b5e9eedc702",
"sha256:f6449672f9c93316deb5e2839e18931f468670e44d5bd9b1301a5a9655d45c07",
"sha256:f683dc6300317700025e41d89a43e0276692ded16113a3c43eab704d605c58e5",
"sha256:f6b9d2aad499c769ee8287609ab0e6de99d8bcea99c6e6c2e64945259fd52fb2",
"sha256:f8b9c8ceebae6387d0dc77f7f4dbbfbfc962dba2efbfe6877486075a480726b4",
"sha256:fad67b12ffe0f71e02b4932b04883cbc76a9072bbd30731409d3523cf058b011",
"sha256:fbfb70ba01355251faf6b293171df49f73a88a1b6494db109ffea85442574458",
"sha256:fe91993149523aa59941b9e3c90e2eb45f57ad014697aef6c8b13339a59c019e",
"sha256:febd35ef45f603c2d74b74655efdbf45e14f55fc0aef4ac82b663ca829b283e0",
"sha256:ff88a92cafde90888511242d1c54afcc1a8adbb6dc0a88fa7f87e29e92400d4a"
],
"index": "pypi",
"markers": "python_version >= '3.8'",
"version": "==6.1.3"
},
"markdown": {
"hashes": [
"sha256:180224db6aed87ba9ce1f2781ebcd5826253de8ff637112090e24b84502bbf9f",
"sha256:cd6c89e7eb308c8b332ed673215a52d208a43f8bacc030b1419376129408719e"
],
"index": "pypi",
"markers": "python_version >= '3.11'",
"version": "==3.11"
},
"markupsafe": {
"hashes": [
"sha256:0bff5e0ae4ef2e1ae4fdf2dfd5b76c75e5c2fa4132d05fc1b0dabcd20c7e28c4",
"sha256:0f4ca02bea9a23221c0182836703cbf8930c5e9454bacce27e767509fa286a30",
"sha256:1225beacc926f536dc82e45f8a4d68502949dc67eea90eab715dea3a21c1b5f0",
"sha256:131a3c7689c85f5ad20f9f6fb1b866f402c445b220c19fe4308c0b147ccd2ad9",
"sha256:15ab75ef81add55874e7ab7055e9c397312385bd9ced94920f2802310c930396",
"sha256:1a9d3f5f0901fdec14d8d2f66ef7d035f2157240a433441719ac9a3fba440b13",
"sha256:1c99d261bd2d5f6b59325c92c73df481e05e57f19837bdca8413b9eac4bd8028",
"sha256:1e084f686b92e5b83186b07e8a17fc09e38fff551f3602b249881fec658d3eca",
"sha256:2181e67807fc2fa785d0592dc2d6206c019b9502410671cc905d132a92866557",
"sha256:2cb8438c3cbb25e220c2ab33bb226559e7afb3baec11c4f218ffa7308603c832",
"sha256:3169b1eefae027567d1ce6ee7cae382c57fe26e82775f460f0b2778beaad66c0",
"sha256:3809ede931876f5b2ec92eef964286840ed3540dadf803dd570c3b7e13141a3b",
"sha256:38a9ef736c01fccdd6600705b09dc574584b89bea478200c5fbf112a6b0d5579",
"sha256:3d79d162e7be8f996986c064d1c7c817f6df3a77fe3d6859f6f9e7be4b8c213a",
"sha256:444dcda765c8a838eaae23112db52f1efaf750daddb2d9ca300bcae1039adc5c",
"sha256:48032821bbdf20f5799ff537c7ac3d1fba0ba032cfc06194faffa8cda8b560ff",
"sha256:4aa4e5faecf353ed117801a068ebab7b7e09ffb6e1d5e412dc852e0da018126c",
"sha256:52305740fe773d09cffb16f8ed0427942901f00adedac82ec8b67752f58a1b22",
"sha256:569511d3b58c8791ab4c2e1285575265991e6d8f8700c7be0e88f86cb0672094",
"sha256:57cb5a3cf367aeb1d316576250f65edec5bb3be939e9247ae594b4bcbc317dfb",
"sha256:5b02fb34468b6aaa40dfc198d813a641e3a63b98c2b05a16b9f80b7ec314185e",
"sha256:6381026f158fdb7c72a168278597a5e3a5222e83ea18f543112b2662a9b699c5",
"sha256:6af100e168aa82a50e186c82875a5893c5597a0c1ccdb0d8b40240b1f28b969a",
"sha256:6c89876f41da747c8d3677a2b540fb32ef5715f97b66eeb0c6b66f5e3ef6f59d",
"sha256:6e296a513ca3d94054c2c881cc913116e90fd030ad1c656b3869762b754f5f8a",
"sha256:70a87b411535ccad5ef2f1df5136506a10775d267e197e4cf531ced10537bd6b",
"sha256:7e94c425039cde14257288fd61dcfb01963e658efbc0ff54f5306b06054700f8",
"sha256:846ade7b71e3536c4e56b386c2a47adf5741d2d8b94ec9dc3e92e5e1ee1e2225",
"sha256:88416bd1e65dcea10bc7569faacb2c20ce071dd1f87539ca2ab364bf6231393c",
"sha256:88b49a3b9ff31e19998750c38e030fc7bb937398b1f78cfa599aaef92d693144",
"sha256:8c4e8c3ce11e1f92f6536ff07154f9d49677ebaaafc32db9db4620bc11ed480f",
"sha256:8e06879fc22a25ca47312fbe7c8264eb0b662f6db27cb2d3bbbc74b1df4b9b87",
"sha256:9025b4018f3a1314059769c7bf15441064b2207cb3f065e6ea1e7359cb46db9d",
"sha256:93335ca3812df2f366e80509ae119189886b0f3c2b81325d39efdb84a1e2ae93",
"sha256:9778bd8ab0a994ebf6f84c2b949e65736d5575320a17ae8984a77fab08db94cf",
"sha256:9e2d922824181480953426608b81967de705c3cef4d1af983af849d7bd619158",
"sha256:a123e330ef0853c6e822384873bef7507557d8e4a082961e1defa947aa59ba84",
"sha256:a904af0a6162c73e3edcb969eeeb53a63ceeb5d8cf642fade7d39e7963a22ddb",
"sha256:ad10d3ded218f1039f11a75f8091880239651b52e9bb592ca27de44eed242a48",
"sha256:b424c77b206d63d500bcb69fa55ed8d0e6a3774056bdc4839fc9298a7edca171",
"sha256:b5a6b3ada725cea8a5e634536b1b01c30bcdcd7f9c6fff4151548d5bf6b3a36c",
"sha256:ba8062ed2cf21c07a9e295d5b8a2a5ce678b913b45fdf68c32d95d6c1291e0b6",
"sha256:ba9527cdd4c926ed0760bc301f6728ef34d841f405abf9d4f959c478421e4efd",
"sha256:bbcb445fa71794da8f178f0f6d66789a28d7319071af7a496d4d507ed566270d",
"sha256:bcf3e58998965654fdaff38e58584d8937aa3096ab5354d493c77d1fdd66d7a1",
"sha256:c0ef13eaeee5b615fb07c9a7dadb38eac06a0608b41570d8ade51c56539e509d",
"sha256:cabc348d87e913db6ab4aa100f01b08f481097838bdddf7c7a84b7575b7309ca",
"sha256:cdb82a876c47801bb54a690c5ae105a46b392ac6099881cdfb9f6e95e4014c6a",
"sha256:cfad01eed2c2e0c01fd0ecd2ef42c492f7f93902e39a42fc9ee1692961443a29",
"sha256:d16a81a06776313e817c951135cf7340a3e91e8c1ff2fac444cfd75fffa04afe",
"sha256:d8213e09c917a951de9d09ecee036d5c7d36cb6cb7dbaece4c71a60d79fb9798",
"sha256:e07c3764494e3776c602c1e78e298937c3315ccc9043ead7e685b7f2b8d47b3c",
"sha256:e17c96c14e19278594aa4841ec148115f9c7615a47382ecb6b82bd8fea3ab0c8",
"sha256:e444a31f8db13eb18ada366ab3cf45fd4b31e4db1236a4448f68778c1d1a5a2f",
"sha256:e6a2a455bd412959b57a172ce6328d2dd1f01cb2135efda2e4576e8a23fa3b0f",
"sha256:eaa0a10b7f72326f1372a713e73c3f739b524b3af41feb43e4921cb529f5929a",
"sha256:eb7972a85c54febfb25b5c4b4f3af4dcc731994c7da0d8a0b4a6eb0640e1d178",
"sha256:ee55d3edf80167e48ea11a923c7386f4669df67d7994554387f84e7d8b0a2bf0",
"sha256:f3818cb119498c0678015754eba762e0d61e5b52d34c8b13d770f0719f7b1d79",
"sha256:f8b3d067f2e40fe93e1ccdd6b2e1d16c43140e76f02fb1319a05cf2b79d99430",
"sha256:fcabf5ff6eea076f859677f5f0b6b5c1a51e70a376b0579e0eadef8db48c6b50"
],
"markers": "python_version >= '3.9'",
"version": "==3.0.2"
},
"pkgutil-resolve-name": {
"hashes": [
"sha256:357d6c9e6a755653cfd78893817c0853af365dd51ec97f3d358a819373bbd174",
"sha256:ca27cc078d25c5ad71a9de0a7a330146c4e014c2462d9af19c6b828280649c5e"
],
"markers": "python_version < '3.9'",
"version": "==1.3.10"
},
"pyyaml": {
"hashes": [
"sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c",
"sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a",
"sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3",
"sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956",
"sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6",
"sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c",
"sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65",
"sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a",
"sha256:1ebe39cb5fc479422b83de611d14e2c0d3bb2a18bbcb01f229ab3cfbd8fee7a0",
"sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b",
"sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1",
"sha256:22ba7cfcad58ef3ecddc7ed1db3409af68d023b7f940da23c6c2a1890976eda6",
"sha256:27c0abcb4a5dac13684a37f76e701e054692a9b2d3064b70f5e4eb54810553d7",
"sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e",
"sha256:2e71d11abed7344e42a8849600193d15b6def118602c4c176f748e4583246007",
"sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310",
"sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4",
"sha256:3c5677e12444c15717b902a5798264fa7909e41153cdf9ef7ad571b704a63dd9",
"sha256:3ff07ec89bae51176c0549bc4c63aa6202991da2d9a6129d7aef7f1407d3f295",
"sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea",
"sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0",
"sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e",
"sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac",
"sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9",
"sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7",
"sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35",
"sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb",
"sha256:5cf4e27da7e3fbed4d6c3d8e797387aaad68102272f8f9752883bc32d61cb87b",
"sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69",
"sha256:5ed875a24292240029e4483f9d4a4b8a1ae08843b9c54f43fcc11e404532a8a5",
"sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b",
"sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c",
"sha256:6344df0d5755a2c9a276d4473ae6b90647e216ab4757f8426893b5dd2ac3f369",
"sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd",
"sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824",
"sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198",
"sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065",
"sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c",
"sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c",
"sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764",
"sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196",
"sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b",
"sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00",
"sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac",
"sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8",
"sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e",
"sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28",
"sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3",
"sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5",
"sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4",
"sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b",
"sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf",
"sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5",
"sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702",
"sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8",
"sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788",
"sha256:b865addae83924361678b652338317d1bd7e79b1f4596f96b96c77a5a34b34da",
"sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d",
"sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc",
"sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c",
"sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba",
"sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f",
"sha256:c3355370a2c156cffb25e876646f149d5d68f5e0a3ce86a5084dd0b64a994917",
"sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5",
"sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26",
"sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f",
"sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b",
"sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be",
"sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c",
"sha256:efd7b85f94a6f21e4932043973a7ba2613b059c4a000551892ac9f1d11f5baf3",
"sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6",
"sha256:fa160448684b4e94d80416c0fa4aac48967a969efe22931448d853ada8baf926",
"sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0"
],
"index": "pypi",
"markers": "python_version >= '3.8'",
"version": "==6.0.3"
},
"referencing": {
"hashes": [
"sha256:381329a9f99628c9069361716891d34ad94af76e461dcb0335825aecc7692231",
"sha256:44aefc3142c5b842538163acb373e24cce6632bd54bdb01b21ad5863489f50d8"
],
"markers": "python_version >= '3.10'",
"version": "==0.37.0"
},
"rpds-py": {
"hashes": [
"sha256:07ae8a593e1c3c6b82ca3292efbe73c30b61332fd612e05abee07c79359f292f",
"sha256:0a59119fc6e3f460315fe9d08149f8102aa322299deaa5cab5b40092345c2136",
"sha256:0c0e95f6819a19965ff420f65578bacb0b00f251fefe2c8b23347c37174271f3",
"sha256:0d08f00679177226c4cb8c5265012eea897c8ca3b93f429e546600c971bcbae7",
"sha256:0ed177ed9bded28f8deb6ab40c183cd1192aa0de40c12f38be4d59cd33cb5c65",
"sha256:12f90dd7557b6bd57f40abe7747e81e0c0b119bef015ea7726e69fe550e394a4",
"sha256:1726859cd0de969f88dc8673bdd954185b9104e05806be64bcd87badbe313169",
"sha256:1ab5b83dbcf55acc8b08fc62b796ef672c457b17dbd7820a11d6c52c06839bdf",
"sha256:1b151685b23929ab7beec71080a8889d4d6d9fa9a983d213f07121205d48e2c4",
"sha256:1f3587eb9b17f3789ad50824084fa6f81921bbf9a795826570bda82cb3ed91f2",
"sha256:250fa00e9543ac9b97ac258bd37367ff5256666122c2d0f2bc97577c60a1818c",
"sha256:2771c6c15973347f50fece41fc447c054b7ac2ae0502388ce3b6738cd366e3d4",
"sha256:27f4b0e92de5bfbc6f86e43959e6edd1425c33b5e69aab0984a72047f2bcf1e3",
"sha256:2e6ecb5a5bcacf59c3f912155044479af1d0b6681280048b338b28e364aca1f6",
"sha256:32c8528634e1bf7121f3de08fa85b138f4e0dc47657866630611b03967f041d7",
"sha256:33f559f3104504506a44bb666b93a33f5d33133765b0c216a5bf2f1e1503af89",
"sha256:3896fa1be39912cf0757753826bc8bdc8ca331a28a7c4ae46b7a21280b06bb85",
"sha256:389a2d49eded1896c3d48b0136ead37c48e221b391c052fba3f4055c367f60a6",
"sha256:39c02563fc592411c2c61d26b6c5fe1e51eaa44a75aa2c8735ca88b0d9599daa",
"sha256:3adbb8179ce342d235c31ab8ec511e66c73faa27a47e076ccc92421add53e2bb",
"sha256:3d4a69de7a3e50ffc214ae16d79d8fbb0922972da0356dcf4d0fdca2878559c6",
"sha256:3e62880792319dbeb7eb866547f2e35973289e7d5696c6e295476448f5b63c87",
"sha256:3e8eeb0544f2eb0d2581774be4c3410356eba189529a6b3e36bbbf9696175856",
"sha256:422c3cb9856d80b09d30d2eb255d0754b23e090034e1deb4083f8004bd0761e4",
"sha256:4559c972db3a360808309e06a74628b95eaccbf961c335c8fe0d590cf587456f",
"sha256:46e83c697b1f1c72b50e5ee5adb4353eef7406fb3f2043d64c33f20ad1c2fc53",
"sha256:47b0ef6231c58f506ef0b74d44e330405caa8428e770fec25329ed2cb971a229",
"sha256:47e77dc9822d3ad616c3d5759ea5631a75e5809d5a28707744ef79d7a1bcfcad",
"sha256:47f236970bccb2233267d89173d3ad2703cd36a0e2a6e92d0560d333871a3d23",
"sha256:47f9a91efc418b54fb8190a6b4aa7813a23fb79c51f4bb84e418f5476c38b8db",
"sha256:495aeca4b93d465efde585977365187149e75383ad2684f81519f504f5c13038",
"sha256:4c5f36a861bc4b7da6516dbdf302c55313afa09b81931e8280361a4f6c9a2d27",
"sha256:4cc2206b76b4f576934f0ed374b10d7ca5f457858b157ca52064bdfc26b9fc00",
"sha256:4e7fc54e0900ab35d041b0601431b0a0eb495f0851a0639b6ef90f7741b39a18",
"sha256:51a1234d8febafdfd33a42d97da7a43f5dcb120c1060e352a3fbc0c6d36e2083",
"sha256:55f66022632205940f1827effeff17c4fa7ae1953d2b74a8581baaefb7d16f8c",
"sha256:58edca431fb9b29950807e301826586e5bbf24163677732429770a697ffe6738",
"sha256:5965af57d5848192c13534f90f9dd16464f3c37aaf166cc1da1cae1fd5a34898",
"sha256:5ba103fb455be00f3b1c2076c9d4264bfcb037c976167a6047ed82f23153f02e",
"sha256:5d4c2aa7c50ad4728a094ebd5eb46c452e9cb7edbfdb18f9e1221f597a73e1e7",
"sha256:61046904275472a76c8c90c9ccee9013d70a6d0f73eecefd38c1ae7c39045a08",
"sha256:613aa4771c99f03346e54c3f038e4cc574ac09a3ddfb0e8878487335e96dead6",
"sha256:626a7433c34566535b6e56a1b39a7b17ba961e97ce3b80ec62e6f1312c025551",
"sha256:669b1805bd639dd2989b281be2cfd951c6121b65e729d9b843e9639ef1fd555e",
"sha256:679ae98e00c0e8d68a7fda324e16b90fd5260945b45d3b824c892cec9eea3288",
"sha256:67b02ec25ba7a9e8fa74c63b6ca44cf5707f2fbfadae3ee8e7494297d56aa9df",
"sha256:68f19c879420aa08f61203801423f6cd5ac5f0ac4ac82a2368a9fcd6a9a075e0",
"sha256:692bef75a5525db97318e8cd061542b5a79812d711ea03dbc1f6f8dbb0c5f0d2",
"sha256:6abc8880d9d036ecaafe709079969f56e876fcf107f7a8e9920ba6d5a3878d05",
"sha256:6bdfdb946967d816e6adf9a3d8201bfad269c67efe6cefd7093ef959683c8de0",
"sha256:6de2a32a1665b93233cde140ff8b3467bdb9e2af2b91079f0333a0974d12d464",
"sha256:73c67f2db7bc334e518d097c6d1e6fed021bbc9b7d678d6cc433478365d1d5f5",
"sha256:74a3243a411126362712ee1524dfc90c650a503502f135d54d1b352bd01f2404",
"sha256:76fec018282b4ead0364022e3c54b60bf368b9d926877957a8624b58419169b7",
"sha256:7c64d38fb49b6cdeda16ab49e35fe0da2e1e9b34bc38bd78386530f218b37139",
"sha256:7cee9c752c0364588353e627da8a7e808a66873672bcb5f52890c33fd965b394",
"sha256:7e6ecfcb62edfd632e56983964e6884851786443739dbfe3582947e87274f7cb",
"sha256:806f36b1b605e2d6a72716f321f20036b9489d29c51c91f4dd29a3e3afb73b15",
"sha256:858738e9c32147f78b3ac24dc0edb6610000e56dc0f700fd5f651d0a0f0eb9ff",
"sha256:8d6d1cc13664ec13c1b84241204ff3b12f9bb82464b8ad6e7a5d3486975c2eed",
"sha256:9027da1ce107104c50c81383cae773ef5c24d296dd11c99e2629dbd7967a20c6",
"sha256:922e10f31f303c7c920da8981051ff6d8c1a56207dbdf330d9047f6d30b70e5e",
"sha256:945dccface01af02675628334f7cf49c2af4c1c904748efc5cf7bbdf0b579f95",
"sha256:946fe926af6e44f3697abbc305ea168c2c31d3e3ef1058cf68f379bf0335a78d",
"sha256:95f0802447ac2d10bcc69f6dc28fe95fdf17940367b21d34e34c737870758950",
"sha256:9854cf4f488b3d57b9aaeb105f06d78e5529d3145b1e4a41750167e8c213c6d3",
"sha256:993914b8e560023bc0a8bf742c5f303551992dcb85e247b1e5c7f4a7d145bda5",
"sha256:99b47d6ad9a6da00bec6aabe5a6279ecd3c06a329d4aa4771034a21e335c3a97",
"sha256:9a4e86e34e9ab6b667c27f3211ca48f73dba7cd3d90f8d5b11be56e5dbc3fb4e",
"sha256:9cf69cdda1f5968a30a359aba2f7f9aa648a9ce4b580d6826437f2b291cfc86e",
"sha256:a090322ca841abd453d43456ac34db46e8b05fd9b3b4ac0c78bcde8b089f959b",
"sha256:a1010ed9524c73b94d15919ca4d41d8780980e1765babf85f9a2f90d247153dd",
"sha256:a161f20d9a43006833cd7068375a94d035714d73a172b681d8881820600abfad",
"sha256:a1d0bc22a7cdc173fedebb73ef81e07faef93692b8c1ad3733b67e31e1b6e1b8",
"sha256:a2bffea6a4ca9f01b3f8e548302470306689684e61602aa3d141e34da06cf425",
"sha256:a452763cc5198f2f98898eb98f7569649fe5da666c2dc6b5ddb10fde5a574221",
"sha256:a4796a717bf12b9da9d3ad002519a86063dcac8988b030e405704ef7d74d2d9d",
"sha256:a51033ff701fca756439d641c0ad09a41d9242fa69121c7d8769604a0a629825",
"sha256:a8fa71a2e078c527c3e9dc9fc5a98c9db40bcc8a92b4e8858e36d329f8684b51",
"sha256:ac37f9f516c51e5753f27dfdef11a88330f04de2d564be3991384b2f3535d02e",
"sha256:ac98b175585ecf4c0348fd7b29c3864bda53b805c773cbf7bfdaffc8070c976f",
"sha256:acd7eb3f4471577b9b5a41baf02a978e8bdeb08b4b355273994f8b87032000a8",
"sha256:ad1fa8db769b76ea911cb4e10f049d80bf518c104f15b3edb2371cc65375c46f",
"sha256:b40fb160a2db369a194cb27943582b38f79fc4887291417685f3ad693c5a1d5d",
"sha256:b4dc1a6ff022ff85ecafef7979a2c6eb423430e05f1165d6688234e62ba99a07",
"sha256:ba3af48635eb83d03f6c9735dfb21785303e73d22ad03d489e88adae6eab8877",
"sha256:ba81a9203d07805435eb06f536d95a266c21e5b2dfbf6517748ca40c98d19e31",
"sha256:c2262bdba0ad4fc6fb5545660673925c2d2a5d9e2e0fb603aad545427be0fc58",
"sha256:c77afbd5f5250bf27bf516c7c4a016813eb2d3e116139aed0096940c5982da94",
"sha256:ca28829ae5f5d569bb62a79512c842a03a12576375d5ece7d2cadf8abe96ec28",
"sha256:cdc62c8286ba9bf7f47befdcea13ea0e26bf294bda99758fd90535cbaf408000",
"sha256:d948b135c4693daff7bc2dcfc4ec57237a29bd37e60c2fabf5aff2bbacf3e2f1",
"sha256:d96c2086587c7c30d44f31f42eae4eac89b60dabbac18c7669be3700f13c3ce1",
"sha256:d9a0ca5da0386dee0655b4ccdf46119df60e0f10da268d04fe7cc87886872ba7",
"sha256:da279aa314f00acbb803da1e76fa18666778e8a8f83484fba94526da5de2cba7",
"sha256:dbd936cde57abfee19ab3213cf9c26be06d60750e60a8e4dd85d1ab12c8b1f40",
"sha256:dc4f992dfe1e2bc3ebc7444f6c7051b4bc13cd8e33e43511e8ffd13bf407010d",
"sha256:dc824125c72246d924f7f796b4f63c1e9dc810c7d9e2355864b3c3a73d59ade0",
"sha256:dd8ff7cf90014af0c0f787eea34794ebf6415242ee1d6fa91eaba725cc441e84",
"sha256:dea5b552272a944763b34394d04577cf0f9bd013207bc32323b5a89a53cf9c2f",
"sha256:dff13836529b921e22f15cb099751209a60009731a68519630a24d61f0b1b30a",
"sha256:e0b65193a413ccc930671c55153a03ee57cecb49e6227204b04fae512eb657a7",
"sha256:e5d3e6b26f2c785d65cc25ef1e5267ccbe1b069c5c21b8cc724efee290554419",
"sha256:e7536cd91353c5273434b4e003cbda89034d67e7710eab8761fd918ec6c69cf8",
"sha256:eb0b93f2e5c2189ee831ee43f156ed34e2a89a78a66b98cadad955972548be5a",
"sha256:eb2c4071ab598733724c08221091e8d80e89064cd472819285a9ab0f24bcedb9",
"sha256:ec7c4490c672c1a0389d319b3a9cfcd098dcdc4783991553c332a15acf7249be",
"sha256:ee454b2a007d57363c2dfd5b6ca4a5d7e2c518938f8ed3b706e37e5d470801ed",
"sha256:ee6af14263f25eedc3bb918a3c04245106a42dfd4f5c2285ea6f997b1fc3f89a",
"sha256:f14fc5df50a716f7ece6a80b6c78bb35ea2ca47c499e422aa4463455dd96d56d",
"sha256:f207f69853edd6f6700b86efb84999651baf3789e78a466431df1331608e5324",
"sha256:f251c812357a3fed308d684a5079ddfb9d933860fc6de89f2b7ab00da481e65f",
"sha256:f83424d738204d9770830d35290ff3273fbb02b41f919870479fab14b9d303b2",
"sha256:f8d1736cfb49381ba528cd5baa46f82fdc65c06e843dab24dd70b63d09121b3f",
"sha256:fe5fa731a1fa8a0a56b0977413f8cacac1768dad38d16b3a296712709476fbd5"
],
"markers": "python_version >= '3.10'",
"version": "==0.30.0"
},
"typing-extensions": {
"hashes": [
"sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466",
"sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"
],
"markers": "python_version >= '3.9'",
"version": "==4.15.0"
},
"zipp": {
"hashes": [
"sha256:071652d6115ed432f5ce1d34c336c0adfd6a884660d1e9712a256d3d3bd4b14e",
"sha256:a07157588a12518c9d4034df3fbbee09c814741a33ff63c05fa29d26a2404166"
],
"markers": "python_version >= '3.9'",
"version": "==3.23.0"
}
},
"develop": {}
}
+14 -14
View File
@@ -2,24 +2,24 @@ Documentation
=============
The jq website, manpages and some of the tests are generated from this
directory. The directory holds a [Bonsai](http://tinytree.info)
website, and the manual is a YAML file in `content/3.manual`.
directory. The manual is a YAML file in `content/manual`.
To build the documentation (including building the jq manpage), you'll
need a working Ruby setup. The easiest way to get one is to install
RVM and Ruby 1.9.3 like so:
need `python3` and `pipenv`. You can install `pipenv` like so:
\curl -L https://get.rvm.io | bash -s stable --ruby=1.9.3
pip install pipenv
After that finishes installing, you'll need to make sure RVM is on
your path by doing `source $HOME/.rvm/scripts/rvm`, or just opening a
new shell. See <http://rvm.io> for more info on RVM.
Though, you may need to say `pip3` instead, depending on your system. Once
you have `pipenv` installed, you can install the dependencies by running
`pipenv sync` from the `docs/` directory.
Once RVM is installed, you can install all the dependencies for jq's
documentation build by running this from the `docs` directory:
Also, you may need to run `virtualenv -p /usr/bin/python3 venv/` and
then `source venv/bin/activate`, and only then `pipenv sync`.
bundle install
Once this is done, rerun `./configure --enable-docs` in the jq root directory and then
the `Makefile` will be able to generate the jq manpage. You can just run
`make jq.1` to build the manpage manually, and `make tests/man.test` to
update the manual tests.
When bundle manages to install the dependencies, rerun `./configure`
in the jq root directory and then the Makefile will be able to
generate the jq manpage.
To build the website, run `pipenv run python3 build_website.py` in the `docs/` directory.
To serve them locally, you can run `python3 -m http.server -d output`.
-146
View File
@@ -1,146 +0,0 @@
require 'yaml'
require 'bonsai'
require 'liquid'
require 'maruku'
require 'json'
require 'ronn'
require 'tempfile'
require 'yaml'
module ExtraFilters
def markdownify(input)
Maruku.new(input).to_html
end
def sanitize(input)
input.gsub(/[^a-zA-Z0-9_]/,"")
end
def json(input)
input.to_json
end
def unique(input)
@n = (@n || 0) + 1
input + @n.to_s
end
end
Liquid::Template.register_filter(ExtraFilters)
task :serve do
begin
Bonsai.log "Press Control+C to quit"
require 'rack'
require 'sinatra'
require 'watch'
require 'launchy'
Bonsai.root_dir = Dir.pwd
server = fork {
app = Rack::Builder.app {
map "/jq" do
use Bonsai::StaticPassThrough, :root => Bonsai.root_dir + "/output", :urls => ["/"]
end
run Bonsai::DevelopmentServer
}
Rack::Handler.default.run(app, :Port => 5000) do
Launchy.open("http://localhost:5000/jq/")
end
}
Watch.new("{content,templates,public}/**/*") { Bonsai::Exporter.process! }
rescue Interrupt
Process.kill("QUIT", server)
Process.wait(server)
exit
end
end
task :build do
Bonsai.root_dir = Dir.pwd
Bonsai::Exporter.publish!
end
$BINARIES = {
:osx32 => "--host=i686-apple-darwin10 CFLAGS='-m32 -g -O'",
:osx64 => "--host=i686-apple-darwin10 CFLAGS='-m64 -g -O'",
:win32 => "--host=i686-w64-mingw32 CFLAGS='-g -O'",
:win64 => "--host=x86_64-w64-mingw32 CFLAGS='-g -O'",
:linux32 => "--host=x86_64-linux-gnu CFLAGS='-m32 -g -O'",
:linux64 => "--host=x86_64-linux-gnu CFLAGS='-m64 -g -O'"
}
$BINARIES.each do |name, args|
file "../build/#{name}" do |t|
sh "MAKEFLAGS=-j4 ../scripts/crosscompile #{name} #{args}"
end
task :binaries => ["../build/#{name}"]
end
task :binaries => ["output/download"] do
$BINARIES.each do |name, args|
FileUtils.cp_r "../build/#{name}", "output/download/"
end
end
def load_manual
YAML::ENGINE.yamler = 'syck'
YAML::load(File.open("content/3.manual/manual.yml"))
end
task :manpage do
Tempfile.open "manpage" do |f|
manual = load_manual
f.puts manual['manpage_intro']
f.puts manual['body']
manual['sections'].each do |section|
f.puts "## #{section['title'].upcase}\n"
f.puts section['body']
f.puts ""
(section['entries'] || []).each do |entry|
f.puts "### #{entry['title']}\n"
f.puts entry['body']
f.puts ""
(entry['examples'] || []).each do |example|
f.puts " jq '#{example['program']}'"
f.puts " #{example['input']}"
f.puts " => #{example['output'].join(", ")}"
f.puts
end
end
f.puts ""
end
f.puts manual['manpage_epilogue']
f.close
puts Ronn::Document.new(f.path).convert('roff').gsub(/<\/?code>/,"")
end
end
task :manpage_default => ["default_manpage.md"] do
puts Ronn::Document.new("default_manpage.md").convert('roff').gsub(/<\/?code>/,"")
end
task :mantests do
load_manual['sections'].each do |section|
(section['entries'] || []).each do |entry|
(entry['examples'] || []).each do |example|
puts example['program'].gsub("\n", " ")
puts example['input']
example['output'].each do |s| puts s end
puts
end
end
end
end
directory "output/download/source"
task :tarball => ["output/download/source"] do
sh "cd ..; ./configure && make dist && make distclean"
sh "cp ../jq-*.tar.gz output/download/source"
end
task :dist => [:build, :binaries, :tarball]
+249
View File
@@ -0,0 +1,249 @@
#!/usr/bin/env python3
from io import StringIO
from lxml import etree
import markdown
from markdown.extensions import Extension
import re
import sys
import yaml
# Prevent our markdown parser from trying to help by interpreting things in angle brackets as HTML tags.
class EscapeHtml(Extension):
def extendMarkdown(self, md):
md.preprocessors.deregister('html_block')
md.inlinePatterns.deregister('html')
class RoffWalker(object):
def __init__(self, tree, output=sys.stdout):
self.tree = tree
self.target = output
self.f = StringIO()
def walk(self):
self._walk(self.tree, parent_tag=None)
# We don't want to start lines with \. because that can confuse man
# For lines that start with \., we need to prefix them with \& so it
# knows not to treat that line as a directive
data = re.sub(r'^\\\.', r'\&.', self.f.getvalue(), flags=re.MULTILINE)
self.target.write(data)
def _ul_is_special(self, root):
if len(root) != 1:
return False
child = root[0]
if child.tag != 'li':
return False
msg = ''.join(child.itertext()).strip()
return msg.endswith(':')
def _walk_child(self, root):
if len(root) > 0:
self._walk(root[0], parent_tag=root.tag)
def _write_element(self, root, ensure_newline=True):
if root.text is not None:
text = self._sanitize(root.text)
self.__write_raw(text)
self._walk_child(root)
self._write_tail(root, ensure_newline=ensure_newline)
def _write_tail(self, root, ensure_newline=False, inline=False):
if root.tail is not None:
if inline or root.tail != '\n':
text = self._sanitize(root.tail)
if text.endswith('\n'):
ensure_newline = False
self.__write_raw(text)
if ensure_newline:
self.__write_raw('\n')
def _walk(self, root, parent_tag=None):
last_tag = None
while root is not None:
if root.tag == 'h1':
self.__write_cmd('.TH "JQ" "1" "" "" ""')
self.__write_cmd('.SH "NAME"')
# TODO: properly parse this
self.__write_raw(r'\fBjq\fR \- Command\-line JSON processor' +
"\n")
elif root.tag == 'h2':
self.__write_cmd('.SH "{}"'.format(''.join(
root.itertext()).strip()))
elif root.tag == 'h3':
text = ''.join(root.itertext()).strip()
self.__write_cmd('.SS "{}"'.format(self._h3_sanitize(text)))
elif root.tag == 'p':
if last_tag not in ['h2', 'h3'] and parent_tag not in ['li']:
self.__write_cmd('.P')
self._write_element(root, ensure_newline=(parent_tag != 'li'))
elif root.tag == 'a':
self._write_element(root, ensure_newline=(parent_tag != 'li'))
elif root.tag == 'ul':
if self._ul_is_special(root):
li = root[0]
self.__write_cmd('.TP')
self._write_element(li)
next = root.getnext()
while next is not None and next.tag == 'p':
if next.getnext() is not None and next.getnext(
).tag == 'pre':
# we don't want to .IP these, because it'll look funny with the code indent
break
self.__write_cmd('.IP')
self._write_element(next)
root = next
next = root.getnext()
else:
self._walk_child(root)
self._write_tail(root)
# A pre tag after the end of a list doesn't want two of the indentation commands
if root.getnext() is None or root.getnext().tag != 'pre':
self.__write_cmd('.IP "" 0')
elif root.tag == 'li':
self.__write_cmd(r'.IP "\(bu" 4')
if root.text is not None and root.text.strip() != '':
text = self._sanitize(root.text)
self.__write_raw(text)
self._walk_child(root)
self._write_tail(root, ensure_newline=True)
elif root.tag == 'strong':
if root.text is not None:
text = self._sanitize(root.text)
self.__write_raw('\\fB{}\\fR'.format(text))
self._write_tail(root, inline=True)
elif root.tag == 'em':
if root.text is not None:
text = self._sanitize(root.text)
self.__write_raw('\\fI{}\\fR'.format(text))
self._write_tail(root, inline=True)
elif root.tag == 'code':
if root.text is not None:
text = self._code_sanitize(root.text)
self.__write_raw('\\fB{}\\fR'.format(text))
self._write_tail(root, inline=True)
elif root.tag == 'pre':
self.__write_cmd('.IP "" 4')
self.__write_cmd('.nf\n') # extra newline for spacing reasons
next = root
first = True
while next is not None and next.tag == 'pre':
if not first:
self.__write_raw('\n')
text = ''.join(next.itertext(with_tail=False))
self.__write_raw(self._pre_sanitize(text))
first = False
root = next
next = next.getnext()
self.__write_cmd('.fi')
self.__write_cmd('.IP "" 0')
else:
self._walk_child(root)
last_tag = root.tag
root = root.getnext()
def _base_sanitize(self, text):
text = re.sub(r'\\', r'\\e', text)
text = re.sub(r'\.', r'\\.', text)
text = re.sub("'", r"\'", text)
text = re.sub('-', r'\-', text)
return text
def _pre_sanitize(self, text):
return self._base_sanitize(text)
def _code_sanitize(self, text):
text = self._base_sanitize(text)
text = re.sub(r'\s', ' ', text)
return text
def _h3_sanitize(self, text):
text = self._base_sanitize(text)
text = re.sub(' \n|\n ', ' ', text)
text = re.sub('\n', ' ', text)
return text
def _sanitize(self, text):
text = self._base_sanitize(text)
text = re.sub(r'<([^>]+)>', r'\\fI\1\\fR', text)
text = re.sub(r' +', ' ', text)
text = re.sub('\n', ' ', text)
return text
def __write_cmd(self, dat):
print('.', dat, sep='\n', file=self.f)
pass
def __write_raw(self, dat):
print(dat, sep='', end='', file=self.f)
pass
def load_yml_file(fn):
with open(fn) as f:
return yaml.safe_load(f)
def dedent_body(body):
lines = [re.sub(r'^ (\S)', r'\1', l) for l in body.split('\n')]
return '\n'.join(lines)
def convert_manual_to_markdown():
f = StringIO()
manual = load_yml_file("content/manual/dev/manual.yml")
f.write(manual.get('manpage_intro', '\n'))
f.write(dedent_body(manual.get('body', '\n')))
for section in manual.get('sections', []):
f.write('## {}\n'.format(section.get('title', '').upper()))
f.write(dedent_body(section.get('body', '\n')))
f.write('\n')
for entry in section.get('entries', []):
f.write('### {}\n'.format(entry.get('title', '')))
f.write(dedent_body(entry.get('body', '\n')))
f.write('\n')
if entry.get('examples') is not None:
f.write("~~~~\n")
first = True
for example in entry.get('examples'):
if not first:
f.write('\n')
f.write("jq '{}'\n".format(example.get('program', '')))
f.write(" {}\n".format(example.get('input', '')))
output = [str(x) for x in example.get('output', [])]
f.write("=> {}\n".format('\n '.join(output)))
first = False
f.write("~~~~\n")
f.write('\n')
f.write(manual.get('manpage_epilogue', ''))
return f.getvalue()
# Convert manual.yml to our special markdown format
markdown_data = convert_manual_to_markdown()
# Convert markdown to html
html_data = markdown.markdown(markdown_data,
extensions=[EscapeHtml(), 'fenced_code'])
# Parse the html into a tree so we can walk it
tr = etree.HTML(html_data, etree.HTMLParser())
# Convert the markdown to ROFF
RoffWalker(tr).walk()
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env python3
import yaml
import re
regex_program_pattern = re.compile(
r'\b(?:test|match|capture|scan|split|splits|sub|gsub)\s*\(')
with open('content/manual/dev/manual.yml') as source, \
open('../tests/man.test', 'w') as man, \
open('../tests/manonig.test', 'w') as manonig:
manual = yaml.safe_load(source)
for section in manual.get('sections', []):
for entry in section.get('entries', []):
for example in entry.get('examples', []):
program = example.get('program', '').replace('\n', ' ')
out = manonig if regex_program_pattern.search(program) else man
print(program, file=out)
print(example.get('input', ''), file=out)
for s in example.get('output', []):
print(s, file=out)
print('', file=out)
+89
View File
@@ -0,0 +1,89 @@
#!/usr/bin/env python3
import glob
import itertools
from jinja2 import Environment, FileSystemLoader, select_autoescape, pass_context
from markdown import markdown
from markupsafe import Markup
import os
import os.path
import re
import shutil
import yaml
env = Environment(
loader=FileSystemLoader('templates'),
autoescape=select_autoescape(['html.j2']),
)
def load_yml_file(fn):
with open(fn) as f:
return yaml.safe_load(f)
env.globals['url'] = 'https://jqlang.org'
env.filters['search_id'] = lambda input: input.replace(r'`', '')
env.filters['section_id'] = lambda input: re.sub(
r'[^-a-zA-Z0-9_]', '', input.replace(' ', '-')).lower()
env.filters['entry_id'] = lambda input: re.sub(
r'^(split|first-last-nth)$',
r'\1' + ('-1' if ';' not in input else '-2'), # avoid id conflict
re.sub(
r'\b([^-]+)(?:-\1)+\b',
r'\1', # e.g. range-range-range -> range
re.sub(r' ?/ ?|,? ', '-',
re.sub(r'[`;]|: .*|\(.*?\)| \[.+\]', '', input)))).lower()
env.filters['markdownify'] = lambda input: Markup(
markdown(input, extensions=['md_in_html']))
env.filters['no_paragraph'] = lambda input: Markup(re.sub(r'</?p>', '', input))
env.globals['unique_id'] = pass_context(
lambda ctx: str(next(ctx['unique_ctr'])))
def raise_handler(message):
raise Exception(message)
env.globals['raise'] = raise_handler
def generate_file(env, fname):
path, base = os.path.split(fname)
path = os.path.relpath(path, 'content')
if path == '.':
path = ''
permalink = ''
else:
permalink = path + '/'
output_dir = os.path.join('output', path)
output_path = os.path.join(output_dir, 'index.html')
template_name = re.sub(r'.yml$', '.html.j2', base)
ctx = load_yml_file(fname)
ctx.update(unique_ctr=itertools.count(1),
permalink=permalink,
navitem=path)
os.makedirs(output_dir, exist_ok=True)
env.get_template(template_name).stream(ctx).dump(output_path,
encoding='utf-8')
def copy_public_files(root=''):
for f in os.scandir(os.path.join('public', root)):
src = os.path.join(root, f.name)
dst = os.path.join('output', src)
if f.is_dir():
os.makedirs(dst, exist_ok=True)
copy_public_files(src)
else:
shutil.copyfile(f.path, dst)
os.makedirs('output', exist_ok=True)
copy_public_files()
for fn in glob.glob('content/**/*.yml', recursive=True):
generate_file(env, fn)
-241
View File
@@ -1,241 +0,0 @@
headline: Tutorial
body:
- text: |
Twitter has a JSON API, so let's play with that. This URL gets
us the last 5 tweets about JSON:
- command: "curl 'http://search.twitter.com/search.json?q=json&rpp=5&include_entities=true'"
result: |
{"completed_in":0.108,"max_id":247677287108067328,"max_id_str":"247677287108067328","next_page":"?page=2&max_id=247677287108067328&q=json&rpp=5&include_entities=1","page":1,"query":"json","refresh_url":"?since_id=247677287108067328&q=json&include_entities=1","results":[{"created_at":"Mon, 17 Sep 2012 12:44:01 +0000","entities":{"hashtags":[],"urls":[{"url":"http:\/\/t.co\/XRvh1ZVw","expanded_url":"http:\/\/jase.im\/Ri7I0M","display_url":"jase.im\/Ri7I0M","indices":[112,132]}],"user_mentions":[{"screen_name":"imagemechanics","name":"Jason Cotterell","id":57271393,"id_str":"57271393","indices":[3,18]}]},"from_user":"_AaronNg","from_user_id":79771704,"from_user_id_str":"79771704","from_user_name":"NgChenChong","geo":null,"id":247677287108067328,"id_str":"247677287108067328","iso_language_code":"en","metadata":{"result_type":"recent"},"profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/2523558403\/ek8mo4j4beq84iw28gjl_normal.jpeg","profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/2523558403\/ek8mo4j4beq84iw28gjl_normal.jpeg","source":"&lt;a href=&quot;http:\/\/twitter.com\/&quot;&gt;web&lt;\/a&gt;","text":"RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt;.\nhttp:\/\/t.co\/XRvh1ZVw","to_user":null,"to_user_id":0,"to_user_id_str":"0","to_user_name":null}, ...
- text: |
There's lots of info and no whitespace, so to make it a bit more
legible we pipe it through jq, telling jq to just spit the input
back at us using the expression `.`:
- command: "curl 'http://search.twitter.com/search.json?q=json&rpp=5&include_entities=true' | jq '.'"
result: |
{
"since_id_str": "0",
"since_id": 0,
"results_per_page": 5,
"completed_in": 0.108,
"max_id": 247677287108067330,
"max_id_str": "247677287108067328",
"next_page": "?page=2&max_id=247677287108067328&q=json&rpp=5&include_entities=1",
"page": 1,
"query": "json",
"refresh_url": "?since_id=247677287108067328&q=json&include_entities=1",
"results": [
{
"from_user_name": "NgChenChong",
"from_user_id_str": "79771704",
"from_user_id": 79771704,
"from_user": "_AaronNg",
"iso_language_code": "en",
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt;.\nhttp://t.co/XRvh1ZVw",
"to_user": null
/* lots more fields... */
},
/* lots more results... */
]
}
- text: |
Let's pull out the first tweet:
- command: "curl 'http://search.twitter.com/search.json?q=json&rpp=5&include_entities=true' | jq '.results[0]'"
result: |
{
"from_user_name": "NgChenChong",
"from_user_id_str": "79771704",
"from_user_id": 79771704,
"from_user": "_AaronNg",
"iso_language_code": "en",
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt;.\nhttp://t.co/XRvh1ZVw",
"to_user": null
/* lots more fields... */
},
- text: |
For the rest of the examples, I'll leave out the `curl` command - it's not going to change.
There's still a lot of info we don't care about there, so we'll
restrict it down to the most interesting fields.
- command: "jq '.results[0] | {from_user, text}'"
result: |
{
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt;.\nhttp://t.co/XRvh1ZVw",
"from_user": "_AaronNg"
}
- text: |
The `|` operator in jq feeds the output of one filter
(`.results[0]` which gets the first element of the results
array) into the input of another (`{from_user, text}` which
builds an object of those two fields).
Now let's get the rest of the tweets:
- command: "jq '.results[] | {from_user, text}'"
result: |
{
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt;.\nhttp://t.co/XRvh1ZVw",
"from_user": "_AaronNg"
}
{
"text": "RT @_kud: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt; -- http://t.co/Lhp92IqD",
"from_user": "blouerat"
}
{
"text": "Dynamic Forms Mobile App by pmadiset: Few Forms details are hosted on our server in the form of JSON. This JSON ... http://t.co/7KALdWaX",
"from_user": "cebu_iphone"
}
{
"text": "iPhone 5 website insanity - Video compressing using JPEG, JSON, and &lt;canvas&gt; http://t.co/28Jesbio (Oh #Apple, U So #Awesome...)",
"from_user": "dieswaytoofast"
}
{
"text": "RT @umutm: A very nice web-based JSON editor - http://t.co/M70snaIf",
"from_user": "Leolik"
}
- text: |
`.results[]` returns each element of the results array, one at a
time, which are all fed into `{from_user, text}`.
Data in jq is represented as streams of JSON values - every jq
expression runs for each value in its input stream, and can
produce any number of values to its output stream.
Streams are serialised by just separating JSON values with
whitespace. This is a `cat`-friendly format - you can just join
two JSON streams together and get a valid JSON stream.
If you want to get the output as a single array, you can tell jq to
"collect" all of the answers by wrapping the filter in square
brackets:
- command: "jq '[.results[] | {from_user, text}]'"
result: |
[
{
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt;.\nhttp://t.co/XRvh1ZVw",
"from_user": "_AaronNg"
},
{
"text": "RT @_kud: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt; -- http://t.co/Lhp92IqD",
"from_user": "blouerat"
},
{
"text": "Dynamic Forms Mobile App by pmadiset: Few Forms details are hosted on our server in the form of JSON. This JSON ... http://t.co/7KALdWaX",
"from_user": "cebu_iphone"
},
{
"text": "iPhone 5 website insanity - Video compressing using JPEG, JSON, and &lt;canvas&gt; http://t.co/28Jesbio (Oh #Apple, U So #Awesome...)",
"from_user": "dieswaytoofast"
},
{
"text": "RT @umutm: A very nice web-based JSON editor - http://t.co/M70snaIf",
"from_user": "Leolik"
}
]
- text: |
- - -
Next, let's try getting the URLs out of those API results as
well. In each tweet, the Twitter API includes a field called
"entities" which looks like this:
{
"user_mentions": [],
"urls": [{
"indices": [83, 103],
"display_url": "bit.ly/StniqT",
"expanded_url": "http://bit.ly/StniqT",
"url": "http://t.co/28Jesbio"
}],
"hashtags": [
{"indices": [108, 114], "text": "Apple" },
{"indices": [121, 129], "text": "Awesome"}
]
}
We want to pull out all of the "url" fields inside that array of url
objects, and make a simple list of strings to go along with the
"from_user" and "text" fields we already have.
- command: "jq '.results[] | {from_user, text, urls: [.entities.urls[].url]}'"
result: |
{
"urls": [
"http://t.co/XRvh1ZVw"
],
"text": "RT @imagemechanics: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt;.\nhttp://t.co/XRvh1ZVw",
"from_user": "_AaronNg"
}
{
"urls": [
"http://t.co/Lhp92IqD"
],
"text": "RT @_kud: iPhone 5 website teardown: How Apple compresses video using JPEG, JSON, and &lt;canvas&gt; -- http://t.co/Lhp92IqD",
"from_user": "blouerat"
}
{
"urls": [
"http://t.co/7KALdWaX"
],
"text": "Dynamic Forms Mobile App by pmadiset: Few Forms details are hosted on our server in the form of JSON. This JSON ... http://t.co/7KALdWaX",
"from_user": "cebu_iphone"
}
{
"urls": [
"http://t.co/28Jesbio"
],
"text": "iPhone 5 website insanity - Video compressing using JPEG, JSON, and &lt;canvas&gt; http://t.co/28Jesbio (Oh #Apple, U So #Awesome...)",
"from_user": "dieswaytoofast"
}
{
"urls": [
"http://t.co/M70snaIf"
],
"text": "RT @umutm: A very nice web-based JSON editor - http://t.co/M70snaIf",
"from_user": "Leolik"
}
- text: |
Here we're making an object as before, but this time the urls
field is being set to `[.entities.urls[].url]`, which collects
all of the URLs defined in the entities object.
- text: |
- - -
Here endeth the tutorial! There's lots more to play with, go
read [the manual](../manual/) if you're interested, and [download
jq](../download/) if you haven't already.
-90
View File
@@ -1,90 +0,0 @@
headline: Download jq
body:
- text: |
jq is written in C and has no runtime dependencies, so it should be
possible to build it for nearly any platform. Prebuilt binaries are
available for Linux, OS X and Windows.
The binaries should just run, but on OS X and Linux you may need
to make them executable first using `chmod +x jq`.
jq is licensed under the MIT license. For all of the gory
details, read the file `COPYING` in the source distribution.
### Linux
* Binaries for [64-bit](linux64/jq) or [32-bit](linux32/jq) systems.
* For Arch users, a PKGBUILD for jq-1.1 is in the
[AUR](https://aur.archlinux.org/packages.php?ID=63849), as
well as a PKGBUILD for the HEAD of master
([jq-git](https://aur.archlinux.org/packages.php?ID=63850)).
You can install them using
[Yaourt](https://wiki.archlinux.org/index.php/Yaourt) or
manually by following instructions on [Arch Linux's
Wiki](https://wiki.archlinux.org/index.php/Arch_UseRepository).
* jq 1.2 is [in Debian](http://packages.debian.org/jq)
### OS X
* `brew install jq` using [homebrew](http://mxcl.github.com/homebrew/)
* Or, grab prebuilt [64-bit binaries](osx64/jq) or [32-bit
binaries](osx32/jq)
### Windows
* Executables for [64-bit](win64/jq.exe) or [32-bit](win32/jq.exe)
### From source on Linux or OS X
* [Source tarball for jq $JQ_VERSION](source/jq-$JQ_VERSION.tar.gz)
You can build it using the usual `./configure && make && sudo
make install` rigmarole.
If you're interested in using the lastest development version, try:
git clone https://github.com/stedolan/jq.git
cd jq
autoreconf
./configure
make
sudo make install
To build it from a git clone, you'll need to install a few
packages first:
* [Flex](http://www.gnu.org/software/flex/)
* [Bison](http://www.gnu.org/software/bison/)
* [GCC](http://gcc.gnu.org)
* [Make](http://www.gnu.org/software/make)
* [Autotools](http://www.gnu.org/software/automake)
For Linux systems, these will all be in your system's package
manager, and if you do development on the machine they're most
likely already installed.
On OS X, these are all included in Apple's command line tools, which
can be installed from [Xcode](http://developer.apple.com/technologies/tools/).
However, you may find that you need a newer version of Bison than the one provided
by Apple. This can be found in [Homebrew](http://mxcl.github.com/homebrew/)
or [MacPorts](http://macports.org/).
`flex` and `bison` are used to generate the lexer and parser for
jq, and some python scripts generate the UTF8 encoding tables
needed for JSON parsing.
#### Building the documentation
jq's documentation is compiled into static HTML using
[Bonsai](http://www.tinytree.info). To view the documentation
locally, run `rake serve` from the docs/ subdirectory. You'll
need a few Ruby dependencies, which can be installed by
following the instructions in `docs/README.md`.
+355
View File
@@ -0,0 +1,355 @@
headline: Download jq
body:
- text: |
jq is written in C and has no runtime dependencies, so it should be
possible to build it for nearly any platform. The prebuilt files linked
below are standalone executables, not archives, and are available for
Linux, macOS and Windows.
The binaries should just run, but on macOS and Linux you may need
to make them executable first using `chmod +x jq`.
jq is licensed under the MIT license. For all of the gory
details, read the file `COPYING` in the source distribution.
jq uses a C library for decimal number support. This is an ICU 1.8.1
licensed code obtained from the ICU downloads archive.
<https://download.icu-project.org/files/decNumber/decNumber-icu-368.zip>
### Linux
* jq is in the official [Debian](https://packages.debian.org/jq) and
[Ubuntu](https://packages.ubuntu.com/jq) repositories. Install using
`sudo apt-get install jq`.
* jq is in the official [Fedora](https://src.fedoraproject.org/rpms/jq) repository.
Install using `sudo dnf install jq`.
* jq is in the official [openSUSE](https://software.opensuse.org/package/jq) repository.
Install using `sudo zypper install jq`.
* jq is in the official [Arch](https://archlinux.org/packages/?q=jq) repository.
Install using `sudo pacman -S jq`.
* jq is in [conda-forge](https://anaconda.org/conda-forge/jq).
Install using `conda install -c conda-forge jq`.
* jq 1.8.2 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-linux-amd64)
or
[ARM64](https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-linux-arm64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-linux-i386).
<details markdown="1">
<summary>Older versions</summary>
* jq 1.8.1 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux-amd64)
or
[ARM64](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux-arm64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-linux-i386).
* jq 1.8.0 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-linux-amd64)
or
[ARM64](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-linux-arm64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-linux-i386).
* jq 1.7.1 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-amd64)
or
[ARM64](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-arm64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-linux-i386).
* jq 1.7 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-amd64)
or
[ARM64](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-arm64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-linux-i386).
* jq 1.6 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-linux32).
* jq 1.5 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-linux64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-linux32).
* jq 1.4 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-linux-x86_64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-linux-x86).
* jq 1.3 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-linux-x86_64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-linux-x86).
</details>
### macOS
* Use [Homebrew](https://brew.sh/) to install jq with `brew install jq`.
* Use [MacPorts](https://www.macports.org) to install jq with `port install jq`.
* Use [Fink](https://finkproject.org) to install jq with `fink install jq`.
* Use [conda-forge](https://anaconda.org/conda-forge/jq) to install jq with
`conda install -c conda-forge jq`.
* jq 1.8.2 binaries for
[Apple Silicon](https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-macos-arm64)
or
[Intel Mac](https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-macos-amd64).
<details markdown="1">
<summary>Older versions</summary>
* jq 1.8.1 binaries for
[Apple Silicon](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-macos-arm64)
or
[Intel Mac](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-macos-amd64).
* jq 1.8.0 binaries for
[Apple Silicon](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-macos-arm64)
or
[Intel Mac](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-macos-amd64).
* jq 1.7.1 binaries for
[Apple Silicon](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-macos-arm64)
or
[Intel Mac](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-macos-amd64).
* jq 1.7 binaries for
[Apple Silicon](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-macos-arm64)
or
[Intel Mac](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-macos-amd64).
* jq 1.6 binary for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-osx-amd64).
* jq 1.5 binary for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-osx-amd64).
* jq 1.4 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-osx-x86_64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-osx-x86).
* jq 1.3 binaries for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-osx-x86_64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-osx-x86).
</details>
### FreeBSD
* `pkg install jq` as root installs a pre-built
[binary package](https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/pkgng-intro.html).
* `make -C /usr/ports/textproc/jq install clean` as root installs the
[jq](https://www.freshports.org/textproc/jq/)
[port](https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html)
from source.
### Solaris
* `pkgutil -i jq` in [OpenCSW](https://www.opencsw.org/p/jq) for Solaris
10+, Sparc and x86.
* jq 1.4 binaries for Solaris 11
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-solaris11-64)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-solaris11-32).
### Windows
* Use [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/)
to install jq with `winget install jqlang.jq`.
* Use [scoop](https://scoop.sh/) to install jq with `scoop install jq`.
* Use [Chocolatey NuGet](https://chocolatey.org/) to install jq with
`choco install jq`.
* jq 1.8.2 executables for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-windows-amd64.exe)
or
[ARM64](https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-windows-arm64.exe)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-windows-i386.exe).
<details markdown="1">
<summary>Older versions</summary>
* jq 1.8.1 executables for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-windows-amd64.exe)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-windows-i386.exe).
* jq 1.8.0 executables for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-windows-amd64.exe)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-windows-i386.exe).
* jq 1.7.1 executables for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-windows-amd64.exe)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-windows-i386.exe).
* jq 1.7 executables for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-windows-amd64.exe)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-windows-i386.exe).
* jq 1.6 executables for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win64.exe)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-win32.exe).
* jq 1.5 executables for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-win64.exe)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-win32.exe).
* jq 1.4 executables for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-win64.exe)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.4/jq-win32.exe).
* jq 1.3 executables for
[AMD64](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-win64.exe)
or
[i386](https://github.com/jqlang/jq/releases/download/jq-1.3/jq-win32.exe).
</details>
### Checksums and signatures
SHA-256 checksums are provided for all release and pre-release binaries,
and all release artifacts are signed by a jq release key. We have two release keys,
[one for 1.6 and older releases](https://raw.githubusercontent.com/jqlang/jq/master/sig/jq-release-old.key),
and
[one for 1.7 and newer releases](https://raw.githubusercontent.com/jqlang/jq/master/sig/jq-release-new.key).
You can use [GnuPG](https://gnupg.org/) to verify a signature by downloading
the signature and running `gpg --verify signature.asc`.
* jq 1.8.2
[checksums](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.8.2/sha256sum.txt)
and
[signatures](https://github.com/jqlang/jq/tree/master/sig/v1.8.2).
<details markdown="1">
<summary>Older versions</summary>
* jq 1.8.1
[checksums](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.8.1/sha256sum.txt)
and
[signatures](https://github.com/jqlang/jq/tree/master/sig/v1.8.1).
* jq 1.8.0
[checksums](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.8.0/sha256sum.txt)
and
[signatures](https://github.com/jqlang/jq/tree/master/sig/v1.8.0).
* jq 1.7.1
[checksums](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.7.1/sha256sum.txt)
and
[signatures](https://github.com/jqlang/jq/tree/master/sig/v1.7.1).
* jq 1.7
[checksums](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.7/sha256sum.txt)
and
[signatures](https://github.com/jqlang/jq/tree/master/sig/v1.7).
* jq 1.6
[checksums](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.6/sha256sum.txt)
and
[signatures](https://github.com/jqlang/jq/tree/master/sig/v1.6).
* jq 1.5
[checksums](https://raw.githubusercontent.com/jqlang/jq/master/sig/v1.5/sha256sum.txt)
and
[signatures](https://github.com/jqlang/jq/tree/master/sig/v1.5).
</details>
### From source on Linux, macOS, Cygwin, and other POSIX-like operating systems
* [Source tarball for jq 1.8.2](https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-1.8.2.tar.gz)
<details markdown="1">
<summary>Older versions</summary>
* [Source tarball for jq 1.8.1](https://github.com/jqlang/jq/releases/download/jq-1.8.1/jq-1.8.1.tar.gz)
* [Source tarball for jq 1.8.0](https://github.com/jqlang/jq/releases/download/jq-1.8.0/jq-1.8.0.tar.gz)
* [Source tarball for jq 1.7.1](https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-1.7.1.tar.gz)
* [Source tarball for jq 1.7](https://github.com/jqlang/jq/releases/download/jq-1.7/jq-1.7.tar.gz)
* [Source tarball for jq 1.6](https://github.com/jqlang/jq/releases/download/jq-1.6/jq-1.6.tar.gz)
* [Source tarball for jq 1.5](https://github.com/jqlang/jq/releases/download/jq-1.5/jq-1.5.tar.gz)
</details>
You can build it using the usual `./configure && make && sudo
make install` rigmarole.
If you're interested in using the latest development version, try:
git clone --recursive https://github.com/jqlang/jq.git
cd jq
autoreconf -i
./configure
make
sudo make install
To build it from a git clone, you'll need to install a few
packages first:
* [GCC](https://gcc.gnu.org)
* [Make](https://www.gnu.org/software/make/)
* [Autotools](https://www.gnu.org/software/automake/)
For Linux systems, these will all be in your system's package
manager, and if you do development on the machine they're most
likely already installed.
On macOS, these are all included in Apple's command line tools, which can
be installed from [Xcode](https://developer.apple.com/xcode/). However,
you may find that you need a newer version of Bison than the one provided
by Apple. This can be found in [Homebrew](https://brew.sh/) or
[MacPorts](https://macports.org/).
If you want to generate the lexer and parser from source you can use the
`--enable-maintainer-mode` configure flag. This requires bison to be installed.
[Flex](https://github.com/westes/flex) and
[Bison](https://www.gnu.org/software/bison/).
### Docker
Docker image is available from
[GitHub Container Registry](https://github.com/jqlang/jq/pkgs/container/jq).
docker run -i --rm ghcr.io/jqlang/jq -n 'range(3)'
#### Building the documentation
jq's documentation is compiled into static HTML using Python.
To build the docs, run `pipenv run python3 build_website.py`
in the `docs/` directory. To serve them locally, you can run
`python3 -m http.server -d output`. You'll need a few Python dependencies,
which can be installed by following the instructions in `docs/README.md`.
The man page is built by `make jq.1`, or just `make`, also from
the YAML docs, and you'll still need the Python dependencies to
build the manpage.
+95
View File
@@ -0,0 +1,95 @@
headline: jq
blurb: |
jq is a lightweight and flexible command-line JSON processor.
body1: |
jq is like `sed` for JSON data - you can use it to slice and filter
and map and transform structured data with the same ease that `sed`,
`awk`, `grep` and friends let you play with text.
body2: |
jq is written in portable C, and it has zero runtime
dependencies. You can download a single binary, `scp` it to a far away
machine of the same type, and expect it to work.
body3: |
jq can mangle the data format that you have into the one that you
want with very little effort, and the program to do so is often
shorter and simpler than you'd expect.
tail: |
Go read the [tutorial](./tutorial/) for more, or the [manual](./manual/)
for *way* more.
Have a question related to jq? You can seek answers on [Stack Overflow](https://stackoverflow.com/)
by using the [jq tag](https://stackoverflow.com/questions/tagged/jq), or in the [#jq channel](https://web.libera.chat/#jq)
on [Libera.Chat](https://libera.chat/). For more interactive discussions, feel free to join our [Discord server](https://discord.gg/yg6yjNmgAC).
news:
- date: 20 June 2026
body: |
jq 1.8.2 released. See [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.8.2) for details.
- date: 1 July 2025
body: |
jq 1.8.1 released. See [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.8.1) for details.
- date: 1 June 2025
body: |
jq 1.8.0 released. See [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.8.0) for details.
- date: 13 December 2023
body: |
jq 1.7.1 released. Security (CVE-2023-50246, CVE-2023-50268) and bug fixes.
See [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.7.1) for details.
- date: 7 September 2023
body: |
After a five-year hiatus, we've returned with a revitalized [GitHub organization](https://github.com/jqlang)
and a much-anticipated 1.7 release, thanks to our new admins and maintainers.
Check out the [download](./download/) page for installation options and see the
[release notes](https://github.com/jqlang/jq/releases/tag/jq-1.7) for details.
- date: 1 November 2018
body: |
jq 1.6 released. See installation options on the [download](./download/)
page, and the [release notes](https://github.com/jqlang/jq/releases/tag/jq-1.6)
for details.
- date: 15 August 2015
body: |
jq 1.5 released, including new datetime, math, and regexp functions,
try/catch syntax, array and object destructuring, a streaming parser,
and a module system. See installation options on the
[download](./download/) page, and the
[release notes](https://github.com/jqlang/jq/releases/tag/jq-1.5)
for details.
- date: 26 July 2015
body: |
jq 1.5rc2 is available. Get it on the
[releases](https://github.com/jqlang/jq/releases) page.
- date: 01 January 2015
body: |
jq 1.5rc1 is available. Get it on the
[releases](https://github.com/jqlang/jq/releases) page.
- date: 09 June 2014
body: |
jq 1.4 (finally) released! Get it on the [download](./download/) page.
- date: 19 May 2013
body: |
jq 1.3 released.
-34
View File
@@ -1,34 +0,0 @@
headline: jq
blurb: |
jq is a lightweight and flexible command-line JSON processor.
body1: |
jq is like `sed` for JSON data - you can use it to slice and filter
and map and transform structured data with the same ease that `sed`,
`awk`, `grep` and friends let you play with text.
body2: |
jq is written in portable C, and it has zero runtime
dependencies. You can download a single binary, `scp` it to a far away
machine, and expect it to work.
body3: |
jq can mangle the data format that you have into the one that you
want with very little effort, and the program to do so is often
shorter and simpler than you'd expect.
tail: |
Go read the [tutorial](tutorial/) for more, or the [manual](manual/)
for *way* more.
news:
- date: 2013-05-19
body: |
jq 1.3 (finally) released! Get it on the [download](download/) page.
File diff suppressed because it is too large. Load diff
+1
View File
@@ -0,0 +1 @@
v1.8/manual.yml
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+767
View File
@@ -0,0 +1,767 @@
headline: Tutorial
body:
- text: |
jq is a command-line JSON processor: it reads JSON, applies the program you
give it, and writes JSON back out. A jq program is called a filter, and the
simplest one is `.`, the identity filter, which produces its input unchanged.
- command: "echo '{\"foo\": 42, \"bar\": [1, 2, 3]}' | jq '.'"
result: |
{
"foo": 42,
"bar": [
1,
2,
3
]
}
- text: |
The value is unchanged, but the formatting is jq's own: it pretty-prints and
colorizes what it writes, so `jq .` alone is already a useful way to make dense
JSON readable. Note the quotes around the program. The shell has no special
meaning for `.`, so `jq .` works without them, but almost every program past
this one contains characters the shell would interpret itself. Quoting is a
habit worth forming early. (On Windows, `cmd.exe` wants double quotes around
the program instead, and any double quote inside it then needs a backslash.)
- text: |
- - -
For something more substantial, let's use GitHub's API. The `gh`
command-line tool speaks it, so this asks for the commits made to the jq
repository before a fixed date and saves the answer:
gh api 'repos/jqlang/jq/commits?until=2026-09-02' > commits.json
(If you do not have `gh`, `curl -s
'https://api.github.com/repos/jqlang/jq/commits?until=2026-09-02' >
commits.json` fetches the same commits. GitHub pretty-prints what it sends to
`curl`, so that file arrives spread over a couple of thousand lines rather
than the single line shown just below; every jq command here gives the same
answer either way.)
- text: |
jq reads the file you name on the command line, or standard input if you name
none, so piping `gh api` straight into `jq` would work just as well, and day
to day that is how you would write it. In this tutorial, we save the response
to a file so you can follow along without downloading it repeatedly. `until`
pins the result to a fixed set of commits, so what you see matches what is
shown here.
The first 200 bytes of that file look like this:
- command: "head -c 200 commits.json"
result: |
[{"sha":"9d241e277204b83c4a7ddc7d733e5c72f99ef500","node_id":"C_kwDOAE3WVdoAKDlkMjQxZTI3NzIwNGI4M2M0YTdkZGM3ZDczM2U1YzcyZjk5ZWY1MDA","commit":{"author":{"name":"dependabot[bot]","email":"49699333+depe
- text: |
One very long line - about 120 KB of it. Pretty-printed it is no better: the
same data runs to some 2,500 lines. Either way it is far more than you can
take in by eye, which is the situation jq exists to fix. Start by asking how
much is in there:
- command: "jq 'length' commits.json"
result: |
30
- text: |
Thirty commits, which is what this endpoint returns when you do not ask for a
particular page size. `.[0]` indexes into an array, `.commit` reads a field of
the element it picks out, and jq pretty-prints the result:
- command: "jq '.[0].commit' commits.json"
result: |
{
"author": {
"name": "dependabot[bot]",
"email": "49699333+dependabot[bot]@users.noreply.github.com",
"date": "2026-09-01T06:30:46Z"
},
"committer": {
"name": "GitHub",
"email": "noreply@github.com",
"date": "2026-09-01T06:30:46Z"
},
"message": "build(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622)",
"tree": {
"sha": "a35a9454bff26f1b7a94d8401ddef014249b3e2a",
"url": "https://api.github.com/repos/jqlang/jq/git/trees/a35a9454bff26f1b7a94d8401ddef014249b3e2a"
},
"url": "https://api.github.com/repos/jqlang/jq/git/commits/9d241e277204b83c4a7ddc7d733e5c72f99ef500",
"comment_count": 0,
"verification": {
"verified": true,
"reason": "valid",
"signature": "-----BEGIN PGP SIGNATURE-----\n\nwsFcBAABCAAQBQJqlnEWCRC1aQ7uu5UhlAAAyOQQACXr1PX49pfMGtGjm3AI44Sq\nZhyHjH7nJ+QagUVpky25lOr86cMTL12b7zQqS8mW9ESUvOB3Og7J3xdDAn8dJb9y\nFDVyKnQwxNVHboSTFzDgI4qORbnJPrT4imdHLbmAf6oodDAtoUjtx9ai/UvbXcud\nl/PKB7CvoGxPqxbjb3mjovM75dQihDcpXJvJ/AxfgJAfecU88o6Oj30XYq6lxwsc\nMMctYKZMPJhIV1IjpTFrkvuFd7ycyghDJG0bTUnruW+kz2Fl4t7OzPzl/ZwqI3pY\nFIeIR31KSz1BsHB2PdanrrN1WPjmbd/7/69/EmdQYNrzxopSfHedbiwF7VMStTyv\nF26sPNogniA2znvEJwY0fLOF6fRKdH8LR5tUVOUm4Rv7Dc7jF8wmapzV94o9+r/p\nV3t6dMwz4KQUnZUbXE+Z5q/Csoy/1nQYcpj/vvIAQOpx+SeFBPtweFeU+oN1W1dZ\nJYS6LvVTS+8xGPEFjFwbA23pCbCqRIUL4JLzRWpfyaHP6bkhRJFWO6SmgOGymWBz\nEhdiO616YxN34C7OMFET/LsPWvowIBJ3NcDGRifb7S6lUtNQ3xBb0GwMYBZcexTT\nlwv8UtiRda4qbDB5/Maejklobv0IM3OrlyyjvqtxVwCf1WSWEjaOkBHxHJE80wBy\nUycRdNdExOiumLaKrUVx\n=qDA7\n-----END PGP SIGNATURE-----\n",
"payload": "tree a35a9454bff26f1b7a94d8401ddef014249b3e2a\nparent 8bce8b65437bf12b9e39d7f5e85f9ef285d7e785\nauthor dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 1788244246 +0900\ncommitter GitHub <noreply@github.com> 1788244246 +0900\n\nbuild(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622)",
"verified_at": "2026-09-01T06:30:46Z"
}
}
- text: |
That is a lot of metadata for one commit. Paths chain as far as you need, so
the commit message is:
- command: "jq '.[0].commit.message' commits.json"
result: |
"build(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622)"
- text: |
The result is a JSON string, quotes and all, because jq writes JSON. When
the value is destined for something that wants plain text, `-r` writes
strings raw instead:
- command: "jq -r '.[0].commit.message' commits.json"
result: |
build(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622)
- text: |
- - -
Most of that commit object is noise. To keep only the interesting parts, build
a new object out of them:
- command: "jq '.[0] | {message: .commit.message, author: .commit.author.name}' commits.json"
result: |
{
"message": "build(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622)",
"author": "dependabot[bot]"
}
- text: |
Two things are happening here. `|` is jq's pipe, borrowed from the shell and
working the same way: it feeds the output of the filter on its left into the
input of the filter on its right. So `.[0]` selects the first commit, and
everything after the pipe is evaluated with that commit as its input. And
`{...}` constructs an object, with each value written as a filter applied to
that input.
Replacing `.[0]` with `.[]` runs the same construction over every element of
the array:
- command: "jq '.[] | {message: .commit.message, author: .commit.author.name}' commits.json"
result: |
{
"message": "build(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622)",
"author": "dependabot[bot]"
}
{
"message": "build(deps): bump lxml from 6.1.1 to 6.1.2 in /docs (#3621)",
"author": "dependabot[bot]"
}
{
"message": "Fix a handful of typos (#3605)",
"author": "Anna Rift"
}
{
"message": "Fix strftime-related functions on NetBSD. (#3579)",
"author": "Thomas Klausner"
}
{
"message": "Reject raw NUL bytes in the parser instead of silently truncating tokens (#3606)",
"author": "august"
}
{
"message": "docs: `in` example use [3,4] instead of [0,1] (#3599)",
"author": "A4-Tacks"
}
{
"message": "Fix typo 'you may wish [to] use' (#3604)\n\nFix all instances of the phrase \"you may wish use `fabs`\" -> \"you may\nwish _to_ use `fabs`\" (emphasis mine) in the manual.",
"author": "Anna Rift"
}
{
"message": "build(deps): bump actions/setup-python from 6 to 7 in the official-actions group (#3595)",
"author": "dependabot[bot]"
}
{
"message": "docs: clarify join behavior on objects (#3555)",
"author": "ded-furby"
}
{
"message": "Advance past the whole codepoint after a zero-width regex match (#3586)",
"author": "WinkleMad"
}
{
"message": "shtest: skip locale test if date lacks locale support (#3583)",
"author": "pavel kuliaka"
}
{
"message": "Cast char to unsigned char before passing to isspace (#3574)",
"author": "Thomas Klausner"
}
{
"message": "Add a download link for Windows arm64",
"author": "itchyny"
}
{
"message": "Update jq documentation for jq 1.8.2 release",
"author": "itchyny"
}
{
"message": "Update signatures of 1.8.2 (#3566)\n\nCo-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>",
"author": "github-actions[bot]"
}
{
"message": "build(deps): bump actions/checkout from 6 to 7 in the official-actions group (#3565)",
"author": "dependabot[bot]"
}
{
"message": "Update NEWS.md and AUTHORS for 1.8.2 (#3529)",
"author": "itchyny"
}
{
"message": "Upload attestation bundle as a release artifact (#3563)\n\nThe bundle generated by actions/attest is currently only retrievable\nvia the GitHub attestations API, which requires authentication.\nUploading it as jq-attestation.json lets downstream consumers\n(distro packagers, unauthenticated CI) verify provenance offline.",
"author": "itchyny"
}
{
"message": "Tighten string length bounds and propagate invalid jv in implode\n\nThe bound added in CVE-2026-32316 (e47e56d22) still allowed\n`sizeof(jvp_string) + (currlen + len) * 2 + 1` to wrap `size_t` on\n32-bit platforms. Tighten the threshold so the final allocation\nfits in 32-bit `size_t`.\n\nAlso break out of `jv_string_implode` and `f_string_implode` once\n`jv_string_append_codepoint` returns an invalid `jv`; otherwise the\nnext iteration triggers the assertion in `jvp_string_ptr` (or\ninvokes undefined behavior under `-DNDEBUG`).\n\nFixes CVE-2026-54679.\n\nCo-authored-by: Dirk Müller <dirk@dmllr.de>",
"author": "itchyny"
}
{
"message": "Fix heap-buffer-overflow in raw file loading\n\nWhen `jv_string_append_buf` overflows the string length limit,\nit returns an invalid `jv`; `jv_load_file` then re-entered it\non the invalid value and overran the heap. Break out of the loop\nonce the value is invalid.\n\nFixes CVE-2026-49839.",
"author": "itchyny"
}
{
"message": "build(deps): bump lxml from 6.1.0 to 6.1.1 in /docs (#3553)",
"author": "dependabot[bot]"
}
{
"message": "Fix undefined pointer arithmetic in UTF-8 helpers\n\nFixes GHSA-ggc9-rpv2-xgpm and GHSA-gvwx-xj9r-3frq.",
"author": "theyoucheng"
}
{
"message": "Fix one-byte over-read in BASE64_DECODE_TABLE (#3547)\n\nThe table was declared with 255 entries but indexed by an unsigned\nchar, so the decoder would read one byte past the array for input\nbytes equal to 0xFF. Through jq's normal input paths the over-read\nis unreachable because invalid UTF-8 bytes are normalized to U+FFFD\nbefore reaching @base64d, but the table is still wrong at the C\nlevel and reachable by libjq callers that construct strings via\nthe C API without UTF-8 validation.",
"author": "itchyny"
}
{
"message": "Guard deep structural equality and comparison recursion (#3539)\n\njv_equal and jv_cmp overflows the C stack on deeply nested\ninput. Cap recursion at 10000 with -1 / INT_MIN sentinels;\noperators that compose user expressions surface this as\n\"Equality check too deep\" / \"Comparison too deep\".\n\nFixes CVE-2026-47770.",
"author": "Yu-Fu Fu"
}
{
"message": "Detect circular module imports to prevent stack overflow\n\njq used to recurse without bound on mutual or self-referential\n`import` declarations, exhausting the stack. Track each library's\nload state with a `loading` flag set before its dependencies are\nprocessed; a recursive reference to an in-progress library now\nreports \"circular import of X\".\n\nFixes CVE-2026-44777.",
"author": "itchyny"
}
{
"message": "Reject embedded NUL bytes in module import paths\n\njq accepts embedded NUL bytes at the language level but resolves\nmodule import paths through NUL-terminated C strings, so the path\nvalidated by policy or audit code could differ from the on-disk\npath jq actually opens. Pass jv through gen_import so the AST\npreserves the original bytes, and reject embedded NULs in\nvalidate_relpath.\n\nFixes CVE-2026-43895.",
"author": "itchyny"
}
{
"message": "Reject numeric literals longer than DEC_MAX_DIGITS (999999999)\n\nA signed-int overflow in decNumber's D2U macro lets huge literals\nwrite attacker-controlled bytes past a stack buffer. Cap the length\nbefore calling decNumberFromString, and pre-slice long strings in\njv_dump_string_trunc so the resulting error message doesn't itself\nallocate a multi-GiB buffer.\n\nFixes CVE-2026-43894.",
"author": "itchyny"
}
{
"message": "Limit recursive object merge depth to prevent stack overflow\n\nThis fixes CVE-2026-43896.",
"author": "itchyny"
}
{
"message": "Avoid stack overflow when freeing deeply nested values",
"author": "itchyny"
}
{
"message": "Fix CI to add `artifact-metadata` permission for actions/attest (#3530)",
"author": "itchyny"
}
- text: |
Thirty objects, not an array of thirty objects. This is central to how jq works:
a jq program transforms a *stream* of JSON values. Every expression runs
once per value in its input stream and may produce any number of values -
zero, one, or many - on its output stream. `.[]` is simply an expression
that takes one array and emits each of its elements.
Every value jq writes is followed by a newline. Reading is more relaxed than
writing: any amount of whitespace between two values will do, and a value that
closes with `}`, `]` or `"` needs no separator at all. That is what makes the
format `cat`-friendly:
join two jq outputs together and the result is still something jq can read. A
pretty-printed value spans as many lines as it needs, so when the next program
in the pipeline is line-oriented, `-c` is what you want. It compacts each value
onto one line:
- command: "jq -c '.[] | {message: .commit.message, author: .commit.author.name}' commits.json"
result: |
{"message":"build(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622)","author":"dependabot[bot]"}
{"message":"build(deps): bump lxml from 6.1.1 to 6.1.2 in /docs (#3621)","author":"dependabot[bot]"}
{"message":"Fix a handful of typos (#3605)","author":"Anna Rift"}
{"message":"Fix strftime-related functions on NetBSD. (#3579)","author":"Thomas Klausner"}
{"message":"Reject raw NUL bytes in the parser instead of silently truncating tokens (#3606)","author":"august"}
{"message":"docs: `in` example use [3,4] instead of [0,1] (#3599)","author":"A4-Tacks"}
{"message":"Fix typo 'you may wish [to] use' (#3604)\n\nFix all instances of the phrase \"you may wish use `fabs`\" -> \"you may\nwish _to_ use `fabs`\" (emphasis mine) in the manual.","author":"Anna Rift"}
{"message":"build(deps): bump actions/setup-python from 6 to 7 in the official-actions group (#3595)","author":"dependabot[bot]"}
{"message":"docs: clarify join behavior on objects (#3555)","author":"ded-furby"}
{"message":"Advance past the whole codepoint after a zero-width regex match (#3586)","author":"WinkleMad"}
{"message":"shtest: skip locale test if date lacks locale support (#3583)","author":"pavel kuliaka"}
{"message":"Cast char to unsigned char before passing to isspace (#3574)","author":"Thomas Klausner"}
{"message":"Add a download link for Windows arm64","author":"itchyny"}
{"message":"Update jq documentation for jq 1.8.2 release","author":"itchyny"}
{"message":"Update signatures of 1.8.2 (#3566)\n\nCo-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>","author":"github-actions[bot]"}
{"message":"build(deps): bump actions/checkout from 6 to 7 in the official-actions group (#3565)","author":"dependabot[bot]"}
{"message":"Update NEWS.md and AUTHORS for 1.8.2 (#3529)","author":"itchyny"}
{"message":"Upload attestation bundle as a release artifact (#3563)\n\nThe bundle generated by actions/attest is currently only retrievable\nvia the GitHub attestations API, which requires authentication.\nUploading it as jq-attestation.json lets downstream consumers\n(distro packagers, unauthenticated CI) verify provenance offline.","author":"itchyny"}
{"message":"Tighten string length bounds and propagate invalid jv in implode\n\nThe bound added in CVE-2026-32316 (e47e56d22) still allowed\n`sizeof(jvp_string) + (currlen + len) * 2 + 1` to wrap `size_t` on\n32-bit platforms. Tighten the threshold so the final allocation\nfits in 32-bit `size_t`.\n\nAlso break out of `jv_string_implode` and `f_string_implode` once\n`jv_string_append_codepoint` returns an invalid `jv`; otherwise the\nnext iteration triggers the assertion in `jvp_string_ptr` (or\ninvokes undefined behavior under `-DNDEBUG`).\n\nFixes CVE-2026-54679.\n\nCo-authored-by: Dirk Müller <dirk@dmllr.de>","author":"itchyny"}
{"message":"Fix heap-buffer-overflow in raw file loading\n\nWhen `jv_string_append_buf` overflows the string length limit,\nit returns an invalid `jv`; `jv_load_file` then re-entered it\non the invalid value and overran the heap. Break out of the loop\nonce the value is invalid.\n\nFixes CVE-2026-49839.","author":"itchyny"}
{"message":"build(deps): bump lxml from 6.1.0 to 6.1.1 in /docs (#3553)","author":"dependabot[bot]"}
{"message":"Fix undefined pointer arithmetic in UTF-8 helpers\n\nFixes GHSA-ggc9-rpv2-xgpm and GHSA-gvwx-xj9r-3frq.","author":"theyoucheng"}
{"message":"Fix one-byte over-read in BASE64_DECODE_TABLE (#3547)\n\nThe table was declared with 255 entries but indexed by an unsigned\nchar, so the decoder would read one byte past the array for input\nbytes equal to 0xFF. Through jq's normal input paths the over-read\nis unreachable because invalid UTF-8 bytes are normalized to U+FFFD\nbefore reaching @base64d, but the table is still wrong at the C\nlevel and reachable by libjq callers that construct strings via\nthe C API without UTF-8 validation.","author":"itchyny"}
{"message":"Guard deep structural equality and comparison recursion (#3539)\n\njv_equal and jv_cmp overflows the C stack on deeply nested\ninput. Cap recursion at 10000 with -1 / INT_MIN sentinels;\noperators that compose user expressions surface this as\n\"Equality check too deep\" / \"Comparison too deep\".\n\nFixes CVE-2026-47770.","author":"Yu-Fu Fu"}
{"message":"Detect circular module imports to prevent stack overflow\n\njq used to recurse without bound on mutual or self-referential\n`import` declarations, exhausting the stack. Track each library's\nload state with a `loading` flag set before its dependencies are\nprocessed; a recursive reference to an in-progress library now\nreports \"circular import of X\".\n\nFixes CVE-2026-44777.","author":"itchyny"}
{"message":"Reject embedded NUL bytes in module import paths\n\njq accepts embedded NUL bytes at the language level but resolves\nmodule import paths through NUL-terminated C strings, so the path\nvalidated by policy or audit code could differ from the on-disk\npath jq actually opens. Pass jv through gen_import so the AST\npreserves the original bytes, and reject embedded NULs in\nvalidate_relpath.\n\nFixes CVE-2026-43895.","author":"itchyny"}
{"message":"Reject numeric literals longer than DEC_MAX_DIGITS (999999999)\n\nA signed-int overflow in decNumber's D2U macro lets huge literals\nwrite attacker-controlled bytes past a stack buffer. Cap the length\nbefore calling decNumberFromString, and pre-slice long strings in\njv_dump_string_trunc so the resulting error message doesn't itself\nallocate a multi-GiB buffer.\n\nFixes CVE-2026-43894.","author":"itchyny"}
{"message":"Limit recursive object merge depth to prevent stack overflow\n\nThis fixes CVE-2026-43896.","author":"itchyny"}
{"message":"Avoid stack overflow when freeing deeply nested values","author":"itchyny"}
{"message":"Fix CI to add `artifact-metadata` permission for actions/attest (#3530)","author":"itchyny"}
- text: |
To get a single array back instead of a stream, collect the results by
wrapping the filter in square brackets:
- command: "jq '[.[] | .commit.author.name]' commits.json"
result: |
[
"dependabot[bot]",
"dependabot[bot]",
"Anna Rift",
"Thomas Klausner",
"august",
"A4-Tacks",
"Anna Rift",
"dependabot[bot]",
"ded-furby",
"WinkleMad",
"pavel kuliaka",
"Thomas Klausner",
"itchyny",
"itchyny",
"github-actions[bot]",
"dependabot[bot]",
"itchyny",
"itchyny",
"itchyny",
"itchyny",
"dependabot[bot]",
"theyoucheng",
"itchyny",
"Yu-Fu Fu",
"itchyny",
"itchyny",
"itchyny",
"itchyny",
"itchyny",
"itchyny"
]
- text: |
Because `[.[] | f]` is such a common shape, jq spells it `map(f)`. Same filter,
same array:
- command: "jq 'map(.commit.author.name)' commits.json"
result: |
[
"dependabot[bot]",
"dependabot[bot]",
"Anna Rift",
"Thomas Klausner",
"august",
"A4-Tacks",
"Anna Rift",
"dependabot[bot]",
"ded-furby",
"WinkleMad",
"pavel kuliaka",
"Thomas Klausner",
"itchyny",
"itchyny",
"github-actions[bot]",
"dependabot[bot]",
"itchyny",
"itchyny",
"itchyny",
"itchyny",
"dependabot[bot]",
"theyoucheng",
"itchyny",
"Yu-Fu Fu",
"itchyny",
"itchyny",
"itchyny",
"itchyny",
"itchyny",
"itchyny"
]
- text: |
- - -
Let's explore filters that operate on arrays. `unique` drops duplicates:
- command: "jq -r 'map(.commit.author.name) | unique[]' commits.json"
result: |
A4-Tacks
Anna Rift
Thomas Klausner
WinkleMad
Yu-Fu Fu
august
ded-furby
dependabot[bot]
github-actions[bot]
itchyny
pavel kuliaka
theyoucheng
- text: |
Note that the names came back sorted. That is not incidental: `unique` finds
duplicates by ordering the array first, and that order is what you get. To sort
on purpose there is `sort`, and `first` and `last` pick the ends off the sorted
array - between them, the stretch of time these thirty commits cover:
- command: "jq 'map(.commit.author.date) | sort | [first, last]' commits.json"
result: |
[
"2026-05-05T05:06:45Z",
"2026-09-01T06:30:46Z"
]
- text: |
`sort_by(f)` is the general form: it orders whole elements by whatever `f`
extracts. That is what you need as soon as the answer involves more than the
key you sorted on - the same two ends, now with their authors attached:
- command: "jq 'sort_by(.commit.author.date) | [first, last] | map({author: .commit.author.name, date: .commit.author.date})' commits.json"
result: |
[
{
"author": "itchyny",
"date": "2026-05-05T05:06:45Z"
},
{
"author": "dependabot[bot]",
"date": "2026-09-01T06:30:46Z"
}
]
- text: |
`sort` could not have done that. It sees only the values it is given, so the
dates would have arrived with nothing attached; `sort_by` keeps whole commits
and merely puts them in order.
- text: |
`group_by(f)` gathers the elements that agree on `f` into sub-arrays, so an
array of thirty commits becomes an array of arrays. It orders them by `f` on
the way, just as `unique` does, which is where the sorted order below
comes from. This is the usual way to count things:
- command: "jq 'group_by(.commit.author.name) | map({author: .[0].commit.author.name, commits: length})' commits.json"
result: |
[
{
"author": "A4-Tacks",
"commits": 1
},
{
"author": "Anna Rift",
"commits": 2
},
{
"author": "Thomas Klausner",
"commits": 2
},
{
"author": "WinkleMad",
"commits": 1
},
{
"author": "Yu-Fu Fu",
"commits": 1
},
{
"author": "august",
"commits": 1
},
{
"author": "ded-furby",
"commits": 1
},
{
"author": "dependabot[bot]",
"commits": 5
},
{
"author": "github-actions[bot]",
"commits": 1
},
{
"author": "itchyny",
"commits": 13
},
{
"author": "pavel kuliaka",
"commits": 1
},
{
"author": "theyoucheng",
"commits": 1
}
]
- text: |
Each group is still a full array of commit objects, so `.[0].commit.author.name`
reads the author off its first member and `length` counts the members.
`unique_by`, `min_by` and `max_by` take a filter the same way `sort_by` does,
and `add` folds an array down to a single value.
- text: |
- - -
An expression that produces *no* output for some inputs is how filtering works.
`select(condition)` emits its input unchanged when the condition is true, and
nothing at all when it is not, so putting one in the middle of a pipeline
drops the values you do not want. What it passes on is the whole value, not
just the part the condition looked at. A filter can therefore test one field
and then go on to read another - here, finding the commits dependabot made and
printing what they say:
- command: "jq -r '.[] | select(.commit.author.name == \"dependabot[bot]\") | .commit.message' commits.json"
result: |
build(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622)
build(deps): bump lxml from 6.1.1 to 6.1.2 in /docs (#3621)
build(deps): bump actions/setup-python from 6 to 7 in the official-actions group (#3595)
build(deps): bump actions/checkout from 6 to 7 in the official-actions group (#3565)
build(deps): bump lxml from 6.1.0 to 6.1.1 in /docs (#3553)
- text: |
Conditions join up with `and` and `or`. Piping into the field first lets the
path be written once, with both comparisons reading `.`. That widens the test
to catch the other bot too:
- command: "jq -c '.[] | select(.commit.author.name | . == \"dependabot[bot]\" or . == \"github-actions[bot]\") | [.commit.author.name, .commit.message]' commits.json"
result: |
["dependabot[bot]","build(deps): bump markdown from 3.10.2 to 3.10.3 in /docs (#3622)"]
["dependabot[bot]","build(deps): bump lxml from 6.1.1 to 6.1.2 in /docs (#3621)"]
["dependabot[bot]","build(deps): bump actions/setup-python from 6 to 7 in the official-actions group (#3595)"]
["github-actions[bot]","Update signatures of 1.8.2 (#3566)\n\nCo-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>"]
["dependabot[bot]","build(deps): bump actions/checkout from 6 to 7 in the official-actions group (#3565)"]
["dependabot[bot]","build(deps): bump lxml from 6.1.0 to 6.1.1 in /docs (#3553)"]
- text: |
One more commit than before, and pairing each message with its author shows
which of the two clauses caught it. Negation is the odd one out of the three:
jq has no `!`, and `not` is a filter like any other, so it takes its argument
from the left. `select` also works on any value, not just objects, so a plain
string can flow straight into the test - here, the people rather than the bots
behind these thirty commits:
- command: "jq -r 'map(.commit.author.name) | unique[] | select(endswith(\"[bot]\") | not)' commits.json"
result: |
A4-Tacks
Anna Rift
Thomas Klausner
WinkleMad
Yu-Fu Fu
august
ded-furby
itchyny
pavel kuliaka
theyoucheng
- text: |
The condition need not be a comparison either - `test` matches a regular
expression. This is the subject line of every commit that mentions a CVE:
- command: "jq -r '.[] | .commit.message | select(test(\"CVE-[0-9]{4}-[0-9]+\")) | split(\"\\n\")[0]' commits.json"
result: |
Tighten string length bounds and propagate invalid jv in implode
Fix heap-buffer-overflow in raw file loading
Guard deep structural equality and comparison recursion (#3539)
Detect circular module imports to prevent stack overflow
Reject embedded NUL bytes in module import paths
Reject numeric literals longer than DEC_MAX_DIGITS (999999999)
Limit recursive object merge depth to prevent stack overflow
- text: |
`test` looks anywhere in the string, so it finds the `Fixes CVE-...` line down
in a commit body even where the subject says nothing about it. Flags go in a
second argument: `test("fix"; "i")` ignores case.
- text: |
- - -
Everything so far has started from an array - `.[]` to open one up, then `map`,
`sort`, `select`. `.[]` and `map` work on objects too, but they see only the
values. `to_entries` turns an object into an array of key/value pairs, which is
how you reach an object's keys when they are data rather than something you
typed:
- command: "jq '.[0].commit.author | to_entries' commits.json"
result: |
[
{
"key": "name",
"value": "dependabot[bot]"
},
{
"key": "email",
"value": "49699333+dependabot[bot]@users.noreply.github.com"
},
{
"key": "date",
"value": "2026-09-01T06:30:46Z"
}
]
- text: |
`from_entries` goes the other way, building an object out of pairs. That turns
the author counts from earlier into a lookup table:
- command: "jq 'group_by(.commit.author.name) | map({key: .[0].commit.author.name, value: length}) | from_entries' commits.json"
result: |
{
"A4-Tacks": 1,
"Anna Rift": 2,
"Thomas Klausner": 2,
"WinkleMad": 1,
"Yu-Fu Fu": 1,
"august": 1,
"ded-furby": 1,
"dependabot[bot]": 5,
"github-actions[bot]": 1,
"itchyny": 13,
"pavel kuliaka": 1,
"theyoucheng": 1
}
- text: |
`with_entries(f)` is that round trip in one step - `to_entries | map(f) |
from_entries` - running `f` over each pair, so a `select` there keeps or drops
whole fields. Next to `commit`, each element of the response carries three
links to the commit, and this keeps just those by testing each key as it goes
past:
- command: "jq '.[0] | with_entries(select(.key | endswith(\"url\")))' commits.json"
result: |
{
"url": "https://api.github.com/repos/jqlang/jq/commits/9d241e277204b83c4a7ddc7d733e5c72f99ef500",
"html_url": "https://github.com/jqlang/jq/commit/9d241e277204b83c4a7ddc7d733e5c72f99ef500",
"comments_url": "https://api.github.com/repos/jqlang/jq/commits/9d241e277204b83c4a7ddc7d733e5c72f99ef500/comments"
}
- text: |
Inside `f` a pair is just an object, so `.key` and `.value` are ordinary paths.
`|=` updates a path in place, running a filter on whatever value it finds
there, so `with_entries(.key |= ascii_downcase)` would lowercase every field
name.
- text: |
Values can be built as well as pulled out. Inside a string, `\(...)` substitutes
the result of a filter, and `[a:b]` slices strings and arrays - between them
enough to turn each commit into a one-line log entry:
- command: "jq -r '.[] | \"\\(.sha[0:7]) \\(.commit.author.name)\"' commits.json"
result: |
9d241e2 dependabot[bot]
8bce8b6 dependabot[bot]
41b8edf Anna Rift
17b4118 Thomas Klausner
fbee8f4 august
8cf81cb A4-Tacks
4bb50d7 Anna Rift
603db3f dependabot[bot]
2d410d6 ded-furby
f1f39b4 WinkleMad
dbcaa9d pavel kuliaka
579e6f7 Thomas Klausner
42d4035 itchyny
3c81b62 itchyny
f0dabad github-actions[bot]
34f7186 dependabot[bot]
88e8340 itchyny
a5a29cc itchyny
46d1da3 itchyny
e987df0 itchyny
985abe5 dependabot[bot]
df924ea theyoucheng
a829f67 itchyny
7122866 Yu-Fu Fu
f58787c itchyny
9d223f1 itchyny
9761ceb itchyny
532ccea itchyny
33d7bce itchyny
7316e5c itchyny
- text: |
The pieces combine. `map(select(...))` is the ordinary way to filter an array:
`map` visits every element and `select` decides whether it survives, so the
`endswith("[bot]") | not` from before clears out dependabot and friends.
`group_by` and `sort_by` then do what they did above. jq sorts ascending, so
negating the key is how you ask for largest-first; `reverse` does the same job
for keys that cannot be negated. `@tsv` joins each pair into a tab-separated
line, giving a plain-text leaderboard of the humans:
- command: "jq -r 'map(select(.commit.author.name | endswith(\"[bot]\") | not)) | group_by(.commit.author.name) | map({author: .[0].commit.author.name, commits: length}) | sort_by(-.commits) | .[] | [.commits, .author] | @tsv' commits.json"
result: |
13 itchyny
2 Anna Rift
2 Thomas Klausner
1 A4-Tacks
1 WinkleMad
1 Yu-Fu Fu
1 august
1 ded-furby
1 pavel kuliaka
1 theyoucheng
- text: |
Seven stages, each doing one thing to the value it receives: drop the bots,
group what is left by author, count each group, put the counts in order, take
the array apart again, pair each count with its author, and join the pair into
a line. Most real jq programs are built exactly this way.
- text: |
- - -
That is the core of it: paths to reach into a document, `|` to chain
filters, `[]` and `{}` to take structures apart and put new ones back
together, and streams tying it all together. Everything else is built on
those.
There is plenty more: arithmetic, variables and conditionals; updating a
document in place; `@base64`, `@uri` and the other `@` formats; `reduce` and
`foreach` for folding over a stream; `inputs` and the rest of the
IO builtins for reading many values instead of one; and defining your own
functions on top of a large library of builtins. Go read
[the manual](../manual/) when you need it, and [download jq](../download/) if
you have not already.
-22
View File
@@ -1,22 +0,0 @@
jq(1) -- Command-line JSON processor
====================================
## DESCRIPTION
`jq` can transform JSON in various ways, by selecting, iterating,
reducing and otherwise mangling JSON documents.
This version of `jq` was built without a manual, so this manpage is a
stub. For full documentation of the `jq` language, see:
http://stedolan.github.com/jq
## BUGS
Presumably. Report them or discuss them at:
https://github.com/stedolan/jq/issues
## AUTHOR
Stephen Dolan `<mu@netsoc.tcd.ie>`
+60
View File
@@ -0,0 +1,60 @@
type: object
required:
- headline
- body
- manpage_intro
- manpage_epilogue
- sections
additionalProperties: false
properties:
headline:
type: string
body:
type: string
manpage_intro:
type: string
manpage_epilogue:
type: string
sections:
type: array
items:
type: object
required:
- title
additionalProperties: false
properties:
title:
type: string
body:
type: string
entries:
type: array
items:
type: object
required:
- title
- body
additionalProperties: false
properties:
title:
type: string
body:
type: string
examples:
type: array
items:
type: object
required:
- program
- input
- output
additionalProperties: false
properties:
program:
type: string
input:
type: string
output:
type: array
items:
type: string
+2 -2
View File
@@ -12,7 +12,7 @@ FileETag All
</IfModule>
</IfModule>
# Cache, aggressively
# Cache, aggressively
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 10 days"
@@ -25,4 +25,4 @@ FileETag All
# Mime-types
AddType application/vnd.ms-fontobject .eot
AddType font/ttf .ttf
AddType font/otf .otf
AddType font/otf .otf
+1
View File
@@ -0,0 +1 @@
jqlang.org
File diff suppressed because it is too large. Load diff
@@ -1,9 +0,0 @@
/*!
* Bootstrap Responsive v2.1.1
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world @twitter by @mdo and @fat.
*/.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}.visible-desktop{display:inherit!important}@media(min-width:768px) and (max-width:979px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}}@media(max-width:767px){.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}.visible-phone{display:inherit!important}.hidden-phone{display:none!important}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:30px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.564102564102564%;*margin-left:2.5109110747408616%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145299145%;*width:91.39979996362975%}.row-fluid .span10{width:82.90598290598291%;*width:82.8527914166212%}.row-fluid .span9{width:74.35897435897436%;*width:74.30578286961266%}.row-fluid .span8{width:65.81196581196582%;*width:65.75877432260411%}.row-fluid .span7{width:57.26495726495726%;*width:57.21176577559556%}.row-fluid .span6{width:48.717948717948715%;*width:48.664757228587014%}.row-fluid .span5{width:40.17094017094017%;*width:40.11774868157847%}.row-fluid .span4{width:31.623931623931625%;*width:31.570740134569924%}.row-fluid .span3{width:23.076923076923077%;*width:23.023731587561375%}.row-fluid .span2{width:14.52991452991453%;*width:14.476723040552828%}.row-fluid .span1{width:5.982905982905983%;*width:5.929714493544281%}.row-fluid .offset12{margin-left:105.12820512820512%;*margin-left:105.02182214948171%}.row-fluid .offset12:first-child{margin-left:102.56410256410257%;*margin-left:102.45771958537915%}.row-fluid .offset11{margin-left:96.58119658119658%;*margin-left:96.47481360247316%}.row-fluid .offset11:first-child{margin-left:94.01709401709402%;*margin-left:93.91071103837061%}.row-fluid .offset10{margin-left:88.03418803418803%;*margin-left:87.92780505546462%}.row-fluid .offset10:first-child{margin-left:85.47008547008548%;*margin-left:85.36370249136206%}.row-fluid .offset9{margin-left:79.48717948717949%;*margin-left:79.38079650845607%}.row-fluid .offset9:first-child{margin-left:76.92307692307693%;*margin-left:76.81669394435352%}.row-fluid .offset8{margin-left:70.94017094017094%;*margin-left:70.83378796144753%}.row-fluid .offset8:first-child{margin-left:68.37606837606839%;*margin-left:68.26968539734497%}.row-fluid .offset7{margin-left:62.393162393162385%;*margin-left:62.28677941443899%}.row-fluid .offset7:first-child{margin-left:59.82905982905982%;*margin-left:59.72267685033642%}.row-fluid .offset6{margin-left:53.84615384615384%;*margin-left:53.739770867430444%}.row-fluid .offset6:first-child{margin-left:51.28205128205128%;*margin-left:51.175668303327875%}.row-fluid .offset5{margin-left:45.299145299145295%;*margin-left:45.1927623204219%}.row-fluid .offset5:first-child{margin-left:42.73504273504273%;*margin-left:42.62865975631933%}.row-fluid .offset4{margin-left:36.75213675213675%;*margin-left:36.645753773413354%}.row-fluid .offset4:first-child{margin-left:34.18803418803419%;*margin-left:34.081651209310785%}.row-fluid .offset3{margin-left:28.205128205128204%;*margin-left:28.0987452264048%}.row-fluid .offset3:first-child{margin-left:25.641025641025642%;*margin-left:25.53464266230224%}.row-fluid .offset2{margin-left:19.65811965811966%;*margin-left:19.551736679396257%}.row-fluid .offset2:first-child{margin-left:17.094017094017094%;*maLine truncated
File diff suppressed because it is too large. Load diff
-9
View File
@@ -1,9 +0,0 @@
/*!
* Bootstrap v2.1.1
*
* Copyright 2012 Twitter, Inc
* Licensed under the Apache License v2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Designed and built with all the love in the world @twitter by @mdo and @fat.
*/article,aside,details,figcaption,figure,footer,header,hgroup,nav,section{display:block}audio,canvas,video{display:inline-block;*display:inline;*zoom:1}audio:not([controls]){display:none}html{font-size:100%;-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%}a:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}a:hover,a:active{outline:0}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{width:auto\9;height:auto;max-width:100%;vertical-align:middle;border:0;-ms-interpolation-mode:bicubic}#map_canvas img{max-width:none}button,input,select,textarea{margin:0;font-size:100%;vertical-align:middle}button,input{*overflow:visible;line-height:normal}button::-moz-focus-inner,input::-moz-focus-inner{padding:0;border:0}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;-webkit-appearance:button}input[type="search"]{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;-webkit-appearance:textfield}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button{-webkit-appearance:none}textarea{overflow:auto;vertical-align:top}.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;line-height:0;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:30px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}body{margin:0;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;line-height:20px;color:#333;background-color:#fff}a{color:#08c;text-decoration:none}a:hover{color:#005580;text-decoration:underline}.img-rounded{-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.img-polaroid{padding:4px;background-color:#fff;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 3px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 3px rgba(0,0,0,0.1);box-shadow:0 1px 3px rgba(0,0,0,0.1)}.img-circle{-webkit-border-radius:500px;-moz-border-radius:500px;border-radius:500px}.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;line-height:0;content:""}.row:after{clear:both}[class*="span"]{float:left;min-height:1px;margin-left:20px}.container,.navbar-static-top .container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:940px}.span12{width:940px}.span11{width:860px}.span10{width:780px}.span9{width:700px}.span8{width:620px}.span7{width:540px}.span6{width:460px}.span5{width:380px}.span4{width:300px}.span3{width:220px}.span2{width:140px}.span1{width:60px}.offset12{margin-left:980px}.offset11{margin-left:900px}.offset10{margin-left:820px}.offset9{margin-left:740px}.offset8{margin-left:660px}.offset7{margin-left:580px}.offset6{margin-left:500px}.offset5{margin-left:420px}.offset4{margin-left:340px}.offset3{margin-left:260px}.offset2{margin-left:180px}.offset1{margin-left:100px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;line-height:0;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:30px;margin-left:2.127659574468085%;*margin-left:2.074468085106383%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.48936170212765%;*width:91.43617021276594%}.row-fluid .span10{width:82.97872340425532%;*width:82.92553191489361%}.row-fluid .span9{width:74.46808510638297%;*width:74.41489361702126%}.row-fluid .span8{width:65.95744680851064%;*width:65.90425531914893%}.row-fluid .span7{width:57.44680851063829%;*width:57.39361702127659%}.row-fluid .span6{width:48.93617021276595%;*width:48.88297872340425%}.row-fluid .span5{width:40.42553191489362%;*width:40.37234042553192%}.row-fluid .span4{width:31.914893617021278%;*width:31.861702127659576%}.row-fluid .span3{width:23.404255319148934%;*width:23.351063829787233%}.row-fluid .span2{width:14.893617021276595%;*width:14.840425531914894%}.row-fluid .span1{width:6.382978723404255%;*width:6.329787234042553%}.row-fluid .offset12{margin-left:104.25531914893617%;*margin-left:104.14893617021275%}.row-fluid .offset12:first-child{margin-left:102.12765957446808%;*margin-left:102.02127659574467%}.row-fluid .offset11{margin-left:95.74468085106382%;*margin-left:95.6382978723404%}.row-fluid .offset11:first-child{margin-left:93.61702127659574%;*margin-left:93.51063829787232%}.row-fluid .offset10{margin-left:87.23404255319149%;*margin-left:87.12765957446807%}.row-fluid .offset10:first-child{margin-left:85.1063829787234%;*margin-left:84.99999999999999%}.row-fluid .offset9{margin-left:78.72340425531914%;*margin-left:78.61702127659572%}.row-fluid .offset9:first-child{margin-left:76.59574468085106%;*margin-left:76.48936170212764%}.row-fluiLine truncated
Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

File diff suppressed because it is too large. Load diff
-6
View File
@@ -1,6 +0,0 @@
/*!
* Bootstrap.js by @fat & @mdo
* Copyright 2012 Twitter, Inc.
* http://www.apache.org/licenses/LICENSE-2.0.txt
*/
!function(e){e(function(){"use strict";e.support.transition=function(){var e=function(){var e=document.createElement("bootstrap"),t={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"},n;for(n in t)if(e.style[n]!==undefined)return t[n]}();return e&&{end:e}}()})}(window.jQuery),!function(e){"use strict";var t='[data-dismiss="alert"]',n=function(n){e(n).on("click",t,this.close)};n.prototype.close=function(t){function s(){i.trigger("closed").remove()}var n=e(this),r=n.attr("data-target"),i;r||(r=n.attr("href"),r=r&&r.replace(/.*(?=#[^\s]*$)/,"")),i=e(r),t&&t.preventDefault(),i.length||(i=n.hasClass("alert")?n:n.parent()),i.trigger(t=e.Event("close"));if(t.isDefaultPrevented())return;i.removeClass("in"),e.support.transition&&i.hasClass("fade")?i.on(e.support.transition.end,s):s()},e.fn.alert=function(t){return this.each(function(){var r=e(this),i=r.data("alert");i||r.data("alert",i=new n(this)),typeof t=="string"&&i[t].call(r)})},e.fn.alert.Constructor=n,e(function(){e("body").on("click.alert.data-api",t,n.prototype.close)})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.button.defaults,n)};t.prototype.setState=function(e){var t="disabled",n=this.$element,r=n.data(),i=n.is("input")?"val":"html";e+="Text",r.resetText||n.data("resetText",n[i]()),n[i](r[e]||this.options[e]),setTimeout(function(){e=="loadingText"?n.addClass(t).attr(t,t):n.removeClass(t).removeAttr(t)},0)},t.prototype.toggle=function(){var e=this.$element.closest('[data-toggle="buttons-radio"]');e&&e.find(".active").removeClass("active"),this.$element.toggleClass("active")},e.fn.button=function(n){return this.each(function(){var r=e(this),i=r.data("button"),s=typeof n=="object"&&n;i||r.data("button",i=new t(this,s)),n=="toggle"?i.toggle():n&&i.setState(n)})},e.fn.button.defaults={loadingText:"loading..."},e.fn.button.Constructor=t,e(function(){e("body").on("click.button.data-api","[data-toggle^=button]",function(t){var n=e(t.target);n.hasClass("btn")||(n=n.closest(".btn")),n.button("toggle")})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=n,this.options.slide&&this.slide(this.options.slide),this.options.pause=="hover"&&this.$element.on("mouseenter",e.proxy(this.pause,this)).on("mouseleave",e.proxy(this.cycle,this))};t.prototype={cycle:function(t){return t||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval(e.proxy(this.next,this),this.options.interval)),this},to:function(t){var n=this.$element.find(".item.active"),r=n.parent().children(),i=r.index(n),s=this;if(t>r.length-1||t<0)return;return this.sliding?this.$element.one("slid",function(){s.to(t)}):i==t?this.pause().cycle():this.slide(t>i?"next":"prev",e(r[t]))},pause:function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&e.support.transition.end&&(this.$element.trigger(e.support.transition.end),this.cycle()),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(t,n){var r=this.$element.find(".item.active"),i=n||r[t](),s=this.interval,o=t=="next"?"left":"right",u=t=="next"?"first":"last",a=this,f=e.Event("slide",{relatedTarget:i[0]});this.sliding=!0,s&&this.pause(),i=i.length?i:this.$element.find(".item")[u]();if(i.hasClass("active"))return;if(e.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(f);if(f.isDefaultPrevented())return;i.addClass(t),i[0].offsetWidth,r.addClass(o),i.addClass(o),this.$element.one(e.support.transition.end,function(){i.removeClass([t,o].join(" ")).addClass("active"),r.removeClass(["active",o].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger("slid")},0)})}else{this.$element.trigger(f);if(f.isDefaultPrevented())return;r.removeClass("active"),i.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return s&&this.cycle(),this}},e.fn.carousel=function(n){return this.each(function(){var r=e(this),i=r.data("carousel"),s=e.extend({},e.fn.carousel.defaults,typeof n=="object"&&n),o=typeof n=="string"?n:s.slide;i||r.data("carousel",i=new t(this,s)),typeof n=="number"?i.to(n):o?i[o]():s.interval&&i.cycle()})},e.fn.carousel.defaults={interval:5e3,pause:"hover"},e.fn.carousel.Constructor=t,e(function(){e("body").on("click.carousel.data-api","[data-slide]",function(t){var n=e(this),r,i=e(n.attr("data-target")||(r=n.attr("href"))&&r.replace(/.*(?=#[^\s]+$)/,"")),s=!i.data("modal")&&e.extend({},i.data(),n.data());i.carousel(s),t.preventDefault()})})}(window.jQuery),!function(e){"use strict";var t=function(t,n){this.$element=e(t),this.options=e.extend({},e.fn.collapse.defaults,n),this.options.parent&&(this.$parent=e(this.options.parent)),this.options.toggle&&this.toggle()};t.prototype={constructor:t,dimension:function(){var e=this.$element.hLine truncated
-99
View File
@@ -1,99 +0,0 @@
@charset "utf-8";
body {
padding-top: 60px;
}
footer {
background-color: #F5F5F5;
padding: 40px 0;
height: 100px;
margin-top: 40px;
color: #999999;
}
section {
padding-top: 30px;
}
.manual-example {
border-top: 1px solid #E5E5E5;
}
.manual-example td {
white-space: pre-wrap;
font-family: Monaco, Menlo, Consolas, "Courier New", monospace;
}
.manual-example td.jqprogram {
font-weight: bold;
}
.manual-example th {
text-align: right;
padding-right: 10px;
}
.tutorial-example {
position: relative;
margin-bottom: 10px;
}
.tutorial-example pre {
margin-bottom: 0px;
}
.tutorial-example a {
position: absolute;
top: 0px;
right: 0px;
padding: 15px 8px;
color: #777777;
font-weight: bold;
line-height: 10px;
font-size: 12px;
border-left: 1px solid #DDDDDD;
bottom: 0;
display: block;
}
#blurb {
padding-top: 40px;
padding-right: 50px;
}
#blurb p {
font-size: 20pt;
}
#blurb .btn-group {
margin-top: 20px;
}
#multiblurb {
line-height: 1.7;
text-align: center;
font-size: 12pt;
}
#multiblurb code {
border: 0;
font-size: 12pt;
}
h3 code {
border: 0;
font-size: 20px;
}
footer {
text-align: center;
}
#news {
font-size: 12pt;
.date {
font-style: italic;
}
}
+116
View File
@@ -0,0 +1,116 @@
main {
padding: 1rem;
& * {
scroll-margin-top: 4rem;
}
@media print {
width: 100%!important;
--bs-code-color: --bs-body-color;
}
}
header {
z-index: 1050!important; /* higher than #contents */
}
section[id] {
display: flow-root;
> :first-child {
.icon-link {
opacity: 0;
&:focus {
opacity: .8;
}
}
&:hover .icon-link {
opacity: 1;
}
}
}
.offcanvas[aria-modal=true] .nav-link {
padding: .7rem;
}
.offcanvas-md {
--bs-offcanvas-width: auto;
}
ul {
list-style: none;
padding-left: 1rem;
}
details {
margin-bottom: 1rem;
padding-left: 1rem;
& summary {
cursor: pointer;
}
& ul {
padding-left: 0;
}
}
pre {
margin: 0 .5rem 1rem;
padding: .5rem 1rem;
background-color: var(--bs-secondary-bg-subtle);
border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
}
button {
&[aria-expanded=false] {
.bi-chevron-down, .hide-result-text {
display: none;
}
}
&[aria-expanded=true] {
.bi-chevron-right, .show-result-text {
display: none;
}
}
}
mark {
padding: 0;
}
.container-searchbox {
position: relative;
& input:focus ~ kbd {
display: none;
}
& ul {
position: absolute;
width: 100%;
top: 100%;
padding: 0;
background-color: var(--bs-body-bg);
border: var(--bs-border-width) var(--bs-border-style) var(--bs-border-color);
}
& li {
padding: .3em .6em;
white-space: nowrap;
overflow-x: hidden;
&[aria-selected=true] {
background-color: var(--bs-secondary-bg);
}
&:hover {
cursor: pointer;
background-color: var(--bs-secondary-bg-subtle);
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

+1
View File
@@ -0,0 +1 @@
<svg width="48" height="48" version="1.0" viewBox="0 0 48 48" xmlns="http://www.w3.org/2000/svg"><style>@media(prefers-color-scheme:dark){g[fill]{filter:invert(1)}}</style><g transform="matrix(.011 0 0 .011 1.94 12)"><g fill="#444"><circle cx="220" cy="1570" r="190"/><path d="m1330 312c-30 41-698 1492-710 1528s25 66 100 101c77 36 102 34 124 3s701-1477 716-1525c15-47-20-73-84-104s-116-44-146-3z"/></g><g fill="#111"><circle cx="2410" cy="200" r="190"/><path d="m1830 655c0 129 0 130 70 130h360v423c0 246-5 474-10 506-19 112-88 176-190 176-59 0-120-27-147-66-51-73-65-84-99-84-31 0-40 8-104 93-84 111-86 129-32 189 227 252 692 187 836-118 53-112 56-153 56-795v-514c0-64-30-100-100-100h-490c-149 0-150 0-150 160zM2867 1233c30 302 250 499 438 527 144 19 244 0 375-90v410c0 81 0 100 150 100 136 0 150-20 150-150v-1420c0-99-19-100-150-100s-139 15-139 82c-103-89-351-149-523-49s-342 278-301 690zm803-107c0 292-105 356-237 356-178 0-249-147-273-296-27-168 25-420 262-420 171 0 248 89 248 360z"/></g></g></svg>

After

Width:  |  Height:  |  Size: 1006 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.0 KiB

+1
View File
@@ -0,0 +1 @@
<svg width="400" height="220" version="1.0" viewBox="0 0 400 220" xmlns="http://www.w3.org/2000/svg"><style>@media (prefers-color-scheme:dark){g[fill]{filter:invert(1);stroke:none}}</style><g transform="scale(.1)" stroke="#fff" stroke-width="10"><g fill="#444"><circle cx="220" cy="1570" r="190"/><path d="m1330 312c-30 41-698 1492-710 1528s25 66 100 101c77 36 102 34 124 3s701-1477 716-1525c15-47-20-73-84-104s-116-44-146-3z"/></g><g fill="#111"><circle cx="2410" cy="200" r="190"/><path d="m1830 655c0 129 0 130 70 130h360v423c0 246-5 474-10 506-19 112-88 176-190 176-59 0-120-27-147-66-51-73-65-84-99-84-31 0-40 8-104 93-84 111-86 129-32 189 227 252 692 187 836-118 53-112 56-153 56-795v-514c0-64-30-100-100-100h-490c-149 0-150 0-150 160zM2867 1233c30 302 250 499 438 527 144 19 244 0 375-90v410c0 81 0 100 150 100 136 0 150-20 150-150v-1420c0-99-19-100-150-100s-139 15-139 82c-103-89-351-149-523-49s-342 278-301 690zm803-107c0 292-105 356-237 356-178 0-249-147-273-296-27-168 25-420 262-420 171 0 248 89 248 360z"/></g></g></svg>

After

Width:  |  Height:  |  Size: 1.0 KiB

+34
View File
@@ -0,0 +1,34 @@
(() => {
const searchInput = document.querySelector('input#searchbox');
const sectionIDs = JSON.parse(document.querySelector('#section-ids').innerText);
const sanitize = (string) => string.replaceAll('<', '&lt;').replaceAll('>', '&gt;');
new autoComplete({
selector: `#${searchInput.id}`,
wrapper: false,
data: {
src: Object.keys(sectionIDs),
filter: (list) => list.sort((x, y) =>
x.match.indexOf('<') - y.match.indexOf('<') || x.value.length - y.value.length),
},
searchEngine: (query, value) => {
const index = value.toLowerCase().indexOf(query.toLowerCase());
if (index >= 0) {
return sanitize(value.substring(0, index)) +
`<mark>${sanitize(value.substring(index, index + query.length))}</mark>` +
sanitize(value.substring(index + query.length));
}
},
});
searchInput.addEventListener('selection', (event) => {
event.target.value = event.detail.selection.value;
location.hash = `#${sectionIDs[event.detail.selection.value]}`;
});
document.addEventListener('keydown', (event) => {
if (event.code === 'Slash' && !event.altKey && !event.ctrlKey && !event.metaKey
&& !event.shiftKey && !/^(INPUT|TEXTAREA)$/.test(event.target.nodeName)) {
searchInput.focus();
searchInput.select();
event.preventDefault();
}
});
})();
-18
View File
@@ -1,18 +0,0 @@
# The key value pairs found below are available within the templates.
:url: http://stedolan.github.io/jq
# This line is modified by the Makefile. To change the version number,
# edit the Autoconf version number at the top of configure.ac
jq_version: "1.3"
root: '/jq'
footer: |
This website is made with [Bonsai](http://www.tinytree.info) and
[Twitter Bootstrap](http://twitter.github.com/bootstrap/), themed
with [Bootswatch](http://bootswatch.com).
jq is licensed under the MIT license (code) and the
[CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/) license
(docs).
+31
View File
@@ -0,0 +1,31 @@
<!DOCTYPE html>
<html lang="en">
{% include "shared/_head.html.j2" %}
<body>
{% include "shared/_navbar.html.j2" %}
<main id="main" class="container-lg">
<h1>{{ headline }}</h1>
{%- for item in body %}
{%- if item.text %}
{{ item.text | markdownify }}
{%- endif %}
{%- if item.command %}
{%- set resultID = unique_id() %}
<div class="tutorial-example mb-3">
<div class="d-flex accordion-heading me-2">
<pre class="flex-grow-1 me-0 mb-0" tabindex="0">{{ item.command }}</pre>
<button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-secondary-subtle link-body-emphasis flex-shrink-0 d-flex align-items-center border border-start-0 d-print-none"
data-bs-toggle="collapse" data-bs-target="#result{{ resultID }}" aria-expanded="false" aria-controls="result{{ resultID }}"><span class="show-result-text">Show result</span><span class="hide-result-text">Hide result</span></button>
</div>
<pre id="result{{ resultID }}" class="accordion-body collapse p-3 border-top-0 d-print-block" tabindex="0">{{ item.result }}</pre>
</div>
{%- endif %}
{%- endfor %}
</main>
{% include "shared/_footer.html.j2" %}
</body>
</html>
-34
View File
@@ -1,34 +0,0 @@
<!DOCTYPE html>
<html lang="en">
{% include "shared/head" %}
<body id="{{slug}}">
{% include "shared/header" %}
<div class="container">
<div class="row">
<h1>{{headline}}</h1>
{% for item in body %}
{% if item.text %}
{{ item.text | replace: '$JQ_VERSION', jq_version | markdownify }}
{% endif %}
{% if item.command %}
{% capture resultID %}{{ "result" | unique}}{% endcapture %}
<div class="tutorial-example">
<div class="accordion-heading">
<pre>{{item.command}}</pre>
<a data-toggle="collapse" href="#{{resultID}}">Show result</a>
</div>
<div id="{{resultID}}" class="accordion-body collapse"><pre>{{item.result}}</pre></div>
</div>
{% endif %}
{% endfor %}
</div>
</div>
{% include "shared/footer" %}
</body>
</html>
+58
View File
@@ -0,0 +1,58 @@
<!DOCTYPE html>
<html lang="en">
{% include "shared/_head.html.j2" %}
<body>
{% include "shared/_navbar.html.j2" %}
<main id="main" class="container-lg">
<div class="row">
<div class="col-md-6 text-center p-3">
<h1><img src="/jq.svg" class="img-fluid" alt="jq" width="400" height="220"></h1>
</div>
<div class="col-md-6 d-flex flex-column justify-content-center text-center align-items-center">
<h2 class="px-1" style="width:16em">{{ blurb }}</h2>
<div class="btn-group d-print-none" role="group">
<button type="button" class="btn btn-primary dropdown-toggle text-nowrap" data-bs-toggle="dropdown" aria-expanded="false">
Download jq 1.8.2
<span class="caret"></span>
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-linux-amd64" aria-label="Link to download executable: Linux (AMD64)"><span class="bi bi-download me-2" aria-hidden="true"></span>Linux (AMD64)</a></li>
<li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-linux-arm64" aria-label="Link to download executable: Linux (ARM64)"><span class="bi bi-download me-2" aria-hidden="true"></span>Linux (ARM64)</a></li>
<li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-macos-arm64" aria-label="Link to download executable: macOS (Apple Silicon)"><span class="bi bi-download me-2" aria-hidden="true"></span>macOS (Apple Silicon)</a></li>
<li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-macos-amd64" aria-label="Link to download executable: macOS (Intel Mac)"><span class="bi bi-download me-2" aria-hidden="true"></span>macOS (Intel Mac)</a></li>
<li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.8.2/jq-windows-amd64.exe" aria-label="Link to download executable: Windows (AMD64)"><span class="bi bi-download me-2" aria-hidden="true"></span>Windows (AMD64)</a></li>
<li><a class="dropdown-item" href="/download/">Other platforms, older versions, and source</a></li>
</ul>
<a class="btn btn-primary text-nowrap" href="https://play.jqlang.org" rel="noopener">
Try online!
</a>
</div>
</div>
</div>
<div class="row my-3">
<div class="col-md-4">{{ body1 | markdownify }}</div>
<div class="col-md-4">{{ body2 | markdownify }}</div>
<div class="col-md-4">{{ body3 | markdownify }}</div>
</div>
<div class="text-center my-3">
{{ tail | markdownify }}
</div>
<h2>News</h2>
<ul>
{%- for item in news %}
<li>
<span class="fst-italic">{{ item.date }}</span>
{{ item.body | markdownify }}
</li>
{%- endfor %}
</ul>
</main>
{% include "shared/_footer.html.j2" %}
</body>
</html>
-51
View File
@@ -1,51 +0,0 @@
<!DOCTYPE html>
<html lang="en">
{% include "shared/head" %}
<body id="{{slug}}">
{% include "shared/header" %}
<div class="container">
<div class="row">
<div class="hero-unit">
<img src="{{root}}/jq.png" style="width: 400px; height: 220px; float: left; margin-right: 60px">
<div id="blurb">
{{blurb | markdownify}}
<div class="btn-group" style="float:right">
<a class="btn btn-primary dropdown-toggle" data-toggle="dropdown" href="#">
Download jq-{{jq_version}}
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li><a href="{{root}}/download/linux64/jq">Linux (64-bit)</a></li>
<li><a href="{{root}}/download/osx64/jq">OS X (64-bit)</a></li>
<li><a href="{{root}}/download/">Other platforms and source</a></li>
</ul>
</div>
</div>
<div style="clear:both;"></div>
</div>
</div>
<div class="row" id="multiblurb">
<div class="span4">{{body1 | markdownify}}</div>
<div class="span4">{{body2 | markdownify}}</div>
<div class="span4">{{body3 | markdownify}}</div>
</div>
<div class="row" style="text-align:center; margin-top: 30px">
{{tail | markdownify}}
</div>
<div class="row">
<h2>News</h2>
<div id="news">
<ul>
{% for item in news %}
<li><span class="date">{{ item.date | date: '%m %B %Y' }}</span>{{item.body | markdownify}}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
{% include "shared/footer" %}
</body>
</html>
+121
View File
@@ -0,0 +1,121 @@
<!DOCTYPE html>
<html lang="en">
{% include "shared/_head.html.j2" %}
<body>
{% include "shared/_navbar.html.j2" %}
<div class="container-lg row align-items-start mx-auto p-3">
<button type="button" class="d-md-none w-auto position-fixed bottom-0 end-0 p-2 m-3 bg-body-secondary border-0 text-body d-print-none"
data-bs-toggle="offcanvas" data-bs-target="#contents" aria-controls="contents" aria-expanded="false" aria-label="Toggle table of contents">
<span class="bi bi-list" aria-hidden="true"></span>
</button>
<nav id="contents" class="col-md-3 sticky-md-top p-3 overflow-y-auto offcanvas-md offcanvas-end d-print-none" style="top:4.5rem; height:calc(100dvh - 5.5rem);" aria-label="Table of contents">
<div class="d-flex justify-content-between">
<h4>Contents</h4>
<button type="button" class="btn-close d-md-none" data-bs-dismiss="offcanvas" data-bs-target="#contents" aria-label="Close table of contents"></button>
</div>
<ul class="offcanvas-md-body nav nav-pills flex-column">
{%- for section in sections %}
<li class="nav-item" data-bs-dismiss="offcanvas" data-bs-target="#contents">
<a class="nav-link" href="#{{ section.title | section_id }}">{{ section.title }}</a>
</li>
{%- endfor %}
</ul>
</nav>
{%- set section_ids = {} %}
{%- macro check_section_id(id) -%}
{%- if section_ids.__contains__(id) %}
{{- raise('Duplicate section id: ' ~ id) }}
{%- endif %}
{%- set _ = section_ids.__setitem__(id, true) %}
{%- endmacro %}
<main id="main" class="col-md-9" data-bs-spy="scroll" data-bs-target="#contents" data-bs-threshold="0,1" data-bs-root-margin="-30% 0% -70%">
<h1>{{ headline }}</h1>
<p>
<em>
For other versions, see
<a href="/manual/v1.8/">1.8</a>,
<a href="/manual/v1.7/">1.7</a>,
<a href="/manual/v1.6/">1.6</a>,
<a href="/manual/v1.5/">1.5</a>,
<a href="/manual/v1.4/">1.4</a>,
<a href="/manual/v1.3/">1.3</a> or
<a href="/manual/dev/">development version</a>.
</em>
</p>
{{ body | markdownify }}
{%- for section in sections %}
<section id="{{ section.title | section_id }}">{{ check_section_id(section.title | section_id) }}
<h2>{{ section.title }} <a href="#{{ section.title | section_id }}" class="icon-link" aria-label="Link to this section: {{ section.title }}"><span class="bi bi-link-45deg" aria-hidden="true"></span></a></h2>
{{ section.body | markdownify if section.body }}
{%- for entry in section.entries %}
<section id="{{ entry.title | entry_id }}">{{ check_section_id(entry.title | entry_id) }}
<h3>
{{ entry.title | markdownify | no_paragraph }}
<a href="#{{ entry.title | entry_id }}" class="icon-link" aria-label="Link to this section: {{ entry.title }}"><span class="bi bi-link-45deg" aria-hidden="true"></span></a>
</h3>
{{ entry.body | markdownify }}
{%- if entry.examples %}
<div class="pb-3">
{%- set exampleID = unique_id() %}
<button type="button" class="btn btn-sm btn-secondary text-body-secondary bg-transparent link-body-emphasis border-0" data-bs-toggle="collapse" data-bs-target="#example{{ exampleID }}" aria-expanded="false" aria-controls="example{{ exampleID }}">
<span class="me-1 d-print-none" aria-hidden="true"><span class="bi bi-chevron-right"></span><span class="bi bi-chevron-down"></span></span>Example{% if entry.examples | length > 1 %}s{% endif %}
</button>
<div id="example{{ exampleID }}" class="collapse mx-3 small d-print-block">
{%- for example in entry.examples %}
<table class="table table-borderless table-sm w-auto">
<tr>
<th class="pe-3">Command</th>
<td class="font-monospace">jq '{{ example.program }}'</td>
</tr>
<tr>
<th>Input</th>
<td class="font-monospace">{{ example.input }}</td>
</tr>
{%- if not example.output[0] %}
<tr>
<th>Output</th>
<td class="fst-italic">none</td>
</tr>
{%- endif %}
{%- for output in example.output %}
<tr>
<th>{% if loop.first %}Output{% endif %}</th>
<td class="font-monospace">{{ output }}</td>
</tr>
{%- endfor %}
<tr class="d-print-none">
<th><a href="https://play.jqlang.org/?q={{ example.program | urlencode }}&j={{ example.input | urlencode }}" class="btn btn-outline-primary btn-sm" target="_blank" rel="noopener">Run<span class="bi bi-box-arrow-up-right ms-2" aria-hidden="true"></span></a></th>
<td></td>
</tr>
</table>
{%- endfor %}
</div>
</div>
{%- endif %}
</section>
{%- endfor %}
</section>
{%- endfor %}
</main>
</div>
{% include "shared/_footer.html.j2" %}
<script src="https://cdn.jsdelivr.net/npm/@tarekraafat/autocomplete.js@10.2.7/dist/autoComplete.min.js"
integrity="sha384-xbzjoN6H5XHmAqoSSR42hZVRninPGx85y+XZQGlWxVu2y91lTmr/oD80i5cjeUBv" crossorigin="anonymous"></script>
<script id="section-ids" type="application/json">
{
{%- for section in sections %}
{%- for entry in section.entries %}
{{ entry.title | search_id | tojson }}: {{ entry.title | entry_id | tojson }},
{%- endfor %}
{{ section.title | search_id | tojson }}: {{ section.title | section_id | tojson }}{{ "," if not loop.last }}
{%- endfor %}
}
</script>
<script src="/js/manual-search.js"></script>
</body>
</html>
-110
View File
@@ -1,110 +0,0 @@
<!DOCTYPE html>
<html lang="en">
{% include "shared/head" %}
<body id="{{slug}}" data-spy="scroll" data-target="#navcolumn" data-offset="100">
{% include "shared/header" %}
<div class="container">
<div class="row">
<div class="span3" id="navcolumn">
<div class="affix">
<h4>Contents</h4>
<ul class="nav nav-pills nav-stacked">
{% for section in sections %}
<li {% if forloop.first %} class="active" {% endif %}>
<a href="#{{section.title | sanitize}}">{{section.title}}</a>
</li>
{% endfor %}
</ul>
<form class="form-search">
<script type="text/javascript">
var section_map = {
{% for section in sections %}
{% for entry in section.entries %}
{{entry.title | json}} : {{entry.title | sanitize | json}},
{% endfor %}
{{section.title | json}} : {{section.title | sanitize | json}}
{% unless forloop.last %},{% endunless %}
{% endfor %}
};
var section_names = $.map(section_map, function(v,k){return k});
$(function(){
$('#searchbox').typeahead({source: section_names})
$('#searchbox').change(function() {
if ($(this).val() in section_map) {
location.hash = '#' + section_map[$(this).val()];
}
});
});
</script>
<input type="text"
class="input-medium search-query"
placeholder="Search"
autocomplete="off"
id="searchbox">
</form>
</div>
</div>
<div class="span9">
<h1>{{headline}}</h1>
{{ body | markdownify }}
{% for section in sections %}
<section id="{{section.title | sanitize}}">
<h2>{{section.title}}</h2>
{{section.body | markdownify}}
{% for entry in section.entries %}
<section id="{{entry.title | sanitize}}">
<h3>
{{entry.title | markdownify}}
{% if entry.subtitle %}<small>{{entry.subtitle}}</small>{% endif %}
</h3>
{{entry.body | markdownify}}
{% if entry.examples %}
<div>
{% capture exampleID %}{{ "" | unique }}{% endcapture %}
<a data-toggle="collapse" href="#example{{exampleID}}">
<i class="icon-chevron-right"></i>
{% if entry.examples[1] %}Examples{%else%}Example{%endif%}
</a>
<div id="example{{exampleID}}" class="collapse">
{% for example in entry.examples %}
<table class="manual-example">
<tr><th></th><td class="jqprogram">jq '{{example.program}}'</td></tr>
<tr><th>Input</th><td>{{example.input}}</td></tr>
{% unless example.output[0] %}
<tr>
<th>Output</th>
<td><i>none</i></td>
</tr>
{% endunless %}
{% for output in example.output %}
<tr>
{% if forloop.index == 1 %}
<th>Output</th>
{% else %}
<th></th>
{% endif %}
<td>{{output}}</td>
</tr>
{% endfor %}
</table>
{% endfor %}
</div>
</div>
{% endif %}
</section>
{% endfor %}
</section>
{% endfor %}
</div>
</div>
</div>
{% include "shared/footer" %}
</body>
</html>
+14
View File
@@ -0,0 +1,14 @@
<footer class="bd-footer bg-body-tertiary">
<div class="py-3 text-center">
<p>
This website is made with <a href="https://getbootstrap.com" target="_blank" rel="noopener">Bootstrap</a>,
themed with <a href="https://bootswatch.com" target="_blank" rel="noopener">Bootswatch</a>.
</p>
<p>
jq is licensed under the MIT license (code) and the
<a href="https://creativecommons.org/licenses/by/3.0/" target="_blank" rel="noopener">CC-BY-3.0</a> license (docs).
</p>
</div>
</footer>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.1/dist/js/bootstrap.bundle.min.js"
integrity="sha384-HwwvtgBNo3bZJJLYd8oVXjrBZt8cqVSpeBNS5n7C8IVInixGAoxmnlMuBnhbgrkm" crossorigin="anonymous"></script>
-5
View File
@@ -1,5 +0,0 @@
<footer>
<div class="container">
{{ footer | markdownify }}
</div>
</footer>
+28
View File
@@ -0,0 +1,28 @@
<head>
<meta charset="utf-8">
<title>{{ headline }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta property="og:title" content="{{ headline }}">
<meta property="og:description" content="jq is a lightweight and flexible command-line JSON processor">
<meta property="og:type" content="website">
<meta property="og:image" content="{{ url }}/icon.png">
<meta property="og:url" content="{{ url }}/{{ permalink }}">
<link rel="icon" href="/icon.svg" type="image/svg+xml">
<link rel="apple-touch-icon" href="/icon.png" type="image/png">
<link rel="canonical" href="{{ url }}/{{ permalink }}">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootswatch@5.3.1/dist/cosmo/bootstrap.min.css"
integrity="sha384-dulfW0vmzZ638jigSgZXvDxMmd70GCnIv6oa+riKq6Kk4E0MKf7qmBfwP02wltv5" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css"
integrity="sha384-Ay26V7L8bsJTsX9Sxclnvsn+hkdiwRnrjZJXqKmkIDobPgIIWBOVguEcQQLDuhfN" crossorigin="anonymous">
<link rel="stylesheet" href="/css/style.css" type="text/css">
<script>
(function() {
function setTheme(mediaQuery) {
document.documentElement.setAttribute('data-bs-theme',
document.documentElement.style.colorScheme = mediaQuery.matches ? 'dark' : 'light');
}
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
setTheme(mediaQuery); mediaQuery.addEventListener('change', setTheme);
})();
</script>
</head>
-12
View File
@@ -1,12 +0,0 @@
<head>
<meta charset=UTF-8>
<title>{{headline}}</title>
<link rel="stylesheet" href="{{root}}/bootstrap/css/bootstrap.css" type="text/css">
<link rel="stylesheet" href="{{root}}/css/base.css" type="text/css">
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>
<script src="{{root}}/bootstrap/js/bootstrap.js"></script>
</head>
-24
View File
@@ -1,24 +0,0 @@
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="brand" href="{{root}}/">jq</a>
<div class="nav-collapse collapse">
<ul class="nav">
{% for item in navigation %}
<li {% if item.permalink == permalink %} class="active" {% endif %}>
<a href="{{root}}{{item.permalink}}">{{item.name}}</a>
</li>
{% endfor %}
<li><a href="https://github.com/stedolan/jq/issues">Issues</a></li>
<li><a href="https://github.com/stedolan/jq">Source</a></li>
</ul>
</div>
</div>
</div>
</div>
+41
View File
@@ -0,0 +1,41 @@
<div class="container visually-hidden-focusable">
<a class="d-inline-flex p-2" href="#main">Skip to main content</a>
{%- if navitem.startswith('manual') %}
<a class="d-inline-flex p-2 m-1" href="#contents">Skip to table of contents</a>
{%- endif %}
</div>
<header class="navbar navbar-expand-md sticky-top bg-body-tertiary d-print-none">
<nav class="container-lg" aria-label="Page navigation">
<button type="button" class="navbar-toggler" data-bs-toggle="offcanvas" data-bs-target="#navbar-collapse"
aria-controls="navbar-collapse" aria-expanded="false" aria-label="Toggle page navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="/" aria-label="Top page"><img src="/jq.svg" alt="jq logo" style="height:1.5rem"></a>
<div id="navbar-collapse" class="offcanvas offcanvas-start navbar-collapse w-auto" aria-labelledby="navbar-title">
<div class="offcanvas-header">
<h3 id="navbar-title" class="me-3">jq</h3>
<button type="button" class="d-md-none btn-close" data-bs-dismiss="offcanvas" aria-label="Close page navigation"></button>
</div>
<ul class="offcanvas-body navbar-nav me-auto text-nowrap">
<li class="nav-item d-md-none"><a class="nav-link{% if not navitem %} active{% endif %}"{% if not navitem %} aria-current="page"{% endif %} href="/">Top page</a></li>
{%- for item in ['tutorial', 'download', 'manual'] %}
<li class="nav-item"><a class="nav-link{% if item == navitem %} active{% endif %}"{% if item == navitem %} aria-current="page"{% endif %} href="/{{ item }}/">{{ item | capitalize }}</a></li>
{%- endfor %}
<li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq" target="_blank" rel="noopener">GitHub</a></li>
<li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq/issues" target="_blank" rel="noopener">Issues</a></li>
<li class="nav-item"><a class="nav-link" href="https://play.jqlang.org" rel="noopener">Try online!</a></li>
<li class="nav-item"><a class="nav-link" href="https://raw.githubusercontent.com/jqlang/jq/master/NEWS.md" target="_blank" rel="noopener">News</a></li>
<li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq/wiki" target="_blank" rel="noopener">Wiki</a></li>
</ul>
</div>
{%- if navitem.startswith('manual') %}
<div class="container-searchbox form-control p-0 d-none d-md-flex d-print-none border" style="width:16rem">
<span class="bi bi-search my-auto ms-2 me-1" aria-hidden="true"></span>
<input type="text" id="searchbox" class="form-control border-0 px-1" placeholder="Search manual" role="combobox"
aria-label="Search manual" aria-keyshortcuts="/" aria-expanded="false" autocomplete="off" spellcheck="false">
<kbd class="mx-1 my-auto text-body bg-body rounded border" style="padding:.1rem .2rem" aria-hidden="true">/</kbd>
</div>
{%- endif %}
<a class="d-md-none bi bi-github fs-4 text-body" href="https://github.com/jqlang/jq" target="_blank" rel="noopener" aria-label="GitHub"></a>
</nav>
</header>
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env python3
import jsonschema
import sys
import yaml
if len(sys.argv) < 2:
sys.exit("Usage: {} MANUAL_FILE ...".format(sys.argv[0]))
with open("manual_schema.yml", "r") as schema_file:
manual_schema = yaml.safe_load(schema_file)
for path in sys.argv[1:]:
with open(path, "r") as manual_file:
manual_data = yaml.safe_load(manual_file)
try:
jsonschema.validate(instance=manual_data, schema=manual_schema)
except jsonschema.exceptions.ValidationError as e:
print("Failed to validate:", path, file=sys.stderr)
sys.exit(e)
Loaded 100 of 495 files, more files were not shown because too many files have changed in this diff. Show more