summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)Author
2020-12-19Clean up compile warnings on macOSWilliam Langford
2020-05-26Reduce allocation on string multiplicationitchyny
2020-05-26Fix multiple string multiplicationitchyny
2020-05-26Fix error handling in strftimeitchyny
2020-03-02compatibiltiy->compatibilityAlanscut
2020-01-14fix typosAlanscut
2020-01-10remove unused conditional branchYoichi Nakayama
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-02Update other manual and source to use ;37David Biesack
2020-01-02fix typosAlanscut
2019-12-30Add -0 / --nul-output option for processing values containing newlinesPaul Wise
Closes: https://github.com/stedolan/jq/issues/1271
2019-11-21Fix nesting try/catch inside internal errorsWilliam Langford
2019-10-22Add configure guards around literal jv_numbersWilliam Langford
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[tests] print test # from the start of the tests file to help with skip and takeLeonid S. Usov
2019-10-22Save literal value of the parsed number to preserve it for the outputLeonid S. Usov
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-22Add decNumber libraryLeonid S. Usov
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-04-07Improve jv_is_integer()Mark Feit
2019-04-04jq_util_input_init: Zero memory using callocMattias Hansson
Calloc will zero the allocated memory which makes one memset and a number of explicit zero assignments redundant.
2019-03-26Fix assert in generator subexpressions (fix #1875)Nicolas Williams
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-24Identify progname in more errors (fix #1860)Nicolas Williams
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-24Add -b / --binary option for WindowsNicolas Williams
2019-03-24Allow .["foo"].["bar"]Nicolas Williams
2019-03-24Allow keywords in more places (fix #1868)Nicolas Williams
2019-02-26Restore cfunction arity in builtins/0Muh Muhten
Count arguments up-front at definition/invocation instead of doing it at bind time, which comes after generating builtins/0 since e843a4f.
2019-02-26Bind libraries backward for consistent shadowingMuh Muhten
2019-02-26Fix regression on ~/.jq being a directoryMuh Muhten
2019-02-26Change contains to return true for empty string needlesWilliam Langford
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-26Simplify and optimize SQLish builtinsMuh Muhten
2019-02-26Fix bizarre bsearch/1 behaviour with a stream argumentMuh Muhten
2019-02-26Make tostream much more efficientMuh Muhten
(`path(.[])` is a streaming `keys`!)
2019-02-26Reimplement fromstream/1 more compactlyMuh Muhten
2019-02-26Simplify definition of range/3Muh Muhten
New implementation in terms of while/2, and branches immediately on $by to avoid checking the sign of $by *in* the loop.
2019-02-26Simplify type-select builtinsMuh Muhten
2019-02-26Redefine isempty/1, and the all and any seriesMuh Muhten
Fixes the bug where all and any evaluate one more item than needed.
2019-02-26Remove scalars_or_emptyMuh Muhten
2019-02-26No need to block_drop_unreferenced after builtinsMuh Muhten
(The correctness of this change is more obvious after the rename.)
2019-02-26Rename block_bind_incremental to block_bind_referencedMuh Muhten
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-26Fix block flipping in block_drop_unreferencedMuh Muhten
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-21Ensure limit(0; ...) is emptyMuh Muhten
2019-02-20Rewrite `_assign/2` using `$argument` syntaxMuh Muhten
2019-02-20Work around fgets()'s lack of length reportingMuh Muhten
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-20Support "if" without "else" clauseChance Zibolski
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-20Bind data imports properly when already resolvedMuh Muhten
2019-02-20Make builtin binding fast again by binding only referenced symbolsMuh Muhten
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-20Load ~/.jq as a library instead of with builtinsMuh Muhten
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-20Add import metadata key "optional"Muh Muhten
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-20Replace TOP-before-imports special case with assertMuh Muhten
The case isn't actually possible afaict.
2019-02-20Catch .. as the first component of a module pathMuh Muhten
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-20Pass on the error message when rel_path is invalidMuh Muhten
"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-20Simplify definition of block_bind_referencedMuh Muhten
2019-02-17Allow globbing on WindowsJason Hood
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.