@port-labs/jq-node-bindings 1.0.4 → 1.1.0-dev

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.
Files changed (352) hide show
  1. package/.claude/settings.local.json +12 -0
  2. package/configure +6 -5
  3. package/deps/jq/.claude/settings.local.json +7 -0
  4. package/deps/jq/.gitattributes +1 -3
  5. package/deps/jq/AUTHORS +55 -1
  6. package/deps/jq/COPYING +40 -0
  7. package/deps/jq/Makefile.am +40 -36
  8. package/deps/jq/NEWS.md +277 -2
  9. package/deps/jq/README.md +23 -5
  10. package/deps/jq/compile-ios.sh +1 -1
  11. package/deps/jq/config/m4/check-math-func.m4 +2 -2
  12. package/deps/jq/config/m4/find-func-no-libs2.m4 +3 -3
  13. package/deps/jq/configure.ac +10 -18
  14. package/deps/jq/docs/Pipfile.lock +368 -313
  15. package/deps/jq/docs/README.md +3 -4
  16. package/deps/jq/docs/build_manpage.py +1 -1
  17. package/deps/jq/docs/build_mantests.py +1 -1
  18. package/deps/jq/docs/build_website.py +1 -8
  19. package/deps/jq/docs/content/download/default.yml +49 -9
  20. package/deps/jq/docs/content/index.yml +9 -0
  21. package/deps/jq/docs/content/manual/{manual.yml → dev/manual.yml} +218 -61
  22. package/deps/jq/docs/content/manual/v1.3/manual.yml +0 -5
  23. package/deps/jq/docs/content/manual/v1.4/manual.yml +0 -5
  24. package/deps/jq/docs/content/manual/v1.5/manual.yml +3 -8
  25. package/deps/jq/docs/content/manual/v1.6/manual.yml +3 -8
  26. package/deps/jq/docs/content/manual/v1.7/manual.yml +499 -500
  27. package/deps/jq/docs/content/manual/v1.8/manual.yml +3858 -0
  28. package/deps/jq/docs/content/tutorial/default.yml +3 -3
  29. package/deps/jq/docs/manual_schema.yml +0 -3
  30. package/deps/jq/docs/public/CNAME +1 -0
  31. package/deps/jq/docs/templates/index.html.j2 +10 -10
  32. package/deps/jq/docs/templates/manual.html.j2 +14 -3
  33. package/deps/jq/docs/templates/shared/_head.html.j2 +8 -3
  34. package/deps/jq/docs/templates/shared/_navbar.html.j2 +4 -4
  35. package/deps/jq/jq.1.prebuilt +219 -44
  36. package/deps/jq/jq.spec +2 -2
  37. package/deps/jq/libjq.pc.in +1 -1
  38. package/deps/jq/scripts/version +1 -1
  39. package/deps/jq/sig/v1.7.1/jq-1.7.1.tar.gz.asc +16 -0
  40. package/deps/jq/sig/v1.7.1/jq-1.7.1.zip.asc +16 -0
  41. package/deps/jq/sig/v1.7.1/jq-linux-amd64.asc +16 -0
  42. package/deps/jq/sig/v1.7.1/jq-linux-arm64.asc +16 -0
  43. package/deps/jq/sig/v1.7.1/jq-linux-armel.asc +16 -0
  44. package/deps/jq/sig/v1.7.1/jq-linux-armhf.asc +16 -0
  45. package/deps/jq/sig/v1.7.1/jq-linux-i386.asc +16 -0
  46. package/deps/jq/sig/v1.7.1/jq-linux-mips.asc +16 -0
  47. package/deps/jq/sig/v1.7.1/jq-linux-mips64.asc +16 -0
  48. package/deps/jq/sig/v1.7.1/jq-linux-mips64el.asc +16 -0
  49. package/deps/jq/sig/v1.7.1/jq-linux-mips64r6.asc +16 -0
  50. package/deps/jq/sig/v1.7.1/jq-linux-mips64r6el.asc +16 -0
  51. package/deps/jq/sig/v1.7.1/jq-linux-mipsel.asc +16 -0
  52. package/deps/jq/sig/v1.7.1/jq-linux-mipsr6.asc +16 -0
  53. package/deps/jq/sig/v1.7.1/jq-linux-mipsr6el.asc +16 -0
  54. package/deps/jq/sig/v1.7.1/jq-linux-powerpc.asc +16 -0
  55. package/deps/jq/sig/v1.7.1/jq-linux-ppc64el.asc +16 -0
  56. package/deps/jq/sig/v1.7.1/jq-linux-riscv64.asc +16 -0
  57. package/deps/jq/sig/v1.7.1/jq-linux-s390x.asc +16 -0
  58. package/deps/jq/sig/v1.7.1/jq-linux64.asc +16 -0
  59. package/deps/jq/sig/v1.7.1/jq-macos-amd64.asc +16 -0
  60. package/deps/jq/sig/v1.7.1/jq-macos-arm64.asc +16 -0
  61. package/deps/jq/sig/v1.7.1/jq-osx-amd64.asc +16 -0
  62. package/deps/jq/sig/v1.7.1/jq-win64.exe.asc +16 -0
  63. package/deps/jq/sig/v1.7.1/jq-windows-amd64.exe.asc +16 -0
  64. package/deps/jq/sig/v1.7.1/jq-windows-i386.exe.asc +16 -0
  65. package/deps/jq/sig/v1.7.1/sha256sum.txt +26 -0
  66. package/deps/jq/sig/v1.8.0/jq-1.8.0.tar.gz.asc +16 -0
  67. package/deps/jq/sig/v1.8.0/jq-1.8.0.zip.asc +16 -0
  68. package/deps/jq/sig/v1.8.0/jq-linux-amd64.asc +16 -0
  69. package/deps/jq/sig/v1.8.0/jq-linux-arm64.asc +16 -0
  70. package/deps/jq/sig/v1.8.0/jq-linux-armel.asc +16 -0
  71. package/deps/jq/sig/v1.8.0/jq-linux-armhf.asc +16 -0
  72. package/deps/jq/sig/v1.8.0/jq-linux-i386.asc +16 -0
  73. package/deps/jq/sig/v1.8.0/jq-linux-mips.asc +16 -0
  74. package/deps/jq/sig/v1.8.0/jq-linux-mips64.asc +16 -0
  75. package/deps/jq/sig/v1.8.0/jq-linux-mips64el.asc +16 -0
  76. package/deps/jq/sig/v1.8.0/jq-linux-mips64r6.asc +16 -0
  77. package/deps/jq/sig/v1.8.0/jq-linux-mips64r6el.asc +16 -0
  78. package/deps/jq/sig/v1.8.0/jq-linux-mipsel.asc +16 -0
  79. package/deps/jq/sig/v1.8.0/jq-linux-mipsr6.asc +16 -0
  80. package/deps/jq/sig/v1.8.0/jq-linux-mipsr6el.asc +16 -0
  81. package/deps/jq/sig/v1.8.0/jq-linux-powerpc.asc +16 -0
  82. package/deps/jq/sig/v1.8.0/jq-linux-ppc64el.asc +16 -0
  83. package/deps/jq/sig/v1.8.0/jq-linux-riscv64.asc +16 -0
  84. package/deps/jq/sig/v1.8.0/jq-linux-s390x.asc +16 -0
  85. package/deps/jq/sig/v1.8.0/jq-linux64.asc +16 -0
  86. package/deps/jq/sig/v1.8.0/jq-macos-amd64.asc +16 -0
  87. package/deps/jq/sig/v1.8.0/jq-macos-arm64.asc +16 -0
  88. package/deps/jq/sig/v1.8.0/jq-osx-amd64.asc +16 -0
  89. package/deps/jq/sig/v1.8.0/jq-win64.exe.asc +16 -0
  90. package/deps/jq/sig/v1.8.0/jq-windows-amd64.exe.asc +16 -0
  91. package/deps/jq/sig/v1.8.0/jq-windows-i386.exe.asc +16 -0
  92. package/deps/jq/sig/v1.8.0/sha256sum.txt +26 -0
  93. package/deps/jq/src/builtin.c +446 -271
  94. package/deps/jq/src/builtin.jq +25 -60
  95. package/deps/jq/src/bytecode.h +8 -3
  96. package/deps/jq/src/compile.c +22 -43
  97. package/deps/jq/src/compile.h +1 -1
  98. package/deps/jq/src/execute.c +20 -25
  99. package/deps/jq/src/jq_test.c +113 -44
  100. package/deps/jq/src/jv.c +134 -42
  101. package/deps/jq/src/jv.h +10 -3
  102. package/deps/jq/src/jv_alloc.c +8 -5
  103. package/deps/jq/src/jv_alloc.h +0 -1
  104. package/deps/jq/src/jv_aux.c +41 -8
  105. package/deps/jq/src/jv_dtoa.c +4 -12
  106. package/deps/jq/src/jv_dtoa_tsd.c +5 -4
  107. package/deps/jq/src/jv_dtoa_tsd.h +1 -1
  108. package/deps/jq/src/jv_parse.c +5 -3
  109. package/deps/jq/src/jv_print.c +87 -65
  110. package/deps/jq/src/jv_unicode.c +18 -0
  111. package/deps/jq/src/jv_unicode.h +2 -0
  112. package/deps/jq/src/lexer.c +303 -278
  113. package/deps/jq/src/lexer.h +5 -4
  114. package/deps/jq/src/lexer.l +8 -2
  115. package/deps/jq/src/libm.h +15 -5
  116. package/deps/jq/src/linker.c +6 -4
  117. package/deps/jq/src/locfile.c +12 -12
  118. package/deps/jq/src/main.c +204 -270
  119. package/deps/jq/src/parser.c +1105 -1273
  120. package/deps/jq/src/parser.y +149 -181
  121. package/deps/jq/src/util.c +46 -48
  122. package/deps/jq/src/util.h +1 -1
  123. package/deps/jq/tests/base64.test +12 -0
  124. package/deps/jq/tests/jq.test +429 -37
  125. package/deps/jq/tests/jq_fuzz_load_file.c +1 -0
  126. package/deps/jq/tests/man.test +46 -13
  127. package/deps/jq/tests/manonig.test +13 -0
  128. package/deps/jq/tests/onig.test +40 -2
  129. package/deps/jq/tests/optional.test +4 -12
  130. package/deps/jq/tests/setup +5 -1
  131. package/deps/jq/tests/shtest +358 -130
  132. package/deps/jq/tests/uri.test +38 -0
  133. package/deps/jq/tests/uritest +5 -0
  134. package/deps/jq/{src → vendor}/decNumber/decBasic.c +1 -1
  135. package/deps/jq/{src → vendor}/decNumber/decCommon.c +1 -1
  136. package/deps/jq/{src → vendor}/decNumber/decNumber.c +4 -4
  137. package/deps/jq/{modules → vendor}/oniguruma/CMakeLists.txt +5 -3
  138. package/deps/jq/{modules → vendor}/oniguruma/HISTORY +45 -7
  139. package/deps/jq/{modules → vendor}/oniguruma/Makefile.am +1 -1
  140. package/deps/jq/{modules → vendor}/oniguruma/README.md +10 -23
  141. package/deps/jq/{modules → vendor}/oniguruma/compile +29 -13
  142. package/deps/jq/{modules → vendor}/oniguruma/config.guess +91 -27
  143. package/deps/jq/{modules → vendor}/oniguruma/config.sub +716 -242
  144. package/deps/jq/{modules → vendor}/oniguruma/configure.ac +2 -2
  145. package/deps/jq/{modules → vendor}/oniguruma/depcomp +10 -9
  146. package/deps/jq/{modules → vendor}/oniguruma/doc/API +3 -1
  147. package/deps/jq/{modules → vendor}/oniguruma/doc/API.ja +3 -1
  148. package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.BUILTIN +10 -1
  149. package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.BUILTIN.ja +9 -1
  150. package/deps/jq/{modules → vendor}/oniguruma/doc/RE +12 -13
  151. package/deps/jq/{modules → vendor}/oniguruma/doc/RE.ja +12 -13
  152. package/deps/jq/{modules → vendor}/oniguruma/doc/SYNTAX.md +202 -167
  153. package/deps/jq/{modules → vendor}/oniguruma/doc/UNICODE_PROPERTIES +33 -1
  154. package/deps/jq/vendor/oniguruma/doc/onig_syn_md.c +667 -0
  155. package/deps/jq/{modules → vendor}/oniguruma/harnesses/base.c +1 -1
  156. package/deps/jq/{modules → vendor}/oniguruma/install-sh +9 -9
  157. package/deps/jq/{modules → vendor}/oniguruma/missing +50 -29
  158. package/deps/jq/{modules → vendor}/oniguruma/sample/callback_each_match.c +1 -3
  159. package/deps/jq/vendor/oniguruma/sbom.cdx.json +44 -0
  160. package/deps/jq/{modules → vendor}/oniguruma/src/ascii.c +4 -1
  161. package/deps/jq/{modules → vendor}/oniguruma/src/gperf_fold_key_conv.py +4 -4
  162. package/deps/jq/{modules → vendor}/oniguruma/src/gperf_unfold_key_conv.py +4 -4
  163. package/deps/jq/vendor/oniguruma/src/make_unicode_egcb.sh +7 -0
  164. package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_egcb_data.py +20 -19
  165. package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_fold.sh +5 -5
  166. package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_fold_data.py +37 -37
  167. package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_property.sh +2 -2
  168. package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_property_data.py +66 -65
  169. package/deps/jq/vendor/oniguruma/src/make_unicode_wb.sh +7 -0
  170. package/deps/jq/{modules → vendor}/oniguruma/src/make_unicode_wb_data.py +20 -19
  171. package/deps/jq/{modules → vendor}/oniguruma/src/oniguruma.h +6 -3
  172. package/deps/jq/{modules → vendor}/oniguruma/src/regcomp.c +14 -6
  173. package/deps/jq/{modules → vendor}/oniguruma/src/regerror.c +2 -2
  174. package/deps/jq/{modules → vendor}/oniguruma/src/regexec.c +85 -14
  175. package/deps/jq/{modules → vendor}/oniguruma/src/regint.h +17 -4
  176. package/deps/jq/{modules → vendor}/oniguruma/src/regparse.c +115 -27
  177. package/deps/jq/{modules → vendor}/oniguruma/src/regsyntax.c +10 -7
  178. package/deps/jq/{modules → vendor}/oniguruma/src/st.c +49 -75
  179. package/deps/jq/{modules → vendor}/oniguruma/src/st.h +3 -10
  180. package/deps/jq/{modules → vendor}/oniguruma/src/unicode_egcb_data.c +54 -49
  181. package/deps/jq/{modules → vendor}/oniguruma/src/unicode_fold1_key.c +1567 -1507
  182. package/deps/jq/{modules → vendor}/oniguruma/src/unicode_fold2_key.c +1 -1
  183. package/deps/jq/{modules → vendor}/oniguruma/src/unicode_fold3_key.c +1 -1
  184. package/deps/jq/vendor/oniguruma/src/unicode_fold_data.c +1619 -0
  185. package/deps/jq/{modules → vendor}/oniguruma/src/unicode_property_data.c +5520 -4178
  186. package/deps/jq/{modules → vendor}/oniguruma/src/unicode_property_data_posix.c +239 -83
  187. package/deps/jq/vendor/oniguruma/src/unicode_unfold_key.c +3497 -0
  188. package/deps/jq/{modules → vendor}/oniguruma/src/unicode_wb_data.c +51 -19
  189. package/deps/jq/{modules → vendor}/oniguruma/src/utf16_be.c +3 -2
  190. package/deps/jq/{modules → vendor}/oniguruma/src/utf16_le.c +3 -2
  191. package/deps/jq/{modules → vendor}/oniguruma/test/test_back.c +3 -3
  192. package/deps/jq/{modules → vendor}/oniguruma/test/test_options.c +2 -2
  193. package/deps/jq/{modules → vendor}/oniguruma/test/test_syntax.c +54 -2
  194. package/deps/jq/{modules → vendor}/oniguruma/test/test_utf8.c +19 -5
  195. package/deps/jq/{modules → vendor}/oniguruma/test/testc.c +1 -1
  196. package/deps/jq/{modules → vendor}/oniguruma/test/testp.c +1 -1
  197. package/deps/jq/{modules → vendor}/oniguruma/test-driver +13 -6
  198. package/deps/jq/{modules → vendor}/oniguruma/windows/CMakeLists.txt +1 -1
  199. package/index.d.ts +2 -1
  200. package/lib/index.js +1 -0
  201. package/lib/jq.js +2 -1
  202. package/package.json +4 -3
  203. package/test/santiy-async.test.js +4 -4
  204. package/test/santiy.test.js +4 -4
  205. package/test/template.test.js +6 -6
  206. package/deps/jq/modules/oniguruma/src/make_unicode_egcb.sh +0 -7
  207. package/deps/jq/modules/oniguruma/src/make_unicode_wb.sh +0 -7
  208. package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +0 -1592
  209. package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +0 -3394
  210. package/deps/jq/scripts/update-website +0 -30
  211. /package/deps/jq/{src → vendor}/decNumber/ICU-license.html +0 -0
  212. /package/deps/jq/{src → vendor}/decNumber/decContext.c +0 -0
  213. /package/deps/jq/{src → vendor}/decNumber/decContext.h +0 -0
  214. /package/deps/jq/{src → vendor}/decNumber/decDPD.h +0 -0
  215. /package/deps/jq/{src → vendor}/decNumber/decDouble.c +0 -0
  216. /package/deps/jq/{src → vendor}/decNumber/decDouble.h +0 -0
  217. /package/deps/jq/{src → vendor}/decNumber/decNumber.h +0 -0
  218. /package/deps/jq/{src → vendor}/decNumber/decNumberLocal.h +0 -0
  219. /package/deps/jq/{src → vendor}/decNumber/decPacked.c +0 -0
  220. /package/deps/jq/{src → vendor}/decNumber/decPacked.h +0 -0
  221. /package/deps/jq/{src → vendor}/decNumber/decQuad.c +0 -0
  222. /package/deps/jq/{src → vendor}/decNumber/decQuad.h +0 -0
  223. /package/deps/jq/{src → vendor}/decNumber/decSingle.c +0 -0
  224. /package/deps/jq/{src → vendor}/decNumber/decSingle.h +0 -0
  225. /package/deps/jq/{src → vendor}/decNumber/decimal128.c +0 -0
  226. /package/deps/jq/{src → vendor}/decNumber/decimal128.h +0 -0
  227. /package/deps/jq/{src → vendor}/decNumber/decimal32.c +0 -0
  228. /package/deps/jq/{src → vendor}/decNumber/decimal32.h +0 -0
  229. /package/deps/jq/{src → vendor}/decNumber/decimal64.c +0 -0
  230. /package/deps/jq/{src → vendor}/decNumber/decimal64.h +0 -0
  231. /package/deps/jq/{src → vendor}/decNumber/decnumber.pdf +0 -0
  232. /package/deps/jq/{src → vendor}/decNumber/example1.c +0 -0
  233. /package/deps/jq/{src → vendor}/decNumber/example2.c +0 -0
  234. /package/deps/jq/{src → vendor}/decNumber/example3.c +0 -0
  235. /package/deps/jq/{src → vendor}/decNumber/example4.c +0 -0
  236. /package/deps/jq/{src → vendor}/decNumber/example5.c +0 -0
  237. /package/deps/jq/{src → vendor}/decNumber/example6.c +0 -0
  238. /package/deps/jq/{src → vendor}/decNumber/example7.c +0 -0
  239. /package/deps/jq/{src → vendor}/decNumber/example8.c +0 -0
  240. /package/deps/jq/{src → vendor}/decNumber/readme.txt +0 -0
  241. /package/deps/jq/{modules → vendor}/oniguruma/.travis.yml +0 -0
  242. /package/deps/jq/{modules → vendor}/oniguruma/AUTHORS +0 -0
  243. /package/deps/jq/{modules → vendor}/oniguruma/COPYING +0 -0
  244. /package/deps/jq/{modules → vendor}/oniguruma/ChangeLog +0 -0
  245. /package/deps/jq/{modules → vendor}/oniguruma/NEWS +0 -0
  246. /package/deps/jq/{modules → vendor}/oniguruma/README +0 -0
  247. /package/deps/jq/{modules → vendor}/oniguruma/README_japanese +0 -0
  248. /package/deps/jq/{modules → vendor}/oniguruma/autogen.sh +0 -0
  249. /package/deps/jq/{modules → vendor}/oniguruma/cmake/Config.cmake.in +0 -0
  250. /package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.API +0 -0
  251. /package/deps/jq/{modules → vendor}/oniguruma/doc/CALLOUTS.API.ja +0 -0
  252. /package/deps/jq/{modules → vendor}/oniguruma/doc/FAQ +0 -0
  253. /package/deps/jq/{modules → vendor}/oniguruma/doc/FAQ.ja +0 -0
  254. /package/deps/jq/{modules → vendor}/oniguruma/harnesses/ascii_compatible.dict +0 -0
  255. /package/deps/jq/{modules → vendor}/oniguruma/harnesses/deluxe.c +0 -0
  256. /package/deps/jq/{modules → vendor}/oniguruma/harnesses/dict_conv.py +0 -0
  257. /package/deps/jq/{modules → vendor}/oniguruma/harnesses/fuzzer.options +0 -0
  258. /package/deps/jq/{modules → vendor}/oniguruma/harnesses/libfuzzer-onig.cpp +0 -0
  259. /package/deps/jq/{modules → vendor}/oniguruma/harnesses/regset.c +0 -0
  260. /package/deps/jq/{modules → vendor}/oniguruma/index.html +0 -0
  261. /package/deps/jq/{modules → vendor}/oniguruma/index_ja.html +0 -0
  262. /package/deps/jq/{modules → vendor}/oniguruma/m4/.whatever +0 -0
  263. /package/deps/jq/{modules → vendor}/oniguruma/make_win.bat +0 -0
  264. /package/deps/jq/{modules → vendor}/oniguruma/make_win32.bat +0 -0
  265. /package/deps/jq/{modules → vendor}/oniguruma/make_win64.bat +0 -0
  266. /package/deps/jq/{modules → vendor}/oniguruma/onig-config.cmake.in +0 -0
  267. /package/deps/jq/{modules → vendor}/oniguruma/onig-config.in +0 -0
  268. /package/deps/jq/{modules → vendor}/oniguruma/oniguruma.pc.cmake.in +0 -0
  269. /package/deps/jq/{modules → vendor}/oniguruma/oniguruma.pc.in +0 -0
  270. /package/deps/jq/{modules → vendor}/oniguruma/sample/CMakeLists.txt +0 -0
  271. /package/deps/jq/{modules → vendor}/oniguruma/sample/Makefile.am +0 -0
  272. /package/deps/jq/{modules → vendor}/oniguruma/sample/bug_fix.c +0 -0
  273. /package/deps/jq/{modules → vendor}/oniguruma/sample/callout.c +0 -0
  274. /package/deps/jq/{modules → vendor}/oniguruma/sample/count.c +0 -0
  275. /package/deps/jq/{modules → vendor}/oniguruma/sample/crnl.c +0 -0
  276. /package/deps/jq/{modules → vendor}/oniguruma/sample/echo.c +0 -0
  277. /package/deps/jq/{modules → vendor}/oniguruma/sample/encode.c +0 -0
  278. /package/deps/jq/{modules → vendor}/oniguruma/sample/listcap.c +0 -0
  279. /package/deps/jq/{modules → vendor}/oniguruma/sample/names.c +0 -0
  280. /package/deps/jq/{modules → vendor}/oniguruma/sample/posix.c +0 -0
  281. /package/deps/jq/{modules → vendor}/oniguruma/sample/regset.c +0 -0
  282. /package/deps/jq/{modules → vendor}/oniguruma/sample/scan.c +0 -0
  283. /package/deps/jq/{modules → vendor}/oniguruma/sample/simple.c +0 -0
  284. /package/deps/jq/{modules → vendor}/oniguruma/sample/sql.c +0 -0
  285. /package/deps/jq/{modules → vendor}/oniguruma/sample/syntax.c +0 -0
  286. /package/deps/jq/{modules → vendor}/oniguruma/sample/user_property.c +0 -0
  287. /package/deps/jq/{modules → vendor}/oniguruma/src/Makefile.am +0 -0
  288. /package/deps/jq/{modules → vendor}/oniguruma/src/Makefile.windows +0 -0
  289. /package/deps/jq/{modules → vendor}/oniguruma/src/big5.c +0 -0
  290. /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.cmake.in +0 -0
  291. /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.win32 +0 -0
  292. /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.win64 +0 -0
  293. /package/deps/jq/{modules → vendor}/oniguruma/src/config.h.windows.in +0 -0
  294. /package/deps/jq/{modules → vendor}/oniguruma/src/cp1251.c +0 -0
  295. /package/deps/jq/{modules → vendor}/oniguruma/src/euc_jp.c +0 -0
  296. /package/deps/jq/{modules → vendor}/oniguruma/src/euc_jp_prop.c +0 -0
  297. /package/deps/jq/{modules → vendor}/oniguruma/src/euc_jp_prop.gperf +0 -0
  298. /package/deps/jq/{modules → vendor}/oniguruma/src/euc_kr.c +0 -0
  299. /package/deps/jq/{modules → vendor}/oniguruma/src/euc_tw.c +0 -0
  300. /package/deps/jq/{modules → vendor}/oniguruma/src/gb18030.c +0 -0
  301. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_1.c +0 -0
  302. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_10.c +0 -0
  303. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_11.c +0 -0
  304. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_13.c +0 -0
  305. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_14.c +0 -0
  306. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_15.c +0 -0
  307. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_16.c +0 -0
  308. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_2.c +0 -0
  309. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_3.c +0 -0
  310. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_4.c +0 -0
  311. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_5.c +0 -0
  312. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_6.c +0 -0
  313. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_7.c +0 -0
  314. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_8.c +0 -0
  315. /package/deps/jq/{modules → vendor}/oniguruma/src/iso8859_9.c +0 -0
  316. /package/deps/jq/{modules → vendor}/oniguruma/src/koi8.c +0 -0
  317. /package/deps/jq/{modules → vendor}/oniguruma/src/koi8_r.c +0 -0
  318. /package/deps/jq/{modules → vendor}/oniguruma/src/make_property.sh +0 -0
  319. /package/deps/jq/{modules → vendor}/oniguruma/src/mktable.c +0 -0
  320. /package/deps/jq/{modules → vendor}/oniguruma/src/onig_init.c +0 -0
  321. /package/deps/jq/{modules → vendor}/oniguruma/src/oniggnu.h +0 -0
  322. /package/deps/jq/{modules → vendor}/oniguruma/src/onigposix.h +0 -0
  323. /package/deps/jq/{modules → vendor}/oniguruma/src/regenc.c +0 -0
  324. /package/deps/jq/{modules → vendor}/oniguruma/src/regenc.h +0 -0
  325. /package/deps/jq/{modules → vendor}/oniguruma/src/regext.c +0 -0
  326. /package/deps/jq/{modules → vendor}/oniguruma/src/reggnu.c +0 -0
  327. /package/deps/jq/{modules → vendor}/oniguruma/src/regparse.h +0 -0
  328. /package/deps/jq/{modules → vendor}/oniguruma/src/regposerr.c +0 -0
  329. /package/deps/jq/{modules → vendor}/oniguruma/src/regposix.c +0 -0
  330. /package/deps/jq/{modules → vendor}/oniguruma/src/regtrav.c +0 -0
  331. /package/deps/jq/{modules → vendor}/oniguruma/src/regversion.c +0 -0
  332. /package/deps/jq/{modules → vendor}/oniguruma/src/sjis.c +0 -0
  333. /package/deps/jq/{modules → vendor}/oniguruma/src/sjis_prop.c +0 -0
  334. /package/deps/jq/{modules → vendor}/oniguruma/src/sjis_prop.gperf +0 -0
  335. /package/deps/jq/{modules → vendor}/oniguruma/src/unicode.c +0 -0
  336. /package/deps/jq/{modules → vendor}/oniguruma/src/utf32_be.c +0 -0
  337. /package/deps/jq/{modules → vendor}/oniguruma/src/utf32_le.c +0 -0
  338. /package/deps/jq/{modules → vendor}/oniguruma/src/utf8.c +0 -0
  339. /package/deps/jq/{modules → vendor}/oniguruma/test/CMakeLists.txt +0 -0
  340. /package/deps/jq/{modules → vendor}/oniguruma/test/Makefile.am +0 -0
  341. /package/deps/jq/{modules → vendor}/oniguruma/test/test.sh +0 -0
  342. /package/deps/jq/{modules → vendor}/oniguruma/test/test_regset.c +0 -0
  343. /package/deps/jq/{modules → vendor}/oniguruma/test/testu.c +0 -0
  344. /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/stub.c +0 -0
  345. /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_back.config +0 -0
  346. /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_regset.config +0 -0
  347. /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_syntax.config +0 -0
  348. /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/test_utf8.config +0 -0
  349. /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/testc.config +0 -0
  350. /package/deps/jq/{modules → vendor}/oniguruma/tis-ci/testu.config +0 -0
  351. /package/deps/jq/{modules → vendor}/oniguruma/tis.config +0 -0
  352. /package/deps/jq/{modules → vendor}/oniguruma/windows/testc.c +0 -0
