debase-ruby_core_source 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +7 -0
  3. data/README.md +1 -0
  4. data/Rakefile +2 -2
  5. data/lib/debase/ruby_core_source.rb +1 -0
  6. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/addr2line.h +21 -0
  7. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/build_assert/build_assert.h +40 -0
  8. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/check_type/check_type.h +63 -0
  9. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/container_of/container_of.h +142 -0
  10. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/list/list.h +635 -0
  11. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ccan/str/str.h +16 -0
  12. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/constant.h +43 -0
  13. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/dln.h +51 -0
  14. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/eval_intern.h +275 -0
  15. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/gc.h +107 -0
  16. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/id.h +210 -0
  17. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/insns.inc +107 -0
  18. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/insns_info.inc +752 -0
  19. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/internal.h +1198 -0
  20. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/iseq.h +158 -0
  21. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/known_errors.inc +746 -0
  22. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/method.h +144 -0
  23. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/node.h +544 -0
  24. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/node_name.inc +212 -0
  25. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/opt_sc.inc +734 -0
  26. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/optinsn.inc +83 -0
  27. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/optunifs.inc +124 -0
  28. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/parse.h +184 -0
  29. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/probes_helper.h +67 -0
  30. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/regenc.h +237 -0
  31. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/regint.h +972 -0
  32. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/regparse.h +363 -0
  33. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/revision.h +1 -0
  34. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/ruby_atomic.h +170 -0
  35. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/siphash.h +48 -0
  36. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/symbol.h +88 -0
  37. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/thread_pthread.h +54 -0
  38. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/thread_win32.h +36 -0
  39. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/timev.h +42 -0
  40. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/transcode_data.h +123 -0
  41. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/version.h +52 -0
  42. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm.inc +3372 -0
  43. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_core.h +1163 -0
  44. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_debug.h +37 -0
  45. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_exec.h +182 -0
  46. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_insnhelper.h +233 -0
  47. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vm_opts.h +56 -0
  48. data/lib/debase/ruby_core_source/ruby-2.2.9-p480/vmtc.inc +105 -0
  49. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/addr2line.h +21 -0
  50. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/build_assert/build_assert.h +40 -0
  51. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/check_type/check_type.h +63 -0
  52. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/container_of/container_of.h +142 -0
  53. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/list/list.h +773 -0
  54. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ccan/str/str.h +16 -0
  55. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/constant.h +50 -0
  56. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/dln.h +51 -0
  57. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/encindex.h +67 -0
  58. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/eval_intern.h +304 -0
  59. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/gc.h +114 -0
  60. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/id.h +211 -0
  61. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/id_table.h +30 -0
  62. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/insns.inc +110 -0
  63. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/insns_info.inc +776 -0
  64. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/internal.h +1408 -0
  65. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/iseq.h +249 -0
  66. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/known_errors.inc +746 -0
  67. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/method.h +213 -0
  68. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/node.h +520 -0
  69. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/node_name.inc +208 -0
  70. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/opt_sc.inc +758 -0
  71. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/optinsn.inc +83 -0
  72. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/optunifs.inc +127 -0
  73. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/parse.h +185 -0
  74. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/probes_helper.h +43 -0
  75. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/regenc.h +237 -0
  76. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/regint.h +987 -0
  77. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/regparse.h +367 -0
  78. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/revision.h +1 -0
  79. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/ruby_atomic.h +233 -0
  80. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/siphash.h +48 -0
  81. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/symbol.h +108 -0
  82. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/thread_pthread.h +54 -0
  83. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/thread_win32.h +36 -0
  84. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/timev.h +42 -0
  85. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/transcode_data.h +139 -0
  86. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/version.h +55 -0
  87. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm.inc +3414 -0
  88. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_call_iseq_optimized.inc +212 -0
  89. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_core.h +1240 -0
  90. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_debug.h +37 -0
  91. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_exec.h +182 -0
  92. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_insnhelper.h +243 -0
  93. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vm_opts.h +57 -0
  94. data/lib/debase/ruby_core_source/ruby-2.3.6-p384/vmtc.inc +108 -0
  95. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/addr2line.h +21 -0
  96. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/build_assert/build_assert.h +40 -0
  97. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/check_type/check_type.h +63 -0
  98. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/container_of/container_of.h +142 -0
  99. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/list/list.h +773 -0
  100. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ccan/str/str.h +16 -0
  101. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/constant.h +50 -0
  102. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/dln.h +51 -0
  103. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/encindex.h +67 -0
  104. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/eval_intern.h +315 -0
  105. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/gc.h +114 -0
  106. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/id.h +220 -0
  107. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/id_table.h +31 -0
  108. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/insns.inc +112 -0
  109. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/insns_info.inc +796 -0
  110. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/internal.h +1790 -0
  111. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/iseq.h +252 -0
  112. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/known_errors.inc +746 -0
  113. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/method.h +213 -0
  114. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/node.h +520 -0
  115. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/node_name.inc +208 -0
  116. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/opt_sc.inc +774 -0
  117. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/optinsn.inc +83 -0
  118. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/optunifs.inc +129 -0
  119. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/parse.h +185 -0
  120. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/probes_helper.h +43 -0
  121. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/regenc.h +254 -0
  122. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/regint.h +938 -0
  123. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/regparse.h +370 -0
  124. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/revision.h +1 -0
  125. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ruby_assert.h +54 -0
  126. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/ruby_atomic.h +233 -0
  127. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/siphash.h +48 -0
  128. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/symbol.h +108 -0
  129. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/thread_pthread.h +54 -0
  130. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/thread_win32.h +36 -0
  131. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/timev.h +42 -0
  132. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/transcode_data.h +139 -0
  133. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/version.h +73 -0
  134. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm.inc +3415 -0
  135. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_call_iseq_optimized.inc +212 -0
  136. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_core.h +1646 -0
  137. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_debug.h +37 -0
  138. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_exec.h +182 -0
  139. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_insnhelper.h +243 -0
  140. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vm_opts.h +57 -0
  141. data/lib/debase/ruby_core_source/ruby-2.4.3-p205/vmtc.inc +110 -0
  142. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/addr2line.h +21 -0
  143. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/build_assert/build_assert.h +40 -0
  144. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/check_type/check_type.h +63 -0
  145. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/container_of/container_of.h +142 -0
  146. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/list/list.h +773 -0
  147. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ccan/str/str.h +16 -0
  148. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/constant.h +50 -0
  149. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/debug_counter.h +109 -0
  150. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/dln.h +51 -0
  151. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/encindex.h +67 -0
  152. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/eval_intern.h +334 -0
  153. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/gc.h +116 -0
  154. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/id.h +250 -0
  155. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/id_table.h +31 -0
  156. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/insns.inc +217 -0
  157. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/insns_info.inc +1570 -0
  158. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/internal.h +2035 -0
  159. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/iseq.h +307 -0
  160. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/known_errors.inc +746 -0
  161. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/method.h +218 -0
  162. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/node.h +540 -0
  163. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/node_name.inc +198 -0
  164. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/opt_sc.inc +1601 -0
  165. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/optinsn.inc +103 -0
  166. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/optunifs.inc +61 -0
  167. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/parse.h +206 -0
  168. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/probes_helper.h +43 -0
  169. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/regenc.h +254 -0
  170. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/regint.h +938 -0
  171. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/regparse.h +370 -0
  172. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/revision.h +1 -0
  173. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ruby_assert.h +54 -0
  174. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/ruby_atomic.h +233 -0
  175. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/siphash.h +48 -0
  176. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/symbol.h +108 -0
  177. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/thread_pthread.h +54 -0
  178. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/thread_win32.h +36 -0
  179. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/timev.h +42 -0
  180. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/transcode_data.h +139 -0
  181. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/version.h +73 -0
  182. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm.inc +3667 -0
  183. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_call_iseq_optimized.inc +213 -0
  184. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_core.h +1768 -0
  185. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_debug.h +37 -0
  186. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_exec.h +192 -0
  187. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_insnhelper.h +255 -0
  188. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vm_opts.h +57 -0
  189. data/lib/debase/ruby_core_source/ruby-2.5.0-rc1/vmtc.inc +214 -0
  190. data/lib/debase/ruby_core_source/version.rb +1 -1
  191. metadata +186 -2
