@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/util.c
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
/*-
|
|
2
|
+
* Parts (strptime()) Copyright (c) 1997, 1998, 2005, 2008 The NetBSD Foundation, Inc.
|
|
3
|
+
* All rights reserved.
|
|
4
|
+
*
|
|
5
|
+
* This code was contributed to The NetBSD Foundation by Klaus Klein.
|
|
6
|
+
* Heavily optimised by David Laight
|
|
7
|
+
*
|
|
8
|
+
* Redistribution and use in source and binary forms, with or without
|
|
9
|
+
* modification, are permitted provided that the following conditions
|
|
10
|
+
* are met:
|
|
11
|
+
* 1. Redistributions of source code must retain the above copyright
|
|
12
|
+
* notice, this list of conditions and the following disclaimer.
|
|
13
|
+
* 2. Redistributions in binary form must reproduce the above copyright
|
|
14
|
+
* notice, this list of conditions and the following disclaimer in the
|
|
15
|
+
* documentation and/or other materials provided with the distribution.
|
|
16
|
+
*
|
|
17
|
+
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
18
|
+
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
19
|
+
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
20
|
+
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
21
|
+
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
22
|
+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
23
|
+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
24
|
+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
25
|
+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
26
|
+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
27
|
+
* POSSIBILITY OF SUCH DAMAGE.
|
|
28
|
+
*/
|
|
5
29
|
|
|
6
30
|
#include <sys/types.h>
|
|
7
31
|
#include <sys/stat.h>
|
|
@@ -28,9 +52,6 @@ extern "C"
|
|
|
28
52
|
void *alloca (size_t);
|
|
29
53
|
# endif
|
|
30
54
|
#endif
|
|
31
|
-
#ifndef WIN32
|
|
32
|
-
#include <pwd.h>
|
|
33
|
-
#endif
|
|
34
55
|
|
|
35
56
|
#ifdef WIN32
|
|
36
57
|
#include <windows.h>
|
|
@@ -58,27 +79,6 @@ FILE *fopen(const char *fname, const char *mode) {
|
|
|
58
79
|
}
|
|
59
80
|
#endif
|
|
60
81
|
|
|
61
|
-
#ifndef HAVE_MKSTEMP
|
|
62
|
-
int mkstemp(char *template) {
|
|
63
|
-
size_t len = strlen(template);
|
|
64
|
-
int tries=5;
|
|
65
|
-
int fd;
|
|
66
|
-
|
|
67
|
-
// mktemp() truncates template when it fails
|
|
68
|
-
char *s = alloca(len + 1);
|
|
69
|
-
assert(s != NULL);
|
|
70
|
-
strcpy(s, template);
|
|
71
|
-
|
|
72
|
-
do {
|
|
73
|
-
// Restore template
|
|
74
|
-
strcpy(template, s);
|
|
75
|
-
(void) mktemp(template);
|
|
76
|
-
fd = open(template, O_CREAT | O_EXCL | O_RDWR, 0600);
|
|
77
|
-
} while (fd == -1 && tries-- > 0);
|
|
78
|
-
return fd;
|
|
79
|
-
}
|
|
80
|
-
#endif
|
|
81
|
-
|
|
82
82
|
jv expand_path(jv path) {
|
|
83
83
|
assert(jv_get_kind(path) == JV_KIND_STRING);
|
|
84
84
|
const char *pstr = jv_string_value(path);
|
|
@@ -103,20 +103,16 @@ jv get_home() {
|
|
|
103
103
|
char *home = getenv("HOME");
|
|
104
104
|
if (!home) {
|
|
105
105
|
#ifndef WIN32
|
|
106
|
-
|
|
107
|
-
if (pwd)
|
|
108
|
-
ret = jv_string(pwd->pw_dir);
|
|
109
|
-
else
|
|
110
|
-
ret = jv_invalid_with_msg(jv_string("Could not find home directory."));
|
|
106
|
+
ret = jv_invalid_with_msg(jv_string("Could not find home directory."));
|
|
111
107
|
#else
|
|
112
108
|
home = getenv("USERPROFILE");
|
|
113
109
|
if (!home) {
|
|
114
|
-
char *hd = getenv("HOMEDRIVE");
|
|
115
|
-
if (!hd) hd = "";
|
|
116
110
|
home = getenv("HOMEPATH");
|
|
117
111
|
if (!home) {
|
|
118
112
|
ret = jv_invalid_with_msg(jv_string("Could not find home directory."));
|
|
119
113
|
} else {
|
|
114
|
+
const char *hd = getenv("HOMEDRIVE");
|
|
115
|
+
if (!hd) hd = "";
|
|
120
116
|
ret = jv_string_fmt("%s%s",hd,home);
|
|
121
117
|
}
|
|
122
118
|
} else {
|
|
@@ -208,20 +204,11 @@ jq_util_input_state *jq_util_input_init(jq_util_msg_cb err_cb, void *err_cb_data
|
|
|
208
204
|
err_cb = fprinter;
|
|
209
205
|
err_cb_data = stderr;
|
|
210
206
|
}
|
|
211
|
-
jq_util_input_state *new_state =
|
|
212
|
-
memset(new_state, 0, sizeof(*new_state));
|
|
207
|
+
jq_util_input_state *new_state = jv_mem_calloc(1, sizeof(*new_state));
|
|
213
208
|
new_state->err_cb = err_cb;
|
|
214
209
|
new_state->err_cb_data = err_cb_data;
|
|
215
|
-
new_state->parser = NULL;
|
|
216
|
-
new_state->current_input = NULL;
|
|
217
|
-
new_state->files = NULL;
|
|
218
|
-
new_state->nfiles = 0;
|
|
219
|
-
new_state->curr_file = 0;
|
|
220
210
|
new_state->slurped = jv_invalid();
|
|
221
|
-
new_state->buf[0] = 0;
|
|
222
|
-
new_state->buf_valid_len = 0;
|
|
223
211
|
new_state->current_filename = jv_invalid();
|
|
224
|
-
new_state->current_line = 0;
|
|
225
212
|
|
|
226
213
|
return new_state;
|
|
227
214
|
}
|
|
@@ -275,7 +262,7 @@ static int jq_util_input_read_more(jq_util_input_state *state) {
|
|
|
275
262
|
// System-level input error on the stream. It will be closed (below).
|
|
276
263
|
// TODO: report it. Can't use 'state->err_cb()' as it is hard-coded for
|
|
277
264
|
// 'open' related problems.
|
|
278
|
-
fprintf(stderr,"
|
|
265
|
+
fprintf(stderr,"jq: error: %s\n", strerror(errno));
|
|
279
266
|
}
|
|
280
267
|
if (state->current_input) {
|
|
281
268
|
if (state->current_input == stdin) {
|
|
@@ -309,7 +296,7 @@ static int jq_util_input_read_more(jq_util_input_state *state) {
|
|
|
309
296
|
state->buf_valid_len = 0;
|
|
310
297
|
if (state->current_input) {
|
|
311
298
|
char *res;
|
|
312
|
-
memset(state->buf,
|
|
299
|
+
memset(state->buf, 0xff, sizeof(state->buf));
|
|
313
300
|
|
|
314
301
|
while (!(res = fgets(state->buf, sizeof(state->buf), state->current_input)) &&
|
|
315
302
|
ferror(state->current_input) && errno == EINTR)
|
|
@@ -334,20 +321,22 @@ static int jq_util_input_read_more(jq_util_input_state *state) {
|
|
|
334
321
|
size_t i;
|
|
335
322
|
|
|
336
323
|
/*
|
|
337
|
-
* XXX We
|
|
324
|
+
* XXX We don't know how many bytes we've read!
|
|
338
325
|
*
|
|
339
326
|
* We can't use getline() because there need not be any newlines
|
|
340
327
|
* in the input. The only entirely correct choices are: use
|
|
341
328
|
* fgetc() or fread(). Using fread() will complicate buffer
|
|
342
329
|
* management here.
|
|
343
330
|
*
|
|
344
|
-
* For now we
|
|
331
|
+
* For now we check how much fgets() read by scanning backwards for the
|
|
332
|
+
* terminating '\0'. This only works because we previously memset our
|
|
333
|
+
* buffer with something nonzero.
|
|
345
334
|
*/
|
|
346
|
-
for (
|
|
347
|
-
if (state->buf[i]
|
|
348
|
-
|
|
335
|
+
for (i = sizeof(state->buf) - 1; i > 0; i--) {
|
|
336
|
+
if (state->buf[i] == '\0')
|
|
337
|
+
break;
|
|
349
338
|
}
|
|
350
|
-
state->buf_valid_len =
|
|
339
|
+
state->buf_valid_len = i;
|
|
351
340
|
} else if (p == NULL) {
|
|
352
341
|
state->buf_valid_len = sizeof(state->buf) - 1;
|
|
353
342
|
} else {
|
|
@@ -436,8 +425,6 @@ jv jq_util_input_next_input(jq_util_input_state *state) {
|
|
|
436
425
|
} else {
|
|
437
426
|
if (jv_parser_remaining(state->parser) == 0) {
|
|
438
427
|
is_last = jq_util_input_read_more(state);
|
|
439
|
-
if (is_last && state->buf_valid_len == 0)
|
|
440
|
-
value = jv_invalid();
|
|
441
428
|
jv_parser_set_buf(state->parser, state->buf, state->buf_valid_len, !is_last);
|
|
442
429
|
}
|
|
443
430
|
value = jv_parser_next(state->parser);
|
|
@@ -463,3 +450,815 @@ jv jq_util_input_next_input(jq_util_input_state *state) {
|
|
|
463
450
|
}
|
|
464
451
|
return value;
|
|
465
452
|
}
|
|
453
|
+
|
|
454
|
+
#ifndef HAVE_STRPTIME
|
|
455
|
+
/* http://cvsweb.netbsd.org/bsdweb.cgi/~checkout~/src/lib/libc/time/strptime.c?only_with_tag=HEAD
|
|
456
|
+
* NetBSD implementation strptime().
|
|
457
|
+
* Format description: https://netbsd.gw.com/cgi-bin/man-cgi?strptime+3+NetBSD-current
|
|
458
|
+
* Adapted by https://github.com/res2001 (https://github.com/res2001/strptime).
|
|
459
|
+
*/
|
|
460
|
+
|
|
461
|
+
#include <ctype.h>
|
|
462
|
+
#include <string.h>
|
|
463
|
+
#include <time.h>
|
|
464
|
+
#include <stdint.h>
|
|
465
|
+
|
|
466
|
+
static const unsigned char *conv_num(const unsigned char *, int *, unsigned int, unsigned int);
|
|
467
|
+
static const unsigned char *find_string(const unsigned char *, int *, const char * const *, const char * const *, int);
|
|
468
|
+
|
|
469
|
+
/*
|
|
470
|
+
* We do not implement alternate representations. However, we always
|
|
471
|
+
* check whether a given modifier is allowed for a certain conversion.
|
|
472
|
+
*/
|
|
473
|
+
#define ALT_E 0x01
|
|
474
|
+
#define ALT_O 0x02
|
|
475
|
+
#define LEGAL_ALT(x) { if (alt_format & ~(x)) return NULL; }
|
|
476
|
+
|
|
477
|
+
#define TM_YEAR_BASE 1900
|
|
478
|
+
|
|
479
|
+
#define TM_SUNDAY 0
|
|
480
|
+
#define TM_MONDAY 1
|
|
481
|
+
#define TM_TUESDAY 2
|
|
482
|
+
#define TM_WEDNESDAY 3
|
|
483
|
+
#define TM_THURSDAY 4
|
|
484
|
+
#define TM_FRIDAY 5
|
|
485
|
+
#define TM_SATURDAY 6
|
|
486
|
+
|
|
487
|
+
#define S_YEAR (1 << 0)
|
|
488
|
+
#define S_MON (1 << 1)
|
|
489
|
+
#define S_YDAY (1 << 2)
|
|
490
|
+
#define S_MDAY (1 << 3)
|
|
491
|
+
#define S_WDAY (1 << 4)
|
|
492
|
+
#define S_HOUR (1 << 5)
|
|
493
|
+
|
|
494
|
+
#define HAVE_MDAY(s) (s & S_MDAY)
|
|
495
|
+
#define HAVE_MON(s) (s & S_MON)
|
|
496
|
+
#define HAVE_WDAY(s) (s & S_WDAY)
|
|
497
|
+
#define HAVE_YDAY(s) (s & S_YDAY)
|
|
498
|
+
#define HAVE_YEAR(s) (s & S_YEAR)
|
|
499
|
+
#define HAVE_HOUR(s) (s & S_HOUR)
|
|
500
|
+
|
|
501
|
+
#define SECSPERMIN 60
|
|
502
|
+
#define MINSPERHOUR 60
|
|
503
|
+
#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR)
|
|
504
|
+
#define HOURSPERDAY 24
|
|
505
|
+
|
|
506
|
+
#define HERE_D_T_FMT "%a %b %e %H:%M:%S %Y"
|
|
507
|
+
#define HERE_D_FMT "%y/%m/%d"
|
|
508
|
+
#define HERE_T_FMT_AMPM "%I:%M:%S %p"
|
|
509
|
+
#define HERE_T_FMT "%H:%M:%S"
|
|
510
|
+
|
|
511
|
+
#define isleap(y) (((y) % 4) == 0 && (((y) % 100) != 0 || ((y) % 400) == 0))
|
|
512
|
+
|
|
513
|
+
/*
|
|
514
|
+
** Since everything in isleap is modulo 400 (or a factor of 400), we know that
|
|
515
|
+
** isleap(y) == isleap(y % 400)
|
|
516
|
+
** and so
|
|
517
|
+
** isleap(a + b) == isleap((a + b) % 400)
|
|
518
|
+
** or
|
|
519
|
+
** isleap(a + b) == isleap(a % 400 + b % 400)
|
|
520
|
+
** This is true even if % means modulo rather than Fortran remainder
|
|
521
|
+
** (which is allowed by C89 but not by C99 or later).
|
|
522
|
+
** We use this to avoid addition overflow problems.
|
|
523
|
+
*/
|
|
524
|
+
|
|
525
|
+
#define isleap_sum(a, b) isleap((a) % 400 + (b) % 400)
|
|
526
|
+
|
|
527
|
+
#ifdef _MSC_VER
|
|
528
|
+
#define tzname _tzname
|
|
529
|
+
#define strncasecmp _strnicmp
|
|
530
|
+
#endif
|
|
531
|
+
|
|
532
|
+
#ifdef TM_ZONE
|
|
533
|
+
static char* utc = "UTC";
|
|
534
|
+
#endif
|
|
535
|
+
/* RFC-822/RFC-2822 */
|
|
536
|
+
static const char *const nast[] = {
|
|
537
|
+
"EST", "CST", "MST", "PST", "\0\0\0"
|
|
538
|
+
};
|
|
539
|
+
static const char *const nadt[] = {
|
|
540
|
+
"EDT", "CDT", "MDT", "PDT", "\0\0\0"
|
|
541
|
+
};
|
|
542
|
+
static const char *const weekday_name[] =
|
|
543
|
+
{
|
|
544
|
+
"Sunday", "Monday", "Tuesday", "Wednesday",
|
|
545
|
+
"Thursday", "Friday", "Saturday"
|
|
546
|
+
};
|
|
547
|
+
static const char *const ab_weekday_name[] =
|
|
548
|
+
{
|
|
549
|
+
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
|
|
550
|
+
};
|
|
551
|
+
static const char *const month_name[] =
|
|
552
|
+
{
|
|
553
|
+
"January", "February", "March", "April", "May", "June",
|
|
554
|
+
"July", "August", "September", "October", "November", "December"
|
|
555
|
+
};
|
|
556
|
+
static const char *const ab_month_name[] =
|
|
557
|
+
{
|
|
558
|
+
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
|
|
559
|
+
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
|
|
560
|
+
};
|
|
561
|
+
static const char *const am_pm[] = {"AM", "PM"};
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
/*
|
|
565
|
+
* Table to determine the ordinal date for the start of a month.
|
|
566
|
+
* Ref: http://en.wikipedia.org/wiki/ISO_week_date
|
|
567
|
+
*/
|
|
568
|
+
static const int start_of_month[2][13] = {
|
|
569
|
+
/* non-leap year */
|
|
570
|
+
{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365 },
|
|
571
|
+
/* leap year */
|
|
572
|
+
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
|
|
573
|
+
};
|
|
574
|
+
|
|
575
|
+
/*
|
|
576
|
+
* Calculate the week day of the first day of a year. Valid for
|
|
577
|
+
* the Gregorian calendar, which began Sept 14, 1752 in the UK
|
|
578
|
+
* and its colonies. Ref:
|
|
579
|
+
* http://en.wikipedia.org/wiki/Determination_of_the_day_of_the_week
|
|
580
|
+
*/
|
|
581
|
+
|
|
582
|
+
static int
|
|
583
|
+
first_wday_of(int yr)
|
|
584
|
+
{
|
|
585
|
+
return ((2 * (3 - (yr / 100) % 4)) + (yr % 100) + ((yr % 100) / 4) +
|
|
586
|
+
(isleap(yr) ? 6 : 0) + 1) % 7;
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
#define delim(p) ((p) == '\0' || isspace((unsigned char)(p)))
|
|
590
|
+
|
|
591
|
+
static int
|
|
592
|
+
fromzone(const unsigned char **bp, struct tm *tm, int mandatory)
|
|
593
|
+
{
|
|
594
|
+
// timezone_t tz;
|
|
595
|
+
char buf[512], *p;
|
|
596
|
+
const unsigned char *rp;
|
|
597
|
+
|
|
598
|
+
for (p = buf, rp = *bp; !delim(*rp) && p < &buf[sizeof(buf) - 1]; rp++)
|
|
599
|
+
*p++ = *rp;
|
|
600
|
+
*p = '\0';
|
|
601
|
+
|
|
602
|
+
if (mandatory)
|
|
603
|
+
*bp = rp;
|
|
604
|
+
if (!isalnum((unsigned char)*buf))
|
|
605
|
+
return 0;
|
|
606
|
+
// tz = tzalloc(buf);
|
|
607
|
+
// if (tz == NULL)
|
|
608
|
+
// return 0;
|
|
609
|
+
|
|
610
|
+
*bp = rp;
|
|
611
|
+
tm->tm_isdst = 0; /* XXX */
|
|
612
|
+
#ifdef TM_GMTOFF
|
|
613
|
+
tm->TM_GMTOFF = tzgetgmtoff(tz, tm->tm_isdst);
|
|
614
|
+
#endif
|
|
615
|
+
#ifdef TM_ZONE
|
|
616
|
+
// Can't use tzgetname() here because we are going to free()
|
|
617
|
+
tm->TM_ZONE = NULL; /* XXX */
|
|
618
|
+
#endif
|
|
619
|
+
// tzfree(tz);
|
|
620
|
+
return 1;
|
|
621
|
+
}
|
|
622
|
+
|
|
623
|
+
char* strptime(const char *buf, const char *fmt, struct tm *tm)
|
|
624
|
+
{
|
|
625
|
+
unsigned char c;
|
|
626
|
+
const unsigned char *bp, *ep, *zname;
|
|
627
|
+
int alt_format, i, split_year = 0, neg = 0, state = 0,
|
|
628
|
+
day_offset = -1, week_offset = 0, offs, mandatory;
|
|
629
|
+
const char *new_fmt;
|
|
630
|
+
|
|
631
|
+
bp = (const unsigned char *)buf;
|
|
632
|
+
|
|
633
|
+
while (bp != NULL && (c = *fmt++) != '\0') {
|
|
634
|
+
/* Clear `alternate' modifier prior to new conversion. */
|
|
635
|
+
alt_format = 0;
|
|
636
|
+
i = 0;
|
|
637
|
+
|
|
638
|
+
/* Eat up white-space. */
|
|
639
|
+
if (isspace(c)) {
|
|
640
|
+
while (isspace(*bp))
|
|
641
|
+
bp++;
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
if (c != '%')
|
|
646
|
+
goto literal;
|
|
647
|
+
|
|
648
|
+
|
|
649
|
+
again: switch (c = *fmt++) {
|
|
650
|
+
case '%': /* "%%" is converted to "%". */
|
|
651
|
+
literal:
|
|
652
|
+
if (c != *bp++)
|
|
653
|
+
return NULL;
|
|
654
|
+
LEGAL_ALT(0);
|
|
655
|
+
continue;
|
|
656
|
+
|
|
657
|
+
/*
|
|
658
|
+
* "Alternative" modifiers. Just set the appropriate flag
|
|
659
|
+
* and start over again.
|
|
660
|
+
*/
|
|
661
|
+
case 'E': /* "%E?" alternative conversion modifier. */
|
|
662
|
+
LEGAL_ALT(0);
|
|
663
|
+
alt_format |= ALT_E;
|
|
664
|
+
goto again;
|
|
665
|
+
|
|
666
|
+
case 'O': /* "%O?" alternative conversion modifier. */
|
|
667
|
+
LEGAL_ALT(0);
|
|
668
|
+
alt_format |= ALT_O;
|
|
669
|
+
goto again;
|
|
670
|
+
|
|
671
|
+
/*
|
|
672
|
+
* "Complex" conversion rules, implemented through recursion.
|
|
673
|
+
*/
|
|
674
|
+
case 'c': /* Date and time, using the locale's format. */
|
|
675
|
+
// new_fmt = _TIME_LOCALE(loc)->d_t_fmt;
|
|
676
|
+
new_fmt = HERE_D_T_FMT;
|
|
677
|
+
state |= S_WDAY | S_MON | S_MDAY | S_YEAR;
|
|
678
|
+
goto recurse;
|
|
679
|
+
|
|
680
|
+
case 'F': /* The date as "%Y-%m-%d". */
|
|
681
|
+
new_fmt = "%Y-%m-%d";
|
|
682
|
+
LEGAL_ALT(0);
|
|
683
|
+
state |= S_MON | S_MDAY | S_YEAR;
|
|
684
|
+
goto recurse;
|
|
685
|
+
|
|
686
|
+
case 'R': /* The time as "%H:%M". */
|
|
687
|
+
new_fmt = "%H:%M";
|
|
688
|
+
LEGAL_ALT(0);
|
|
689
|
+
goto recurse;
|
|
690
|
+
|
|
691
|
+
case 'r': /* The time in 12-hour clock representation. */
|
|
692
|
+
// new_fmt = _TIME_LOCALE(loc)->t_fmt_ampm;
|
|
693
|
+
new_fmt = HERE_T_FMT_AMPM;
|
|
694
|
+
LEGAL_ALT(0);
|
|
695
|
+
goto recurse;
|
|
696
|
+
|
|
697
|
+
case 'X': /* The time, using the locale's format. */
|
|
698
|
+
/* fall through */
|
|
699
|
+
|
|
700
|
+
case 'T': /* The time as "%H:%M:%S". */
|
|
701
|
+
new_fmt = HERE_T_FMT;
|
|
702
|
+
LEGAL_ALT(0);
|
|
703
|
+
|
|
704
|
+
recurse:
|
|
705
|
+
bp = (const unsigned char *)strptime((const char *)bp,
|
|
706
|
+
new_fmt, tm);
|
|
707
|
+
LEGAL_ALT(ALT_E);
|
|
708
|
+
continue;
|
|
709
|
+
|
|
710
|
+
case 'x': /* The date, using the locale's format. */
|
|
711
|
+
/* fall through */
|
|
712
|
+
|
|
713
|
+
case 'D': /* The date as "%y/%m/%d". */
|
|
714
|
+
{
|
|
715
|
+
new_fmt = HERE_D_FMT;
|
|
716
|
+
LEGAL_ALT(0);
|
|
717
|
+
state |= S_MON | S_MDAY | S_YEAR;
|
|
718
|
+
const int year = split_year ? tm->tm_year : 0;
|
|
719
|
+
|
|
720
|
+
bp = (const unsigned char *)strptime((const char *)bp,
|
|
721
|
+
new_fmt, tm);
|
|
722
|
+
LEGAL_ALT(ALT_E);
|
|
723
|
+
tm->tm_year += year;
|
|
724
|
+
if (split_year && tm->tm_year % (2000 - TM_YEAR_BASE) <= 68)
|
|
725
|
+
tm->tm_year -= 2000 - TM_YEAR_BASE;
|
|
726
|
+
split_year = 1;
|
|
727
|
+
continue;
|
|
728
|
+
}
|
|
729
|
+
/*
|
|
730
|
+
* "Elementary" conversion rules.
|
|
731
|
+
*/
|
|
732
|
+
case 'A': /* The day of week, using the locale's form. */
|
|
733
|
+
case 'a':
|
|
734
|
+
bp = find_string(bp, &tm->tm_wday, weekday_name, ab_weekday_name, 7);
|
|
735
|
+
LEGAL_ALT(0);
|
|
736
|
+
state |= S_WDAY;
|
|
737
|
+
continue;
|
|
738
|
+
|
|
739
|
+
case 'B': /* The month, using the locale's form. */
|
|
740
|
+
case 'b':
|
|
741
|
+
case 'h':
|
|
742
|
+
bp = find_string(bp, &tm->tm_mon, month_name, ab_month_name, 12);
|
|
743
|
+
LEGAL_ALT(0);
|
|
744
|
+
state |= S_MON;
|
|
745
|
+
continue;
|
|
746
|
+
|
|
747
|
+
case 'C': /* The century number. */
|
|
748
|
+
i = 20;
|
|
749
|
+
bp = conv_num(bp, &i, 0, 99);
|
|
750
|
+
|
|
751
|
+
i = i * 100 - TM_YEAR_BASE;
|
|
752
|
+
if (split_year)
|
|
753
|
+
i += tm->tm_year % 100;
|
|
754
|
+
split_year = 1;
|
|
755
|
+
tm->tm_year = i;
|
|
756
|
+
LEGAL_ALT(ALT_E);
|
|
757
|
+
state |= S_YEAR;
|
|
758
|
+
continue;
|
|
759
|
+
|
|
760
|
+
case 'd': /* The day of month. */
|
|
761
|
+
case 'e':
|
|
762
|
+
bp = conv_num(bp, &tm->tm_mday, 1, 31);
|
|
763
|
+
LEGAL_ALT(ALT_O);
|
|
764
|
+
state |= S_MDAY;
|
|
765
|
+
continue;
|
|
766
|
+
|
|
767
|
+
case 'k': /* The hour (24-hour clock representation). */
|
|
768
|
+
LEGAL_ALT(0);
|
|
769
|
+
/* FALLTHROUGH */
|
|
770
|
+
case 'H':
|
|
771
|
+
bp = conv_num(bp, &tm->tm_hour, 0, 23);
|
|
772
|
+
LEGAL_ALT(ALT_O);
|
|
773
|
+
state |= S_HOUR;
|
|
774
|
+
continue;
|
|
775
|
+
|
|
776
|
+
case 'l': /* The hour (12-hour clock representation). */
|
|
777
|
+
LEGAL_ALT(0);
|
|
778
|
+
/* FALLTHROUGH */
|
|
779
|
+
case 'I':
|
|
780
|
+
bp = conv_num(bp, &tm->tm_hour, 1, 12);
|
|
781
|
+
if (tm->tm_hour == 12)
|
|
782
|
+
tm->tm_hour = 0;
|
|
783
|
+
LEGAL_ALT(ALT_O);
|
|
784
|
+
state |= S_HOUR;
|
|
785
|
+
continue;
|
|
786
|
+
|
|
787
|
+
case 'j': /* The day of year. */
|
|
788
|
+
i = 1;
|
|
789
|
+
bp = conv_num(bp, &i, 1, 366);
|
|
790
|
+
tm->tm_yday = i - 1;
|
|
791
|
+
LEGAL_ALT(0);
|
|
792
|
+
state |= S_YDAY;
|
|
793
|
+
continue;
|
|
794
|
+
|
|
795
|
+
case 'M': /* The minute. */
|
|
796
|
+
bp = conv_num(bp, &tm->tm_min, 0, 59);
|
|
797
|
+
LEGAL_ALT(ALT_O);
|
|
798
|
+
continue;
|
|
799
|
+
|
|
800
|
+
case 'm': /* The month. */
|
|
801
|
+
i = 1;
|
|
802
|
+
bp = conv_num(bp, &i, 1, 12);
|
|
803
|
+
tm->tm_mon = i - 1;
|
|
804
|
+
LEGAL_ALT(ALT_O);
|
|
805
|
+
state |= S_MON;
|
|
806
|
+
continue;
|
|
807
|
+
|
|
808
|
+
case 'p': /* The locale's equivalent of AM/PM. */
|
|
809
|
+
bp = find_string(bp, &i, am_pm, NULL, 2);
|
|
810
|
+
if (HAVE_HOUR(state) && tm->tm_hour > 11)
|
|
811
|
+
return NULL;
|
|
812
|
+
tm->tm_hour += i * 12;
|
|
813
|
+
LEGAL_ALT(0);
|
|
814
|
+
continue;
|
|
815
|
+
|
|
816
|
+
case 'S': /* The seconds. */
|
|
817
|
+
bp = conv_num(bp, &tm->tm_sec, 0, 61);
|
|
818
|
+
LEGAL_ALT(ALT_O);
|
|
819
|
+
continue;
|
|
820
|
+
|
|
821
|
+
case 's': { /* seconds since the epoch */
|
|
822
|
+
#ifdef _WIN32
|
|
823
|
+
const time_t TIME_MAX = INT32_MAX;
|
|
824
|
+
#else
|
|
825
|
+
const time_t TIME_MAX = INT64_MAX;
|
|
826
|
+
#endif
|
|
827
|
+
time_t sse, d;
|
|
828
|
+
|
|
829
|
+
if (*bp < '0' || *bp > '9') {
|
|
830
|
+
bp = NULL;
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
sse = *bp++ - '0';
|
|
835
|
+
while (*bp >= '0' && *bp <= '9') {
|
|
836
|
+
d = *bp++ - '0';
|
|
837
|
+
if (sse > TIME_MAX/10) {
|
|
838
|
+
bp = NULL;
|
|
839
|
+
break;
|
|
840
|
+
}
|
|
841
|
+
sse *= 10;
|
|
842
|
+
if (sse > TIME_MAX - d) {
|
|
843
|
+
bp = NULL;
|
|
844
|
+
break;
|
|
845
|
+
}
|
|
846
|
+
sse += d;
|
|
847
|
+
}
|
|
848
|
+
if (bp == NULL)
|
|
849
|
+
continue;
|
|
850
|
+
|
|
851
|
+
#ifdef _WIN32
|
|
852
|
+
if (localtime_s(tm, &sse))
|
|
853
|
+
#else
|
|
854
|
+
if (localtime_r(&sse, tm) == NULL)
|
|
855
|
+
#endif
|
|
856
|
+
bp = NULL;
|
|
857
|
+
else
|
|
858
|
+
state |= S_YDAY | S_WDAY | S_MON | S_MDAY | S_YEAR;
|
|
859
|
+
continue;
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
case 'U': /* The week of year, beginning on sunday. */
|
|
863
|
+
case 'W': /* The week of year, beginning on monday. */
|
|
864
|
+
/*
|
|
865
|
+
* This is bogus, as we can not assume any valid
|
|
866
|
+
* information present in the tm structure at this
|
|
867
|
+
* point to calculate a real value, so save the
|
|
868
|
+
* week for now in case it can be used later.
|
|
869
|
+
*/
|
|
870
|
+
bp = conv_num(bp, &i, 0, 53);
|
|
871
|
+
LEGAL_ALT(ALT_O);
|
|
872
|
+
if (c == 'U')
|
|
873
|
+
day_offset = TM_SUNDAY;
|
|
874
|
+
else
|
|
875
|
+
day_offset = TM_MONDAY;
|
|
876
|
+
week_offset = i;
|
|
877
|
+
continue;
|
|
878
|
+
|
|
879
|
+
case 'w': /* The day of week, beginning on sunday. */
|
|
880
|
+
bp = conv_num(bp, &tm->tm_wday, 0, 6);
|
|
881
|
+
LEGAL_ALT(ALT_O);
|
|
882
|
+
state |= S_WDAY;
|
|
883
|
+
continue;
|
|
884
|
+
|
|
885
|
+
case 'u': /* The day of week, monday = 1. */
|
|
886
|
+
bp = conv_num(bp, &i, 1, 7);
|
|
887
|
+
tm->tm_wday = i % 7;
|
|
888
|
+
LEGAL_ALT(ALT_O);
|
|
889
|
+
state |= S_WDAY;
|
|
890
|
+
continue;
|
|
891
|
+
|
|
892
|
+
case 'g': /* The year corresponding to the ISO week
|
|
893
|
+
* number but without the century.
|
|
894
|
+
*/
|
|
895
|
+
bp = conv_num(bp, &i, 0, 99);
|
|
896
|
+
continue;
|
|
897
|
+
|
|
898
|
+
case 'G': /* The year corresponding to the ISO week
|
|
899
|
+
* number with century.
|
|
900
|
+
*/
|
|
901
|
+
do
|
|
902
|
+
bp++;
|
|
903
|
+
while (isdigit(*bp));
|
|
904
|
+
continue;
|
|
905
|
+
|
|
906
|
+
case 'V': /* The ISO 8601:1988 week number as decimal */
|
|
907
|
+
bp = conv_num(bp, &i, 0, 53);
|
|
908
|
+
continue;
|
|
909
|
+
|
|
910
|
+
case 'Y': /* The year. */
|
|
911
|
+
i = TM_YEAR_BASE; /* just for data sanity... */
|
|
912
|
+
bp = conv_num(bp, &i, 0, 9999);
|
|
913
|
+
tm->tm_year = i - TM_YEAR_BASE;
|
|
914
|
+
LEGAL_ALT(ALT_E);
|
|
915
|
+
state |= S_YEAR;
|
|
916
|
+
continue;
|
|
917
|
+
|
|
918
|
+
case 'y': /* The year within 100 years of the epoch. */
|
|
919
|
+
/* LEGAL_ALT(ALT_E | ALT_O); */
|
|
920
|
+
bp = conv_num(bp, &i, 0, 99);
|
|
921
|
+
|
|
922
|
+
if (split_year)
|
|
923
|
+
/* preserve century */
|
|
924
|
+
i += (tm->tm_year / 100) * 100;
|
|
925
|
+
else {
|
|
926
|
+
split_year = 1;
|
|
927
|
+
if (i <= 68)
|
|
928
|
+
i = i + 2000 - TM_YEAR_BASE;
|
|
929
|
+
}
|
|
930
|
+
tm->tm_year = i;
|
|
931
|
+
state |= S_YEAR;
|
|
932
|
+
continue;
|
|
933
|
+
|
|
934
|
+
case 'Z': // time zone name
|
|
935
|
+
case 'z': //
|
|
936
|
+
#ifdef _WIN32
|
|
937
|
+
_tzset();
|
|
938
|
+
#else
|
|
939
|
+
tzset();
|
|
940
|
+
#endif
|
|
941
|
+
mandatory = c == 'z';
|
|
942
|
+
/*
|
|
943
|
+
* We recognize all ISO 8601 formats:
|
|
944
|
+
* Z = Zulu time/UTC
|
|
945
|
+
* [+-]hhmm
|
|
946
|
+
* [+-]hh:mm
|
|
947
|
+
* [+-]hh
|
|
948
|
+
* We recognize all RFC-822/RFC-2822 formats:
|
|
949
|
+
* UT|GMT
|
|
950
|
+
* North American : UTC offsets
|
|
951
|
+
* E[DS]T = Eastern : -4 | -5
|
|
952
|
+
* C[DS]T = Central : -5 | -6
|
|
953
|
+
* M[DS]T = Mountain: -6 | -7
|
|
954
|
+
* P[DS]T = Pacific : -7 | -8
|
|
955
|
+
* Nautical/Military
|
|
956
|
+
* [A-IL-M] = -1 ... -9 (J not used)
|
|
957
|
+
* [N-Y] = +1 ... +12
|
|
958
|
+
* Note: J maybe used to denote non-nautical
|
|
959
|
+
* local time
|
|
960
|
+
*/
|
|
961
|
+
if (mandatory)
|
|
962
|
+
while (isspace(*bp))
|
|
963
|
+
bp++;
|
|
964
|
+
|
|
965
|
+
zname = bp;
|
|
966
|
+
switch (*bp++) {
|
|
967
|
+
case 'G':
|
|
968
|
+
if (*bp++ != 'M')
|
|
969
|
+
goto namedzone;
|
|
970
|
+
/*FALLTHROUGH*/
|
|
971
|
+
case 'U':
|
|
972
|
+
if (*bp++ != 'T')
|
|
973
|
+
goto namedzone;
|
|
974
|
+
else if (!delim(*bp) && *bp++ != 'C')
|
|
975
|
+
goto namedzone;
|
|
976
|
+
/*FALLTHROUGH*/
|
|
977
|
+
case 'Z':
|
|
978
|
+
if (!delim(*bp))
|
|
979
|
+
goto namedzone;
|
|
980
|
+
tm->tm_isdst = 0;
|
|
981
|
+
#ifdef TM_GMTOFF
|
|
982
|
+
tm->TM_GMTOFF = 0;
|
|
983
|
+
#endif
|
|
984
|
+
#ifdef TM_ZONE
|
|
985
|
+
tm->TM_ZONE = utc;
|
|
986
|
+
#endif
|
|
987
|
+
continue;
|
|
988
|
+
case '+':
|
|
989
|
+
neg = 0;
|
|
990
|
+
break;
|
|
991
|
+
case '-':
|
|
992
|
+
neg = 1;
|
|
993
|
+
break;
|
|
994
|
+
default:
|
|
995
|
+
namedzone:
|
|
996
|
+
bp = zname;
|
|
997
|
+
|
|
998
|
+
/* Nautical / Military style */
|
|
999
|
+
if (delim(bp[1]) &&
|
|
1000
|
+
((*bp >= 'A' && *bp <= 'I') ||
|
|
1001
|
+
(*bp >= 'L' && *bp <= 'Y'))) {
|
|
1002
|
+
#ifdef TM_GMTOFF
|
|
1003
|
+
/* Argh! No 'J'! */
|
|
1004
|
+
if (*bp >= 'A' && *bp <= 'I')
|
|
1005
|
+
tm->TM_GMTOFF =
|
|
1006
|
+
(int)*bp - ('A' - 1);
|
|
1007
|
+
else if (*bp >= 'L' && *bp <= 'M')
|
|
1008
|
+
tm->TM_GMTOFF = (int)*bp - 'A';
|
|
1009
|
+
else if (*bp >= 'N' && *bp <= 'Y')
|
|
1010
|
+
tm->TM_GMTOFF = 'M' - (int)*bp;
|
|
1011
|
+
tm->TM_GMTOFF *= SECSPERHOUR;
|
|
1012
|
+
#endif
|
|
1013
|
+
#ifdef TM_ZONE
|
|
1014
|
+
tm->TM_ZONE = NULL; /* XXX */
|
|
1015
|
+
#endif
|
|
1016
|
+
bp++;
|
|
1017
|
+
continue;
|
|
1018
|
+
}
|
|
1019
|
+
/* 'J' is local time */
|
|
1020
|
+
if (delim(bp[1]) && *bp == 'J') {
|
|
1021
|
+
#ifdef TM_GMTOFF
|
|
1022
|
+
tm->TM_GMTOFF = -timezone;
|
|
1023
|
+
#endif
|
|
1024
|
+
#ifdef TM_ZONE
|
|
1025
|
+
tm->TM_ZONE = NULL; /* XXX */
|
|
1026
|
+
#endif
|
|
1027
|
+
bp++;
|
|
1028
|
+
continue;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/*
|
|
1032
|
+
* From our 3 letter hard-coded table
|
|
1033
|
+
* XXX: Can be removed, handled by tzload()
|
|
1034
|
+
*/
|
|
1035
|
+
if (delim(bp[0]) || delim(bp[1]) ||
|
|
1036
|
+
delim(bp[2]) || !delim(bp[3]))
|
|
1037
|
+
goto loadzone;
|
|
1038
|
+
ep = find_string(bp, &i, nast, NULL, 4);
|
|
1039
|
+
if (ep != NULL) {
|
|
1040
|
+
#ifdef TM_GMTOFF
|
|
1041
|
+
tm->TM_GMTOFF = (-5 - i) * SECSPERHOUR;
|
|
1042
|
+
#endif
|
|
1043
|
+
#ifdef TM_ZONE
|
|
1044
|
+
tm->TM_ZONE = __UNCONST(nast[i]);
|
|
1045
|
+
#endif
|
|
1046
|
+
bp = ep;
|
|
1047
|
+
continue;
|
|
1048
|
+
}
|
|
1049
|
+
ep = find_string(bp, &i, nadt, NULL, 4);
|
|
1050
|
+
if (ep != NULL) {
|
|
1051
|
+
tm->tm_isdst = 1;
|
|
1052
|
+
#ifdef TM_GMTOFF
|
|
1053
|
+
tm->TM_GMTOFF = (-4 - i) * SECSPERHOUR;
|
|
1054
|
+
#endif
|
|
1055
|
+
#ifdef TM_ZONE
|
|
1056
|
+
tm->TM_ZONE = __UNCONST(nadt[i]);
|
|
1057
|
+
#endif
|
|
1058
|
+
bp = ep;
|
|
1059
|
+
continue;
|
|
1060
|
+
}
|
|
1061
|
+
/*
|
|
1062
|
+
* Our current timezone
|
|
1063
|
+
*/
|
|
1064
|
+
ep = find_string(bp, &i,
|
|
1065
|
+
(const char * const *)tzname,
|
|
1066
|
+
NULL, 2);
|
|
1067
|
+
if (ep != NULL) {
|
|
1068
|
+
tm->tm_isdst = i;
|
|
1069
|
+
#ifdef TM_GMTOFF
|
|
1070
|
+
tm->TM_GMTOFF = -timezone;
|
|
1071
|
+
#endif
|
|
1072
|
+
#ifdef TM_ZONE
|
|
1073
|
+
tm->TM_ZONE = tzname[i];
|
|
1074
|
+
#endif
|
|
1075
|
+
bp = ep;
|
|
1076
|
+
continue;
|
|
1077
|
+
}
|
|
1078
|
+
loadzone:
|
|
1079
|
+
/*
|
|
1080
|
+
* The hard way, load the zone!
|
|
1081
|
+
*/
|
|
1082
|
+
if (fromzone(&bp, tm, mandatory))
|
|
1083
|
+
continue;
|
|
1084
|
+
goto out;
|
|
1085
|
+
}
|
|
1086
|
+
offs = 0;
|
|
1087
|
+
for (i = 0; i < 4; ) {
|
|
1088
|
+
if (isdigit(*bp)) {
|
|
1089
|
+
offs = offs * 10 + (*bp++ - '0');
|
|
1090
|
+
i++;
|
|
1091
|
+
continue;
|
|
1092
|
+
}
|
|
1093
|
+
if (i == 2 && *bp == ':') {
|
|
1094
|
+
bp++;
|
|
1095
|
+
continue;
|
|
1096
|
+
}
|
|
1097
|
+
break;
|
|
1098
|
+
}
|
|
1099
|
+
if (isdigit(*bp))
|
|
1100
|
+
goto out;
|
|
1101
|
+
switch (i) {
|
|
1102
|
+
case 2:
|
|
1103
|
+
offs *= SECSPERHOUR;
|
|
1104
|
+
break;
|
|
1105
|
+
case 4:
|
|
1106
|
+
i = offs % 100;
|
|
1107
|
+
offs /= 100;
|
|
1108
|
+
if (i >= SECSPERMIN)
|
|
1109
|
+
goto out;
|
|
1110
|
+
/* Convert minutes into decimal */
|
|
1111
|
+
offs = offs * SECSPERHOUR + i * SECSPERMIN;
|
|
1112
|
+
break;
|
|
1113
|
+
default:
|
|
1114
|
+
out:
|
|
1115
|
+
if (mandatory)
|
|
1116
|
+
return NULL;
|
|
1117
|
+
bp = zname;
|
|
1118
|
+
continue;
|
|
1119
|
+
}
|
|
1120
|
+
/* ISO 8601 & RFC 3339 limit to 23:59 max */
|
|
1121
|
+
if (offs >= (HOURSPERDAY * SECSPERHOUR))
|
|
1122
|
+
goto out;
|
|
1123
|
+
if (neg)
|
|
1124
|
+
offs = -offs;
|
|
1125
|
+
tm->tm_isdst = 0; /* XXX */
|
|
1126
|
+
#ifdef TM_GMTOFF
|
|
1127
|
+
tm->TM_GMTOFF = offs;
|
|
1128
|
+
#endif
|
|
1129
|
+
#ifdef TM_ZONE
|
|
1130
|
+
tm->TM_ZONE = NULL; /* XXX */
|
|
1131
|
+
#endif
|
|
1132
|
+
continue;
|
|
1133
|
+
|
|
1134
|
+
/*
|
|
1135
|
+
* Miscellaneous conversions.
|
|
1136
|
+
*/
|
|
1137
|
+
case 'n': /* Any kind of white-space. */
|
|
1138
|
+
case 't':
|
|
1139
|
+
while (isspace(*bp))
|
|
1140
|
+
bp++;
|
|
1141
|
+
LEGAL_ALT(0);
|
|
1142
|
+
continue;
|
|
1143
|
+
|
|
1144
|
+
|
|
1145
|
+
default: /* Unknown/unsupported conversion. */
|
|
1146
|
+
return NULL;
|
|
1147
|
+
}
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
if (!HAVE_YDAY(state) && HAVE_YEAR(state)) {
|
|
1151
|
+
if (HAVE_MON(state) && HAVE_MDAY(state)) {
|
|
1152
|
+
/* calculate day of year (ordinal date) */
|
|
1153
|
+
tm->tm_yday = start_of_month[isleap_sum(tm->tm_year,
|
|
1154
|
+
TM_YEAR_BASE)][tm->tm_mon] + (tm->tm_mday - 1);
|
|
1155
|
+
state |= S_YDAY;
|
|
1156
|
+
} else if (day_offset != -1) {
|
|
1157
|
+
/*
|
|
1158
|
+
* Set the date to the first Sunday (or Monday)
|
|
1159
|
+
* of the specified week of the year.
|
|
1160
|
+
*/
|
|
1161
|
+
if (!HAVE_WDAY(state)) {
|
|
1162
|
+
tm->tm_wday = day_offset;
|
|
1163
|
+
state |= S_WDAY;
|
|
1164
|
+
}
|
|
1165
|
+
tm->tm_yday = (7 -
|
|
1166
|
+
first_wday_of(tm->tm_year + TM_YEAR_BASE) +
|
|
1167
|
+
day_offset) % 7 + (week_offset - 1) * 7 +
|
|
1168
|
+
tm->tm_wday - day_offset;
|
|
1169
|
+
state |= S_YDAY;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
|
|
1173
|
+
if (HAVE_YDAY(state) && HAVE_YEAR(state)) {
|
|
1174
|
+
int isleap;
|
|
1175
|
+
|
|
1176
|
+
if (!HAVE_MON(state)) {
|
|
1177
|
+
/* calculate month of day of year */
|
|
1178
|
+
i = 0;
|
|
1179
|
+
isleap = isleap_sum(tm->tm_year, TM_YEAR_BASE);
|
|
1180
|
+
while (tm->tm_yday >= start_of_month[isleap][i])
|
|
1181
|
+
i++;
|
|
1182
|
+
if (i > 12) {
|
|
1183
|
+
i = 1;
|
|
1184
|
+
tm->tm_yday -= start_of_month[isleap][12];
|
|
1185
|
+
tm->tm_year++;
|
|
1186
|
+
}
|
|
1187
|
+
tm->tm_mon = i - 1;
|
|
1188
|
+
state |= S_MON;
|
|
1189
|
+
}
|
|
1190
|
+
|
|
1191
|
+
if (!HAVE_MDAY(state)) {
|
|
1192
|
+
/* calculate day of month */
|
|
1193
|
+
isleap = isleap_sum(tm->tm_year, TM_YEAR_BASE);
|
|
1194
|
+
tm->tm_mday = tm->tm_yday -
|
|
1195
|
+
start_of_month[isleap][tm->tm_mon] + 1;
|
|
1196
|
+
state |= S_MDAY;
|
|
1197
|
+
}
|
|
1198
|
+
|
|
1199
|
+
if (!HAVE_WDAY(state)) {
|
|
1200
|
+
/* calculate day of week */
|
|
1201
|
+
i = 0;
|
|
1202
|
+
week_offset = first_wday_of(tm->tm_year);
|
|
1203
|
+
while (i++ <= tm->tm_yday) {
|
|
1204
|
+
if (week_offset++ >= 6)
|
|
1205
|
+
week_offset = 0;
|
|
1206
|
+
}
|
|
1207
|
+
tm->tm_wday = week_offset;
|
|
1208
|
+
state |= S_WDAY;
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
|
|
1212
|
+
return (char*)bp;
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
|
|
1216
|
+
static const unsigned char *
|
|
1217
|
+
conv_num(const unsigned char *buf, int *dest, unsigned int llim, unsigned int ulim)
|
|
1218
|
+
{
|
|
1219
|
+
unsigned int result = 0;
|
|
1220
|
+
unsigned char ch;
|
|
1221
|
+
|
|
1222
|
+
/* The limit also determines the number of valid digits. */
|
|
1223
|
+
unsigned int rulim = ulim;
|
|
1224
|
+
|
|
1225
|
+
ch = *buf;
|
|
1226
|
+
if (ch < '0' || ch > '9')
|
|
1227
|
+
return NULL;
|
|
1228
|
+
|
|
1229
|
+
do {
|
|
1230
|
+
result *= 10;
|
|
1231
|
+
result += ch - '0';
|
|
1232
|
+
rulim /= 10;
|
|
1233
|
+
ch = *++buf;
|
|
1234
|
+
} while ((result <= ulim) && rulim && ch >= '0' && ch <= '9');
|
|
1235
|
+
|
|
1236
|
+
if (result < llim || result > ulim)
|
|
1237
|
+
return NULL;
|
|
1238
|
+
|
|
1239
|
+
*dest = result;
|
|
1240
|
+
return buf;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
static const unsigned char *
|
|
1244
|
+
find_string(const unsigned char *bp, int *tgt, const char * const *n1,
|
|
1245
|
+
const char * const *n2, int c)
|
|
1246
|
+
{
|
|
1247
|
+
int i;
|
|
1248
|
+
size_t len;
|
|
1249
|
+
|
|
1250
|
+
/* check full name - then abbreviated ones */
|
|
1251
|
+
for (; n1 != NULL; n1 = n2, n2 = NULL) {
|
|
1252
|
+
for (i = 0; i < c; i++, n1++) {
|
|
1253
|
+
len = strlen(*n1);
|
|
1254
|
+
if (strncasecmp(*n1, (const char *)bp, len) == 0) {
|
|
1255
|
+
*tgt = i;
|
|
1256
|
+
return bp + len;
|
|
1257
|
+
}
|
|
1258
|
+
}
|
|
1259
|
+
}
|
|
1260
|
+
|
|
1261
|
+
/* Nothing matched */
|
|
1262
|
+
return NULL;
|
|
1263
|
+
}
|
|
1264
|
+
#endif
|