@@ -21,6 +21,10 @@
21
21
  extern void jv_tsd_dtoa_ctx_init();
22
22
  #endif
23
23
 
24
+ #ifdef HAVE_LIBONIG
25
+ #include <oniguruma.h>
26
+ #endif
27
+
24
28
  #if !defined(HAVE_ISATTY) && defined(HAVE__ISATTY)
25
29
  #undef isatty
26
30
  #define isatty _isatty
@@ -30,18 +34,14 @@ extern void jv_tsd_dtoa_ctx_init();
30
34
  #define USE_ISATTY
31
35
  #endif
32
36
 
33
- #include "compile.h"
34
37
  #include "jv.h"
35
38
  #include "jq.h"
36
- #include "jv_alloc.h"
37
39
  #include "util.h"
38
40
  #include "src/version.h"
39
41
  #include "src/config_opts.inc"
40
42
 
41
43
  int jq_testsuite(jv lib_dirs, int verbose, int argc, char* argv[]);
42
44
 
43
- static const char* progname;
44
-
45
45
  /*
46
46
  * For a longer help message we could use a better option parsing
47
47
  * strategy, one that lets stack options.
@@ -54,22 +54,19 @@ static void usage(int code, int keep_it_short) {
54
54
 
55
55
  int ret = fprintf(f,
56
56
  "jq - commandline JSON processor [version %s]\n"
57
- "\nUsage:\t%s [options] <jq filter> [file...]\n"
58
- "\t%s [options] --args <jq filter> [strings...]\n"
59
- "\t%s [options] --jsonargs <jq filter> [JSON_TEXTS...]\n\n"
57
+ "\nUsage:\tjq [options] <jq filter> [file...]\n"
58
+ "\tjq [options] --args <jq filter> [strings...]\n"
59
+ "\tjq [options] --jsonargs <jq filter> [JSON_TEXTS...]\n\n"
60
60
  "jq is a tool for processing JSON inputs, applying the given filter to\n"
61
61
  "its JSON text inputs and producing the filter's results as JSON on\n"
62
62
  "standard output.\n\n"
63
63
  "The simplest filter is ., which copies jq's input to its output\n"
64
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"
65
+ "the jq(1) manpage (\"man jq\") and/or https://jqlang.org/.\n\n"
66
66
  "Example:\n\n\t$ echo '{\"foo\": 0}' | jq .\n"
67
- "\t{\n\t \"foo\": 0\n\t}\n\n",
68
- JQ_VERSION, progname, progname, progname);
67
+ "\t{\n\t \"foo\": 0\n\t}\n\n", JQ_VERSION);
69
68
  if (keep_it_short) {
70
- fprintf(f,
71
- "For listing the command options, use %s --help.\n",
72
- progname);
69
+ fprintf(f, "For listing the command options, use jq --help.\n");
73
70
  } else {
74
71
  (void) fprintf(f,
75
72
  "Command options:\n"
@@ -94,8 +91,8 @@ static void usage(int code, int keep_it_short) {
94
91
  " --stream-errors implies --stream and report parse error as\n"
95
92
  " an array;\n"
96
93
  " --seq parse input/output as application/json-seq;\n"
97
- " -f, --from-file file load filter from the file;\n"
98
- " -L directory search modules from the directory;\n"
94
+ " -f, --from-file load the filter from a file;\n"
95
+ " -L, --library-path dir search modules from the directory;\n"
99
96
  " --arg name value set $name to the string value;\n"
100
97
  " --argjson name value set $name to the JSON value;\n"
101
98
  " --slurpfile name file set $name to an array of JSON values read\n"
@@ -119,30 +116,28 @@ static void usage(int code, int keep_it_short) {
119
116
  exit((ret < 0 && code == 0) ? 2 : code);
120
117
  }
121
118
 
122
- static void die() {
123
- fprintf(stderr, "Use %s --help for help with command-line options,\n", progname);
124
- fprintf(stderr, "or see the jq manpage, or online docs at https://jqlang.github.io/jq\n");
119
+ static void die(void) {
120
+ fprintf(stderr, "Use jq --help for help with command-line options,\n");
121
+ fprintf(stderr, "or see the jq manpage, or online docs at https://jqlang.org\n");
125
122
  exit(2);
126
123
  }
127
124
 
128
125
  static int isoptish(const char* text) {
129
- return text[0] == '-' && (text[1] == '-' || isalpha(text[1]));
126
+ return text[0] == '-' && (text[1] == '-' || isalpha((unsigned char)text[1]));
130
127
  }
131
128
 
132
- static int isoption(const char* text, char shortopt, const char* longopt, size_t *short_opts) {
133
- if (text[0] != '-' || text[1] == '-')
134
- *short_opts = 0;
135
- if (text[0] != '-') return 0;
136
-
137
- // check long option
138
- if (text[1] == '-' && !strcmp(text+2, longopt)) return 1;
139
- else if (text[1] == '-') return 0;
140
-
141
- // must be short option; check it and...
142
- if (!shortopt) return 0;
143
- if (strchr(text, shortopt) != NULL) {
144
- (*short_opts)++; // ...count it (for option stacking)
145
- return 1;
129
+ static int isoption(const char** text, char shortopt, const char* longopt, int is_short) {
130
+ if (is_short) {
131
+ if (shortopt && **text == shortopt) {
132
+ (*text)++;
133
+ if (!**text) *text = NULL;
134
+ return 1;
135
+ }
136
+ } else {
137
+ if (!strcmp(*text, longopt)) {
138
+ *text = NULL;
139
+ return 1;
140
+ }
146
141
  }
147
142
  return 0;
148
143
  }
@@ -162,9 +157,8 @@ enum {
162
157
  UNBUFFERED_OUTPUT = 2048,
163
158
  EXIT_STATUS = 4096,
164
159
  SEQ = 16384,
165
- RUN_TESTS = 32768,
166
160
  /* debugging only */
