Commit Graph
1222 Commits
Author SHA1 Message Date
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 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.
1.6rc2
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 jq-1.6rc1 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