@port-labs/jq-node-bindings 0.0.4 → 0.0.6

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 (286) hide show
  1. package/binding.gyp +3 -3
  2. package/configure +8 -6
  3. package/deps/jq/.travis.yml +184 -35
  4. package/deps/jq/AUTHORS +31 -30
  5. package/deps/jq/COPYING +2 -2
  6. package/deps/jq/KEYS +8 -0
  7. package/deps/jq/Makefile.am +85 -70
  8. package/deps/jq/NEWS +5 -4
  9. package/deps/jq/README.md +18 -9
  10. package/deps/jq/appveyor.yml +53 -0
  11. package/deps/jq/compile-ios.sh +5 -5
  12. package/deps/jq/config/m4/check-math-func.m4 +7 -2
  13. package/deps/jq/configure.ac +130 -68
  14. package/deps/jq/docs/Rakefile +14 -135
  15. package/deps/jq/docs/Rakefile.manual +49 -0
  16. package/deps/jq/docs/Rakefile.website +76 -0
  17. package/deps/jq/docs/content/2.download/default.yml +115 -39
  18. package/deps/jq/docs/content/3.manual/manual.yml +641 -231
  19. package/deps/jq/docs/content/3.manual/v1.3/manual.yml +130 -130
  20. package/deps/jq/docs/content/3.manual/v1.4/manual.yml +160 -160
  21. package/deps/jq/docs/content/3.manual/v1.5/manual.yml +2878 -0
  22. package/deps/jq/docs/content/3.manual/v1.6/manual.yml +3287 -0
  23. package/deps/jq/docs/content/index/index.yml +28 -6
  24. package/deps/jq/docs/public/.htaccess +2 -2
  25. package/deps/jq/docs/public/css/base.scss +141 -59
  26. package/deps/jq/docs/public/js/manual-search.js +52 -0
  27. package/deps/jq/docs/site.yml +1 -10
  28. package/deps/jq/docs/templates/default.liquid +10 -10
  29. package/deps/jq/docs/templates/index.liquid +45 -32
  30. package/deps/jq/docs/templates/manual.liquid +67 -90
  31. package/deps/jq/docs/templates/shared/_footer.liquid +10 -5
  32. package/deps/jq/docs/templates/shared/_head.liquid +17 -12
  33. package/deps/jq/docs/templates/shared/_navbar.liquid +27 -0
  34. package/deps/jq/jq.1.prebuilt +523 -139
  35. package/deps/jq/modules/oniguruma/AUTHORS +1 -0
  36. package/deps/jq/modules/oniguruma/CMakeLists.txt +86 -0
  37. package/deps/jq/modules/oniguruma/COPYING +28 -0
  38. package/deps/jq/modules/oniguruma/ChangeLog +0 -0
  39. package/deps/jq/modules/oniguruma/HISTORY +2138 -0
  40. package/deps/jq/modules/oniguruma/Makefile.am +33 -0
  41. package/deps/jq/modules/oniguruma/NEWS +0 -0
  42. package/deps/jq/modules/oniguruma/README +189 -0
  43. package/deps/jq/modules/oniguruma/README.ja +195 -0
  44. package/deps/jq/modules/oniguruma/README.md +203 -0
  45. package/deps/jq/modules/oniguruma/cmake/dist.cmake +321 -0
  46. package/deps/jq/modules/oniguruma/compile +348 -0
  47. package/deps/jq/modules/oniguruma/config.guess +1754 -0
  48. package/deps/jq/modules/oniguruma/config.sub +1890 -0
  49. package/deps/jq/modules/oniguruma/configure.ac +87 -0
  50. package/deps/jq/modules/oniguruma/contributed/libfuzzer-onig.cpp +31 -0
  51. package/deps/jq/modules/oniguruma/depcomp +791 -0
  52. package/deps/jq/modules/oniguruma/dist.info +10 -0
  53. package/deps/jq/modules/oniguruma/doc/API +660 -0
  54. package/deps/jq/modules/oniguruma/doc/API.ja +667 -0
  55. package/deps/jq/modules/oniguruma/doc/FAQ +12 -0
  56. package/deps/jq/modules/oniguruma/doc/FAQ.ja +22 -0
  57. package/deps/jq/modules/oniguruma/doc/RE +436 -0
  58. package/deps/jq/modules/oniguruma/doc/RE.ja +448 -0
  59. package/deps/jq/modules/oniguruma/doc/UNICODE_PROPERTIES +698 -0
  60. package/deps/jq/modules/oniguruma/index.html +181 -0
  61. package/deps/jq/modules/oniguruma/index_ja.html +184 -0
  62. package/deps/jq/modules/oniguruma/install-sh +541 -0
  63. package/deps/jq/modules/oniguruma/m4/.whatever +0 -0
  64. package/deps/jq/modules/oniguruma/make_win32.bat +3 -0
  65. package/deps/jq/modules/oniguruma/make_win64.bat +3 -0
  66. package/deps/jq/modules/oniguruma/missing +215 -0
  67. package/deps/jq/modules/oniguruma/onig-config.in +78 -0
  68. package/deps/jq/modules/oniguruma/oniguruma.pc.cmake.in +13 -0
  69. package/deps/jq/modules/oniguruma/oniguruma.pc.in +14 -0
  70. package/deps/jq/modules/oniguruma/sample/CMakeLists.txt +28 -0
  71. package/deps/jq/modules/oniguruma/sample/Makefile.am +34 -0
  72. package/deps/jq/modules/oniguruma/sample/bug_fix.c +131 -0
  73. package/deps/jq/modules/oniguruma/sample/crnl.c +127 -0
  74. package/deps/jq/modules/oniguruma/sample/encode.c +308 -0
  75. package/deps/jq/modules/oniguruma/sample/listcap.c +110 -0
  76. package/deps/jq/modules/oniguruma/sample/names.c +75 -0
  77. package/deps/jq/modules/oniguruma/sample/posix.c +96 -0
  78. package/deps/jq/modules/oniguruma/sample/scan.c +88 -0
  79. package/deps/jq/modules/oniguruma/sample/simple.c +59 -0
  80. package/deps/jq/modules/oniguruma/sample/sql.c +76 -0
  81. package/deps/jq/modules/oniguruma/sample/syntax.c +76 -0
  82. package/deps/jq/modules/oniguruma/sample/user_property.c +87 -0
  83. package/deps/jq/modules/oniguruma/src/Makefile.am +58 -0
  84. package/deps/jq/modules/oniguruma/src/Makefile.windows +183 -0
  85. package/deps/jq/modules/oniguruma/src/ascii.c +61 -0
  86. package/deps/jq/modules/oniguruma/src/big5.c +190 -0
  87. package/deps/jq/modules/oniguruma/src/config.h.cmake.in +71 -0
  88. package/deps/jq/modules/oniguruma/src/config.h.win32 +84 -0
  89. package/deps/jq/modules/oniguruma/src/config.h.win64 +84 -0
  90. package/deps/jq/modules/oniguruma/src/cp1251.c +203 -0
  91. package/deps/jq/modules/oniguruma/src/euc_jp.c +310 -0
  92. package/deps/jq/modules/oniguruma/src/euc_jp_prop.c +158 -0
  93. package/deps/jq/modules/oniguruma/src/euc_jp_prop.gperf +27 -0
  94. package/deps/jq/modules/oniguruma/src/euc_kr.c +188 -0
  95. package/deps/jq/modules/oniguruma/src/euc_tw.c +171 -0
  96. package/deps/jq/modules/oniguruma/src/gb18030.c +538 -0
  97. package/deps/jq/modules/oniguruma/src/gperf_fold_key_conv.py +67 -0
  98. package/deps/jq/modules/oniguruma/src/gperf_unfold_key_conv.py +55 -0
  99. package/deps/jq/modules/oniguruma/src/iso8859_1.c +275 -0
  100. package/deps/jq/modules/oniguruma/src/iso8859_10.c +242 -0
  101. package/deps/jq/modules/oniguruma/src/iso8859_11.c +99 -0
  102. package/deps/jq/modules/oniguruma/src/iso8859_13.c +231 -0
  103. package/deps/jq/modules/oniguruma/src/iso8859_14.c +244 -0
  104. package/deps/jq/modules/oniguruma/src/iso8859_15.c +238 -0
  105. package/deps/jq/modules/oniguruma/src/iso8859_16.c +240 -0
  106. package/deps/jq/modules/oniguruma/src/iso8859_2.c +238 -0
  107. package/deps/jq/modules/oniguruma/src/iso8859_3.c +238 -0
  108. package/deps/jq/modules/oniguruma/src/iso8859_4.c +240 -0
  109. package/deps/jq/modules/oniguruma/src/iso8859_5.c +229 -0
  110. package/deps/jq/modules/oniguruma/src/iso8859_6.c +99 -0
  111. package/deps/jq/modules/oniguruma/src/iso8859_7.c +225 -0
  112. package/deps/jq/modules/oniguruma/src/iso8859_8.c +99 -0
  113. package/deps/jq/modules/oniguruma/src/iso8859_9.c +231 -0
  114. package/deps/jq/modules/oniguruma/src/koi8.c +253 -0
  115. package/deps/jq/modules/oniguruma/src/koi8_r.c +215 -0
  116. package/deps/jq/modules/oniguruma/src/make_unicode_fold.sh +22 -0
  117. package/deps/jq/modules/oniguruma/src/make_unicode_fold_data.py +306 -0
  118. package/deps/jq/modules/oniguruma/src/make_unicode_property.sh +18 -0
  119. package/deps/jq/modules/oniguruma/src/make_unicode_property_data.py +545 -0
  120. package/deps/jq/modules/oniguruma/src/mktable.c +1184 -0
  121. package/deps/jq/modules/oniguruma/src/onig_init.c +45 -0
  122. package/deps/jq/modules/oniguruma/src/oniggnu.h +85 -0
  123. package/deps/jq/modules/oniguruma/src/onigposix.h +169 -0
  124. package/deps/jq/modules/oniguruma/src/oniguruma.h +841 -0
  125. package/deps/jq/modules/oniguruma/src/regcomp.c +6300 -0
  126. package/deps/jq/modules/oniguruma/src/regenc.c +917 -0
  127. package/deps/jq/modules/oniguruma/src/regenc.h +243 -0
  128. package/deps/jq/modules/oniguruma/src/regerror.c +393 -0
  129. package/deps/jq/modules/oniguruma/src/regexec.c +3856 -0
  130. package/deps/jq/modules/oniguruma/src/regext.c +202 -0
  131. package/deps/jq/modules/oniguruma/src/reggnu.c +147 -0
  132. package/deps/jq/modules/oniguruma/src/regint.h +779 -0
  133. package/deps/jq/modules/oniguruma/src/regparse.c +5403 -0
  134. package/deps/jq/modules/oniguruma/src/regparse.h +351 -0
  135. package/deps/jq/modules/oniguruma/src/regposerr.c +105 -0
  136. package/deps/jq/modules/oniguruma/src/regposix.c +306 -0
  137. package/deps/jq/modules/oniguruma/src/regsyntax.c +315 -0
  138. package/deps/jq/modules/oniguruma/src/regtrav.c +76 -0
  139. package/deps/jq/modules/oniguruma/src/regversion.c +57 -0
  140. package/deps/jq/modules/oniguruma/src/sjis.c +341 -0
  141. package/deps/jq/modules/oniguruma/src/sjis_prop.c +158 -0
  142. package/deps/jq/modules/oniguruma/src/sjis_prop.gperf +27 -0
  143. package/deps/jq/modules/oniguruma/src/st.c +589 -0
  144. package/deps/jq/modules/oniguruma/src/st.h +68 -0
  145. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold1_key.c +2250 -0
  146. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold2_key.c +203 -0
  147. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold3_key.c +113 -0
  148. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_fold_data.c +1225 -0
  149. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data.c +24742 -0
  150. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_property_data_posix.c +4846 -0
  151. package/deps/jq/modules/oniguruma/src/unicode-7.0/unicode_unfold_key.c +2571 -0
  152. package/deps/jq/modules/oniguruma/src/unicode.c +664 -0
  153. package/deps/jq/modules/oniguruma/src/unicode_fold1_key.c +2548 -0
  154. package/deps/jq/modules/oniguruma/src/unicode_fold2_key.c +203 -0
  155. package/deps/jq/modules/oniguruma/src/unicode_fold3_key.c +113 -0
  156. package/deps/jq/modules/oniguruma/src/unicode_fold_data.c +1366 -0
  157. package/deps/jq/modules/oniguruma/src/unicode_property_data.c +25306 -0
  158. package/deps/jq/modules/oniguruma/src/unicode_property_data_posix.c +4940 -0
  159. package/deps/jq/modules/oniguruma/src/unicode_unfold_key.c +2854 -0
  160. package/deps/jq/modules/oniguruma/src/utf16_be.c +235 -0
  161. package/deps/jq/modules/oniguruma/src/utf16_le.c +245 -0
  162. package/deps/jq/modules/oniguruma/src/utf32_be.c +194 -0
  163. package/deps/jq/modules/oniguruma/src/utf32_le.c +194 -0
  164. package/deps/jq/modules/oniguruma/src/utf8.c +335 -0
  165. package/deps/jq/modules/oniguruma/test/Makefile.am +28 -0
  166. package/deps/jq/modules/oniguruma/test/testc.c +874 -0
  167. package/deps/jq/modules/oniguruma/test/testu.c +916 -0
  168. package/deps/jq/modules/oniguruma/test-driver +153 -0
  169. package/deps/jq/modules/oniguruma/windows/testc.c +869 -0
  170. package/deps/jq/scripts/crosscompile +2 -1
  171. package/deps/jq/scripts/gen_utf8_tables.py +2 -3
  172. package/deps/jq/scripts/update-website +29 -0
  173. package/deps/jq/scripts/version +7 -2
  174. package/deps/jq/sig/jq-release.key +41 -0
  175. package/deps/jq/sig/v1.3/jq-linux-x86.asc +17 -0
  176. package/deps/jq/sig/v1.3/jq-linux-x86_64.asc +17 -0
  177. package/deps/jq/sig/v1.3/jq-osx-x86.asc +17 -0
  178. package/deps/jq/sig/v1.3/jq-osx-x86_64.asc +17 -0
  179. package/deps/jq/sig/v1.3/jq-win32.exe.asc +17 -0
  180. package/deps/jq/sig/v1.3/jq-win64.exe.asc +17 -0
  181. package/deps/jq/sig/v1.3/sha256sum.txt +6 -0
  182. package/deps/jq/sig/v1.4/jq-linux-x86.asc +17 -0
  183. package/deps/jq/sig/v1.4/jq-linux-x86_64.asc +17 -0
  184. package/deps/jq/sig/v1.4/jq-osx-x86.asc +17 -0
  185. package/deps/jq/sig/v1.4/jq-osx-x86_64.asc +17 -0
  186. package/deps/jq/sig/v1.4/jq-solaris11-32.asc +17 -0
  187. package/deps/jq/sig/v1.4/jq-solaris11-64.asc +17 -0
  188. package/deps/jq/sig/v1.4/jq-win32.exe.asc +17 -0
  189. package/deps/jq/sig/v1.4/jq-win64.exe.asc +17 -0
  190. package/deps/jq/sig/v1.4/sha256sum.txt +8 -0
  191. package/deps/jq/sig/v1.5/jq-linux32-no-oniguruma.asc +17 -0
  192. package/deps/jq/sig/v1.5/jq-linux32.asc +17 -0
  193. package/deps/jq/sig/v1.5/jq-linux64.asc +17 -0
  194. package/deps/jq/sig/v1.5/jq-osx-amd64.asc +17 -0
  195. package/deps/jq/sig/v1.5/jq-win32.exe.asc +17 -0
  196. package/deps/jq/sig/v1.5/jq-win64.exe.asc +17 -0
  197. package/deps/jq/sig/v1.5/sha256sum.txt +5 -0
  198. package/deps/jq/sig/v1.5rc1/jq-linux-x86_64-static.asc +17 -0
  199. package/deps/jq/sig/v1.5rc1/jq-win32.exe.asc +17 -0
  200. package/deps/jq/sig/v1.5rc1/jq-win64.exe.asc +17 -0
  201. package/deps/jq/sig/v1.5rc1/sha256sum.txt +3 -0
  202. package/deps/jq/sig/v1.5rc2/jq-linux-x86.asc +17 -0
  203. package/deps/jq/sig/v1.5rc2/jq-linux-x86_64.asc +17 -0
  204. package/deps/jq/sig/v1.5rc2/jq-osx-x86_64.asc +17 -0
  205. package/deps/jq/sig/v1.5rc2/jq-win32.exe.asc +17 -0
  206. package/deps/jq/sig/v1.5rc2/jq-win64.exe.asc +17 -0
  207. package/deps/jq/sig/v1.5rc2/sha256sum.txt +5 -0
  208. package/deps/jq/sig/v1.6/jq-linux32.asc +16 -0
  209. package/deps/jq/sig/v1.6/jq-linux64.asc +16 -0
  210. package/deps/jq/sig/v1.6/jq-osx-amd64.asc +16 -0
  211. package/deps/jq/sig/v1.6/jq-win32.exe.asc +16 -0
  212. package/deps/jq/sig/v1.6/jq-win64.exe.asc +16 -0
  213. package/deps/jq/sig/v1.6/sha256sum.txt +5 -0
  214. package/deps/jq/{builtin.c → src/builtin.c} +449 -344
  215. package/deps/jq/{builtin.h → src/builtin.h} +0 -0
  216. package/deps/jq/src/builtin.jq +311 -0
  217. package/deps/jq/{bytecode.c → src/bytecode.c} +0 -0
  218. package/deps/jq/{bytecode.h → src/bytecode.h} +0 -0
  219. package/deps/jq/{compile.c → src/compile.c} +213 -37
  220. package/deps/jq/{compile.h → src/compile.h} +7 -2
  221. package/deps/jq/{exec_stack.h → src/exec_stack.h} +0 -0
  222. package/deps/jq/{execute.c → src/execute.c} +127 -24
  223. package/deps/jq/{inject_errors.c → src/inject_errors.c} +0 -0
  224. package/deps/jq/{jq.h → src/jq.h} +13 -2
  225. package/deps/jq/{jq_parser.h → src/jq_parser.h} +0 -0
  226. package/deps/jq/{jq_test.c → src/jq_test.c} +1 -1
  227. package/deps/jq/{jv.c → src/jv.c} +24 -5
  228. package/deps/jq/{jv.h → src/jv.h} +46 -11
  229. package/deps/jq/{jv_alloc.c → src/jv_alloc.c} +0 -0
  230. package/deps/jq/{jv_alloc.h → src/jv_alloc.h} +0 -0
  231. package/deps/jq/{jv_aux.c → src/jv_aux.c} +38 -14
  232. package/deps/jq/{jv_dtoa.c → src/jv_dtoa.c} +4 -5
  233. package/deps/jq/{jv_dtoa.h → src/jv_dtoa.h} +0 -0
  234. package/deps/jq/src/jv_file.c +81 -0
  235. package/deps/jq/{jv_parse.c → src/jv_parse.c} +8 -2
  236. package/deps/jq/{jv_print.c → src/jv_print.c} +80 -27
  237. package/deps/jq/{jv_unicode.c → src/jv_unicode.c} +28 -4
  238. package/deps/jq/{jv_unicode.h → src/jv_unicode.h} +1 -0
  239. package/deps/jq/{jv_utf8_tables.h → src/jv_utf8_tables.h} +0 -0
  240. package/deps/jq/{lexer.c → src/lexer.c} +317 -292
  241. package/deps/jq/{lexer.h → src/lexer.h} +16 -12
  242. package/deps/jq/{lexer.l → src/lexer.l} +5 -4
  243. package/deps/jq/src/libm.h +291 -0
  244. package/deps/jq/{linker.c → src/linker.c} +5 -3
  245. package/deps/jq/{linker.h → src/linker.h} +0 -0
  246. package/deps/jq/{locfile.c → src/locfile.c} +1 -1
  247. package/deps/jq/{locfile.h → src/locfile.h} +0 -0
  248. package/deps/jq/{main.c → src/main.c} +202 -100
  249. package/deps/jq/{opcode_list.h → src/opcode_list.h} +4 -0
  250. package/deps/jq/{parser.c → src/parser.c} +1149 -1069
  251. package/deps/jq/{parser.h → src/parser.h} +28 -24
  252. package/deps/jq/{parser.y → src/parser.y} +108 -52
  253. package/deps/jq/{util.c → src/util.c} +12 -9
  254. package/deps/jq/{util.h → src/util.h} +0 -0
  255. package/deps/jq/tests/base64.test +35 -0
  256. package/deps/jq/tests/base64test +5 -0
  257. package/deps/jq/tests/jq-f-test.sh +4 -0
  258. package/deps/jq/tests/jq.test +305 -21
  259. package/deps/jq/tests/jqtest +1 -1
  260. package/deps/jq/tests/mantest +1 -1
  261. package/deps/jq/tests/onig.test +13 -0
  262. package/deps/jq/tests/onigtest +1 -1
  263. package/deps/jq/tests/optional.test +20 -0
  264. package/deps/jq/tests/optionaltest +5 -0
  265. package/deps/jq/tests/setup +7 -1
  266. package/deps/jq/tests/shtest +133 -29
  267. package/deps/jq/tests/utf8-truncate.jq +3 -0
  268. package/deps/jq/tests/utf8test +10 -0
  269. package/lib/index.js +7 -1
  270. package/package.json +3 -3
  271. package/test/santiy.test.js +24 -0
  272. package/deps/jq/docs/default_manpage.md +0 -22
  273. package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.css +0 -1058
  274. package/deps/jq/docs/public/bootstrap/css/bootstrap-responsive.min.css +0 -9
  275. package/deps/jq/docs/public/bootstrap/css/bootstrap.css +0 -5224
  276. package/deps/jq/docs/public/bootstrap/css/bootstrap.min.css +0 -9
  277. package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings-white.png +0 -0
  278. package/deps/jq/docs/public/bootstrap/img/glyphicons-halflings.png +0 -0
  279. package/deps/jq/docs/public/bootstrap/js/bootstrap.js +0 -2027
  280. package/deps/jq/docs/public/bootstrap/js/bootstrap.min.js +0 -6
  281. package/deps/jq/docs/templates/shared/_header.liquid +0 -26
  282. package/deps/jq/jq.1.default +0 -39
  283. package/deps/jq/jv_file.c +0 -49
  284. package/deps/jq/libm.h +0 -160
  285. package/deps/jq/setup.sh +0 -33
  286. package/reports/jest-port-api.xml +0 -35