167
- DUMP_DISASM = 65536,
161
+ DUMP_DISASM = 32768,
168
162
  };
169
163
 
170
164
  enum {
@@ -180,21 +174,6 @@ enum {
180
174
 
181
175
  #define TIMEOUT_SEC 5
182
176
 
183
- static const char *skip_shebang(const char *p) {
184
- if (strncmp(p, "#!", sizeof("#!") - 1) != 0)
185
- return p;
186
- const char *n = strchr(p, '\n');
187
- if (n == NULL || n[1] != '#')
188
- return p;
189
- n = strchr(n + 1, '\n');
190
- if (n == NULL || n[1] == '#' || n[1] == '\0' || n[-1] != '\\' || n[-2] == '\\')
191
- return p;
192
- n = strchr(n + 1, '\n');
193
- if (n == NULL)
194
- return p;
195
- return n+1;
196
- }
197
-
198
177
  static int process(jq_state *jq, jv value, int flags, int dumpopts, int options) {
199
178
  int ret = JQ_OK_NO_OUTPUT; // No valid results && -e -> exit(4)
200
179
  jq_start(jq, value, flags);
@@ -325,6 +304,13 @@ int main(int argc, char* argv[]) {
325
304
  (void) setlocale(LC_ALL, "");
326
305
  #endif
327
306
 
307
+ #ifdef HAVE_LIBONIG
308
+ // use a lower regex parse depth limit than the default (4096) to protect
309
+ // from stack-overflows
310
+ // https://github.com/jqlang/jq/security/advisories/GHSA-f946-j5j2-4w5m
311
+ onig_set_parse_depth_limit(1024);
312
+ #endif
313
+
328
314
  #ifdef __OpenBSD__
329
315
  if (pledge("stdio rpath", NULL) == -1) {
330
316
  perror("pledge");
@@ -343,8 +329,6 @@ int main(int argc, char* argv[]) {
343
329
  jv ARGS = jv_array(); /* positional arguments */
344
330
  jv program_arguments = jv_object(); /* named arguments */
345
331
 
346
- if (argc) progname = argv[0];
347
-
348
332
  jq = jq_init();
349
333
  if (jq == NULL) {
350
334
  perror("jq_init");
@@ -361,9 +345,8 @@ int main(int argc, char* argv[]) {
361
345
  int further_args_are_json = 0;
362
346
  int args_done = 0;
363
347
  int jq_flags = 0;
364
- size_t short_opts = 0;
365
348
  jv lib_search_paths = jv_null();
366
- for (int i=1; i<argc; i++, short_opts = 0) {
349
+ for (int i=1; i<argc; i++) {
367
350
  if (args_done || !isoptish(argv[i])) {
368
351
  if (!program) {
369
352
  program = argv[i];
@@ -372,7 +355,7 @@ int main(int argc, char* argv[]) {
372
355
  } else if (further_args_are_json) {
373
356
  jv v = jv_parse(argv[i]);
374
357
  if (!jv_is_valid(v)) {
375
- fprintf(stderr, "%s: invalid JSON text passed to --jsonargs\n", progname);
358
+ fprintf(stderr, "jq: invalid JSON text passed to --jsonargs\n");
376
359
  die();
377
360
  }
378
361
  ARGS = jv_array_append(ARGS, v);
@@ -383,223 +366,174 @@ int main(int argc, char* argv[]) {
383
366
  } else if (!strcmp(argv[i], "--")) {
384
367
  args_done = 1;
385
368
  } else {
386
- if (argv[i][1] == 'L') {
387
- if (jv_get_kind(lib_search_paths) == JV_KIND_NULL)
388
- lib_search_paths = jv_array();
389
- if (argv[i][2] != 0) { // -Lname (faster check than strlen)
390
- lib_search_paths = jv_array_append(lib_search_paths, jq_realpath(jv_string(argv[i]+2)));
391
- } else if (i >= argc - 1) {
392
- fprintf(stderr, "-L takes a parameter: (e.g. -L /search/path or -L/search/path)\n");
393
- die();
394
- } else {
395
- lib_search_paths = jv_array_append(lib_search_paths, jq_realpath(jv_string(argv[i+1])));
396
- i++;
397
- }
398
- continue;
399
- }
400
-
401
- if (isoption(argv[i], 's', "slurp", &short_opts)) {
402
- options |= SLURP;
403
- if (!short_opts) continue;
404
- }
405
- if (isoption(argv[i], 'r', "raw-output", &short_opts)) {
406
- options |= RAW_OUTPUT;
407
- if (!short_opts) continue;
408
- }
409
- if (isoption(argv[i], 0, "raw-output0", &short_opts)) {
410
- options |= RAW_OUTPUT | RAW_NO_LF | RAW_OUTPUT0;
411
- if (!short_opts) continue;
412
- }
413
- if (isoption(argv[i], 'j', "join-output", &short_opts)) {
414
- options |= RAW_OUTPUT | RAW_NO_LF;
415
- if (!short_opts) continue;
416
- }
417
- if (isoption(argv[i], 'c', "compact-output", &short_opts)) {
418
- dumpopts &= ~(JV_PRINT_TAB | JV_PRINT_INDENT_FLAGS(7));
419
- if (!short_opts) continue;
420
- }
421
- if (isoption(argv[i], 'C', "color-output", &short_opts)) {
422
- options |= COLOR_OUTPUT;
423
- if (!short_opts) continue;
424
- }
425
- if (isoption(argv[i], 'M', "monochrome-output", &short_opts)) {
426
- options |= NO_COLOR_OUTPUT;
427
- if (!short_opts) continue;
428
- }
429
- if (isoption(argv[i], 'a', "ascii-output", &short_opts)) {
430
- options |= ASCII_OUTPUT;
431
- if (!short_opts) continue;
432
- }
433
- if (isoption(argv[i], 0, "unbuffered", &short_opts)) {
434
- options |= UNBUFFERED_OUTPUT;
435
- continue;
436
- }
437
- if (isoption(argv[i], 'S', "sort-keys", &short_opts)) {
438
- options |= SORTED_OUTPUT;
439
- if (!short_opts) continue;
440
- }
441
- if (isoption(argv[i], 'R', "raw-input", &short_opts)) {
442
- options |= RAW_INPUT;
443
- if (!short_opts) continue;
444
- }
445
- if (isoption(argv[i], 'n', "null-input", &short_opts)) {
446
- options |= PROVIDE_NULL;
447
- if (!short_opts) continue;
448
- }
449
- if (isoption(argv[i], 'f', "from-file", &short_opts)) {
450
- options |= FROM_FILE;
451
- if (!short_opts) continue;
452
- }
453
- if (isoption(argv[i], 'b', "binary", &short_opts)) {
369
+ const char* text = argv[i];
370
+ int is_short;
371
+ // First '-' already checked by isoptish
372
+ if (text[1] == '-') {
373
+ text += 2;
374
+ is_short = 0;
375
+ } else {
376
+ text++;
377
+ is_short = 1;
378
+ }
379
+ int raw; // Temporary for --rawfile
380
+
381
+ // Parse a long option in one iteration or iterate over short options
382
+ while (text != NULL) {
383
+ if (isoption(&text, 's', "slurp", is_short)) {
384
+ options |= SLURP;
385
+ } else if (isoption(&text, 'r', "raw-output", is_short)) {
386
+ options |= RAW_OUTPUT;
387
+ } else if (isoption(&text, 0, "raw-output0", is_short)) {
388
+ options |= RAW_OUTPUT | RAW_NO_LF | RAW_OUTPUT0;
389
+ } else if (isoption(&text, 'j', "join-output", is_short)) {
390
+ options |= RAW_OUTPUT | RAW_NO_LF;
391
+ } else if (isoption(&text, 'c', "compact-output", is_short)) {
392
+ dumpopts &= ~(JV_PRINT_TAB | JV_PRINT_INDENT_FLAGS(7));
393
+ } else if (isoption(&text, 'C', "color-output", is_short)) {
394
+ options |= COLOR_OUTPUT;
395
+ } else if (isoption(&text, 'M', "monochrome-output", is_short)) {
396
+ options |= NO_COLOR_OUTPUT;
397
+ } else if (isoption(&text, 'a', "ascii-output", is_short)) {
398
+ options |= ASCII_OUTPUT;
399
+ } else if (isoption(&text, 0, "unbuffered", is_short)) {
400
+ options |= UNBUFFERED_OUTPUT;
401
+ } else if (isoption(&text, 'S', "sort-keys", is_short)) {
402
+ options |= SORTED_OUTPUT;
403
+ } else if (isoption(&text, 'R', "raw-input", is_short)) {
404
+ options |= RAW_INPUT;
405
+ } else if (isoption(&text, 'n', "null-input", is_short)) {
406
+ options |= PROVIDE_NULL;
407
+ } else if (isoption(&text, 'f', "from-file", is_short)) {
408
+ options |= FROM_FILE;
409
+ } else if (isoption(&text, 'L', "library-path", is_short)) {
410
+ if (jv_get_kind(lib_search_paths) == JV_KIND_NULL)
411
+ lib_search_paths = jv_array();
412
+ if (text != NULL) { // -Lname
413
+ lib_search_paths = jv_array_append(lib_search_paths, jq_realpath(jv_string(text)));
414
+ text = NULL;
415
+ } else if (i >= argc - 1) {
416
+ fprintf(stderr, "-L takes a parameter: (e.g. -L /search/path or -L/search/path)\n");
417
+ die();
418
+ } else {
419
+ lib_search_paths = jv_array_append(lib_search_paths, jq_realpath(jv_string(argv[i+1])));
420
+ i++;
421
+ }
422
+ } else if (isoption(&text, 'b', "binary", is_short)) {
454
423
  #ifdef WIN32
455
- fflush(stdout);
456
- fflush(stderr);
457
- _setmode(fileno(stdin), _O_BINARY);
458
- _setmode(fileno(stdout), _O_BINARY);
459
- _setmode(fileno(stderr), _O_BINARY);
460
- if (!short_opts) continue;
424
+ fflush(stdout);
425
+ fflush(stderr);
426
+ _setmode(fileno(stdin), _O_BINARY);
427
+ _setmode(fileno(stdout), _O_BINARY);
428
+ _setmode(fileno(stderr), _O_BINARY);
461
429
  #endif
462
- }
463
- if (isoption(argv[i], 0, "tab", &short_opts)) {
464
- dumpopts &= ~JV_PRINT_INDENT_FLAGS(7);
465
- dumpopts |= JV_PRINT_TAB | JV_PRINT_PRETTY;
466
- continue;
467
- }
468
- if (isoption(argv[i], 0, "indent", &short_opts)) {
469
- if (i >= argc - 1) {
470
- fprintf(stderr, "%s: --indent takes one parameter\n", progname);
471
- die();
472
- }
473
- dumpopts &= ~(JV_PRINT_TAB | JV_PRINT_INDENT_FLAGS(7));
474
- int indent = atoi(argv[i+1]);
475
- if (indent < -1 || indent > 7) {
476
- fprintf(stderr, "%s: --indent takes a number between -1 and 7\n", progname);
477
- die();
478
- }
479
- dumpopts |= JV_PRINT_INDENT_FLAGS(indent);
480
- i++;
481
- continue;
482
- }
483
- if (isoption(argv[i], 0, "seq", &short_opts)) {
484
- options |= SEQ;
485
- continue;
486
- }
487
- if (isoption(argv[i], 0, "stream", &short_opts)) {
488
- parser_flags |= JV_PARSE_STREAMING;
489
- continue;
490
- }
491
- if (isoption(argv[i], 0, "stream-errors", &short_opts)) {
492
- parser_flags |= JV_PARSE_STREAMING | JV_PARSE_STREAM_ERRORS;
493
- continue;
494
- }
495
- if (isoption(argv[i], 'e', "exit-status", &short_opts)) {
496
- options |= EXIT_STATUS;
497
- if (!short_opts) continue;
498
- }
499
- // FIXME: For --arg* we should check that the varname is acceptable
500
- if (isoption(argv[i], 0, "args", &short_opts)) {
501
- further_args_are_strings = 1;
502
- further_args_are_json = 0;
503
- continue;
504
- }
505
- if (isoption(argv[i], 0, "jsonargs", &short_opts)) {
506
- further_args_are_strings = 0;
507
- further_args_are_json = 1;
508
- continue;
509
- }
510
- if (isoption(argv[i], 0, "arg", &short_opts)) {
511
- if (i >= argc - 2) {
512
- fprintf(stderr, "%s: --arg takes two parameters (e.g. --arg varname value)\n", progname);
513
- die();
514
- }
515
- if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1])))
516
- program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), jv_string(argv[i+2]));
517
- i += 2; // skip the next two arguments
518
- continue;
519
- }
520
- if (isoption(argv[i], 0, "argjson", &short_opts)) {
521
- if (i >= argc - 2) {
522
- fprintf(stderr, "%s: --argjson takes two parameters (e.g. --argjson varname text)\n", progname);
523
- die();
524
- }
525
- if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {
526
- jv v = jv_parse(argv[i+2]);
527
- if (!jv_is_valid(v)) {
528
- fprintf(stderr, "%s: invalid JSON text passed to --argjson\n", progname);
430
+ } else if (isoption(&text, 0, "tab", is_short)) {
431
+ dumpopts &= ~JV_PRINT_INDENT_FLAGS(7);
432
+ dumpopts |= JV_PRINT_TAB | JV_PRINT_PRETTY;
433
+ } else if (isoption(&text, 0, "indent", is_short)) {
434
+ if (i >= argc - 1) {
435
+ fprintf(stderr, "jq: --indent takes one parameter\n");
529
436
  die();
530
437
  }
531
- program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), v);
532
- }
533
- i += 2; // skip the next two arguments
534
- continue;
535
- }
536
- if (isoption(argv[i], 0, "rawfile", &short_opts) ||
537
- isoption(argv[i], 0, "slurpfile", &short_opts)) {
538
- int raw = isoption(argv[i], 0, "rawfile", &short_opts);
539
- const char *which;
540
- if (raw)
541
- which = "rawfile";
542
- else
543
- which = "slurpfile";
544
- if (i >= argc - 2) {
545
- fprintf(stderr, "%s: --%s takes two parameters (e.g. --%s varname filename)\n", progname, which, which);
546
- die();
547
- }
548
- if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {
549
- jv data = jv_load_file(argv[i+2], raw);
550
- if (!jv_is_valid(data)) {
551
- data = jv_invalid_get_msg(data);
552
- fprintf(stderr, "%s: Bad JSON in --%s %s %s: %s\n", progname, which,
553
- argv[i+1], argv[i+2], jv_string_value(data));
554
- jv_free(data);
555
- ret = JQ_ERROR_SYSTEM;
556
- goto out;
438
+ char* end = NULL;
439
+ errno = 0;
440
+ long indent = strtol(argv[i+1], &end, 10);
441
+ if (errno || indent < -1 || indent > 7 ||
442
+ isspace(*argv[i+1]) || end == argv[i+1] || *end) {
443
+ fprintf(stderr, "jq: --indent takes a number between -1 and 7\n");
444
+ die();
445
+ }
446
+ dumpopts &= ~(JV_PRINT_TAB | JV_PRINT_INDENT_FLAGS(7));
447
+ dumpopts |= JV_PRINT_INDENT_FLAGS(indent);
448
+ i++;
449
+ } else if (isoption(&text, 0, "seq", is_short)) {
450
+ options |= SEQ;
451
+ } else if (isoption(&text, 0, "stream", is_short)) {
452
+ parser_flags |= JV_PARSE_STREAMING;
453
+ } else if (isoption(&text, 0, "stream-errors", is_short)) {
454
+ parser_flags |= JV_PARSE_STREAMING | JV_PARSE_STREAM_ERRORS;
455
+ } else if (isoption(&text, 'e', "exit-status", is_short)) {
456
+ options |= EXIT_STATUS;
457
+ } else if (isoption(&text, 0, "args", is_short)) {
458
+ further_args_are_strings = 1;
459
+ further_args_are_json = 0;
460
+ } else if (isoption(&text, 0, "jsonargs", is_short)) {
461
+ further_args_are_strings = 0;
462
+ further_args_are_json = 1;
463
+ } else if (isoption(&text, 0, "arg", is_short)) {
464
+ if (i >= argc - 2) {
465
+ fprintf(stderr, "jq: --arg takes two parameters (e.g. --arg varname value)\n");
466
+ die();
557
467
  }
558
- program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), data);
468
+ if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1])))
469
+ program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), jv_string(argv[i+2]));
470
+ i += 2; // skip the next two arguments
471
+ } else if (isoption(&text, 0, "argjson", is_short)) {
472
+ if (i >= argc - 2) {
473
+ fprintf(stderr, "jq: --argjson takes two parameters (e.g. --argjson varname text)\n");
474
+ die();
475
+ }
476
+ if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {
477
+ jv v = jv_parse(argv[i+2]);
478
+ if (!jv_is_valid(v)) {
479
+ fprintf(stderr, "jq: invalid JSON text passed to --argjson\n");
480
+ die();
481
+ }
482
+ program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), v);
483
+ }
484
+ i += 2; // skip the next two arguments
485
+ } else if ((raw = isoption(&text, 0, "rawfile", is_short)) ||
486
+ isoption(&text, 0, "slurpfile", is_short)) {
487
+ const char *which = raw ? "rawfile" : "slurpfile";
488
+ if (i >= argc - 2) {
489
+ fprintf(stderr, "jq: --%s takes two parameters (e.g. --%s varname filename)\n", which, which);
490
+ die();
491
+ }
492
+ if (!jv_object_has(jv_copy(program_arguments), jv_string(argv[i+1]))) {
493
+ jv data = jv_load_file(argv[i+2], raw);
494
+ if (!jv_is_valid(data)) {
495
+ data = jv_invalid_get_msg(data);
496
+ fprintf(stderr, "jq: Bad JSON in --%s %s %s: %s\n", which,
497
+ argv[i+1], argv[i+2], jv_string_value(data));
498
+ jv_free(data);
499
+ ret = JQ_ERROR_SYSTEM;
500
+ goto out;
501
+ }
502
+ program_arguments = jv_object_set(program_arguments, jv_string(argv[i+1]), data);
503
+ }
504
+ i += 2; // skip the next two arguments
505
+ } else if (isoption(&text, 0, "debug-dump-disasm", is_short)) {
506
+ options |= DUMP_DISASM;
507
+ } else if (isoption(&text, 0, "debug-trace=all", is_short)) {
508
+ jq_flags |= JQ_DEBUG_TRACE_ALL;
509
+ } else if (isoption(&text, 0, "debug-trace", is_short)) {
510
+ jq_flags |= JQ_DEBUG_TRACE;
511
+ } else if (isoption(&text, 'h', "help", is_short)) {
512
+ usage(0, 0);
513
+ } else if (isoption(&text, 'V', "version", is_short)) {
514
+ printf("jq-%s\n", JQ_VERSION);
515
+ ret = JQ_OK;
516
+ goto out;
517
+ } else if (isoption(&text, 0, "build-configuration", is_short)) {
518
+ printf("%s\n", JQ_CONFIG);
519
+ ret = JQ_OK;
520
+ goto out;
521
+ } else if (isoption(&text, 0, "run-tests", is_short)) {
522
+ i++;
523
+ // XXX Pass program_arguments, even a whole jq_state *, through;
524
+ // could be useful for testing
525
+ ret = jq_testsuite(lib_search_paths,
526
+ (options & DUMP_DISASM) || (jq_flags & JQ_DEBUG_TRACE),
527
+ argc - i, argv + i);
528
+ goto out;
529
+ } else {
530
+ if (is_short) {
531
+ fprintf(stderr, "jq: Unknown option -%c\n", text[0]);
532
+ } else {
533
+ fprintf(stderr, "jq: Unknown option --%s\n", text);
534
+ }
535
+ die();
559
536
  }
560
- i += 2; // skip the next two arguments
561
- continue;
562
- }
563
- if (isoption(argv[i], 0, "debug-dump-disasm", &short_opts)) {
564
- options |= DUMP_DISASM;
565
- continue;
566
- }
567
- if (isoption(argv[i], 0, "debug-trace=all", &short_opts)) {
568
- jq_flags |= JQ_DEBUG_TRACE_ALL;
569
- if (!short_opts) continue;
570
- }
571
- if (isoption(argv[i], 0, "debug-trace", &short_opts)) {
572
- jq_flags |= JQ_DEBUG_TRACE;
573
- continue;
574
- }
575
- if (isoption(argv[i], 'h', "help", &short_opts)) {
576
- usage(0, 0);
577
- if (!short_opts) continue;
578
- }
579
- if (isoption(argv[i], 'V', "version", &short_opts)) {
580
- printf("jq-%s\n", JQ_VERSION);
581
- ret = JQ_OK;
582
- goto out;
583
- }
584
- if (isoption(argv[i], 0, "build-configuration", &short_opts)) {
585
- printf("%s\n", JQ_CONFIG);
586
- ret = JQ_OK;
587
- goto out;
588
- }
589
- if (isoption(argv[i], 0, "run-tests", &short_opts)) {
590
- i++;
591
- // XXX Pass program_arguments, even a whole jq_state *, through;
592
- // could be useful for testing
593
- ret = jq_testsuite(lib_search_paths,
594
- (options & DUMP_DISASM) || (jq_flags & JQ_DEBUG_TRACE),
595
- argc - i, argv + i);
596
- goto out;
597
- }
598
-
599
- // check for unknown options... if this argument was a short option
600
- if (strlen(argv[i]) != short_opts + 1) {
601
- fprintf(stderr, "%s: Unknown option %s\n", progname, argv[i]);
602
- die();
603
537
  }