@@ -0,0 +1,237 @@
1
+ #ifndef ONIGURUMA_REGENC_H
2
+ #define ONIGURUMA_REGENC_H
3
+ /**********************************************************************
4
+ regenc.h - Onigmo (Oniguruma-mod) (regular expression library)
5
+ **********************************************************************/
6
+ /*-
7
+ * Copyright (c) 2002-2008 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
8
+ * Copyright (c) 2011 K.Takata <kentkt AT csc DOT jp>
9
+ * All rights reserved.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted provided that the following conditions
13
+ * are met:
14
+ * 1. Redistributions of source code must retain the above copyright
15
+ * notice, this list of conditions and the following disclaimer.
16
+ * 2. Redistributions in binary form must reproduce the above copyright
17
+ * notice, this list of conditions and the following disclaimer in the
18
+ * documentation and/or other materials provided with the distribution.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+ #ifndef REGINT_H
34
+ #ifndef RUBY_EXTERN
35
+ #include "ruby/config.h"
36
+ #include "ruby/defines.h"
37
+ #endif
38
+ #endif
39
+
40
+ #ifdef ONIG_ESCAPE_UCHAR_COLLISION
41
+ #undef ONIG_ESCAPE_UCHAR_COLLISION
42
+ #endif
43
+
44
+ #include "ruby/oniguruma.h"
45
+
46
+ RUBY_SYMBOL_EXPORT_BEGIN
47
+
48
+ typedef struct {
49
+ OnigCodePoint from;
50
+ OnigCodePoint to;
51
+ } OnigPairCaseFoldCodes;
52
+
53
+
54
+ #ifndef NULL
55
+ #define NULL ((void* )0)
56
+ #endif
57
+
58
+ #ifndef TRUE
59
+ #define TRUE 1
60
+ #endif
61
+
62
+ #ifndef FALSE
63
+ #define FALSE 0
64
+ #endif
65
+
66
+ #ifndef ARG_UNUSED
67
+ #if defined(__GNUC__)
68
+ # define ARG_UNUSED __attribute__ ((unused))
69
+ #else
70
+ # define ARG_UNUSED
71
+ #endif
72
+ #endif
73
+
74
+ #define ONIG_IS_NULL(p) (((void*)(p)) == (void*)0)
75
+ #define ONIG_IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
76
+ #define ONIG_CHECK_NULL_RETURN(p) if (ONIG_IS_NULL(p)) return NULL
77
+ #define ONIG_CHECK_NULL_RETURN_VAL(p,val) if (ONIG_IS_NULL(p)) return (val)
78
+
79
+ #define enclen(enc,p,e) ((enc->max_enc_len == enc->min_enc_len) ? enc->min_enc_len : ONIGENC_MBC_ENC_LEN(enc,p,e))
80
+
81
+ /* character types bit flag */
82
+ #define BIT_CTYPE_NEWLINE (1<< ONIGENC_CTYPE_NEWLINE)
83
+ #define BIT_CTYPE_ALPHA (1<< ONIGENC_CTYPE_ALPHA)
84
+ #define BIT_CTYPE_BLANK (1<< ONIGENC_CTYPE_BLANK)
85
+ #define BIT_CTYPE_CNTRL (1<< ONIGENC_CTYPE_CNTRL)
86
+ #define BIT_CTYPE_DIGIT (1<< ONIGENC_CTYPE_DIGIT)
87
+ #define BIT_CTYPE_GRAPH (1<< ONIGENC_CTYPE_GRAPH)
88
+ #define BIT_CTYPE_LOWER (1<< ONIGENC_CTYPE_LOWER)
89
+ #define BIT_CTYPE_PRINT (1<< ONIGENC_CTYPE_PRINT)
90
+ #define BIT_CTYPE_PUNCT (1<< ONIGENC_CTYPE_PUNCT)
91
+ #define BIT_CTYPE_SPACE (1<< ONIGENC_CTYPE_SPACE)
92
+ #define BIT_CTYPE_UPPER (1<< ONIGENC_CTYPE_UPPER)
93
+ #define BIT_CTYPE_XDIGIT (1<< ONIGENC_CTYPE_XDIGIT)
94
+ #define BIT_CTYPE_WORD (1<< ONIGENC_CTYPE_WORD)
95
+ #define BIT_CTYPE_ALNUM (1<< ONIGENC_CTYPE_ALNUM)
96
+ #define BIT_CTYPE_ASCII (1<< ONIGENC_CTYPE_ASCII)
97
+
98
+ #define CTYPE_TO_BIT(ctype) (1<<(ctype))
99
+ #define CTYPE_IS_WORD_GRAPH_PRINT(ctype) \
100
+ ((ctype) == ONIGENC_CTYPE_WORD || (ctype) == ONIGENC_CTYPE_GRAPH ||\
101
+ (ctype) == ONIGENC_CTYPE_PRINT)
102
+
103
+
104
+ typedef struct {
105
+ short int len;
106
+ const UChar name[6];
107
+ int ctype;
108
+ } PosixBracketEntryType;
109
+
110
+ #define POSIX_BRACKET_ENTRY_INIT(name, ctype) \
111
+ {(short int )(sizeof(name) - 1), (name), (ctype)}
112
+
113
+ #ifndef numberof
114
+ #define numberof(array) (int )(sizeof(array) / sizeof((array)[0]))
115
+ #endif
116
+
117
+
118
+ #define USE_CRNL_AS_LINE_TERMINATOR
119
+ #define USE_UNICODE_PROPERTIES
120
+ #define USE_UNICODE_AGE_PROPERTIES
121
+ /* #define USE_UNICODE_CASE_FOLD_TURKISH_AZERI */
122
+ /* #define USE_UNICODE_ALL_LINE_TERMINATORS */ /* see Unicode.org UTS #18 */
123
+
124
+
125
+ #define ONIG_ENCODING_INIT_DEFAULT ONIG_ENCODING_ASCII
126
+
127
+ /* for encoding system implementation (internal) */
128
+ ONIG_EXTERN int onigenc_ascii_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
129
+ ONIG_EXTERN int onigenc_ascii_get_case_fold_codes_by_str P_((OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[], OnigEncoding enc));
130
+ ONIG_EXTERN int onigenc_apply_all_case_fold_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg));
131
+ ONIG_EXTERN int onigenc_get_case_fold_codes_by_str_with_map P_((int map_size, const OnigPairCaseFoldCodes map[], int ess_tsett_flag, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
132
+ ONIG_EXTERN int onigenc_not_support_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint* sb_out, const OnigCodePoint* ranges[], OnigEncoding enc));
133
+ ONIG_EXTERN int onigenc_is_mbc_newline_0x0a P_((const UChar* p, const UChar* end, OnigEncoding enc));
134
+
135
+
136
+ /* methods for single byte encoding */
137
+ ONIG_EXTERN int onigenc_ascii_mbc_case_fold P_((OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower, OnigEncoding enc));
138
+ ONIG_EXTERN int onigenc_single_byte_mbc_enc_len P_((const UChar* p, const UChar* e, OnigEncoding enc));
139
+ ONIG_EXTERN OnigCodePoint onigenc_single_byte_mbc_to_code P_((const UChar* p, const UChar* end, OnigEncoding enc));
140
+ ONIG_EXTERN int onigenc_single_byte_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc));
141
+ ONIG_EXTERN int onigenc_single_byte_code_to_mbc P_((OnigCodePoint code, UChar *buf, OnigEncoding enc));
142
+ ONIG_EXTERN UChar* onigenc_single_byte_left_adjust_char_head P_((const UChar* start, const UChar* s, const OnigUChar* end, OnigEncoding enc));
143
+ ONIG_EXTERN int onigenc_always_true_is_allowed_reverse_match P_((const UChar* s, const UChar* end, OnigEncoding enc));
144
+ ONIG_EXTERN int onigenc_always_false_is_allowed_reverse_match P_((const UChar* s, const UChar* end, OnigEncoding enc));
145
+ ONIG_EXTERN int onigenc_ascii_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc));
146
+
147
+ /* methods for multi byte encoding */
148
+ ONIG_EXTERN OnigCodePoint onigenc_mbn_mbc_to_code P_((OnigEncoding enc, const UChar* p, const UChar* end));
149
+ ONIG_EXTERN int onigenc_mbn_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** p, const UChar* end, UChar* lower));
150
+ ONIG_EXTERN int onigenc_mb2_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc));
151
+ ONIG_EXTERN int onigenc_mb2_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
152
+ ONIG_EXTERN int onigenc_minimum_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));
153
+ ONIG_EXTERN int onigenc_unicode_property_name_to_ctype P_((OnigEncoding enc, UChar* p, UChar* end));
154
+ ONIG_EXTERN int onigenc_mb2_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
155
+ ONIG_EXTERN int onigenc_mb4_code_to_mbclen P_((OnigCodePoint code, OnigEncoding enc));
156
+ ONIG_EXTERN int onigenc_mb4_code_to_mbc P_((OnigEncoding enc, OnigCodePoint code, UChar *buf));
157
+ ONIG_EXTERN int onigenc_mb4_is_code_ctype P_((OnigEncoding enc, OnigCodePoint code, unsigned int ctype));
158
+
159
+
160
+ /* in enc/unicode.c */
161
+ ONIG_EXTERN int onigenc_unicode_is_code_ctype P_((OnigCodePoint code, unsigned int ctype, OnigEncoding enc));
162
+ ONIG_EXTERN int onigenc_utf16_32_get_ctype_code_range P_((OnigCtype ctype, OnigCodePoint *sb_out, const OnigCodePoint* ranges[], OnigEncoding enc));
163
+ ONIG_EXTERN int onigenc_unicode_ctype_code_range P_((int ctype, const OnigCodePoint* ranges[]));
164
+ ONIG_EXTERN int onigenc_unicode_get_case_fold_codes_by_str P_((OnigEncoding enc, OnigCaseFoldType flag, const OnigUChar* p, const OnigUChar* end, OnigCaseFoldCodeItem items[]));
165
+ ONIG_EXTERN int onigenc_unicode_mbc_case_fold P_((OnigEncoding enc, OnigCaseFoldType flag, const UChar** pp, const UChar* end, UChar* fold));
166
+ ONIG_EXTERN int onigenc_unicode_apply_all_case_fold P_((OnigCaseFoldType flag, OnigApplyAllCaseFoldFunc f, void* arg, OnigEncoding enc));
167
+
168
+
169
+ #define UTF16_IS_SURROGATE_FIRST(c) (((c) & 0xfc) == 0xd8)
170
+ #define UTF16_IS_SURROGATE_SECOND(c) (((c) & 0xfc) == 0xdc)
171
+ #define UTF16_IS_SURROGATE(c) (((c) & 0xf8) == 0xd8)
172
+ #define UNICODE_VALID_CODEPOINT_P(c) ( \
173
+ ((c) <= 0x10ffff) && \
174
+ !((c) < 0x10000 && UTF16_IS_SURROGATE((c) >> 8)))
175
+
176
+ #define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \
177
+ OnigEncISO_8859_1_ToLowerCaseTable[c]
178
+ #define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \
179
+ OnigEncISO_8859_1_ToUpperCaseTable[c]
180
+
181
+ ONIG_EXTERN const UChar OnigEncISO_8859_1_ToLowerCaseTable[];
182
+ ONIG_EXTERN const UChar OnigEncISO_8859_1_ToUpperCaseTable[];
183
+
184
+ ONIG_EXTERN int
185
+ onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
186
+ ONIG_EXTERN int
187
+ onigenc_with_ascii_strnicmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
188
+ ONIG_EXTERN UChar*
189
+ onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n));
190
+
191
+ /* defined in regexec.c, but used in enc/xxx.c */
192
+ extern int onig_is_in_code_range P_((const UChar* p, OnigCodePoint code));
193
+
194
+ ONIG_EXTERN OnigEncoding OnigEncDefaultCharEncoding;
195
+ ONIG_EXTERN const UChar OnigEncAsciiToLowerCaseTable[];
196
+ ONIG_EXTERN const UChar OnigEncAsciiToUpperCaseTable[];
197
+ ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];
198
+
199
+ #define ONIGENC_IS_ASCII_CODE(code) ((code) < 0x80)
200
+ #define ONIGENC_ASCII_CODE_TO_LOWER_CASE(c) OnigEncAsciiToLowerCaseTable[c]
201
+ #define ONIGENC_ASCII_CODE_TO_UPPER_CASE(c) OnigEncAsciiToUpperCaseTable[c]
202
+ #define ONIGENC_IS_ASCII_CODE_CTYPE(code,ctype) \
203
+ ((OnigEncAsciiCtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
204
+ #define ONIGENC_IS_ASCII_CODE_CASE_AMBIG(code) \
205
+ (ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_UPPER) ||\
206
+ ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_LOWER))
207
+
208
+ /* Check if the code is in the range. (from <= code && code <= to) */
209
+ #define ONIGENC_IS_IN_RANGE(code, from, to) \
210
+ ((OnigCodePoint )((code) - (from)) <= (OnigCodePoint )((to) - (from)))
211
+
212
+
213
+ #ifdef ONIG_ENC_REGISTER
214
+ extern int ONIG_ENC_REGISTER(const char *, OnigEncoding);
215
+ #define OnigEncodingName(n) encoding_##n
216
+ #define OnigEncodingDeclare(n) static const OnigEncodingType OnigEncodingName(n)
217
+ #define OnigEncodingDefine(f,n) \
218
+ OnigEncodingDeclare(n); \
219
+ void Init_##f(void) { \
220
+ ONIG_ENC_REGISTER(OnigEncodingName(n).name, \
221
+ &OnigEncodingName(n)); \
222
+ } \
223
+ OnigEncodingDeclare(n)
224
+ #else
225
+ #define OnigEncodingName(n) OnigEncoding##n
226
+ #define OnigEncodingDeclare(n) const OnigEncodingType OnigEncodingName(n)
227
+ #define OnigEncodingDefine(f,n) OnigEncodingDeclare(n)
228
+ #endif
229
+
230
+ /* macros for define replica encoding and encoding alias */
231
+ #define ENC_REPLICATE(name, orig)
232
+ #define ENC_ALIAS(name, orig)
233
+ #define ENC_DUMMY(name)
234
+
235
+ RUBY_SYMBOL_EXPORT_END
236
+
237
+ #endif /* ONIGURUMA_REGENC_H */
@@ -0,0 +1,972 @@
1
+ #ifndef ONIGURUMA_REGINT_H
2
+ #define ONIGURUMA_REGINT_H
3
+ /**********************************************************************
4
+ regint.h - Onigmo (Oniguruma-mod) (regular expression library)
5
+ **********************************************************************/
6
+ /*-
7
+ * Copyright (c) 2002-2008 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
8
+ * Copyright (c) 2011-2014 K.Takata <kentkt AT csc DOT jp>
9
+ * All rights reserved.
10
+ *
11
+ * Redistribution and use in source and binary forms, with or without
12
+ * modification, are permitted provided that the following conditions
13
+ * are met:
14
+ * 1. Redistributions of source code must retain the above copyright
15
+ * notice, this list of conditions and the following disclaimer.
16
+ * 2. Redistributions in binary form must reproduce the above copyright
17
+ * notice, this list of conditions and the following disclaimer in the
18
+ * documentation and/or other materials provided with the distribution.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30
+ * SUCH DAMAGE.
31
+ */
32
+
33
+ /* for debug */
34
+ /* #define ONIG_DEBUG_PARSE_TREE */
35
+ /* #define ONIG_DEBUG_COMPILE */
36
+ /* #define ONIG_DEBUG_SEARCH */
37
+ /* #define ONIG_DEBUG_MATCH */
38
+ /* #define ONIG_DONT_OPTIMIZE */
39
+
40
+ /* for byte-code statistical data. */
41
+ /* #define ONIG_DEBUG_STATISTICS */
42
+
43
+ #if defined(ONIG_DEBUG_PARSE_TREE) || defined(ONIG_DEBUG_MATCH) || \
44
+ defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) || \
45
+ defined(ONIG_DEBUG_STATISTICS)
46
+ #ifndef ONIG_DEBUG
47
+ #define ONIG_DEBUG
48
+ #endif
49
+ #endif
50
+
51
+ #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
52
+ defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
53
+ defined(__powerpc64__) || \
54
+ defined(__mc68020__)
55
+ #define PLATFORM_UNALIGNED_WORD_ACCESS
56
+ #endif
57
+
58
+ /* config */
59
+ /* spec. config */
60
+ #define USE_NAMED_GROUP
61
+ #define USE_SUBEXP_CALL
62
+ #define USE_PERL_SUBEXP_CALL
63
+ #define USE_CAPITAL_P_NAMED_GROUP
64
+ #define USE_BACKREF_WITH_LEVEL /* \k<name+n>, \k<name-n> */
65
+ #define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT /* /(?:()|())*\2/ */
66
+ #define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
67
+ #define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
68
+ /* #define USE_RECOMPILE_API */
69
+ /* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */
70
+ #define USE_NO_INVALID_QUANTIFIER
71
+
72
+ /* internal config */
73
+ #define USE_PARSE_TREE_NODE_RECYCLE
74
+ #define USE_OP_PUSH_OR_JUMP_EXACT
75
+ #define USE_QTFR_PEEK_NEXT
76
+ #define USE_ST_LIBRARY
77
+ #define USE_SHARED_CCLASS_TABLE
78
+ #define USE_SUNDAY_QUICK_SEARCH
79
+
80
+ #define INIT_MATCH_STACK_SIZE 160
81
+ #define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
82
+
83
+ /* check config */
84
+ #if defined(USE_PERL_SUBEXP_CALL) || defined(USE_CAPITAL_P_NAMED_GROUP)
85
+ #if !defined(USE_NAMED_GROUP) || !defined(USE_SUBEXP_CALL)
86
+ #error USE_NAMED_GROUP and USE_SUBEXP_CALL must be defined.
87
+ #endif
88
+ #endif
89
+
90
+ #if defined(__GNUC__)
91
+ # define ARG_UNUSED __attribute__ ((unused))
92
+ #else
93
+ # define ARG_UNUSED
94
+ #endif
95
+
96
+ #ifndef RUBY_DEFINES_H
97
+ #include "ruby/ruby.h"
98
+ #undef xmalloc
99
+ #undef xrealloc
100
+ #undef xcalloc
101
+ #undef xfree
102
+ #endif
103
+
104
+ /* */
105
+ /* escape other system UChar definition */
106
+ #ifdef ONIG_ESCAPE_UCHAR_COLLISION
107
+ #undef ONIG_ESCAPE_UCHAR_COLLISION
108
+ #endif
109
+
110
+ #define USE_WORD_BEGIN_END /* "\<": word-begin, "\>": word-end */
111
+ #undef USE_CAPTURE_HISTORY
112
+ #define USE_VARIABLE_META_CHARS
113
+ #define USE_POSIX_API_REGION_OPTION /* needed for POSIX API support */
114
+ #define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
115
+ /* #define USE_COMBINATION_EXPLOSION_CHECK */ /* (X*)* */
116
+
117
+ /* multithread config */
118
+ /* #define USE_MULTI_THREAD_SYSTEM */
119
+ /* #define USE_DEFAULT_MULTI_THREAD_SYSTEM */
120
+
121
+ #if defined(USE_MULTI_THREAD_SYSTEM) \
122
+ && defined(USE_DEFAULT_MULTI_THREAD_SYSTEM)
123
+
124
+ #ifdef _WIN32
125
+ #define WIN32_LEAN_AND_MEAN
126
+ #include <windows.h>
127
+ extern CRITICAL_SECTION gOnigMutex;
128
+ #define THREAD_SYSTEM_INIT InitializeCriticalSection(&gOnigMutex)
129
+ #define THREAD_SYSTEM_END DeleteCriticalSection(&gOnigMutex)
130
+ #define THREAD_ATOMIC_START EnterCriticalSection(&gOnigMutex)
131
+ #define THREAD_ATOMIC_END LeaveCriticalSection(&gOnigMutex)
132
+ #define THREAD_PASS Sleep(0)
133
+ #else /* _WIN32 */
134
+ #include <pthread.h>
135
+ #include <sched.h>
136
+ extern pthread_mutex_t gOnigMutex;
137
+ #define THREAD_SYSTEM_INIT pthread_mutex_init(&gOnigMutex, NULL)
138
+ #define THREAD_SYSTEM_END pthread_mutex_destroy(&gOnigMutex)
139
+ #define THREAD_ATOMIC_START pthread_mutex_lock(&gOnigMutex)
140
+ #define THREAD_ATOMIC_END pthread_mutex_unlock(&gOnigMutex)
141
+ #define THREAD_PASS sched_yield()
142
+ #endif /* _WIN32 */
143
+
144
+ #else /* USE_DEFAULT_MULTI_THREAD_SYSTEM */
145
+
146
+ #ifndef THREAD_SYSTEM_INIT
147
+ #define THREAD_SYSTEM_INIT /* depend on thread system */
148
+ #endif
149
+ #ifndef THREAD_SYSTEM_END
150
+ #define THREAD_SYSTEM_END /* depend on thread system */
151
+ #endif
152
+ #ifndef THREAD_ATOMIC_START
153
+ #define THREAD_ATOMIC_START /* depend on thread system */
154
+ #endif
155
+ #ifndef THREAD_ATOMIC_END
156
+ #define THREAD_ATOMIC_END /* depend on thread system */
157
+ #endif
158
+ #ifndef THREAD_PASS
159
+ #define THREAD_PASS /* depend on thread system */
160
+ #endif
161
+
162
+ #endif /* USE_DEFAULT_MULTI_THREAD_SYSTEM */
163
+
164
+ #ifndef xmalloc
165
+ #define xmalloc malloc
166
+ #define xrealloc realloc
167
+ #define xcalloc calloc
168
+ #define xfree free
169
+ #endif
170
+
171
+ #ifdef RUBY
172
+
173
+ #define CHECK_INTERRUPT_IN_MATCH_AT rb_thread_check_ints()
174
+ #define onig_st_init_table st_init_table
175
+ #define onig_st_init_table_with_size st_init_table_with_size
176
+ #define onig_st_init_numtable st_init_numtable
177
+ #define onig_st_init_numtable_with_size st_init_numtable_with_size
178
+ #define onig_st_init_strtable st_init_strtable
179
+ #define onig_st_init_strtable_with_size st_init_strtable_with_size
180
+ #define onig_st_delete st_delete
181
+ #define onig_st_delete_safe st_delete_safe
182
+ #define onig_st_insert st_insert
183
+ #define onig_st_lookup st_lookup
184
+ #define onig_st_foreach st_foreach
185
+ #define onig_st_add_direct st_add_direct
186
+ #define onig_st_free_table st_free_table
187
+ #define onig_st_cleanup_safe st_cleanup_safe
188
+ #define onig_st_copy st_copy
189
+ #define onig_st_nothing_key_clone st_nothing_key_clone
190
+ #define onig_st_nothing_key_free st_nothing_key_free
191
+ #define onig_st_is_member st_is_member
192
+
193
+ #define USE_UPPER_CASE_TABLE
194
+ #else
195
+
196
+ #define CHECK_INTERRUPT_IN_MATCH_AT
197
+
198
+ #define st_init_table onig_st_init_table
199
+ #define st_init_table_with_size onig_st_init_table_with_size
200
+ #define st_init_numtable onig_st_init_numtable
201
+ #define st_init_numtable_with_size onig_st_init_numtable_with_size
202
+ #define st_init_strtable onig_st_init_strtable
203
+ #define st_init_strtable_with_size onig_st_init_strtable_with_size
204
+ #define st_delete onig_st_delete
205
+ #define st_delete_safe onig_st_delete_safe
206
+ #define st_insert onig_st_insert
207
+ #define st_lookup onig_st_lookup
208
+ #define st_foreach onig_st_foreach
209
+ #define st_add_direct onig_st_add_direct
210
+ #define st_free_table onig_st_free_table
211
+ #define st_cleanup_safe onig_st_cleanup_safe
212
+ #define st_copy onig_st_copy
213
+ #define st_nothing_key_clone onig_st_nothing_key_clone
214
+ #define st_nothing_key_free onig_st_nothing_key_free
215
+ /* */
216
+ #define onig_st_is_member st_is_member
217
+
218
+ #endif
219
+
220
+ #define STATE_CHECK_STRING_THRESHOLD_LEN 7
221
+ #define STATE_CHECK_BUFF_MAX_SIZE 0x4000
222
+
223
+ #define THREAD_PASS_LIMIT_COUNT 8
224
+ #define xmemset memset
225
+ #define xmemcpy memcpy
226
+ #define xmemmove memmove
227
+
228
+ #if defined(_WIN32) && !defined(__GNUC__)
229
+ #define xalloca _alloca
230
+ #define xvsnprintf _vsnprintf
231
+ #else
232
+ #define xalloca alloca
233
+ #define xvsnprintf vsnprintf
234
+ #endif
235
+
236
+
237
+ #if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
238
+ #define ONIG_STATE_INC(reg) (reg)->state++
239
+ #define ONIG_STATE_DEC(reg) (reg)->state--
240
+
241
+ #define ONIG_STATE_INC_THREAD(reg) do {\
242
+ THREAD_ATOMIC_START;\
243
+ (reg)->state++;\
244
+ THREAD_ATOMIC_END;\
245
+ } while(0)
246
+ #define ONIG_STATE_DEC_THREAD(reg) do {\
247
+ THREAD_ATOMIC_START;\
248
+ (reg)->state--;\
249
+ THREAD_ATOMIC_END;\
250
+ } while(0)
251
+ #else
252
+ #define ONIG_STATE_INC(reg) /* Nothing */
253
+ #define ONIG_STATE_DEC(reg) /* Nothing */
254
+ #define ONIG_STATE_INC_THREAD(reg) /* Nothing */
255
+ #define ONIG_STATE_DEC_THREAD(reg) /* Nothing */
256
+ #endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
257
+
258
+ #ifdef HAVE_STDLIB_H
259
+ #include <stdlib.h>
260
+ #endif
261
+
262
+ #if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
263
+ #include <alloca.h>
264
+ #endif
265
+
266
+ #ifdef HAVE_STRING_H
267
+ # include <string.h>
268
+ #else
269
+ # include <strings.h>
270
+ #endif
271
+
272
+ #include <ctype.h>
273
+ #ifdef HAVE_SYS_TYPES_H
274
+ #include <sys/types.h>
275
+ #endif
276
+
277
+ #ifdef HAVE_STDINT_H
278
+ # include <stdint.h>
279
+ #endif
280
+
281
+ #ifdef HAVE_INTTYPES_H
282
+ # include <inttypes.h>
283
+ #endif
284
+
285
+ #ifdef STDC_HEADERS
286
+ # include <stddef.h>
287
+ #endif
288
+
289
+ #ifdef _WIN32
290
+ #include <malloc.h> /* for alloca() */
291
+ #endif
292
+
293
+ #ifdef ONIG_DEBUG
294
+ # include <stdio.h>
295
+ #endif
296
+
297
+ #ifdef _WIN32
298
+ #if defined(_MSC_VER) && (_MSC_VER < 1300)
299
+ #ifndef _INTPTR_T_DEFINED
300
+ #define _INTPTR_T_DEFINED
301
+ typedef int intptr_t;
302
+ #endif
303
+ #ifndef _UINTPTR_T_DEFINED
304
+ #define _UINTPTR_T_DEFINED
305
+ typedef unsigned int uintptr_t;
306
+ #endif
307
+ #endif
308
+ #endif /* _WIN32 */
309
+
310
+ #ifndef PRIdPTR
311
+ #ifdef _WIN64
312
+ #define PRIdPTR "I64d"
313
+ #define PRIuPTR "I64u"
314
+ #define PRIxPTR "I64x"
315
+ #else
316
+ #define PRIdPTR "ld"
317
+ #define PRIuPTR "lu"
318
+ #define PRIxPTR "lx"
319
+ #endif
320
+ #endif
321
+
322
+ #include "regenc.h"
323
+
324
+ RUBY_SYMBOL_EXPORT_BEGIN
325
+
326
+ #ifdef MIN
327
+ #undef MIN
328
+ #endif
329
+ #ifdef MAX
330
+ #undef MAX
331
+ #endif
332
+ #define MIN(a,b) (((a)>(b))?(b):(a))
333
+ #define MAX(a,b) (((a)<(b))?(b):(a))
334
+
335
+ #define IS_NULL(p) (((void*)(p)) == (void*)0)
336
+ #define IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
337
+ #define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL
338
+ #define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
339
+ #define NULL_UCHARP ((UChar* )0)
340
+
341
+ #define ONIG_LAST_CODE_POINT (~((OnigCodePoint )0))
342
+
343
+ #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
344
+
345
+ #define PLATFORM_GET_INC(val,p,type) do{\
346
+ val = *(type* )p;\
347
+ (p) += sizeof(type);\
348
+ } while(0)
349
+
350
+ #else
351
+
352
+ #define PLATFORM_GET_INC(val,p,type) do{\
353
+ xmemcpy(&val, (p), sizeof(type));\
354
+ (p) += sizeof(type);\
355
+ } while(0)
356
+
357
+ /* sizeof(OnigCodePoint) */
358
+ #define WORD_ALIGNMENT_SIZE SIZEOF_LONG
359
+
360
+ #define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
361
+ (pad_size) = WORD_ALIGNMENT_SIZE \
362
+ - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
363
+ if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
364
+ } while (0)
365
+
366
+ #define ALIGNMENT_RIGHT(addr) do {\
367
+ (addr) += (WORD_ALIGNMENT_SIZE - 1);\
368
+ (addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
369
+ } while (0)
370
+
371
+ #endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
372
+
373
+ /* stack pop level */
374
+ #define STACK_POP_LEVEL_FREE 0
375
+ #define STACK_POP_LEVEL_MEM_START 1
376
+ #define STACK_POP_LEVEL_ALL 2
377
+
378
+ /* optimize flags */
379
+ #define ONIG_OPTIMIZE_NONE 0
380
+ #define ONIG_OPTIMIZE_EXACT 1 /* Slow Search */
381
+ #define ONIG_OPTIMIZE_EXACT_BM 2 /* Boyer Moore Search */
382
+ #define ONIG_OPTIMIZE_EXACT_BM_NOT_REV 3 /* BM (applied to a multibyte string) */
383
+ #define ONIG_OPTIMIZE_EXACT_IC 4 /* Slow Search (ignore case) */
384
+ #define ONIG_OPTIMIZE_MAP 5 /* char map */
385
+ #define ONIG_OPTIMIZE_EXACT_BM_IC 6 /* BM (ignore case) */
386
+ #define ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC 7 /* BM (applied to a multibyte string) (ignore case) */
387
+
388
+ /* bit status */
389
+ typedef unsigned int BitStatusType;
390
+
391
+ #define BIT_STATUS_BITS_NUM (sizeof(BitStatusType) * 8)
392
+ #define BIT_STATUS_CLEAR(stats) (stats) = 0
393
+ #define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
394
+ #define BIT_STATUS_AT(stats,n) \
395
+ ((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & ((BitStatusType)1 << n)) : ((stats) & 1))
396
+
397
+ #define BIT_STATUS_ON_AT(stats,n) do {\
398
+ if ((n) < (int )BIT_STATUS_BITS_NUM) \
399
+ (stats) |= (1 << (n));\
400
+ else\
401
+ (stats) |= 1;\
402
+ } while (0)
403
+
404
+ #define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
405
+ if ((n) < (int )BIT_STATUS_BITS_NUM)\
406
+ (stats) |= (1 << (n));\
407
+ } while (0)
408
+
409
+
410
+ #define INT_MAX_LIMIT ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
411
+
412
+ #define DIGITVAL(code) ((code) - '0')
413
+ #define ODIGITVAL(code) DIGITVAL(code)
414
+ #define XDIGITVAL(enc,code) \
415
+ (ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
416
+ : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
417
+
418
+ #define IS_SINGLELINE(option) ((option) & ONIG_OPTION_SINGLELINE)
419
+ #define IS_MULTILINE(option) ((option) & ONIG_OPTION_MULTILINE)
420
+ #define IS_IGNORECASE(option) ((option) & ONIG_OPTION_IGNORECASE)
421
+ #define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND)
422
+ #define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST)
423
+ #define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
424
+ #define IS_FIND_CONDITION(option) ((option) & \
425
+ (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
426
+ #define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL)
427
+ #define IS_NOTEOL(option) ((option) & ONIG_OPTION_NOTEOL)
428
+ #define IS_NOTBOS(option) ((option) & ONIG_OPTION_NOTBOS)
429
+ #define IS_NOTEOS(option) ((option) & ONIG_OPTION_NOTEOS)
430
+ #define IS_POSIX_REGION(option) ((option) & ONIG_OPTION_POSIX_REGION)
431
+ #define IS_ASCII_RANGE(option) ((option) & ONIG_OPTION_ASCII_RANGE)
432
+ #define IS_POSIX_BRACKET_ALL_RANGE(option) ((option) & ONIG_OPTION_POSIX_BRACKET_ALL_RANGE)
433
+ #define IS_WORD_BOUND_ALL_RANGE(option) ((option) & ONIG_OPTION_WORD_BOUND_ALL_RANGE)
434
+ #define IS_NEWLINE_CRLF(option) ((option) & ONIG_OPTION_NEWLINE_CRLF)
435
+
436
+ /* OP_SET_OPTION is required for these options.
437
+ #define IS_DYNAMIC_OPTION(option) \
438
+ (((option) & (ONIG_OPTION_MULTILINE | ONIG_OPTION_IGNORECASE)) != 0)
439
+ */
440
+ /* ignore-case and multibyte status are included in compiled code. */
441
+ #define IS_DYNAMIC_OPTION(option) 0
442
+
443
+ #define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
444
+ ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
445
+
446
+ #define REPEAT_INFINITE -1
447
+ #define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE)
448
+
449
+ /* bitset */
450
+ #define BITS_PER_BYTE 8
451
+ #define SINGLE_BYTE_SIZE (1 << BITS_PER_BYTE)
452
+ #define BITS_IN_ROOM ((int )sizeof(Bits) * BITS_PER_BYTE)
453
+ #define BITSET_SIZE (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
454
+
455
+ #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
456
+ typedef unsigned int Bits;
457
+ #else
458
+ typedef unsigned char Bits;
459
+ #endif
460
+ typedef Bits BitSet[BITSET_SIZE];
461
+ typedef Bits* BitSetRef;
462
+
463
+ #define SIZE_BITSET (int )sizeof(BitSet)
464
+
465
+ #define BITSET_CLEAR(bs) do {\
466
+ int i;\
467
+ for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; } \
468
+ } while (0)
469
+
470
+ #define BS_ROOM(bs,pos) (bs)[(int )(pos) / BITS_IN_ROOM]
471
+ #define BS_BIT(pos) (1U << ((int )(pos) % BITS_IN_ROOM))
472
+
473
+ #define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
474
+ #define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)
475
+ #define BITSET_CLEAR_BIT(bs, pos) BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
476
+ #define BITSET_INVERT_BIT(bs, pos) BS_ROOM(bs,pos) ^= BS_BIT(pos)
477
+
478
+ /* bytes buffer */
479
+ typedef struct _BBuf {
480
+ UChar* p;
481
+ unsigned int used;
482
+ unsigned int alloc;
483
+ } BBuf;
484
+
485
+ #define BBUF_INIT(buf,size) onig_bbuf_init((BBuf* )(buf), (size))
486
+
487
+ #define BBUF_SIZE_INC(buf,inc) do{\
488
+ (buf)->alloc += (inc);\
489
+ (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
490
+ if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
491
+ } while (0)
492
+
493
+ #define BBUF_EXPAND(buf,low) do{\
494
+ do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
495
+ (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
496
+ if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
497
+ } while (0)
498
+
499
+ #define BBUF_ENSURE_SIZE(buf,size) do{\
500
+ unsigned int new_alloc = (buf)->alloc;\
501
+ while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
502
+ if ((buf)->alloc != new_alloc) {\
503
+ (buf)->p = (UChar* )xrealloc((buf)->p, new_alloc);\
504
+ if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
505
+ (buf)->alloc = new_alloc;\
506
+ }\
507
+ } while (0)
508
+
509
+ #define BBUF_WRITE(buf,pos,bytes,n) do{\
510
+ int used = (pos) + (int )(n);\
511
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
512
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
513
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
514
+ } while (0)
515
+
516
+ #define BBUF_WRITE1(buf,pos,byte) do{\
517
+ int used = (pos) + 1;\
518
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
519
+ (buf)->p[(pos)] = (UChar )(byte);\
520
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
521
+ } while (0)
522
+
523
+ #define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
524
+ #define BBUF_ADD1(buf,byte) BBUF_WRITE1((buf),(buf)->used,(byte))
525
+ #define BBUF_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
526
+ #define BBUF_GET_OFFSET_POS(buf) ((buf)->used)
527
+
528
+ /* from < to */
529
+ #define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
530
+ if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
531
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
532
+ if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
533
+ } while (0)
534
+
535
+ /* from > to */
536
+ #define BBUF_MOVE_LEFT(buf,from,to,n) do {\
537
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
538
+ } while (0)
539
+
540
+ /* from > to */
541
+ #define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
542
+ xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
543
+ (buf)->used -= (from - to);\
544
+ } while (0)
545
+
546
+ #define BBUF_INSERT(buf,pos,bytes,n) do {\
547
+ if (pos >= (buf)->used) {\
548
+ BBUF_WRITE(buf,pos,bytes,n);\
549
+ }\
550
+ else {\
551
+ BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
552
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
553
+ }\
554
+ } while (0)
555
+
556
+ #define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
557
+
558
+
559
+ #define ANCHOR_BEGIN_BUF (1<<0)
560
+ #define ANCHOR_BEGIN_LINE (1<<1)
561
+ #define ANCHOR_BEGIN_POSITION (1<<2)
562
+ #define ANCHOR_END_BUF (1<<3)
563
+ #define ANCHOR_SEMI_END_BUF (1<<4)
564
+ #define ANCHOR_END_LINE (1<<5)
565
+
566
+ #define ANCHOR_WORD_BOUND (1<<6)
567
+ #define ANCHOR_NOT_WORD_BOUND (1<<7)
568
+ #define ANCHOR_WORD_BEGIN (1<<8)
569
+ #define ANCHOR_WORD_END (1<<9)
570
+ #define ANCHOR_PREC_READ (1<<10)
571
+ #define ANCHOR_PREC_READ_NOT (1<<11)
572
+ #define ANCHOR_LOOK_BEHIND (1<<12)
573
+ #define ANCHOR_LOOK_BEHIND_NOT (1<<13)
574
+
575
+ #define ANCHOR_ANYCHAR_STAR (1<<14) /* ".*" optimize info */
576
+ #define ANCHOR_ANYCHAR_STAR_ML (1<<15) /* ".*" optimize info (multi-line) */
577
+
578
+ #define ANCHOR_KEEP (1<<16)
579
+
580
+ /* operation code */
581
+ enum OpCode {
582
+ OP_FINISH = 0, /* matching process terminator (no more alternative) */
583
+ OP_END = 1, /* pattern code terminator (success end) */
584
+
585
+ OP_EXACT1 = 2, /* single byte, N = 1 */
586
+ OP_EXACT2, /* single byte, N = 2 */
587
+ OP_EXACT3, /* single byte, N = 3 */
588
+ OP_EXACT4, /* single byte, N = 4 */
589
+ OP_EXACT5, /* single byte, N = 5 */
590
+ OP_EXACTN, /* single byte */
591
+ OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
592
+ OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
593
+ OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
594
+ OP_EXACTMB2N, /* mb-length = 2 */
595
+ OP_EXACTMB3N, /* mb-length = 3 */
596
+ OP_EXACTMBN, /* other length */
597
+
598
+ OP_EXACT1_IC, /* single byte, N = 1, ignore case */
599
+ OP_EXACTN_IC, /* single byte, ignore case */
600
+
601
+ OP_CCLASS,
602
+ OP_CCLASS_MB,
603
+ OP_CCLASS_MIX,
604
+ OP_CCLASS_NOT,
605
+ OP_CCLASS_MB_NOT,
606
+ OP_CCLASS_MIX_NOT,
607
+ OP_CCLASS_NODE, /* pointer to CClassNode node */
608
+
609
+ OP_ANYCHAR, /* "." */
610
+ OP_ANYCHAR_ML, /* "." multi-line */
611
+ OP_ANYCHAR_STAR, /* ".*" */
612
+ OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
613
+ OP_ANYCHAR_STAR_PEEK_NEXT,
614
+ OP_ANYCHAR_ML_STAR_PEEK_NEXT,
615
+
616
+ OP_WORD,
617
+ OP_NOT_WORD,
618
+ OP_WORD_BOUND,
619
+ OP_NOT_WORD_BOUND,
620
+ OP_WORD_BEGIN,
621
+ OP_WORD_END,
622
+
623
+ OP_ASCII_WORD,
624
+ OP_NOT_ASCII_WORD,
625
+ OP_ASCII_WORD_BOUND,
626
+ OP_NOT_ASCII_WORD_BOUND,
627
+ OP_ASCII_WORD_BEGIN,
628
+ OP_ASCII_WORD_END,
629
+
630
+ OP_BEGIN_BUF,
631
+ OP_END_BUF,
632
+ OP_BEGIN_LINE,
633
+ OP_END_LINE,
634
+ OP_SEMI_END_BUF,
635
+ OP_BEGIN_POSITION,
636
+ OP_BEGIN_POS_OR_LINE, /* used for implicit anchor optimization */
637
+
638
+ OP_BACKREF1,
639
+ OP_BACKREF2,
640
+ OP_BACKREFN,
641
+ OP_BACKREFN_IC,
642
+ OP_BACKREF_MULTI,
643
+ OP_BACKREF_MULTI_IC,
644
+ OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
645
+
646
+ OP_MEMORY_START,
647
+ OP_MEMORY_START_PUSH, /* push back-tracker to stack */
648
+ OP_MEMORY_END_PUSH, /* push back-tracker to stack */
649
+ OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
650
+ OP_MEMORY_END,
651
+ OP_MEMORY_END_REC, /* push marker to stack */
652
+
653
+ OP_KEEP,
654
+
655
+ OP_FAIL, /* pop stack and move */
656
+ OP_JUMP,
657
+ OP_PUSH,
658
+ OP_POP,
659
+ OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
660
+ OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
661
+ OP_REPEAT, /* {n,m} */
662
+ OP_REPEAT_NG, /* {n,m}? (non greedy) */
663
+ OP_REPEAT_INC,
664
+ OP_REPEAT_INC_NG, /* non greedy */
665
+ OP_REPEAT_INC_SG, /* search and get in stack */
666
+ OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
667
+ OP_NULL_CHECK_START, /* null loop checker start */
668
+ OP_NULL_CHECK_END, /* null loop checker end */
669
+ OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
670
+ OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
671
+
672
+ OP_PUSH_POS, /* (?=...) start */
673
+ OP_POP_POS, /* (?=...) end */
674
+ OP_PUSH_POS_NOT, /* (?!...) start */
675
+ OP_FAIL_POS, /* (?!...) end */
676
+ OP_PUSH_STOP_BT, /* (?>...) start */
677
+ OP_POP_STOP_BT, /* (?>...) end */
678
+ OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
679
+ OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
680
+ OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end */
681
+
682
+ OP_CALL, /* \g<name> */
683
+ OP_RETURN,
684
+
685
+ OP_CONDITION,
686
+
687
+ OP_STATE_CHECK_PUSH, /* combination explosion check and push */
688
+ OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */
689
+ OP_STATE_CHECK, /* check only */
690
+ OP_STATE_CHECK_ANYCHAR_STAR,
691
+ OP_STATE_CHECK_ANYCHAR_ML_STAR,
692
+
693
+ /* no need: IS_DYNAMIC_OPTION() == 0 */
694
+ OP_SET_OPTION_PUSH, /* set option and push recover option */
695
+ OP_SET_OPTION /* set option */
696
+ };
697
+
698
+ typedef int RelAddrType;
699
+ typedef int AbsAddrType;
700
+ typedef int LengthType;
701
+ typedef int RepeatNumType;
702
+ typedef short int MemNumType;
703
+ typedef short int StateCheckNumType;
704
+ typedef void* PointerType;
705
+
706
+ #define SIZE_OPCODE 1
707
+ #define SIZE_RELADDR (int )sizeof(RelAddrType)
708
+ #define SIZE_ABSADDR (int )sizeof(AbsAddrType)
709
+ #define SIZE_LENGTH (int )sizeof(LengthType)
710
+ #define SIZE_MEMNUM (int )sizeof(MemNumType)
711
+ #define SIZE_STATE_CHECK_NUM (int )sizeof(StateCheckNumType)
712
+ #define SIZE_REPEATNUM (int )sizeof(RepeatNumType)
713
+ #define SIZE_OPTION (int )sizeof(OnigOptionType)
714
+ #define SIZE_CODE_POINT (int )sizeof(OnigCodePoint)
715
+ #define SIZE_POINTER (int )sizeof(PointerType)
716
+
717
+
718
+ #define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
719
+ #define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
720
+ #define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
721
+ #define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
722
+ #define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
723
+ #define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
724
+ #define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
725
+ #define GET_STATE_CHECK_NUM_INC(num,p) PLATFORM_GET_INC(num, p, StateCheckNumType)
726
+
727
+ /* code point's address must be aligned address. */
728
+ #define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
729
+ #define GET_BYTE_INC(byte,p) do{\
730
+ byte = *(p);\
731
+ (p)++;\
732
+ } while(0)
733
+
734
+
735
+ /* op-code + arg size */
736
+ #define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
737
+ #define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
738
+ #define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
739
+ #define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
740
+ #define SIZE_OP_POP SIZE_OPCODE
741
+ #define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
742
+ #define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
743
+ #define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
744
+ #define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
745
+ #define SIZE_OP_PUSH_POS SIZE_OPCODE
746
+ #define SIZE_OP_PUSH_POS_NOT (SIZE_OPCODE + SIZE_RELADDR)
747
+ #define SIZE_OP_POP_POS SIZE_OPCODE
748
+ #define SIZE_OP_FAIL_POS SIZE_OPCODE
749
+ #define SIZE_OP_SET_OPTION (SIZE_OPCODE + SIZE_OPTION)
750
+ #define SIZE_OP_SET_OPTION_PUSH (SIZE_OPCODE + SIZE_OPTION)
751
+ #define SIZE_OP_FAIL SIZE_OPCODE
752
+ #define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
753
+ #define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
754
+ #define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
755
+ #define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
756
+ #define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
757
+ #define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
758
+ #define SIZE_OP_PUSH_STOP_BT SIZE_OPCODE
759
+ #define SIZE_OP_POP_STOP_BT SIZE_OPCODE
760
+ #define SIZE_OP_NULL_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
761
+ #define SIZE_OP_NULL_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
762
+ #define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
763
+ #define SIZE_OP_PUSH_LOOK_BEHIND_NOT (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
764
+ #define SIZE_OP_FAIL_LOOK_BEHIND_NOT SIZE_OPCODE
765
+ #define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
766
+ #define SIZE_OP_RETURN SIZE_OPCODE
767
+ #define SIZE_OP_CONDITION (SIZE_OPCODE + SIZE_MEMNUM + SIZE_RELADDR)
768
+
769
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
770
+ #define SIZE_OP_STATE_CHECK (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
771
+ #define SIZE_OP_STATE_CHECK_PUSH (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
772
+ #define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
773
+ #define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
774
+ #endif
775
+
776
+ #define MC_ESC(syn) (syn)->meta_char_table.esc
777
+ #define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
778
+ #define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
779
+ #define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
780
+ #define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
781
+ #define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
782
+
783
+ #define IS_MC_ESC_CODE(code, syn) \
784
+ ((code) == MC_ESC(syn) && \
785
+ !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
786
+
787
+
788
+ #define SYN_POSIX_COMMON_OP \
789
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
790
+ ONIG_SYN_OP_DECIMAL_BACKREF | \
791
+ ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
792
+ ONIG_SYN_OP_LINE_ANCHOR | \
793
+ ONIG_SYN_OP_ESC_CONTROL_CHARS )
794
+
795
+ #define SYN_GNU_REGEX_OP \
796
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
797
+ ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
798
+ ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
799
+ ONIG_SYN_OP_VBAR_ALT | \
800
+ ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
801
+ ONIG_SYN_OP_QMARK_ZERO_ONE | \
802
+ ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
803
+ ONIG_SYN_OP_ESC_W_WORD | \
804
+ ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
805
+ ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
806
+ ONIG_SYN_OP_LINE_ANCHOR )
807
+
808
+ #define SYN_GNU_REGEX_BV \
809
+ ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
810
+ ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
811
+ ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
812
+
813
+
814
+ #define NCCLASS_FLAGS(cc) ((cc)->flags)
815
+ #define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
816
+ #define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
817
+ #define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
818
+
819
+ /* cclass node */
820
+ #define FLAG_NCCLASS_NOT (1<<0)
821
+ #define FLAG_NCCLASS_SHARE (1<<1)
822
+
823
+ #define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
824
+ #define NCCLASS_SET_SHARE(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_SHARE)
825
+ #define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
826
+ #define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
827
+ #define IS_NCCLASS_SHARE(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_SHARE)
828
+
829
+ typedef struct {
830
+ int type;
831
+ /* struct _Node* next; */
832
+ /* unsigned int flags; */
833
+ } NodeBase;
834
+
835
+ typedef struct {
836
+ NodeBase base;
837
+ unsigned int flags;
838
+ BitSet bs;
839
+ BBuf* mbuf; /* multi-byte info or NULL */
840
+ } CClassNode;
841
+
842
+ typedef intptr_t OnigStackIndex;
843
+
844
+ typedef struct _OnigStackType {
845
+ unsigned int type;
846
+ union {
847
+ struct {
848
+ UChar *pcode; /* byte code position */
849
+ UChar *pstr; /* string position */
850
+ UChar *pstr_prev; /* previous char position of pstr */
851
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
852
+ unsigned int state_check;
853
+ #endif
854
+ UChar *pkeep; /* keep pattern position */
855
+ } state;
856
+ struct {
857
+ int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
858
+ UChar *pcode; /* byte code position (head of repeated target) */
859
+ int num; /* repeat id */
860
+ } repeat;
861
+ struct {
862
+ OnigStackIndex si; /* index of stack */
863
+ } repeat_inc;
864
+ struct {
865
+ int num; /* memory num */
866
+ UChar *pstr; /* start/end position */
867
+ /* Following information is set, if this stack type is MEM-START */
868
+ OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */
869
+ OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */
870
+ } mem;
871
+ struct {
872
+ int num; /* null check id */
873
+ UChar *pstr; /* start position */
874
+ } null_check;
875
+ #ifdef USE_SUBEXP_CALL
876
+ struct {
877
+ UChar *ret_addr; /* byte code position */
878
+ int num; /* null check id */
879
+ UChar *pstr; /* string position */
880
+ } call_frame;
881
+ #endif
882
+ } u;
883
+ } OnigStackType;
884
+
885
+ typedef struct {
886
+ void* stack_p;
887
+ size_t stack_n;
888
+ OnigOptionType options;
889
+ OnigRegion* region;
890
+ const UChar* start; /* search start position */
891
+ const UChar* gpos; /* global position (for \G: BEGIN_POSITION) */
892
+ #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
893
+ OnigPosition best_len; /* for ONIG_OPTION_FIND_LONGEST */
894
+ UChar* best_s;
895
+ #endif
896
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
897
+ void* state_check_buff;
898
+ int state_check_buff_size;
899
+ #endif
900
+ } OnigMatchArg;
901
+
902
+
903
+ #define IS_CODE_SB_WORD(enc,code) \
904
+ (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
905
+
906
+ #ifdef ONIG_DEBUG
907
+
908
+ typedef struct {
909
+ short int opcode;
910
+ const char* name;
911
+ short int arg_type;
912
+ } OnigOpInfoType;
913
+
914
+ extern OnigOpInfoType OnigOpInfo[];
915
+
916
+ extern void onig_print_compiled_byte_code P_((FILE* f, UChar* bp, UChar* bpend, UChar** nextp, OnigEncoding enc));
917
+
918
+ #ifdef ONIG_DEBUG_STATISTICS
919
+ extern void onig_statistics_init P_((void));
920
+ extern void onig_print_statistics P_((FILE* f));
921
+ #endif
922
+ #endif
923
+
924
+ extern UChar* onig_error_code_to_format P_((OnigPosition code));
925
+ extern void onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...));
926
+ extern int onig_bbuf_init P_((BBuf* buf, OnigDistance size));
927
+ extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo, const char *sourcefile, int sourceline));
928
+ extern void onig_chain_reduce P_((regex_t* reg));
929
+ extern void onig_chain_link_add P_((regex_t* to, regex_t* add));
930
+ extern void onig_transfer P_((regex_t* to, regex_t* from));
931
+ extern int onig_is_code_in_cc P_((OnigEncoding enc, OnigCodePoint code, CClassNode* cc));
932
+ extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, CClassNode* cc));
933
+
934
+ /* strend hash */
935
+ typedef void hash_table_type;
936
+ #ifdef RUBY
937
+ #include "ruby/st.h"
938
+ typedef st_data_t hash_data_type;
939
+ #else
940
+ #include "st.h"
941
+ typedef uintptr_t hash_data_type;
942
+ #endif
943
+
944
+ extern hash_table_type* onig_st_init_strend_table_with_size P_((st_index_t size));
945
+ extern int onig_st_lookup_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value));
946
+ extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value));
947
+
948
+ /* encoding property management */
949
+ #define PROPERTY_LIST_ADD_PROP(Name, CR) \
950
+ r = onigenc_property_list_add_property((UChar* )Name, CR,\
951
+ &PropertyNameTable, &PropertyList, &PropertyListNum,\
952
+ &PropertyListSize);\
953
+ if (r != 0) goto end
954
+
955
+ #define PROPERTY_LIST_INIT_CHECK \
956
+ if (PropertyInited == 0) {\
957
+ int r = onigenc_property_list_init(init_property_list);\
958
+ if (r != 0) return r;\
959
+ }
960
+
961
+ extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize));
962
+
963
+ typedef int (*ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void);
964
+
965
+ extern int onigenc_property_list_init P_((ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE));
966
+
967
+ extern size_t onig_memsize P_((const regex_t *reg));
968
+ extern size_t onig_region_memsize P_((const struct re_registers *regs));
969
+
970
+ RUBY_SYMBOL_EXPORT_END
971
+
972
+ #endif /* ONIGURUMA_REGINT_H */