@@ -0,0 +1,306 @@
1
+ /**********************************************************************
2
+ regposix.c - Oniguruma (regular expression library)
3
+ **********************************************************************/
4
+ /*-
5
+ * Copyright (c) 2002-2008 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
6
+ * All rights reserved.
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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
+ * SUCH DAMAGE.
28
+ */
29
+
30
+ #define regex_t onig_regex_t
31
+ #include "regint.h"
32
+ #undef regex_t
33
+ #include "onigposix.h"
34
+
35
+ #define ONIG_C(reg) ((onig_regex_t* )((reg)->onig))
36
+ #define PONIG_C(reg) ((onig_regex_t** )(&(reg)->onig))
37
+
38
+ /* #define ENC_STRING_LEN(enc,s,len) len = strlen(s) */
39
+ #define ENC_STRING_LEN(enc,s,len) do { \
40
+ if (ONIGENC_MBC_MINLEN(enc) == 1) { \
41
+ UChar* tmps = (UChar* )(s); \
42
+ while (*tmps != 0) tmps++; \
43
+ len = tmps - (UChar* )(s); \
44
+ } \
45
+ else { \
46
+ len = onigenc_str_bytelen_null(enc, (UChar* )s); \
47
+ } \
48
+ } while(0)
49
+
50
+ typedef struct {
51
+ int onig_err;
52
+ int posix_err;
53
+ } O2PERR;
54
+
55
+ static int
56
+ onig2posix_error_code(int code)
57
+ {
58
+ static const O2PERR o2p[] = {
59
+ { ONIG_MISMATCH, REG_NOMATCH },
60
+ { ONIG_NO_SUPPORT_CONFIG, REG_EONIG_INTERNAL },
61
+ { ONIGERR_MEMORY, REG_ESPACE },
62
+ { ONIGERR_MATCH_STACK_LIMIT_OVER, REG_EONIG_INTERNAL },
63
+ { ONIGERR_TYPE_BUG, REG_EONIG_INTERNAL },
64
+ { ONIGERR_PARSER_BUG, REG_EONIG_INTERNAL },
65
+ { ONIGERR_STACK_BUG, REG_EONIG_INTERNAL },
66
+ { ONIGERR_UNDEFINED_BYTECODE, REG_EONIG_INTERNAL },
67
+ { ONIGERR_UNEXPECTED_BYTECODE, REG_EONIG_INTERNAL },
68
+ { ONIGERR_DEFAULT_ENCODING_IS_NOT_SETTED, REG_EONIG_BADARG },
69
+ { ONIGERR_SPECIFIED_ENCODING_CANT_CONVERT_TO_WIDE_CHAR, REG_EONIG_BADARG },
70
+ { ONIGERR_FAIL_TO_INITIALIZE, REG_EONIG_INTERNAL },
71
+ { ONIGERR_INVALID_ARGUMENT, REG_EONIG_BADARG },
72
+ { ONIGERR_END_PATTERN_AT_LEFT_BRACE, REG_EBRACE },
73
+ { ONIGERR_END_PATTERN_AT_LEFT_BRACKET, REG_EBRACK },
74
+ { ONIGERR_EMPTY_CHAR_CLASS, REG_ECTYPE },
75
+ { ONIGERR_PREMATURE_END_OF_CHAR_CLASS, REG_ECTYPE },
76
+ { ONIGERR_END_PATTERN_AT_ESCAPE, REG_EESCAPE },
77
+ { ONIGERR_END_PATTERN_AT_META, REG_EESCAPE },
78
+ { ONIGERR_END_PATTERN_AT_CONTROL, REG_EESCAPE },
79
+ { ONIGERR_META_CODE_SYNTAX, REG_BADPAT },
80
+ { ONIGERR_CONTROL_CODE_SYNTAX, REG_BADPAT },
81
+ { ONIGERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE, REG_ECTYPE },
82
+ { ONIGERR_CHAR_CLASS_VALUE_AT_START_OF_RANGE, REG_ECTYPE },
83
+ { ONIGERR_UNMATCHED_RANGE_SPECIFIER_IN_CHAR_CLASS, REG_ECTYPE },
84
+ { ONIGERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED, REG_BADRPT },
85
+ { ONIGERR_TARGET_OF_REPEAT_OPERATOR_INVALID, REG_BADRPT },
86
+ { ONIGERR_NESTED_REPEAT_OPERATOR, REG_BADRPT },
87
+ { ONIGERR_UNMATCHED_CLOSE_PARENTHESIS, REG_EPAREN },
88
+ { ONIGERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS, REG_EPAREN },
89
+ { ONIGERR_END_PATTERN_IN_GROUP, REG_BADPAT },
90
+ { ONIGERR_UNDEFINED_GROUP_OPTION, REG_BADPAT },
91
+ { ONIGERR_INVALID_POSIX_BRACKET_TYPE, REG_BADPAT },
92
+ { ONIGERR_INVALID_LOOK_BEHIND_PATTERN, REG_BADPAT },
93
+ { ONIGERR_INVALID_REPEAT_RANGE_PATTERN, REG_BADPAT },
94
+ { ONIGERR_TOO_BIG_NUMBER, REG_BADPAT },
95
+ { ONIGERR_TOO_BIG_NUMBER_FOR_REPEAT_RANGE, REG_BADBR },
96
+ { ONIGERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE, REG_BADBR },
97
+ { ONIGERR_EMPTY_RANGE_IN_CHAR_CLASS, REG_ECTYPE },
98
+ { ONIGERR_MISMATCH_CODE_LENGTH_IN_CLASS_RANGE, REG_ECTYPE },
99
+ { ONIGERR_TOO_MANY_MULTI_BYTE_RANGES, REG_ECTYPE },
100
+ { ONIGERR_TOO_SHORT_MULTI_BYTE_STRING, REG_BADPAT },
101
+ { ONIGERR_TOO_BIG_BACKREF_NUMBER, REG_ESUBREG },
102
+ { ONIGERR_INVALID_BACKREF, REG_ESUBREG },
103
+ { ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED, REG_BADPAT },
104
+ { ONIGERR_TOO_BIG_WIDE_CHAR_VALUE, REG_EONIG_BADWC },
105
+ { ONIGERR_TOO_LONG_WIDE_CHAR_VALUE, REG_EONIG_BADWC },
106
+ { ONIGERR_INVALID_CODE_POINT_VALUE, REG_EONIG_BADWC },
107
+ { ONIGERR_EMPTY_GROUP_NAME, REG_BADPAT },
108
+ { ONIGERR_INVALID_GROUP_NAME, REG_BADPAT },
109
+ { ONIGERR_INVALID_CHAR_IN_GROUP_NAME, REG_BADPAT },
110
+ { ONIGERR_UNDEFINED_NAME_REFERENCE, REG_BADPAT },
111
+ { ONIGERR_UNDEFINED_GROUP_REFERENCE, REG_BADPAT },
112
+ { ONIGERR_MULTIPLEX_DEFINED_NAME, REG_BADPAT },
113
+ { ONIGERR_MULTIPLEX_DEFINITION_NAME_CALL, REG_BADPAT },
114
+ { ONIGERR_NEVER_ENDING_RECURSION, REG_BADPAT },
115
+ { ONIGERR_GROUP_NUMBER_OVER_FOR_CAPTURE_HISTORY, REG_BADPAT },
116
+ { ONIGERR_INVALID_CHAR_PROPERTY_NAME, REG_BADPAT },
117
+ { ONIGERR_NOT_SUPPORTED_ENCODING_COMBINATION, REG_EONIG_BADARG },
118
+ { ONIGERR_LIBRARY_IS_NOT_INITIALIZED, REG_EONIG_INTERNAL }
119
+ };
120
+
121
+ int i;
122
+
123
+ if (code >= 0) return 0;
124
+
125
+ for (i = 0; i < (int )(sizeof(o2p) / sizeof(o2p[0])); i++) {
126
+ if (code == o2p[i].onig_err)
127
+ return o2p[i].posix_err;
128
+ }
129
+
130
+ return REG_EONIG_INTERNAL; /* but, unknown error code */
131
+ }
132
+
133
+ extern int
134
+ regcomp(regex_t* reg, const char* pattern, int posix_options)
135
+ {
136
+ int r, len;
137
+ OnigSyntaxType* syntax = OnigDefaultSyntax;
138
+ OnigOptionType options;
139
+
140
+ if ((posix_options & REG_EXTENDED) == 0)
141
+ syntax = ONIG_SYNTAX_POSIX_BASIC;
142
+
143
+ options = syntax->options;
144
+ if ((posix_options & REG_ICASE) != 0)
145
+ ONIG_OPTION_ON(options, ONIG_OPTION_IGNORECASE);
146
+ if ((posix_options & REG_NEWLINE) != 0) {
147
+ ONIG_OPTION_ON( options, ONIG_OPTION_NEGATE_SINGLELINE);
148
+ ONIG_OPTION_OFF(options, ONIG_OPTION_SINGLELINE);
149
+ }
150
+
151
+ reg->comp_options = posix_options;
152
+
153
+ ENC_STRING_LEN(OnigEncDefaultCharEncoding, pattern, len);
154
+ r = onig_new(PONIG_C(reg), (UChar* )pattern, (UChar* )(pattern + len),
155
+ options, OnigEncDefaultCharEncoding, syntax,
156
+ (OnigErrorInfo* )NULL);
157
+ if (r != ONIG_NORMAL) {
158
+ return onig2posix_error_code(r);
159
+ }
160
+
161
+ reg->re_nsub = ONIG_C(reg)->num_mem;
162
+ return 0;
163
+ }
164
+
165
+ extern int
166
+ regexec(regex_t* reg, const char* str, size_t nmatch,
167
+ regmatch_t pmatch[], int posix_options)
168
+ {
169
+ int r, i, len;
170
+ UChar* end;
171
+ regmatch_t* pm;
172
+ OnigOptionType options;
173
+
174
+ options = ONIG_OPTION_POSIX_REGION;
175
+ if ((posix_options & REG_NOTBOL) != 0) options |= ONIG_OPTION_NOTBOL;
176
+ if ((posix_options & REG_NOTEOL) != 0) options |= ONIG_OPTION_NOTEOL;
177
+
178
+ if (nmatch == 0 || (reg->comp_options & REG_NOSUB) != 0) {
179
+ pm = (regmatch_t* )NULL;
180
+ nmatch = 0;
181
+ }
182
+ else if ((int )nmatch < ONIG_C(reg)->num_mem + 1) {
183
+ pm = (regmatch_t* )xmalloc(sizeof(regmatch_t)
184
+ * (ONIG_C(reg)->num_mem + 1));
185
+ if (pm == NULL)
186
+ return REG_ESPACE;
187
+ }
188
+ else {
189
+ pm = pmatch;
190
+ }
191
+
192
+ ENC_STRING_LEN(ONIG_C(reg)->enc, str, len);
193
+ end = (UChar* )(str + len);
194
+ r = onig_search(ONIG_C(reg), (UChar* )str, end, (UChar* )str, end,
195
+ (OnigRegion* )pm, options);
196
+
197
+ if (r >= 0) {
198
+ r = 0; /* Match */
199
+ if (pm != pmatch && pm != NULL) {
200
+ xmemcpy(pmatch, pm, sizeof(regmatch_t) * nmatch);
201
+ }
202
+ }
203
+ else if (r == ONIG_MISMATCH) {
204
+ r = REG_NOMATCH;
205
+ for (i = 0; i < (int )nmatch; i++)
206
+ pmatch[i].rm_so = pmatch[i].rm_eo = ONIG_REGION_NOTPOS;
207
+ }
208
+ else {
209
+ r = onig2posix_error_code(r);
210
+ }
211
+
212
+ if (pm != pmatch && pm != NULL)
213
+ xfree(pm);
214
+
215
+ #if 0
216
+ if (reg->re_nsub > nmatch - 1)
217
+ reg->re_nsub = (nmatch <= 1 ? 0 : nmatch - 1);
218
+ #endif
219
+
220
+ return r;
221
+ }
222
+
223
+ extern void
224
+ regfree(regex_t* reg)
225
+ {
226
+ onig_free(ONIG_C(reg));
227
+ }
228
+
229
+
230
+ extern void
231
+ reg_set_encoding(int mb_code)
232
+ {
233
+ OnigEncoding enc;
234
+
235
+ switch (mb_code) {
236
+ case REG_POSIX_ENCODING_ASCII:
237
+ enc = ONIG_ENCODING_ASCII;
238
+ break;
239
+ case REG_POSIX_ENCODING_EUC_JP:
240
+ enc = ONIG_ENCODING_EUC_JP;
241
+ break;
242
+ case REG_POSIX_ENCODING_SJIS:
243
+ enc = ONIG_ENCODING_SJIS;
244
+ break;
245
+ case REG_POSIX_ENCODING_UTF8:
246
+ enc = ONIG_ENCODING_UTF8;
247
+ break;
248
+ case REG_POSIX_ENCODING_UTF16_BE:
249
+ enc = ONIG_ENCODING_UTF16_BE;
250
+ break;
251
+ case REG_POSIX_ENCODING_UTF16_LE:
252
+ enc = ONIG_ENCODING_UTF16_LE;
253
+ break;
254
+
255
+ default:
256
+ return ;
257
+ break;
258
+ }
259
+
260
+ onig_initialize(0, 0);
261
+ onig_initialize_encoding(enc);
262
+
263
+ onigenc_set_default_encoding(enc);
264
+ }
265
+
266
+ extern int
267
+ reg_name_to_group_numbers(regex_t* reg,
268
+ const unsigned char* name, const unsigned char* name_end, int** nums)
269
+ {
270
+ return onig_name_to_group_numbers(ONIG_C(reg), name, name_end, nums);
271
+ }
272
+
273
+ typedef struct {
274
+ int (*func)(const unsigned char*, const unsigned char*,int,int*,regex_t*,void*);
275
+ regex_t* reg;
276
+ void* arg;
277
+ } i_wrap;
278
+
279
+ static int
280
+ i_wrapper(const UChar* name, const UChar* name_end, int ng, int* gs,
281
+ onig_regex_t* reg ARG_UNUSED, void* arg)
282
+ {
283
+ i_wrap* warg = (i_wrap* )arg;
284
+
285
+ return (*warg->func)(name, name_end, ng, gs, warg->reg, warg->arg);
286
+ }
287
+
288
+ extern int
289
+ reg_foreach_name(regex_t* reg,
290
+ int (*func)(const unsigned char*, const unsigned char*,int,int*,regex_t*,void*),
291
+ void* arg)
292
+ {
293
+ i_wrap warg;
294
+
295
+ warg.func = func;
296
+ warg.reg = reg;
297
+ warg.arg = arg;
298
+
299
+ return onig_foreach_name(ONIG_C(reg), i_wrapper, &warg);
300
+ }
301
+
302
+ extern int
303
+ reg_number_of_names(regex_t* reg)
304
+ {
305
+ return onig_number_of_names(ONIG_C(reg));
306
+ }
@@ -0,0 +1,315 @@
1
+ /**********************************************************************
2
+ regsyntax.c - Oniguruma (regular expression library)
3
+ **********************************************************************/
4
+ /*-
5
+ * Copyright (c) 2002-2006 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
6
+ * All rights reserved.
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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
+ * SUCH DAMAGE.
28
+ */
29
+
30
+ #include "regint.h"
31
+
32
+ OnigSyntaxType OnigSyntaxASIS = {
33
+ 0
34
+ , ONIG_SYN_OP2_INEFFECTIVE_ESCAPE
35
+ , 0
36
+ , ONIG_OPTION_NONE
37
+ ,
38
+ {
39
+ (OnigCodePoint )'\\' /* esc */
40
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
41
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
42
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
43
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
44
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
45
+ }
46
+ };
47
+
48
+ OnigSyntaxType OnigSyntaxPosixBasic = {
49
+ ( SYN_POSIX_COMMON_OP | ONIG_SYN_OP_ESC_LPAREN_SUBEXP |
50
+ ONIG_SYN_OP_ESC_BRACE_INTERVAL )
51
+ , 0
52
+ , 0
53
+ , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE )
54
+ ,
55
+ {
56
+ (OnigCodePoint )'\\' /* esc */
57
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
58
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
59
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
60
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
61
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
62
+ }
63
+ };
64
+
65
+ OnigSyntaxType OnigSyntaxPosixExtended = {
66
+ ( SYN_POSIX_COMMON_OP | ONIG_SYN_OP_LPAREN_SUBEXP |
67
+ ONIG_SYN_OP_BRACE_INTERVAL |
68
+ ONIG_SYN_OP_PLUS_ONE_INF | ONIG_SYN_OP_QMARK_ZERO_ONE | ONIG_SYN_OP_VBAR_ALT )
69
+ , 0
70
+ , ( ONIG_SYN_CONTEXT_INDEP_ANCHORS |
71
+ ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS |
72
+ ONIG_SYN_ALLOW_UNMATCHED_CLOSE_SUBEXP |
73
+ ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
74
+ , ( ONIG_OPTION_SINGLELINE | ONIG_OPTION_MULTILINE )
75
+ ,
76
+ {
77
+ (OnigCodePoint )'\\' /* esc */
78
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
79
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
80
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
81
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
82
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
83
+ }
84
+ };
85
+
86
+ OnigSyntaxType OnigSyntaxEmacs = {
87
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC |
88
+ ONIG_SYN_OP_ESC_BRACE_INTERVAL |
89
+ ONIG_SYN_OP_ESC_LPAREN_SUBEXP | ONIG_SYN_OP_ESC_VBAR_ALT |
90
+ ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF |
91
+ ONIG_SYN_OP_QMARK_ZERO_ONE | ONIG_SYN_OP_DECIMAL_BACKREF |
92
+ ONIG_SYN_OP_LINE_ANCHOR | ONIG_SYN_OP_ESC_CONTROL_CHARS )
93
+ , ONIG_SYN_OP2_ESC_GNU_BUF_ANCHOR
94
+ , ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC
95
+ , ONIG_OPTION_NONE
96
+ ,
97
+ {
98
+ (OnigCodePoint )'\\' /* esc */
99
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
100
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
101
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
102
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
103
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
104
+ }
105
+ };
106
+
107
+ OnigSyntaxType OnigSyntaxGrep = {
108
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_POSIX_BRACKET |
109
+ ONIG_SYN_OP_ESC_BRACE_INTERVAL | ONIG_SYN_OP_ESC_LPAREN_SUBEXP |
110
+ ONIG_SYN_OP_ESC_VBAR_ALT |
111
+ ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_ESC_PLUS_ONE_INF |
112
+ ONIG_SYN_OP_ESC_QMARK_ZERO_ONE | ONIG_SYN_OP_LINE_ANCHOR |
113
+ ONIG_SYN_OP_ESC_W_WORD | ONIG_SYN_OP_ESC_B_WORD_BOUND |
114
+ ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | ONIG_SYN_OP_DECIMAL_BACKREF )
115
+ , 0
116
+ , ( ONIG_SYN_ALLOW_EMPTY_RANGE_IN_CC | ONIG_SYN_NOT_NEWLINE_IN_NEGATIVE_CC )
117
+ , ONIG_OPTION_NONE
118
+ ,
119
+ {
120
+ (OnigCodePoint )'\\' /* esc */
121
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
122
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
123
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
124
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
125
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
126
+ }
127
+ };
128
+
129
+ OnigSyntaxType OnigSyntaxGnuRegex = {
130
+ SYN_GNU_REGEX_OP
131
+ , 0
132
+ , SYN_GNU_REGEX_BV
133
+ , ONIG_OPTION_NONE
134
+ ,
135
+ {
136
+ (OnigCodePoint )'\\' /* esc */
137
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
138
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
139
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
140
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
141
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
142
+ }
143
+ };
144
+
145
+ OnigSyntaxType OnigSyntaxJava = {
146
+ (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
147
+ ONIG_SYN_OP_ESC_CONTROL_CHARS | ONIG_SYN_OP_ESC_C_CONTROL |
148
+ ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 )
149
+ & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
150
+ , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE | ONIG_SYN_OP2_QMARK_GROUP_EFFECT |
151
+ ONIG_SYN_OP2_OPTION_PERL | ONIG_SYN_OP2_PLUS_POSSESSIVE_REPEAT |
152
+ ONIG_SYN_OP2_PLUS_POSSESSIVE_INTERVAL | ONIG_SYN_OP2_CCLASS_SET_OP |
153
+ ONIG_SYN_OP2_ESC_V_VTAB | ONIG_SYN_OP2_ESC_U_HEX4 |
154
+ ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY )
155
+ , ( SYN_GNU_REGEX_BV | ONIG_SYN_DIFFERENT_LEN_ALT_LOOK_BEHIND )
156
+ , ONIG_OPTION_SINGLELINE
157
+ ,
158
+ {
159
+ (OnigCodePoint )'\\' /* esc */
160
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
161
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
162
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
163
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
164
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
165
+ }
166
+ };
167
+
168
+ OnigSyntaxType OnigSyntaxPerl = {
169
+ (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
170
+ ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
171
+ ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
172
+ ONIG_SYN_OP_ESC_C_CONTROL )
173
+ & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
174
+ , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE |
175
+ ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL |
176
+ ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY |
177
+ ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT )
178
+ , SYN_GNU_REGEX_BV
179
+ , ONIG_OPTION_SINGLELINE
180
+ ,
181
+ {
182
+ (OnigCodePoint )'\\' /* esc */
183
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
184
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
185
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
186
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
187
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
188
+ }
189
+ };
190
+
191
+ /* Perl + named group */
192
+ OnigSyntaxType OnigSyntaxPerl_NG = {
193
+ (( SYN_GNU_REGEX_OP | ONIG_SYN_OP_QMARK_NON_GREEDY |
194
+ ONIG_SYN_OP_ESC_OCTAL3 | ONIG_SYN_OP_ESC_X_HEX2 |
195
+ ONIG_SYN_OP_ESC_X_BRACE_HEX8 | ONIG_SYN_OP_ESC_CONTROL_CHARS |
196
+ ONIG_SYN_OP_ESC_C_CONTROL )
197
+ & ~ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END )
198
+ , ( ONIG_SYN_OP2_ESC_CAPITAL_Q_QUOTE |
199
+ ONIG_SYN_OP2_QMARK_GROUP_EFFECT | ONIG_SYN_OP2_OPTION_PERL |
200
+ ONIG_SYN_OP2_ESC_P_BRACE_CHAR_PROPERTY |
201
+ ONIG_SYN_OP2_ESC_P_BRACE_CIRCUMFLEX_NOT |
202
+ ONIG_SYN_OP2_QMARK_LT_NAMED_GROUP |
203
+ ONIG_SYN_OP2_ESC_K_NAMED_BACKREF |
204
+ ONIG_SYN_OP2_ESC_G_SUBEXP_CALL )
205
+ , ( SYN_GNU_REGEX_BV |
206
+ ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP |
207
+ ONIG_SYN_ALLOW_MULTIPLEX_DEFINITION_NAME )
208
+ , ONIG_OPTION_SINGLELINE
209
+ ,
210
+ {
211
+ (OnigCodePoint )'\\' /* esc */
212
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar '.' */
213
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anytime '*' */
214
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* zero or one time '?' */
215
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* one or more time '+' */
216
+ , (OnigCodePoint )ONIG_INEFFECTIVE_META_CHAR /* anychar anytime */
217
+ }
218
+ };
219
+
220
+
221
+
222
+ extern int
223
+ onig_set_default_syntax(OnigSyntaxType* syntax)
224
+ {
225
+ if (IS_NULL(syntax))
226
+ syntax = ONIG_SYNTAX_RUBY;
227
+
228
+ OnigDefaultSyntax = syntax;
229
+ return 0;
230
+ }
231
+
232
+ extern void
233
+ onig_copy_syntax(OnigSyntaxType* to, OnigSyntaxType* from)
234
+ {
235
+ *to = *from;
236
+ }
237
+
238
+ extern void
239
+ onig_set_syntax_op(OnigSyntaxType* syntax, unsigned int op)
240
+ {
241
+ syntax->op = op;
242
+ }
243
+
244
+ extern void
245
+ onig_set_syntax_op2(OnigSyntaxType* syntax, unsigned int op2)
246
+ {
247
+ syntax->op2 = op2;
248
+ }
249
+
250
+ extern void
251
+ onig_set_syntax_behavior(OnigSyntaxType* syntax, unsigned int behavior)
252
+ {
253
+ syntax->behavior = behavior;
254
+ }
255
+
256
+ extern void
257
+ onig_set_syntax_options(OnigSyntaxType* syntax, OnigOptionType options)
258
+ {
259
+ syntax->options = options;
260
+ }
261
+
262
+ extern unsigned int
263
+ onig_get_syntax_op(OnigSyntaxType* syntax)
264
+ {
265
+ return syntax->op;
266
+ }
267
+
268
+ extern unsigned int
269
+ onig_get_syntax_op2(OnigSyntaxType* syntax)
270
+ {
271
+ return syntax->op2;
272
+ }
273
+
274
+ extern unsigned int
275
+ onig_get_syntax_behavior(OnigSyntaxType* syntax)
276
+ {
277
+ return syntax->behavior;
278
+ }
279
+
280
+ extern OnigOptionType
281
+ onig_get_syntax_options(OnigSyntaxType* syntax)
282
+ {
283
+ return syntax->options;
284
+ }
285
+
286
+ #ifdef USE_VARIABLE_META_CHARS
287
+ extern int onig_set_meta_char(OnigSyntaxType* enc,
288
+ unsigned int what, OnigCodePoint code)
289
+ {
290
+ switch (what) {
291
+ case ONIG_META_CHAR_ESCAPE:
292
+ enc->meta_char_table.esc = code;
293
+ break;
294
+ case ONIG_META_CHAR_ANYCHAR:
295
+ enc->meta_char_table.anychar = code;
296
+ break;
297
+ case ONIG_META_CHAR_ANYTIME:
298
+ enc->meta_char_table.anytime = code;
299
+ break;
300
+ case ONIG_META_CHAR_ZERO_OR_ONE_TIME:
301
+ enc->meta_char_table.zero_or_one_time = code;
302
+ break;
303
+ case ONIG_META_CHAR_ONE_OR_MORE_TIME:
304
+ enc->meta_char_table.one_or_more_time = code;
305
+ break;
306
+ case ONIG_META_CHAR_ANYCHAR_ANYTIME:
307
+ enc->meta_char_table.anychar_anytime = code;
308
+ break;
309
+ default:
310
+ return ONIGERR_INVALID_ARGUMENT;
311
+ break;
312
+ }
313
+ return 0;
314
+ }
315
+ #endif /* USE_VARIABLE_META_CHARS */
@@ -0,0 +1,76 @@
1
+ /**********************************************************************
2
+ regtrav.c - Oniguruma (regular expression library)
3
+ **********************************************************************/
4
+ /*-
5
+ * Copyright (c) 2002-2004 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
6
+ * All rights reserved.
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 AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
+ * SUCH DAMAGE.
28
+ */
29
+
30
+ #include "regint.h"
31
+
32
+ #ifdef USE_CAPTURE_HISTORY
33
+
34
+ static int
35
+ capture_tree_traverse(OnigCaptureTreeNode* node, int at,
36
+ int(*callback_func)(int,int,int,int,int,void*),
37
+ int level, void* arg)
38
+ {
39
+ int r, i;
40
+
41
+ if (node == (OnigCaptureTreeNode* )0)
42
+ return 0;
43
+
44
+ if ((at & ONIG_TRAVERSE_CALLBACK_AT_FIRST) != 0) {
45
+ r = (*callback_func)(node->group, node->beg, node->end,
46
+ level, ONIG_TRAVERSE_CALLBACK_AT_FIRST, arg);
47
+ if (r != 0) return r;
48
+ }
49
+
50
+ for (i = 0; i < node->num_childs; i++) {
51
+ r = capture_tree_traverse(node->childs[i], at,
52
+ callback_func, level + 1, arg);
53
+ if (r != 0) return r;
54
+ }
55
+
56
+ if ((at & ONIG_TRAVERSE_CALLBACK_AT_LAST) != 0) {
57
+ r = (*callback_func)(node->group, node->beg, node->end,
58
+ level, ONIG_TRAVERSE_CALLBACK_AT_LAST, arg);
59
+ if (r != 0) return r;
60
+ }
61
+
62
+ return 0;
63
+ }
64
+ #endif /* USE_CAPTURE_HISTORY */
65
+
66
+ extern int
67
+ onig_capture_tree_traverse(OnigRegion* region, int at,
68
+ int(*callback_func)(int,int,int,int,int,void*), void* arg)
69
+ {
70
+ #ifdef USE_CAPTURE_HISTORY
71
+ return capture_tree_traverse(region->history_root, at,
72
+ callback_func, 0, arg);
73
+ #else
74
+ return ONIG_NO_SUPPORT_CONFIG;
75
+ #endif
76
+ }