604
538
  }
605
539
  }
@@ -633,7 +567,7 @@ int main(int argc, char* argv[]) {
633
567
  if (options & COLOR_OUTPUT) dumpopts |= JV_PRINT_COLOR;
634
568
  if (options & NO_COLOR_OUTPUT) dumpopts &= ~JV_PRINT_COLOR;
635
569
 
636
- if (getenv("JQ_COLORS") != NULL && !jq_set_colors(getenv("JQ_COLORS")))
570
+ if (!jq_set_colors(getenv("JQ_COLORS")))
637
571
  fprintf(stderr, "Failed to set $JQ_COLORS\n");
638
572
 
639
573
  if (jv_get_kind(lib_search_paths) == JV_KIND_NULL) {
@@ -658,7 +592,7 @@ int main(int argc, char* argv[]) {
658
592
  jq_set_attr(jq, jv_string("VERSION_DIR"), jv_string_fmt("%.*s-master", (int)(strchr(JQ_VERSION, '-') - JQ_VERSION), JQ_VERSION));
659
593
 
660
594
  #ifdef USE_ISATTY
661
- if (!program && (!isatty(STDOUT_FILENO) || !isatty(STDIN_FILENO)))
595
+ if (!program && !(options & FROM_FILE) && (!isatty(STDOUT_FILENO) || !isatty(STDIN_FILENO)))
662
596
  program = ".";
663
597
  #endif
664
598
 
@@ -674,7 +608,7 @@ int main(int argc, char* argv[]) {
674
608
  jv data = jv_load_file(program, 1);
675
609
  if (!jv_is_valid(data)) {
676
610
  data = jv_invalid_get_msg(data);
677
- fprintf(stderr, "%s: %s\n", progname, jv_string_value(data));
611
+ fprintf(stderr, "jq: %s\n", jv_string_value(data));
678
612
  jv_free(data);
679
613
  ret = JQ_ERROR_SYSTEM;
680
614
  goto out;
@@ -687,7 +621,7 @@ int main(int argc, char* argv[]) {
687
621
  program_arguments = jv_object_set(program_arguments,
688
622
  jv_string("JQ_BUILD_CONFIGURATION"),
689
623
  jv_string(JQ_CONFIG)); /* named arguments */
690
- compiled = jq_compile_args(jq, skip_shebang(jv_string_value(data)), jv_copy(program_arguments));
624
+ compiled = jq_compile_args(jq, jv_string_value(data), jv_copy(program_arguments));
691
625
  free(program_origin);
692
626
  jv_free(data);
693
627
  } else {