@port-labs/jq-node-bindings 0.0.14 → 0.0.15-dev2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -1
- package/binding.gyp +42 -20
- package/configure +1 -1
- package/deps/jq/.gitattributes +12 -0
- package/deps/jq/AUTHORS +149 -43
- package/deps/jq/COPYING +75 -1
- package/deps/jq/ChangeLog +2 -2
- package/deps/jq/Makefile.am +106 -65
- package/deps/jq/NEWS.md +391 -0
- package/deps/jq/README.md +54 -52
- package/deps/jq/SECURITY.md +7 -0
- package/deps/jq/compile-ios.sh +106 -102
- package/deps/jq/configure.ac +72 -59
- package/deps/jq/docs/Pipfile +14 -0
- package/deps/jq/docs/Pipfile.lock +415 -0
- package/deps/jq/docs/README.md +15 -14
- package/deps/jq/docs/build_manpage.py +251 -0
- package/deps/jq/docs/build_mantests.py +21 -0
- package/deps/jq/docs/build_website.py +95 -0
- package/deps/jq/docs/content/download/default.yml +249 -0
- package/deps/jq/docs/content/index.yml +83 -0
- package/deps/jq/docs/content/{3.manual/v1.6 → manual/dev}/manual.yml +992 -452
- package/deps/jq/docs/content/{3.manual → manual}/v1.3/manual.yml +105 -116
- package/deps/jq/docs/content/{3.manual → manual}/v1.4/manual.yml +122 -129
- package/deps/jq/docs/content/{3.manual → manual}/v1.5/manual.yml +313 -262
- package/deps/jq/docs/content/{3.manual → manual/v1.6}/manual.yml +407 -332
- package/deps/jq/docs/content/manual/v1.7/manual.yml +3697 -0
- package/deps/jq/docs/content/tutorial/default.yml +337 -0
- package/deps/jq/docs/manual_schema.yml +60 -0
- package/deps/jq/docs/public/css/style.css +99 -0
- package/deps/jq/docs/public/icon.png +0 -0
- package/deps/jq/docs/public/icon.svg +1 -0
- package/deps/jq/docs/public/jq.svg +1 -0
- package/deps/jq/docs/public/js/manual-search.js +31 -49
- package/deps/jq/docs/templates/default.html.j2 +31 -0
- package/deps/jq/docs/templates/index.html.j2 +58 -0
- package/deps/jq/docs/templates/manual.html.j2 +120 -0
- package/deps/jq/docs/templates/shared/_footer.html.j2 +14 -0
- package/deps/jq/docs/templates/shared/_head.html.j2 +23 -0
- package/deps/jq/docs/templates/shared/_navbar.html.j2 +40 -0
- package/deps/jq/docs/validate_manual_schema.py +19 -0
- package/deps/jq/jq.1.prebuilt +1102 -294
- package/deps/jq/jq.spec +2 -3
- package/deps/jq/libjq.pc.in +11 -0
- package/deps/jq/m4/ax_pthread.m4 +522 -0
- package/deps/jq/modules/oniguruma/.travis.yml +17 -0
- package/deps/jq/modules/oniguruma/CMakeLists.txt +206 -41
- package/deps/jq/modules/oniguruma/COPYING +23 -25
- package/deps/jq/modules/oniguruma/HISTORY +368 -23
- package/deps/jq/modules/oniguruma/Makefile.am +61 -7
- package/deps/jq/modules/oniguruma/README +34 -20
- package/deps/jq/modules/oniguruma/README.md +106 -33
- package/deps/jq/modules/oniguruma/README_japanese +183 -0
- package/deps/jq/modules/oniguruma/autogen.sh +9 -0
- package/deps/jq/modules/oniguruma/cmake/Config.cmake.in +4 -0
- package/deps/jq/modules/oniguruma/configure.ac +66 -55
- package/deps/jq/modules/oniguruma/doc/API +485 -42
- package/deps/jq/modules/oniguruma/doc/API.ja +732 -293
- package/deps/jq/modules/oniguruma/doc/CALLOUTS.API +397 -0
- package/deps/jq/modules/oniguruma/doc/CALLOUTS.API.ja +393 -0
- package/deps/jq/modules/oniguruma/doc/CALLOUTS.BUILTIN +95 -0
- package/deps/jq/modules/oniguruma/doc/CALLOUTS.BUILTIN.ja +93 -0
- package/deps/jq/modules/oniguruma/doc/FAQ +3 -3
- package/deps/jq/modules/oniguruma/doc/FAQ.ja +8 -8
- package/deps/jq/modules/oniguruma/doc/RE +223 -63
- package/deps/jq/modules/oniguruma/doc/RE.ja +420 -265
- package/deps/jq/modules/oniguruma/doc/SYNTAX.md +1091 -0
- package/deps/jq/modules/oniguruma/doc/UNICODE_PROPERTIES +840 -697
- package/deps/jq/modules/oniguruma/harnesses/ascii_compatible.dict +113 -0
- package/deps/jq/modules/oniguruma/harnesses/base.c +749 -0
- package/deps/jq/modules/oniguruma/harnesses/deluxe.c +206 -0
- package/deps/jq/modules/oniguruma/harnesses/dict_conv.py +72 -0
- package/deps/jq/modules/oniguruma/harnesses/fuzzer.options +2 -0
- package/deps/jq/modules/oniguruma/harnesses/libfuzzer-onig.cpp +45 -0
- package/deps/jq/modules/oniguruma/harnesses/regset.c +392 -0
- package/deps/jq/modules/oniguruma/index.html +16 -5
- package/deps/jq/modules/oniguruma/index_ja.html +16 -5
- package/deps/jq/modules/oniguruma/make_win.bat +5 -0
- package/deps/jq/modules/oniguruma/make_win32.bat +5 -3
- package/deps/jq/modules/oniguruma/make_win64.bat +5 -3
- package/deps/jq/modules/oniguruma/onig-config.cmake.in +80 -0
- package/deps/jq/modules/oniguruma/onig-config.in +1 -1
- package/deps/jq/modules/oniguruma/oniguruma.pc.cmake.in +1 -1
- package/deps/jq/modules/oniguruma/oniguruma.pc.in +0 -1
- package/deps/jq/modules/oniguruma/sample/CMakeLists.txt +9 -2
- package/deps/jq/modules/oniguruma/sample/Makefile.am +24 -5
- package/deps/jq/modules/oniguruma/sample/bug_fix.c +13 -51
- package/deps/jq/modules/oniguruma/sample/callback_each_match.c +168 -0
- package/deps/jq/modules/oniguruma/sample/callout.c +268 -0
- package/deps/jq/modules/oniguruma/sample/count.c +125 -0
- package/deps/jq/modules/oniguruma/sample/crnl.c +6 -4
- package/deps/jq/modules/oniguruma/sample/echo.c +136 -0
- package/deps/jq/modules/oniguruma/sample/encode.c +53 -146
- package/deps/jq/modules/oniguruma/sample/listcap.c +18 -10
- package/deps/jq/modules/oniguruma/sample/names.c +10 -6
- package/deps/jq/modules/oniguruma/sample/posix.c +13 -2
- package/deps/jq/modules/oniguruma/sample/regset.c +95 -0
- package/deps/jq/modules/oniguruma/sample/scan.c +20 -6
- package/deps/jq/modules/oniguruma/sample/simple.c +8 -4
- package/deps/jq/modules/oniguruma/sample/sql.c +13 -8
- package/deps/jq/modules/oniguruma/sample/syntax.c +11 -10
- package/deps/jq/modules/oniguruma/sample/user_property.c +12 -7
- package/deps/jq/modules/oniguruma/src/Makefile.am +41 -15
- package/deps/jq/modules/oniguruma/src/Makefile.windows +196 -183
- package/deps/jq/modules/oniguruma/src/ascii.c +64 -7
- package/deps/jq/modules/oniguruma/src/big5.c +25 -15
- package/deps/jq/modules/oniguruma/src/config.h.cmake.in +7 -22
- package/deps/jq/modules/oniguruma/src/config.h.win32 +56 -84
- package/deps/jq/modules/oniguruma/src/config.h.win64 +56 -84
- package/deps/jq/modules/oniguruma/src/config.h.windows.in +62 -0
- package/deps/jq/modules/oniguruma/src/cp1251.c +14 -8
- package/deps/jq/modules/oniguruma/src/euc_jp.c +28 -30
- package/deps/jq/modules/oniguruma/src/euc_jp_prop.c +25 -32
- package/deps/jq/modules/oniguruma/src/euc_jp_prop.gperf +1 -2
- package/deps/jq/modules/oniguruma/src/euc_kr.c +27 -15
- package/deps/jq/modules/oniguruma/src/euc_tw.c +40 -17
- package/deps/jq/modules/oniguruma/src/gb18030.c +177 -119
- package/deps/jq/modules/oniguruma/src/gperf_fold_key_conv.py +12 -8
- package/deps/jq/modules/oniguruma/src/gperf_unfold_key_conv.py +8 -6
- package/deps/jq/modules/oniguruma/src/iso8859_1.c +92 -91
- package/deps/jq/modules/oniguruma/src/iso8859_10.c +13 -29
- package/deps/jq/modules/oniguruma/src/iso8859_11.c +4 -2
- package/deps/jq/modules/oniguruma/src/iso8859_13.c +13 -33
- package/deps/jq/modules/oniguruma/src/iso8859_14.c +13 -30
- package/deps/jq/modules/oniguruma/src/iso8859_15.c +13 -34
- package/deps/jq/modules/oniguruma/src/iso8859_16.c +13 -29
- package/deps/jq/modules/oniguruma/src/iso8859_2.c +13 -29
- package/deps/jq/modules/oniguruma/src/iso8859_3.c +13 -33
- package/deps/jq/modules/oniguruma/src/iso8859_4.c +13 -32
- package/deps/jq/modules/oniguruma/src/iso8859_5.c +16 -23
- package/deps/jq/modules/oniguruma/src/iso8859_6.c +4 -2
- package/deps/jq/modules/oniguruma/src/iso8859_7.c +14 -29
- package/deps/jq/modules/oniguruma/src/iso8859_8.c +4 -2
- package/deps/jq/modules/oniguruma/src/iso8859_9.c +13 -33
- package/deps/jq/modules/oniguruma/src/koi8.c +14 -27
- package/deps/jq/modules/oniguruma/src/koi8_r.c +12 -19
- package/deps/jq/modules/oniguruma/src/make_property.sh +21 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_egcb.sh +7 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_egcb_data.py +267 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_fold.sh +25 -11
- package/deps/jq/modules/oniguruma/src/make_unicode_fold_data.py +206 -26
- package/deps/jq/modules/oniguruma/src/make_unicode_property.sh +19 -10
- package/deps/jq/modules/oniguruma/src/make_unicode_property_data.py +474 -375
- package/deps/jq/modules/oniguruma/src/make_unicode_wb.sh +7 -0
- package/deps/jq/modules/oniguruma/src/make_unicode_wb_data.py +267 -0
- package/deps/jq/modules/oniguruma/src/mktable.c +28 -24
- package/deps/jq/modules/oniguruma/src/onig_init.c +2 -2
- package/deps/jq/modules/oniguruma/src/oniggnu.h +7 -5
- package/deps/jq/modules/oniguruma/src/onigposix.h +40 -16
- package/deps/jq/modules/oniguruma/src/oniguruma.h +357 -107
- package/deps/jq/modules/oniguruma/src/regcomp.c +6214 -3933
- package/deps/jq/modules/oniguruma/src/regenc.c +197 -120
- package/deps/jq/modules/oniguruma/src/regenc.h +106 -63
- package/deps/jq/modules/oniguruma/src/regerror.c +112 -91
- package/deps/jq/modules/oniguruma/src/regexec.c +4876 -2010
- package/deps/jq/modules/oniguruma/src/regext.c +8 -8
- package/deps/jq/modules/oniguruma/src/reggnu.c +13 -17
- package/deps/jq/modules/oniguruma/src/regint.h +757 -491
- package/deps/jq/modules/oniguruma/src/regparse.c +7204 -3240
- package/deps/jq/modules/oniguruma/src/regparse.h +361 -218
- package/deps/jq/modules/oniguruma/src/regposerr.c +49 -9
- package/deps/jq/modules/oniguruma/src/regposix.c +106 -24
- package/deps/jq/modules/oniguruma/src/regsyntax.c +66 -13
- package/deps/jq/modules/oniguruma/src/regtrav.c +1 -1
- package/deps/jq/modules/oniguruma/src/regversion.c +6 -4
- package/deps/jq/modules/oniguruma/src/sjis.c +23 -52
- package/deps/jq/modules/oniguruma/src/sjis_prop.c +25 -32
- package/deps/jq/modules/oniguruma/src/sjis_prop.gperf +1 -2
- package/deps/jq/modules/oniguruma/src/st.c +248 -249
- package/deps/jq/modules/oniguruma/src/st.h +4 -5
- package/deps/jq/modules/oniguruma/src/unicode.c +869 -294
- package/deps/jq/modules/oniguruma/src/unicode_egcb_data.c +1419 -0
- package/deps/jq/modules/oniguruma/src/unicode_fold1_key.c +1829 -1300
- package/deps/jq/modules/oniguruma/src/unicode_fold2_key.c +32 -9
- package/deps/jq/modules/oniguruma/src/unicode_fold3_key.c +32 -9
- package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +1210 -984
- package/deps/jq/modules/oniguruma/src/unicode_property_data.c +22480 -15198
- package/deps/jq/modules/oniguruma/src/unicode_property_data_posix.c +1463 -591
- package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +1958 -1418
- package/deps/jq/modules/oniguruma/src/unicode_wb_data.c +1106 -0
- package/deps/jq/modules/oniguruma/src/utf16_be.c +90 -49
- package/deps/jq/modules/oniguruma/src/utf16_le.c +80 -49
- package/deps/jq/modules/oniguruma/src/utf32_be.c +14 -42
- package/deps/jq/modules/oniguruma/src/utf32_le.c +13 -40
- package/deps/jq/modules/oniguruma/src/utf8.c +33 -78
- package/deps/jq/modules/oniguruma/test/CMakeLists.txt +55 -0
- package/deps/jq/modules/oniguruma/test/Makefile.am +65 -10
- package/deps/jq/modules/oniguruma/test/test.sh +17 -0
- package/deps/jq/modules/oniguruma/test/test_back.c +1450 -0
- package/deps/jq/modules/oniguruma/test/test_options.c +228 -0
- package/deps/jq/modules/oniguruma/test/test_regset.c +466 -0
- package/deps/jq/modules/oniguruma/test/test_syntax.c +365 -0
- package/deps/jq/modules/oniguruma/test/test_utf8.c +1761 -0
- package/deps/jq/modules/oniguruma/test/testc.c +128 -88
- package/deps/jq/modules/oniguruma/test/testp.c +613 -0
- package/deps/jq/modules/oniguruma/test/testu.c +75 -28
- package/deps/jq/modules/oniguruma/tis-ci/stub.c +3 -0
- package/deps/jq/modules/oniguruma/tis-ci/test_back.config +26 -0
- package/deps/jq/modules/oniguruma/tis-ci/test_regset.config +20 -0
- package/deps/jq/modules/oniguruma/tis-ci/test_syntax.config +26 -0
- package/deps/jq/modules/oniguruma/tis-ci/test_utf8.config +25 -0
- package/deps/jq/modules/oniguruma/tis-ci/testc.config +26 -0
- package/deps/jq/modules/oniguruma/tis-ci/testu.config +24 -0
- package/deps/jq/modules/oniguruma/tis.config +1336 -0
- package/deps/jq/modules/oniguruma/windows/CMakeLists.txt +8 -0
- package/deps/jq/modules/oniguruma/windows/testc.c +865 -869
- package/deps/jq/scripts/update-website +6 -5
- package/deps/jq/scripts/version +10 -7
- package/deps/jq/sig/jq-release-new.key +29 -0
- package/deps/jq/sig/v1.4/sha256sum.txt +1 -0
- package/deps/jq/sig/v1.5/sha256sum.txt +2 -0
- package/deps/jq/sig/v1.5rc1/sha256sum.txt +1 -0
- package/deps/jq/sig/v1.5rc2/sha256sum.txt +2 -0
- package/deps/jq/sig/v1.6/sha256sum.txt +2 -0
- package/deps/jq/sig/v1.7/jq-1.7.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.7/jq-1.7.zip.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.7/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.7/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.7/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.7/sha256sum.txt +23 -0
- package/deps/jq/sig/v1.7.1/jq-1.7.1.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-1.7.1.zip.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-linux64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-osx-amd64.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-win64.exe.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.7.1/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.7.1/sha256sum.txt +26 -0
- package/deps/jq/sig/v1.7rc1/jq-1.7rc1.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-1.7rc1.zip.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.7rc1/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.7rc1/sha256sum.txt +23 -0
- package/deps/jq/sig/v1.7rc2/jq-1.7rc2.tar.gz.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-1.7rc2.zip.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-amd64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-arm64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-armel.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-armhf.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-i386.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips64el.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips64r6.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mips64r6el.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mipsel.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mipsr6.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-mipsr6el.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-powerpc.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-ppc64el.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-riscv64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-linux-s390x.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-macos-amd64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-macos-arm64.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-windows-amd64.exe.asc +16 -0
- package/deps/jq/sig/v1.7rc2/jq-windows-i386.exe.asc +16 -0
- package/deps/jq/sig/v1.7rc2/sha256sum.txt +23 -0
- package/deps/jq/src/builtin.c +537 -343
- package/deps/jq/src/builtin.h +18 -0
- package/deps/jq/src/builtin.jq +116 -143
- package/deps/jq/src/bytecode.h +8 -4
- package/deps/jq/src/compile.c +157 -143
- package/deps/jq/src/compile.h +3 -4
- package/deps/jq/src/decNumber/ICU-license.html +45 -0
- package/deps/jq/src/decNumber/decBasic.c +3908 -0
- package/deps/jq/src/decNumber/decCommon.c +1835 -0
- package/deps/jq/src/decNumber/decContext.c +437 -0
- package/deps/jq/src/decNumber/decContext.h +254 -0
- package/deps/jq/src/decNumber/decDPD.h +1185 -0
- package/deps/jq/src/decNumber/decDouble.c +140 -0
- package/deps/jq/src/decNumber/decDouble.h +155 -0
- package/deps/jq/src/decNumber/decNumber.c +8143 -0
- package/deps/jq/src/decNumber/decNumber.h +182 -0
- package/deps/jq/src/decNumber/decNumberLocal.h +757 -0
- package/deps/jq/src/decNumber/decPacked.c +220 -0
- package/deps/jq/src/decNumber/decPacked.h +52 -0
- package/deps/jq/src/decNumber/decQuad.c +135 -0
- package/deps/jq/src/decNumber/decQuad.h +177 -0
- package/deps/jq/src/decNumber/decSingle.c +71 -0
- package/deps/jq/src/decNumber/decSingle.h +86 -0
- package/deps/jq/src/decNumber/decimal128.c +553 -0
- package/deps/jq/src/decNumber/decimal128.h +81 -0
- package/deps/jq/src/decNumber/decimal32.c +476 -0
- package/deps/jq/src/decNumber/decimal32.h +81 -0
- package/deps/jq/src/decNumber/decimal64.c +839 -0
- package/deps/jq/src/decNumber/decimal64.h +83 -0
- package/deps/jq/src/decNumber/decnumber.pdf +0 -0
- package/deps/jq/src/decNumber/example1.c +38 -0
- package/deps/jq/src/decNumber/example2.c +52 -0
- package/deps/jq/src/decNumber/example3.c +64 -0
- package/deps/jq/src/decNumber/example4.c +61 -0
- package/deps/jq/src/decNumber/example5.c +36 -0
- package/deps/jq/src/decNumber/example6.c +61 -0
- package/deps/jq/src/decNumber/example7.c +35 -0
- package/deps/jq/src/decNumber/example8.c +39 -0
- package/deps/jq/src/decNumber/readme.txt +81 -0
- package/deps/jq/src/exec_stack.h +5 -3
- package/deps/jq/src/execute.c +126 -44
- package/deps/jq/src/inject_errors.c +0 -2
- package/deps/jq/src/jq.h +10 -1
- package/deps/jq/src/jq_test.c +222 -11
- package/deps/jq/src/jv.c +807 -176
- package/deps/jq/src/jv.h +22 -1
- package/deps/jq/src/jv_alloc.c +33 -26
- package/deps/jq/src/jv_alloc.h +0 -11
- package/deps/jq/src/jv_aux.c +153 -67
- package/deps/jq/src/jv_dtoa.c +12 -2
- package/deps/jq/src/jv_dtoa_tsd.c +51 -0
- package/deps/jq/src/jv_dtoa_tsd.h +4 -0
- package/deps/jq/src/jv_parse.c +70 -15
- package/deps/jq/src/jv_print.c +56 -60
- package/deps/jq/src/jv_private.h +7 -0
- package/deps/jq/src/jv_thread.h +76 -0
- package/deps/jq/src/jv_unicode.c +18 -0
- package/deps/jq/src/jv_unicode.h +2 -0
- package/deps/jq/src/lexer.c +782 -543
- package/deps/jq/src/lexer.h +438 -64
- package/deps/jq/src/lexer.l +10 -3
- package/deps/jq/src/libm.h +16 -6
- package/deps/jq/src/linker.c +97 -40
- package/deps/jq/src/locfile.c +2 -1
- package/deps/jq/src/main.c +384 -336
- package/deps/jq/src/opcode_list.h +5 -2
- package/deps/jq/src/parser.c +2260 -1898
- package/deps/jq/src/parser.h +115 -98
- package/deps/jq/src/parser.y +124 -89
- package/deps/jq/src/util.c +854 -55
- package/deps/jq/src/util.h +6 -4
- package/deps/jq/tests/jq.test +762 -26
- package/deps/jq/tests/jq_fuzz_compile.c +27 -0
- package/deps/jq/tests/jq_fuzz_execute.cpp +42 -0
- package/deps/jq/tests/jq_fuzz_fixed.cpp +297 -0
- package/deps/jq/tests/jq_fuzz_load_file.c +28 -0
- package/deps/jq/tests/jq_fuzz_parse.c +21 -0
- package/deps/jq/tests/jq_fuzz_parse_extended.c +36 -0
- package/deps/jq/tests/jq_fuzz_parse_stream.c +21 -0
- package/deps/jq/tests/local.supp +14 -0
- package/deps/jq/tests/man.test +979 -0
- package/deps/jq/tests/manonig.test +76 -0
- package/deps/jq/tests/manonigtest +5 -0
- package/deps/jq/tests/mantest +1 -2
- package/deps/jq/tests/modules/home2/.jq/g.jq +1 -0
- package/deps/jq/tests/modules/shadow1.jq +2 -0
- package/deps/jq/tests/modules/shadow2.jq +1 -0
- package/deps/jq/tests/modules/test_bind_order0.jq +1 -0
- package/deps/jq/tests/modules/test_bind_order1.jq +1 -1
- package/deps/jq/tests/modules/test_bind_order2.jq +0 -1
- package/deps/jq/tests/no-main-program.jq +1 -0
- package/deps/jq/tests/onig.test +77 -2
- package/deps/jq/tests/setup +7 -2
- package/deps/jq/tests/shtest +478 -59
- package/deps/jq/tests/uri.test +38 -0
- package/deps/jq/tests/uritest +5 -0
- package/deps/jq/tests/yes-main-program.jq +2 -0
- package/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/jq.js +15 -1
- package/lib/templateAsync.js +137 -0
- package/package.json +3 -3
- package/src/binding.cc +623 -146
- package/src/binding.h +3 -4
- package/test/santiy-async.test.js +171 -0
- package/test/santiy.test.js +2 -2
- package/test/template-async.test.js +182 -0
- package/test/template.test.js +3 -3
- package/deps/jq/.travis.yml +0 -202
- package/deps/jq/NEWS +0 -89
- package/deps/jq/appveyor.yml +0 -53
- package/deps/jq/docs/Gemfile +0 -7
- package/deps/jq/docs/Gemfile.lock +0 -63
- package/deps/jq/docs/Rakefile +0 -24
- package/deps/jq/docs/Rakefile.manual +0 -49
- package/deps/jq/docs/Rakefile.website +0 -76
- package/deps/jq/docs/content/1.tutorial/default.yml +0 -327
- package/deps/jq/docs/content/2.download/default.yml +0 -193
- package/deps/jq/docs/content/index/index.yml +0 -73
- package/deps/jq/docs/public/css/base.scss +0 -181
- package/deps/jq/docs/public/jq.png +0 -0
- package/deps/jq/docs/site.yml +0 -9
- package/deps/jq/docs/templates/default.liquid +0 -34
- package/deps/jq/docs/templates/index.liquid +0 -73
- package/deps/jq/docs/templates/manual.liquid +0 -99
- package/deps/jq/docs/templates/shared/_footer.liquid +0 -10
- package/deps/jq/docs/templates/shared/_head.liquid +0 -17
- package/deps/jq/docs/templates/shared/_navbar.liquid +0 -27
- package/deps/jq/modules/oniguruma/README.ja +0 -195
- package/deps/jq/modules/oniguruma/cmake/dist.cmake +0 -321
- package/deps/jq/modules/oniguruma/contributed/libfuzzer-onig.cpp +0 -31
- package/deps/jq/modules/oniguruma/dist.info +0 -10
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold1_key.c +0 -2250
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold2_key.c +0 -203
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold3_key.c +0 -113
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold_data.c +0 -1225
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data.c +0 -24742
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data_posix.c +0 -4846
- package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_unfold_key.c +0 -2571
- /package/deps/jq/sig/{jq-release.key → jq-release-old.key} +0 -0
- /package/deps/jq/tests/modules/{.jq → home1/.jq} +0 -0
package/deps/jq/src/main.c
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
#include <ctype.h>
|
|
3
3
|
#include <errno.h>
|
|
4
4
|
#include <libgen.h>
|
|
5
|
+
#ifdef HAVE_SETLOCALE
|
|
6
|
+
#include <locale.h>
|
|
7
|
+
#endif
|
|
5
8
|
#include <stdlib.h>
|
|
6
9
|
#include <stdio.h>
|
|
7
10
|
#include <string.h>
|
|
@@ -15,6 +18,7 @@
|
|
|
15
18
|
#include <shellapi.h>
|
|
16
19
|
#include <wchar.h>
|
|
17
20
|
#include <wtypes.h>
|
|
21
|
+
extern void jv_tsd_dtoa_ctx_init();
|
|
18
22
|
#endif
|
|
19
23
|
|
|
20
24
|
#if !defined(HAVE_ISATTY) && defined(HAVE__ISATTY)
|
|
@@ -32,6 +36,7 @@
|
|
|
32
36
|
#include "jv_alloc.h"
|
|
33
37
|
#include "util.h"
|
|
34
38
|
#include "src/version.h"
|
|
39
|
+
#include "src/config_opts.inc"
|
|
35
40
|
|
|
36
41
|
int jq_testsuite(jv lib_dirs, int verbose, int argc, char* argv[]);
|
|
37
42
|
|
|
@@ -56,71 +61,86 @@ static void usage(int code, int keep_it_short) {
|
|
|
56
61
|
"its JSON text inputs and producing the filter's results as JSON on\n"
|
|
57
62
|
"standard output.\n\n"
|
|
58
63
|
"The simplest filter is ., which copies jq's input to its output\n"
|
|
59
|
-
"unmodified
|
|
60
|
-
"
|
|
61
|
-
"For more advanced filters see the jq(1) manpage (\"man jq\")\n"
|
|
62
|
-
"and/or https://stedolan.github.io/jq\n\n"
|
|
64
|
+
"unmodified except for formatting. For more advanced filters see\n"
|
|
65
|
+
"the jq(1) manpage (\"man jq\") and/or https://jqlang.github.io/jq/.\n\n"
|
|
63
66
|
"Example:\n\n\t$ echo '{\"foo\": 0}' | jq .\n"
|
|
64
|
-
"\t{\n\t\
|
|
67
|
+
"\t{\n\t \"foo\": 0\n\t}\n\n",
|
|
65
68
|
JQ_VERSION, progname, progname, progname);
|
|
66
69
|
if (keep_it_short) {
|
|
67
70
|
fprintf(f,
|
|
68
|
-
"For
|
|
71
|
+
"For listing the command options, use %s --help.\n",
|
|
69
72
|
progname);
|
|
70
73
|
} else {
|
|
71
74
|
(void) fprintf(f,
|
|
72
|
-
"
|
|
73
|
-
" -
|
|
74
|
-
" -
|
|
75
|
-
" -
|
|
76
|
-
"
|
|
77
|
-
" -
|
|
78
|
-
" -
|
|
79
|
-
"
|
|
80
|
-
" -
|
|
81
|
-
"
|
|
82
|
-
" --
|
|
83
|
-
"
|
|
84
|
-
" --
|
|
85
|
-
" --
|
|
86
|
-
" --
|
|
87
|
-
"
|
|
88
|
-
"
|
|
89
|
-
"
|
|
75
|
+
"Command options:\n"
|
|
76
|
+
" -n, --null-input use `null` as the single input value;\n"
|
|
77
|
+
" -R, --raw-input read each line as string instead of JSON;\n"
|
|
78
|
+
" -s, --slurp read all inputs into an array and use it as\n"
|
|
79
|
+
" the single input value;\n"
|
|
80
|
+
" -c, --compact-output compact instead of pretty-printed output;\n"
|
|
81
|
+
" -r, --raw-output output strings without escapes and quotes;\n"
|
|
82
|
+
" --raw-output0 implies -r and output NUL after each output;\n"
|
|
83
|
+
" -j, --join-output implies -r and output without newline after\n"
|
|
84
|
+
" each output;\n"
|
|
85
|
+
" -a, --ascii-output output strings by only ASCII characters\n"
|
|
86
|
+
" using escape sequences;\n"
|
|
87
|
+
" -S, --sort-keys sort keys of each object on output;\n"
|
|
88
|
+
" -C, --color-output colorize JSON output;\n"
|
|
89
|
+
" -M, --monochrome-output disable colored output;\n"
|
|
90
|
+
" --tab use tabs for indentation;\n"
|
|
91
|
+
" --indent n use n spaces for indentation (max 7 spaces);\n"
|
|
92
|
+
" --unbuffered flush output stream after each output;\n"
|
|
93
|
+
" --stream parse the input value in streaming fashion;\n"
|
|
94
|
+
" --stream-errors implies --stream and report parse error as\n"
|
|
95
|
+
" an array;\n"
|
|
96
|
+
" --seq parse input/output as application/json-seq;\n"
|
|
97
|
+
" -f, --from-file load the filter from a file;\n"
|
|
98
|
+
" -L, --library-path dir search modules from the directory;\n"
|
|
99
|
+
" --arg name value set $name to the string value;\n"
|
|
100
|
+
" --argjson name value set $name to the JSON value;\n"
|
|
101
|
+
" --slurpfile name file set $name to an array of JSON values read\n"
|
|
102
|
+
" from the file;\n"
|
|
103
|
+
" --rawfile name file set $name to string contents of file;\n"
|
|
104
|
+
" --args consume remaining arguments as positional\n"
|
|
105
|
+
" string values;\n"
|
|
106
|
+
" --jsonargs consume remaining arguments as positional\n"
|
|
107
|
+
" JSON values;\n"
|
|
108
|
+
" -e, --exit-status set exit status code based on the output;\n"
|
|
109
|
+
#ifdef WIN32
|
|
110
|
+
" -b, --binary open input/output streams in binary mode;\n"
|
|
111
|
+
#endif
|
|
112
|
+
" -V, --version show the version;\n"
|
|
113
|
+
" --build-configuration show jq's build configuration;\n"
|
|
114
|
+
" -h, --help show the help;\n"
|
|
115
|
+
" -- terminates argument processing;\n\n"
|
|
90
116
|
"Named arguments are also available as $ARGS.named[], while\n"
|
|
91
|
-
"positional arguments are available as $ARGS.positional[].\n"
|
|
92
|
-
"\nSee the manpage for more options.\n");
|
|
117
|
+
"positional arguments are available as $ARGS.positional[].\n");
|
|
93
118
|
}
|
|
94
119
|
exit((ret < 0 && code == 0) ? 2 : code);
|
|
95
120
|
}
|
|
96
121
|
|
|
97
122
|
static void die() {
|
|
98
123
|
fprintf(stderr, "Use %s --help for help with command-line options,\n", progname);
|
|
99
|
-
fprintf(stderr, "or see the jq manpage, or online docs at https://
|
|
124
|
+
fprintf(stderr, "or see the jq manpage, or online docs at https://jqlang.github.io/jq\n");
|
|
100
125
|
exit(2);
|
|
101
126
|
}
|
|
102
127
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
128
|
static int isoptish(const char* text) {
|
|
107
|
-
return text[0] == '-' && (text[1] == '-' || isalpha(text[1]));
|
|
129
|
+
return text[0] == '-' && (text[1] == '-' || isalpha((unsigned char)text[1]));
|
|
108
130
|
}
|
|
109
131
|
|
|
110
|
-
static int isoption(const char
|
|
111
|
-
if (
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
else
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
(*short_opts)++; // ...count it (for option stacking)
|
|
123
|
-
return 1;
|
|
132
|
+
static int isoption(const char** text, char shortopt, const char* longopt, int is_short) {
|
|
133
|
+
if (is_short) {
|
|
134
|
+
if (shortopt && **text == shortopt) {
|
|
135
|
+
(*text)++;
|
|
136
|
+
if (!**text) *text = NULL;
|
|
137
|
+
return 1;
|
|
138
|
+
}
|
|
139
|
+
} else {
|
|
140
|
+
if (!strcmp(*text, longopt)) {
|
|
141
|
+
*text = NULL;
|
|
142
|
+
return 1;
|
|
143
|
+
}
|
|
124
144
|
}
|
|
125
145
|
return 0;
|
|
126
146
|
}
|
|
@@ -130,6 +150,7 @@ enum {
|
|
|
130
150
|
RAW_INPUT = 2,
|
|
131
151
|
PROVIDE_NULL = 4,
|
|
132
152
|
RAW_OUTPUT = 8,
|
|
153
|
+
RAW_OUTPUT0 = 16,
|
|
133
154
|
ASCII_OUTPUT = 32,
|
|
134
155
|
COLOR_OUTPUT = 64,
|
|
135
156
|
NO_COLOR_OUTPUT = 128,
|
|
@@ -138,74 +159,76 @@ enum {
|
|
|
138
159
|
RAW_NO_LF = 1024,
|
|
139
160
|
UNBUFFERED_OUTPUT = 2048,
|
|
140
161
|
EXIT_STATUS = 4096,
|
|
141
|
-
EXIT_STATUS_EXACT = 8192,
|
|
142
162
|
SEQ = 16384,
|
|
143
|
-
RUN_TESTS = 32768,
|
|
144
163
|
/* debugging only */
|
|
145
|
-
DUMP_DISASM =
|
|
164
|
+
DUMP_DISASM = 32768,
|
|
146
165
|
};
|
|
147
|
-
static int options = 0;
|
|
148
|
-
|
|
149
|
-
static const char *skip_shebang(const char *p) {
|
|
150
|
-
if (strncmp(p, "#!", sizeof("#!") - 1) != 0)
|
|
151
|
-
return p;
|
|
152
|
-
const char *n = strchr(p, '\n');
|
|
153
|
-
if (n == NULL || n[1] != '#')
|
|
154
|
-
return p;
|
|
155
|
-
n = strchr(n + 1, '\n');
|
|
156
|
-
if (n == NULL || n[1] == '#' || n[1] == '\0' || n[-1] != '\\' || n[-2] == '\\')
|
|
157
|
-
return p;
|
|
158
|
-
n = strchr(n + 1, '\n');
|
|
159
|
-
if (n == NULL)
|
|
160
|
-
return p;
|
|
161
|
-
return n+1;
|
|
162
|
-
}
|
|
163
166
|
|
|
164
|
-
|
|
165
|
-
|
|
167
|
+
enum {
|
|
168
|
+
JQ_OK = 0,
|
|
169
|
+
JQ_OK_NULL_KIND = -1, /* exit 0 if --exit-status is not set*/
|
|
170
|
+
JQ_ERROR_SYSTEM = 2,
|
|
171
|
+
JQ_ERROR_COMPILE = 3,
|
|
172
|
+
JQ_OK_NO_OUTPUT = -4, /* exit 0 if --exit-status is not set*/
|
|
173
|
+
JQ_ERROR_UNKNOWN = 5,
|
|
174
|
+
};
|
|
175
|
+
#define jq_exit_with_status(r) exit(abs(r))
|
|
176
|
+
#define jq_exit(r) exit( r > 0 ? r : 0 )
|
|
177
|
+
|
|
178
|
+
static int process(jq_state *jq, jv value, int flags, int dumpopts, int options) {
|
|
179
|
+
int ret = JQ_OK_NO_OUTPUT; // No valid results && -e -> exit(4)
|
|
166
180
|
jq_start(jq, value, flags);
|
|
167
181
|
jv result;
|
|
168
182
|
while (jv_is_valid(result = jq_next(jq))) {
|
|
169
183
|
if ((options & RAW_OUTPUT) && jv_get_kind(result) == JV_KIND_STRING) {
|
|
170
184
|
if (options & ASCII_OUTPUT) {
|
|
171
|
-
jv_dumpf(result, stdout, JV_PRINT_ASCII);
|
|
185
|
+
jv_dumpf(jv_copy(result), stdout, JV_PRINT_ASCII);
|
|
186
|
+
} else if ((options & RAW_OUTPUT0) && strlen(jv_string_value(result)) != (unsigned long)jv_string_length_bytes(jv_copy(result))) {
|
|
187
|
+
jv_free(result);
|
|
188
|
+
result = jv_invalid_with_msg(jv_string(
|
|
189
|
+
"Cannot dump a string containing NUL with --raw-output0 option"));
|
|
190
|
+
break;
|
|
172
191
|
} else {
|
|
173
|
-
|
|
192
|
+
priv_fwrite(jv_string_value(result), jv_string_length_bytes(jv_copy(result)),
|
|
193
|
+
stdout, dumpopts & JV_PRINT_ISATTY);
|
|
174
194
|
}
|
|
175
|
-
ret =
|
|
195
|
+
ret = JQ_OK;
|
|
176
196
|
jv_free(result);
|
|
177
197
|
} else {
|
|
178
198
|
if (jv_get_kind(result) == JV_KIND_FALSE || jv_get_kind(result) == JV_KIND_NULL)
|
|
179
|
-
ret =
|
|
199
|
+
ret = JQ_OK_NULL_KIND;
|
|
180
200
|
else
|
|
181
|
-
ret =
|
|
201
|
+
ret = JQ_OK;
|
|
182
202
|
if (options & SEQ)
|
|
183
203
|
priv_fwrite("\036", 1, stdout, dumpopts & JV_PRINT_ISATTY);
|
|
184
204
|
jv_dump(result, dumpopts);
|
|
185
205
|
}
|
|
186
206
|
if (!(options & RAW_NO_LF))
|
|
187
207
|
priv_fwrite("\n", 1, stdout, dumpopts & JV_PRINT_ISATTY);
|
|
208
|
+
if (options & RAW_OUTPUT0)
|
|
209
|
+
priv_fwrite("\0", 1, stdout, dumpopts & JV_PRINT_ISATTY);
|
|
188
210
|
if (options & UNBUFFERED_OUTPUT)
|
|
189
211
|
fflush(stdout);
|
|
190
212
|
}
|
|
191
213
|
if (jq_halted(jq)) {
|
|
192
214
|
// jq program invoked `halt` or `halt_error`
|
|
193
|
-
options |= EXIT_STATUS_EXACT;
|
|
194
215
|
jv exit_code = jq_get_exit_code(jq);
|
|
195
216
|
if (!jv_is_valid(exit_code))
|
|
196
|
-
ret =
|
|
217
|
+
ret = JQ_OK;
|
|
197
218
|
else if (jv_get_kind(exit_code) == JV_KIND_NUMBER)
|
|
198
219
|
ret = jv_number_value(exit_code);
|
|
199
220
|
else
|
|
200
|
-
ret =
|
|
221
|
+
ret = JQ_ERROR_UNKNOWN;
|
|
201
222
|
jv_free(exit_code);
|
|
202
223
|
jv error_message = jq_get_error_message(jq);
|
|
203
224
|
if (jv_get_kind(error_message) == JV_KIND_STRING) {
|
|
204
|
-
|
|
225
|
+
// No prefix should be added to the output of `halt_error`.
|
|
226
|
+
priv_fwrite(jv_string_value(error_message), jv_string_length_bytes(jv_copy(error_message)),
|
|
227
|
+
stderr, dumpopts & JV_PRINT_ISATTY);
|
|
205
228
|
} else if (jv_get_kind(error_message) == JV_KIND_NULL) {
|
|
206
229
|
// Halt with no output
|
|
207
230
|
} else if (jv_is_valid(error_message)) {
|
|
208
|
-
error_message = jv_dump_string(
|
|
231
|
+
error_message = jv_dump_string(error_message, 0);
|
|
209
232
|
fprintf(stderr, "%s\n", jv_string_value(error_message));
|
|
210
233
|
} // else no message on stderr; use --debug-trace to see a message
|
|
211
234
|
fflush(stderr);
|
|
@@ -222,7 +245,7 @@ static int process(jq_state *jq, jv value, int flags, int dumpopts) {
|
|
|
222
245
|
fprintf(stderr, "jq: error (at %s) (not a string): %s\n",
|
|
223
246
|
jv_string_value(input_pos), jv_string_value(msg));
|
|
224
247
|
}
|
|
225
|
-
ret =
|
|
248
|
+
ret = JQ_ERROR_UNKNOWN;
|
|
226
249
|
jv_free(input_pos);
|
|
227
250
|
jv_free(msg);
|
|
228
251
|
}
|
|
@@ -236,297 +259,300 @@ static void debug_cb(void *data, jv input) {
|
|
|
236
259
|
fprintf(stderr, "\n");
|
|
237
260
|
}
|
|
238
261
|
|
|
262
|
+
static void stderr_cb(void *data, jv input) {
|
|
263
|
+
if (jv_get_kind(input) == JV_KIND_STRING) {
|
|
264
|
+
int dumpopts = *(int *)data;
|
|
265
|
+
priv_fwrite(jv_string_value(input), jv_string_length_bytes(jv_copy(input)),
|
|
266
|
+
stderr, dumpopts & JV_PRINT_ISATTY);
|
|
267
|
+
} else {
|
|
268
|
+
input = jv_dump_string(input, 0);
|
|
269
|
+
fprintf(stderr, "%s", jv_string_value(input));
|
|
270
|
+
}
|
|
271
|
+
jv_free(input);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
#ifdef WIN32
|
|
275
|
+
int umain(int argc, char* argv[]);
|
|
276
|
+
|
|
277
|
+
int wmain(int argc, wchar_t* wargv[]) {
|
|
278
|
+
size_t arg_sz;
|
|
279
|
+
char **argv = alloca(argc * sizeof(wchar_t*));
|
|
280
|
+
for (int i = 0; i < argc; i++) {
|
|
281
|
+
argv[i] = alloca((arg_sz = WideCharToMultiByte(CP_UTF8,
|
|
282
|
+
0,
|
|
283
|
+
wargv[i],
|
|
284
|
+
-1, 0, 0, 0, 0)));
|
|
285
|
+
WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, argv[i], arg_sz, 0, 0);
|
|
286
|
+
}
|
|
287
|
+
return umain(argc, argv);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
int umain(int argc, char* argv[]) {
|
|
291
|
+
#else /*}*/
|
|
239
292
|
int main(int argc, char* argv[]) {
|
|
293
|
+
#endif
|
|
240
294
|
jq_state *jq = NULL;
|
|
241
|
-
|
|
295
|
+
jq_util_input_state *input_state = NULL;
|
|
296
|
+
int ret = JQ_OK_NO_OUTPUT;
|
|
242
297
|
int compiled = 0;
|
|
243
298
|
int parser_flags = 0;
|
|
244
299
|
int nfiles = 0;
|
|
300
|
+
int last_result = -1; /* -1 = no result, 0=null or false, 1=true */
|
|
245
301
|
int badwrite;
|
|
246
|
-
|
|
247
|
-
|
|
302
|
+
int options = 0;
|
|
303
|
+
|
|
304
|
+
#ifdef HAVE_SETLOCALE
|
|
305
|
+
(void) setlocale(LC_ALL, "");
|
|
306
|
+
#endif
|
|
307
|
+
|
|
308
|
+
#ifdef __OpenBSD__
|
|
309
|
+
if (pledge("stdio rpath", NULL) == -1) {
|
|
310
|
+
perror("pledge");
|
|
311
|
+
exit(JQ_ERROR_SYSTEM);
|
|
312
|
+
}
|
|
313
|
+
#endif
|
|
248
314
|
|
|
249
315
|
#ifdef WIN32
|
|
316
|
+
jv_tsd_dtoa_ctx_init();
|
|
250
317
|
fflush(stdout);
|
|
251
318
|
fflush(stderr);
|
|
252
319
|
_setmode(fileno(stdout), _O_TEXT | _O_U8TEXT);
|
|
253
320
|
_setmode(fileno(stderr), _O_TEXT | _O_U8TEXT);
|
|
254
|
-
int wargc;
|
|
255
|
-
wchar_t **wargv = CommandLineToArgvW(GetCommandLineW(), &wargc);
|
|
256
|
-
assert(wargc == argc);
|
|
257
|
-
size_t arg_sz;
|
|
258
|
-
for (int i = 0; i < argc; i++) {
|
|
259
|
-
argv[i] = alloca((arg_sz = WideCharToMultiByte(CP_UTF8,
|
|
260
|
-
0,
|
|
261
|
-
wargv[i],
|
|
262
|
-
-1, 0, 0, 0, 0)));
|
|
263
|
-
WideCharToMultiByte(CP_UTF8, 0, wargv[i], -1, argv[i], arg_sz, 0, 0);
|
|
264
|
-
}
|
|
265
321
|
#endif
|
|
266
322
|
|
|
323
|
+
jv ARGS = jv_array(); /* positional arguments */
|
|
324
|
+
jv program_arguments = jv_object(); /* named arguments */
|
|
325
|
+
|
|
267
326
|
if (argc) progname = argv[0];
|
|
268
327
|
|
|
269
328
|
jq = jq_init();
|
|
270
329
|
if (jq == NULL) {
|
|
271
|
-
perror("
|
|
272
|
-
ret =
|
|
330
|
+
perror("jq_init");
|
|
331
|
+
ret = JQ_ERROR_SYSTEM;
|
|
273
332
|
goto out;
|
|
274
333
|
}
|
|
275
334
|
|
|
276
335
|
int dumpopts = JV_PRINT_INDENT_FLAGS(2);
|
|
277
336
|
const char* program = 0;
|
|
278
337
|
|
|
279
|
-
|
|
338
|
+
input_state = jq_util_input_init(NULL, NULL); // XXX add err_cb
|
|
280
339
|
|
|
281
340
|
int further_args_are_strings = 0;
|
|
282
341
|
int further_args_are_json = 0;
|
|
283
342
|
int args_done = 0;
|
|
284
343
|
int jq_flags = 0;
|
|
285
|
-
size_t short_opts = 0;
|
|
286
344
|
jv lib_search_paths = jv_null();
|
|
287
|
-
for (int i=1; i<argc; i
|
|
288
|
-
if (args_done) {
|
|
289
|
-
if (
|
|
345
|
+
for (int i=1; i<argc; i++) {
|
|
346
|
+
if (args_done || !isoptish(argv[i])) {
|
|
347
|
+
if (!program) {
|
|
348
|
+
program = argv[i];
|
|
349
|
+
} else if (further_args_are_strings) {
|
|
290
350
|
ARGS = jv_array_append(ARGS, jv_string(argv[i]));
|
|
291
351
|
} else if (further_args_are_json) {
|
|
292
|
-
|
|
352
|
+
jv v = jv_parse(argv[i]);
|
|
353
|
+
if (!jv_is_valid(v)) {
|
|
354
|
+
fprintf(stderr, "%s: invalid JSON text passed to --jsonargs\n", progname);
|
|
355
|
+
die();
|
|
356
|
+
}
|
|
357
|
+
ARGS = jv_array_append(ARGS, v);
|
|
293
358
|
} else {
|
|
294
359
|
jq_util_input_add_input(input_state, argv[i]);
|
|
295
360
|
nfiles++;
|
|
296
361
|
}
|
|
297
362
|
} else if (!strcmp(argv[i], "--")) {
|
|
298
|
-
if (!program) usage(2, 1);
|
|
299
363
|
args_done = 1;
|
|
300
|
-
} else if (!isoptish(argv[i])) {
|
|
301
|
-
if (program) {
|
|
302
|
-
if (further_args_are_strings) {
|
|
303
|
-
ARGS = jv_array_append(ARGS, jv_string(argv[i]));
|
|
304
|
-
} else if (further_args_are_json) {
|
|
305
|
-
ARGS = jv_array_append(ARGS, jv_parse(argv[i]));
|
|
306
|
-
} else {
|
|
307
|
-
jq_util_input_add_input(input_state, argv[i]);
|
|
308
|
-
nfiles++;
|
|
309
|
-
}
|
|
310
|
-
} else {
|
|
311
|
-
program = argv[i];
|
|
312
|
-
}
|
|
313
364
|
} else {
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
365
|
+
const char* text = argv[i];
|
|
366
|
+
int is_short;
|
|
367
|
+
// First '-' already checked by isoptish
|
|
368
|
+
if (text[1] == '-') {
|
|
369
|
+
text += 2;
|
|
370
|
+
is_short = 0;
|
|
371
|
+
} else {
|
|
372
|
+
text++;
|
|
373
|
+
is_short = 1;
|
|
374
|
+
}
|
|
375
|
+
int raw; // Temporary for --rawfile
|
|
376
|
+
|
|
377
|
+
// Parse a long option in one iteration or iterate over short options
|
|
378
|
+
while (text != NULL) {
|
|
379
|
+
if (isoption(&text, 's', "slurp", is_short)) {
|
|
380
|
+
options |= SLURP;
|
|
381
|
+
} else if (isoption(&text, 'r', "raw-output", is_short)) {
|
|
382
|
+
options |= RAW_OUTPUT;
|
|
383
|
+
} else if (isoption(&text, 0, "raw-output0", is_short)) {
|
|
384
|
+
options |= RAW_OUTPUT | RAW_NO_LF | RAW_OUTPUT0;
|
|
385
|
+
} else if (isoption(&text, 'j', "join-output", is_short)) {
|
|
386
|
+
options |= RAW_OUTPUT | RAW_NO_LF;
|
|
387
|
+
} else if (isoption(&text, 'c', "compact-output", is_short)) {
|
|
388
|
+
dumpopts &= ~(JV_PRINT_TAB | JV_PRINT_INDENT_FLAGS(7));
|
|
389
|
+
} else if (isoption(&text, 'C', "color-output", is_short)) {
|
|
390
|
+
options |= COLOR_OUTPUT;
|
|
391
|
+
} else if (isoption(&text, 'M', "monochrome-output", is_short)) {
|
|
392
|
+
options |= NO_COLOR_OUTPUT;
|
|
393
|
+
} else if (isoption(&text, 'a', "ascii-output", is_short)) {
|
|
394
|
+
options |= ASCII_OUTPUT;
|
|
395
|
+
} else if (isoption(&text, 0, "unbuffered", is_short)) {
|
|
396
|
+
options |= UNBUFFERED_OUTPUT;
|
|
397
|
+
} else if (isoption(&text, 'S', "sort-keys", is_short)) {
|
|
398
|
+
options |= SORTED_OUTPUT;
|
|
399
|
+
} else if (isoption(&text, 'R', "raw-input", is_short)) {
|
|
400
|
+
options |= RAW_INPUT;
|
|
401
|
+
} else if (isoption(&text, 'n', "null-input", is_short)) {
|
|
402
|
+
options |= PROVIDE_NULL;
|
|
403
|
+
} else if (isoption(&text, 'f', "from-file", is_short)) {
|
|
404
|
+
options |= FROM_FILE;
|
|
405
|
+
} else if (isoption(&text, 'L', "library-path", is_short)) {
|
|
406
|
+
if (jv_get_kind(lib_search_paths) == JV_KIND_NULL)
|
|
407
|
+
lib_search_paths = jv_array();
|
|
408
|
+
if (text != NULL) { // -Lname
|
|
409
|
+
lib_search_paths = jv_array_append(lib_search_paths, jq_realpath(jv_string(text)));
|
|
410
|
+
text = NULL;
|
|
411
|
+
} else if (i >= argc - 1) {
|
|
412
|
+
fprintf(stderr, "-L takes a parameter: (e.g. -L /search/path or -L/search/path)\n");
|
|
413
|
+
die();
|
|
414
|
+
} else {
|
|
415
|
+
lib_search_paths = jv_array_append(lib_search_paths, jq_realpath(jv_string(argv[i+1])));
|
|
416
|
+
i++;
|
|
417
|
+
}
|
|
418
|
+
} else if (isoption(&text, 'b', "binary", is_short)) {
|
|
419
|
+
#ifdef WIN32
|
|
420
|
+
fflush(stdout);
|
|
421
|
+
fflush(stderr);
|
|
422
|
+
_setmode(fileno(stdin), _O_BINARY);
|
|
423
|
+
_setmode(fileno(stdout), _O_BINARY);
|
|
424
|
+
_setmode(fileno(stderr), _O_BINARY);
|
|
425
|
+
#endif
|
|
426
|
+
} else if (isoption(&text, 0, "tab", is_short)) {
|
|
427
|
+
dumpopts &= ~JV_PRINT_INDENT_FLAGS(7);
|
|
428
|
+
dumpopts |= JV_PRINT_TAB | JV_PRINT_PRETTY;
|
|
429
|
+
} else if (isoption(&text, 0, "indent", is_short)) {
|
|
430
|
+
if (i >= argc - 1) {
|
|
431
|
+
fprintf(stderr, "%s: --indent takes one parameter\n", progname);
|
|
432
|
+
die();
|
|
433
|
+
}
|
|
434
|
+
dumpopts &= ~(JV_PRINT_TAB | JV_PRINT_INDENT_FLAGS(7));
|
|
435
|
+
int indent = atoi(argv[i+1]);
|
|
436
|
+
if (indent < -1 || indent > 7) {
|
|
437
|
+
fprintf(stderr, "%s: --indent takes a number between -1 and 7\n", progname);
|
|
438
|
+
die();
|
|
439
|
+
}
|
|
440
|
+
dumpopts |= JV_PRINT_INDENT_FLAGS(indent);
|
|
324
441
|
i++;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
if (
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
if (
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
options |= COLOR_OUTPUT;
|
|
343
|
-
if (!short_opts) continue;
|
|
344
|
-
}
|
|
345
|
-
if (isoption(argv[i], 'M', "monochrome-output", &short_opts)) {
|
|
346
|
-
options |= NO_COLOR_OUTPUT;
|
|
347
|
-
if (!short_opts) continue;
|
|
348
|
-
}
|
|
349
|
-
if (isoption(argv[i], 'a', "ascii-output", &short_opts)) {
|
|
350
|
-
options |= ASCII_OUTPUT;
|
|
351
|
-
if (!short_opts) continue;
|
|
352
|
-
}
|
|
353
|
-
if (isoption(argv[i], 0, "unbuffered", &short_opts)) {
|
|
354
|
-
options |= UNBUFFERED_OUTPUT;
|
|
355
|
-
continue;
|
|
356
|
-
}
|
|
357
|
-
if (isoption(argv[i], 'S', "sort-keys", &short_opts)) {
|
|
358
|
-
options |= SORTED_OUTPUT;
|
|
359
|
-
if (!short_opts) continue;
|
|
360
|
-
}
|
|
361
|
-
if (isoption(argv[i], 'R', "raw-input", &short_opts)) {
|
|
362
|
-
options |= RAW_INPUT;
|
|
363
|
-
if (!short_opts) continue;
|
|
364
|
-
}
|
|
365
|
-
if (isoption(argv[i], 'n', "null-input", &short_opts)) {
|
|
366
|
-
options |= PROVIDE_NULL;
|
|
367
|
-
if (!short_opts) continue;
|
|
368
|
-
}
|
|
369
|
-
if (isoption(argv[i], 'f', "from-file", &short_opts)) {
|
|
370
|
-
options |= FROM_FILE;
|
|
371
|
-
if (!short_opts) continue;
|
|
372
|
-
}
|
|
373
|
-
if (isoption(argv[i], 'j', "join-output", &short_opts)) {
|
|
374
|
-
options |= RAW_OUTPUT | RAW_NO_LF;
|
|
375
|
-
if (!short_opts) continue;
|
|
376
|
-
}
|
|
377
|
-
if (isoption(argv[i], 0, "tab", &short_opts)) {
|
|
378
|
-
dumpopts &= ~JV_PRINT_INDENT_FLAGS(7);
|
|
379
|
-
dumpopts |= JV_PRINT_TAB | JV_PRINT_PRETTY;
|
|
380
|
-
continue;
|
|
381
|
-
}
|
|
382
|
-
if (isoption(argv[i], 0, "indent", &short_opts)) {
|
|
383
|
-
if (i >= argc - 1) {
|
|
384
|
-
fprintf(stderr, "%s: --indent takes one parameter\n", progname);
|
|
385
|
-
die();
|
|
386
|
-
}
|
|
387
|
-
dumpopts &= ~(JV_PRINT_TAB | JV_PRINT_INDENT_FLAGS(7));
|
|
388
|
-
int indent = atoi(argv[i+1]);
|
|
389
|
-
if (indent < -1 || indent > 7) {
|
|
390
|
-
fprintf(stderr, "%s: --indent takes a number between -1 and 7\n", progname);
|
|
391
|
-
die();
|
|
392
|
-
}
|
|
393
|
-
dumpopts |= JV_PRINT_INDENT_FLAGS(indent);
|
|
394
|
-
i++;
|
|
395
|
-
continue;
|
|
396
|
-
}
|
|
397
|
-
if (isoption(argv[i], 0, "seq", &short_opts)) {
|
|
398
|
-
options |= SEQ;
|
|
399
|
-
continue;
|
|
400
|
-
}
|
|
401
|
-
if (isoption(argv[i], 0, "stream", &short_opts)) {
|
|
402
|
-
parser_flags |= JV_PARSE_STREAMING;
|
|
403
|
-
continue;
|
|
404
|
-
}
|
|
405
|
-
if (isoption(argv[i], 0, "stream-errors", &short_opts)) {
|
|
406
|
-
parser_flags |= JV_PARSE_STREAM_ERRORS;
|
|
407
|
-
continue;
|
|
408
|
-
}
|
|
409
|
-
if (isoption(argv[i], 'e', "exit-status", &short_opts)) {
|
|
410
|
-
options |= EXIT_STATUS;
|
|
411
|
-
if (!short_opts) continue;
|
|
412
|
-
}
|
|
413
|
-
// FIXME: For --arg* we should check that the varname is acceptable
|
|
414
|
-
if (isoption(argv[i], 0, "args", &short_opts)) {
|
|
415
|
-
further_args_are_strings = 1;
|
|
416
|
-
further_args_are_json = 0;
|
|
417
|
-
continue;
|
|
418
|
-
}
|
|
419
|
-
if (isoption(argv[i], 0, "jsonargs", &short_opts)) {
|
|
420
|
-
further_args_are_strings = 0;
|
|
421
|
-
further_args_are_json = 1;
|
|
422
|
-
continue;
|
|
423
|
-
}
|
|
424
|
-
if (isoption(argv[i], 0, "arg", &short_opts)) {
|
|
425
|
-
if (i >= argc - 2) {
|
|
426
|
-
fprintf(stderr, "%s: --arg takes two parameters (e.g. --arg varname value)\n", progname);
|
|
427
|
-
die();
|
|
428
|
-
}
|
|
429
|
-
if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1])))
|
|
430
|
-
program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), jv_string(argv[i+2]));
|
|
431
|
-
i += 2; // skip the next two arguments
|
|
432
|
-
continue;
|
|
433
|
-
}
|
|
434
|
-
if (isoption(argv[i], 0, "argjson", &short_opts)) {
|
|
435
|
-
if (i >= argc - 2) {
|
|
436
|
-
fprintf(stderr, "%s: --argjson takes two parameters (e.g. --argjson varname text)\n", progname);
|
|
437
|
-
die();
|
|
438
|
-
}
|
|
439
|
-
if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {
|
|
440
|
-
jv v = jv_parse(argv[i+2]);
|
|
441
|
-
if (!jv_is_valid(v)) {
|
|
442
|
-
fprintf(stderr, "%s: invalid JSON text passed to --argjson\n", progname);
|
|
442
|
+
} else if (isoption(&text, 0, "seq", is_short)) {
|
|
443
|
+
options |= SEQ;
|
|
444
|
+
} else if (isoption(&text, 0, "stream", is_short)) {
|
|
445
|
+
parser_flags |= JV_PARSE_STREAMING;
|
|
446
|
+
} else if (isoption(&text, 0, "stream-errors", is_short)) {
|
|
447
|
+
parser_flags |= JV_PARSE_STREAMING | JV_PARSE_STREAM_ERRORS;
|
|
448
|
+
} else if (isoption(&text, 'e', "exit-status", is_short)) {
|
|
449
|
+
options |= EXIT_STATUS;
|
|
450
|
+
} else if (isoption(&text, 0, "args", is_short)) {
|
|
451
|
+
further_args_are_strings = 1;
|
|
452
|
+
further_args_are_json = 0;
|
|
453
|
+
} else if (isoption(&text, 0, "jsonargs", is_short)) {
|
|
454
|
+
further_args_are_strings = 0;
|
|
455
|
+
further_args_are_json = 1;
|
|
456
|
+
} else if (isoption(&text, 0, "arg", is_short)) {
|
|
457
|
+
if (i >= argc - 2) {
|
|
458
|
+
fprintf(stderr, "%s: --arg takes two parameters (e.g. --arg varname value)\n", progname);
|
|
443
459
|
die();
|
|
444
460
|
}
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
461
|
+
if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1])))
|
|
462
|
+
program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), jv_string(argv[i+2]));
|
|
463
|
+
i += 2; // skip the next two arguments
|
|
464
|
+
} else if (isoption(&text, 0, "argjson", is_short)) {
|
|
465
|
+
if (i >= argc - 2) {
|
|
466
|
+
fprintf(stderr, "%s: --argjson takes two parameters (e.g. --argjson varname text)\n", progname);
|
|
467
|
+
die();
|
|
468
|
+
}
|
|
469
|
+
if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {
|
|
470
|
+
jv v = jv_parse(argv[i+2]);
|
|
471
|
+
if (!jv_is_valid(v)) {
|
|
472
|
+
fprintf(stderr, "%s: invalid JSON text passed to --argjson\n", progname);
|
|
473
|
+
die();
|
|
474
|
+
}
|
|
475
|
+
program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), v);
|
|
476
|
+
}
|
|
477
|
+
i += 2; // skip the next two arguments
|
|
478
|
+
} else if ((raw = isoption(&text, 0, "rawfile", is_short)) ||
|
|
479
|
+
isoption(&text, 0, "slurpfile", is_short)) {
|
|
480
|
+
const char *which = raw ? "rawfile" : "slurpfile";
|
|
481
|
+
if (i >= argc - 2) {
|
|
482
|
+
fprintf(stderr, "%s: --%s takes two parameters (e.g. --%s varname filename)\n", progname, which, which);
|
|
483
|
+
die();
|
|
484
|
+
}
|
|
485
|
+
if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {
|
|
486
|
+
jv data = jv_load_file(argv[i+2], raw);
|
|
487
|
+
if (!jv_is_valid(data)) {
|
|
488
|
+
data = jv_invalid_get_msg(data);
|
|
489
|
+
fprintf(stderr, "%s: Bad JSON in --%s %s %s: %s\n", progname, which,
|
|
490
|
+
argv[i+1], argv[i+2], jv_string_value(data));
|
|
491
|
+
jv_free(data);
|
|
492
|
+
ret = JQ_ERROR_SYSTEM;
|
|
493
|
+
goto out;
|
|
494
|
+
}
|
|
495
|
+
program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), data);
|
|
474
496
|
}
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
497
|
+
i += 2; // skip the next two arguments
|
|
498
|
+
} else if (isoption(&text, 0, "debug-dump-disasm", is_short)) {
|
|
499
|
+
options |= DUMP_DISASM;
|
|
500
|
+
} else if (isoption(&text, 0, "debug-trace=all", is_short)) {
|
|
501
|
+
jq_flags |= JQ_DEBUG_TRACE_ALL;
|
|
502
|
+
} else if (isoption(&text, 0, "debug-trace", is_short)) {
|
|
503
|
+
jq_flags |= JQ_DEBUG_TRACE;
|
|
504
|
+
} else if (isoption(&text, 'h', "help", is_short)) {
|
|
505
|
+
usage(0, 0);
|
|
506
|
+
} else if (isoption(&text, 'V', "version", is_short)) {
|
|
507
|
+
printf("jq-%s\n", JQ_VERSION);
|
|
508
|
+
ret = JQ_OK;
|
|
509
|
+
goto out;
|
|
510
|
+
} else if (isoption(&text, 0, "build-configuration", is_short)) {
|
|
511
|
+
printf("%s\n", JQ_CONFIG);
|
|
512
|
+
ret = JQ_OK;
|
|
513
|
+
goto out;
|
|
514
|
+
} else if (isoption(&text, 0, "run-tests", is_short)) {
|
|
515
|
+
i++;
|
|
516
|
+
// XXX Pass program_arguments, even a whole jq_state *, through;
|
|
517
|
+
// could be useful for testing
|
|
518
|
+
ret = jq_testsuite(lib_search_paths,
|
|
519
|
+
(options & DUMP_DISASM) || (jq_flags & JQ_DEBUG_TRACE),
|
|
520
|
+
argc - i, argv + i);
|
|
521
|
+
goto out;
|
|
522
|
+
} else {
|
|
523
|
+
if (is_short) {
|
|
524
|
+
fprintf(stderr, "%s: Unknown option -%c\n", progname, text[0]);
|
|
525
|
+
} else {
|
|
526
|
+
fprintf(stderr, "%s: Unknown option --%s\n", progname, text);
|
|
527
|
+
}
|
|
528
|
+
die();
|
|
479
529
|
}
|
|
480
|
-
i += 2; // skip the next two arguments
|
|
481
|
-
continue;
|
|
482
|
-
}
|
|
483
|
-
if (isoption(argv[i], 0, "debug-dump-disasm", &short_opts)) {
|
|
484
|
-
options |= DUMP_DISASM;
|
|
485
|
-
continue;
|
|
486
|
-
}
|
|
487
|
-
if (isoption(argv[i], 0, "debug-trace=all", &short_opts)) {
|
|
488
|
-
jq_flags |= JQ_DEBUG_TRACE_ALL;
|
|
489
|
-
if (!short_opts) continue;
|
|
490
|
-
}
|
|
491
|
-
if (isoption(argv[i], 0, "debug-trace", &short_opts)) {
|
|
492
|
-
jq_flags |= JQ_DEBUG_TRACE;
|
|
493
|
-
continue;
|
|
494
|
-
}
|
|
495
|
-
if (isoption(argv[i], 'h', "help", &short_opts)) {
|
|
496
|
-
usage(0, 0);
|
|
497
|
-
if (!short_opts) continue;
|
|
498
|
-
}
|
|
499
|
-
if (isoption(argv[i], 'V', "version", &short_opts)) {
|
|
500
|
-
printf("jq-%s\n", JQ_VERSION);
|
|
501
|
-
ret = 0;
|
|
502
|
-
goto out;
|
|
503
|
-
}
|
|
504
|
-
if (isoption(argv[i], 0, "run-tests", &short_opts)) {
|
|
505
|
-
i++;
|
|
506
|
-
// XXX Pass program_arguments, even a whole jq_state *, through;
|
|
507
|
-
// could be useful for testing
|
|
508
|
-
ret = jq_testsuite(lib_search_paths,
|
|
509
|
-
(options & DUMP_DISASM) || (jq_flags & JQ_DEBUG_TRACE),
|
|
510
|
-
argc - i, argv + i);
|
|
511
|
-
goto out;
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
// check for unknown options... if this argument was a short option
|
|
515
|
-
if (strlen(argv[i]) != short_opts + 1) {
|
|
516
|
-
fprintf(stderr, "%s: Unknown option %s\n", progname, argv[i]);
|
|
517
|
-
die();
|
|
518
530
|
}
|
|
519
531
|
}
|
|
520
532
|
}
|
|
521
533
|
|
|
522
534
|
#ifdef USE_ISATTY
|
|
523
535
|
if (isatty(STDOUT_FILENO)) {
|
|
524
|
-
dumpopts |= JV_PRINT_ISATTY;
|
|
525
536
|
#ifndef WIN32
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
537
|
+
dumpopts |= JV_PRINT_ISATTY | JV_PRINT_COLOR;
|
|
538
|
+
#else
|
|
539
|
+
/* Verify we actually have the console, as the NUL device is also regarded as
|
|
540
|
+
tty. Windows can handle color if ANSICON (or ConEmu) is installed, or
|
|
541
|
+
Windows 10 supports the virtual terminal */
|
|
542
|
+
DWORD mode;
|
|
543
|
+
HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);
|
|
544
|
+
if (GetConsoleMode(con, &mode)) {
|
|
545
|
+
dumpopts |= JV_PRINT_ISATTY;
|
|
546
|
+
if (getenv("ANSICON") != NULL ||
|
|
547
|
+
SetConsoleMode(con, mode | 4/*ENABLE_VIRTUAL_TERMINAL_PROCESSING*/))
|
|
548
|
+
dumpopts |= JV_PRINT_COLOR;
|
|
549
|
+
}
|
|
529
550
|
#endif
|
|
551
|
+
if (dumpopts & JV_PRINT_COLOR) {
|
|
552
|
+
char *no_color = getenv("NO_COLOR");
|
|
553
|
+
if (no_color != NULL && no_color[0] != '\0')
|
|
554
|
+
dumpopts &= ~JV_PRINT_COLOR;
|
|
555
|
+
}
|
|
530
556
|
}
|
|
531
557
|
#endif
|
|
532
558
|
if (options & SORTED_OUTPUT) dumpopts |= JV_PRINT_SORTED;
|
|
@@ -541,13 +567,13 @@ int main(int argc, char* argv[]) {
|
|
|
541
567
|
// Default search path list
|
|
542
568
|
lib_search_paths = JV_ARRAY(jv_string("~/.jq"),
|
|
543
569
|
jv_string("$ORIGIN/../lib/jq"),
|
|
544
|
-
jv_string("$ORIGIN
|
|
570
|
+
jv_string("$ORIGIN/../lib"));
|
|
545
571
|
}
|
|
546
572
|
jq_set_attr(jq, jv_string("JQ_LIBRARY_PATH"), lib_search_paths);
|
|
547
573
|
|
|
548
574
|
char *origin = strdup(argv[0]);
|
|
549
575
|
if (origin == NULL) {
|
|
550
|
-
fprintf(stderr, "
|
|
576
|
+
fprintf(stderr, "jq: error: out of memory\n");
|
|
551
577
|
exit(1);
|
|
552
578
|
}
|
|
553
579
|
jq_set_attr(jq, jv_string("JQ_ORIGIN"), jv_string(dirname(origin)));
|
|
@@ -559,7 +585,7 @@ int main(int argc, char* argv[]) {
|
|
|
559
585
|
jq_set_attr(jq, jv_string("VERSION_DIR"), jv_string_fmt("%.*s-master", (int)(strchr(JQ_VERSION, '-') - JQ_VERSION), JQ_VERSION));
|
|
560
586
|
|
|
561
587
|
#ifdef USE_ISATTY
|
|
562
|
-
if (!program && (!isatty(STDOUT_FILENO) || !isatty(STDIN_FILENO)))
|
|
588
|
+
if (!program && !(options & FROM_FILE) && (!isatty(STDOUT_FILENO) || !isatty(STDIN_FILENO)))
|
|
563
589
|
program = ".";
|
|
564
590
|
#endif
|
|
565
591
|
|
|
@@ -577,14 +603,18 @@ int main(int argc, char* argv[]) {
|
|
|
577
603
|
data = jv_invalid_get_msg(data);
|
|
578
604
|
fprintf(stderr, "%s: %s\n", progname, jv_string_value(data));
|
|
579
605
|
jv_free(data);
|
|
580
|
-
ret =
|
|
606
|
+
ret = JQ_ERROR_SYSTEM;
|
|
581
607
|
goto out;
|
|
582
608
|
}
|
|
583
609
|
jq_set_attr(jq, jv_string("PROGRAM_ORIGIN"), jq_realpath(jv_string(dirname(program_origin))));
|
|
584
610
|
ARGS = JV_OBJECT(jv_string("positional"), ARGS,
|
|
585
611
|
jv_string("named"), jv_copy(program_arguments));
|
|
586
612
|
program_arguments = jv_object_set(program_arguments, jv_string("ARGS"), jv_copy(ARGS));
|
|
587
|
-
|
|
613
|
+
if (!jv_object_has(jv_copy(program_arguments), jv_string("JQ_BUILD_CONFIGURATION")))
|
|
614
|
+
program_arguments = jv_object_set(program_arguments,
|
|
615
|
+
jv_string("JQ_BUILD_CONFIGURATION"),
|
|
616
|
+
jv_string(JQ_CONFIG)); /* named arguments */
|
|
617
|
+
compiled = jq_compile_args(jq, jv_string_value(data), jv_copy(program_arguments));
|
|
588
618
|
free(program_origin);
|
|
589
619
|
jv_free(data);
|
|
590
620
|
} else {
|
|
@@ -592,10 +622,14 @@ int main(int argc, char* argv[]) {
|
|
|
592
622
|
ARGS = JV_OBJECT(jv_string("positional"), ARGS,
|
|
593
623
|
jv_string("named"), jv_copy(program_arguments));
|
|
594
624
|
program_arguments = jv_object_set(program_arguments, jv_string("ARGS"), jv_copy(ARGS));
|
|
625
|
+
if (!jv_object_has(jv_copy(program_arguments), jv_string("JQ_BUILD_CONFIGURATION")))
|
|
626
|
+
program_arguments = jv_object_set(program_arguments,
|
|
627
|
+
jv_string("JQ_BUILD_CONFIGURATION"),
|
|
628
|
+
jv_string(JQ_CONFIG)); /* named arguments */
|
|
595
629
|
compiled = jq_compile_args(jq, program, jv_copy(program_arguments));
|
|
596
630
|
}
|
|
597
631
|
if (!compiled){
|
|
598
|
-
ret =
|
|
632
|
+
ret = JQ_ERROR_COMPILE;
|
|
599
633
|
goto out;
|
|
600
634
|
}
|
|
601
635
|
|
|
@@ -618,51 +652,65 @@ int main(int argc, char* argv[]) {
|
|
|
618
652
|
// Let jq program call `debug` builtin and have that go somewhere
|
|
619
653
|
jq_set_debug_cb(jq, debug_cb, &dumpopts);
|
|
620
654
|
|
|
655
|
+
// Let jq program call `stderr` builtin and have that go somewhere
|
|
656
|
+
jq_set_stderr_cb(jq, stderr_cb, &dumpopts);
|
|
657
|
+
|
|
621
658
|
if (nfiles == 0)
|
|
622
659
|
jq_util_input_add_input(input_state, "-");
|
|
623
660
|
|
|
624
661
|
if (options & PROVIDE_NULL) {
|
|
625
|
-
ret = process(jq, jv_null(), jq_flags, dumpopts);
|
|
662
|
+
ret = process(jq, jv_null(), jq_flags, dumpopts, options);
|
|
626
663
|
} else {
|
|
627
664
|
jv value;
|
|
628
665
|
while (jq_util_input_errors(input_state) == 0 &&
|
|
629
666
|
(jv_is_valid((value = jq_util_input_next_input(input_state))) || jv_invalid_has_msg(jv_copy(value)))) {
|
|
630
667
|
if (jv_is_valid(value)) {
|
|
631
|
-
ret = process(jq, value, jq_flags, dumpopts);
|
|
668
|
+
ret = process(jq, value, jq_flags, dumpopts, options);
|
|
669
|
+
if (ret <= 0 && ret != JQ_OK_NO_OUTPUT)
|
|
670
|
+
last_result = (ret != JQ_OK_NULL_KIND);
|
|
671
|
+
if (jq_halted(jq))
|
|
672
|
+
break;
|
|
632
673
|
continue;
|
|
633
674
|
}
|
|
634
675
|
|
|
635
676
|
// Parse error
|
|
636
677
|
jv msg = jv_invalid_get_msg(value);
|
|
637
678
|
if (!(options & SEQ)) {
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
fprintf(stderr, "parse error: %s\n", jv_string_value(msg));
|
|
679
|
+
ret = JQ_ERROR_UNKNOWN;
|
|
680
|
+
fprintf(stderr, "jq: parse error: %s\n", jv_string_value(msg));
|
|
641
681
|
jv_free(msg);
|
|
642
682
|
break;
|
|
643
683
|
}
|
|
644
|
-
|
|
684
|
+
// --seq -> errors are not fatal
|
|
685
|
+
fprintf(stderr, "jq: ignoring parse error: %s\n", jv_string_value(msg));
|
|
645
686
|
jv_free(msg);
|
|
646
687
|
}
|
|
647
688
|
}
|
|
648
689
|
|
|
649
690
|
if (jq_util_input_errors(input_state) != 0)
|
|
650
|
-
ret =
|
|
691
|
+
ret = JQ_ERROR_SYSTEM;
|
|
651
692
|
|
|
652
693
|
out:
|
|
653
694
|
badwrite = ferror(stdout);
|
|
654
695
|
if (fclose(stdout)!=0 || badwrite) {
|
|
655
|
-
fprintf(stderr,"
|
|
656
|
-
ret =
|
|
696
|
+
fprintf(stderr,"jq: error: writing output failed: %s\n", strerror(errno));
|
|
697
|
+
ret = JQ_ERROR_SYSTEM;
|
|
657
698
|
}
|
|
658
699
|
|
|
659
700
|
jv_free(ARGS);
|
|
660
701
|
jv_free(program_arguments);
|
|
661
702
|
jq_util_input_free(&input_state);
|
|
662
703
|
jq_teardown(&jq);
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
704
|
+
|
|
705
|
+
if (options & EXIT_STATUS) {
|
|
706
|
+
if (ret != JQ_OK_NO_OUTPUT)
|
|
707
|
+
jq_exit_with_status(ret);
|
|
708
|
+
else
|
|
709
|
+
switch (last_result) {
|
|
710
|
+
case -1: jq_exit_with_status(JQ_OK_NO_OUTPUT);
|
|
711
|
+
case 0: jq_exit_with_status(JQ_OK_NULL_KIND);
|
|
712
|
+
default: jq_exit_with_status(JQ_OK);
|
|
713
|
+
}
|
|
714
|
+
} else
|
|
715
|
+
jq_exit(ret);
|
|
668
716
|
}
|