debase-ruby_core_source 0.10.16 → 0.10.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/addr2line.h +20 -0
  4. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/builtin.h +121 -0
  5. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/build_assert/build_assert.h +40 -0
  6. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/check_type/check_type.h +63 -0
  7. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/container_of/container_of.h +142 -0
  8. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/list/list.h +789 -0
  9. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ccan/str/str.h +17 -0
  10. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/constant.h +55 -0
  11. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/darray.h +179 -0
  12. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/debug_counter.h +469 -0
  13. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/dln.h +31 -0
  14. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/encindex.h +70 -0
  15. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/eval_intern.h +339 -0
  16. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/gc.h +143 -0
  17. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/hrtime.h +226 -0
  18. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/id.h +295 -0
  19. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/id_table.h +36 -0
  20. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/insns.inc +249 -0
  21. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/insns_info.inc +9061 -0
  22. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/array.h +162 -0
  23. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/bignum.h +246 -0
  24. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/bits.h +565 -0
  25. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/class.h +212 -0
  26. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/cmdlineopt.h +58 -0
  27. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/compar.h +49 -0
  28. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/compile.h +35 -0
  29. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/compilers.h +107 -0
  30. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/complex.h +29 -0
  31. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/cont.h +26 -0
  32. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/dir.h +16 -0
  33. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/enc.h +19 -0
  34. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/encoding.h +30 -0
  35. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/enum.h +18 -0
  36. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/enumerator.h +21 -0
  37. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/error.h +191 -0
  38. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/eval.h +32 -0
  39. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/file.h +38 -0
  40. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/fixnum.h +184 -0
  41. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/gc.h +188 -0
  42. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/hash.h +243 -0
  43. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/imemo.h +242 -0
  44. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/inits.h +50 -0
  45. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/io.h +38 -0
  46. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/load.h +18 -0
  47. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/loadpath.h +16 -0
  48. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/math.h +23 -0
  49. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/missing.h +18 -0
  50. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/numeric.h +271 -0
  51. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/object.h +83 -0
  52. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/parse.h +23 -0
  53. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/proc.h +32 -0
  54. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/process.h +137 -0
  55. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/ractor.h +6 -0
  56. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/random.h +16 -0
  57. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/range.h +40 -0
  58. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/rational.h +72 -0
  59. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/re.h +30 -0
  60. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/sanitizers.h +190 -0
  61. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/serial.h +23 -0
  62. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/signal.h +21 -0
  63. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/static_assert.h +16 -0
  64. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/string.h +146 -0
  65. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/struct.h +153 -0
  66. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/symbol.h +42 -0
  67. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/thread.h +54 -0
  68. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/time.h +34 -0
  69. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/transcode.h +20 -0
  70. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/util.h +27 -0
  71. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/variable.h +83 -0
  72. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/vm.h +134 -0
  73. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal/warnings.h +16 -0
  74. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/internal.h +113 -0
  75. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/iseq.h +328 -0
  76. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/known_errors.inc +791 -0
  77. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/method.h +253 -0
  78. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/mjit.h +136 -0
  79. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/mjit_compile_attr.inc +430 -0
  80. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/mjit_compiler.h +58 -0
  81. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/mjit_unit.h +29 -0
  82. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/node.h +510 -0
  83. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/node_name.inc +208 -0
  84. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/opt_sc.inc +109 -0
  85. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/optinsn.inc +128 -0
  86. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/optunifs.inc +43 -0
  87. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/parse.h +214 -0
  88. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/probes_helper.h +44 -0
  89. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ractor_core.h +341 -0
  90. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/regenc.h +255 -0
  91. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/regint.h +957 -0
  92. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/regparse.h +370 -0
  93. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/revision.h +2 -0
  94. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ruby_assert.h +14 -0
  95. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/ruby_atomic.h +23 -0
  96. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/siphash.h +48 -0
  97. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/symbol.h +119 -0
  98. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/thread_none.h +20 -0
  99. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/thread_pthread.h +132 -0
  100. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/thread_win32.h +63 -0
  101. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/timev.h +57 -0
  102. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/transcode_data.h +138 -0
  103. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/transient_heap.h +65 -0
  104. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/variable.h +21 -0
  105. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/version.h +68 -0
  106. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm.inc +5476 -0
  107. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_call_iseq_optimized.inc +244 -0
  108. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_callinfo.h +522 -0
  109. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_core.h +2130 -0
  110. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_debug.h +122 -0
  111. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_exec.h +197 -0
  112. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_insnhelper.h +269 -0
  113. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_opts.h +73 -0
  114. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vm_sync.h +137 -0
  115. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/vmtc.inc +243 -0
  116. data/lib/debase/ruby_core_source/ruby-3.2.0-preview2/yjit.h +72 -0
  117. data/lib/debase/ruby_core_source/version.rb +1 -1
  118. metadata +116 -2
@@ -0,0 +1,957 @@
1
+ #ifndef ONIGMO_REGINT_H
2
+ #define ONIGMO_REGINT_H
3
+ /**********************************************************************
4
+ regint.h - Onigmo (Oniguruma-mod) (regular expression library)
5
+ **********************************************************************/
6
+ /*-
7
+ * Copyright (c) 2002-2013 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
8
+ * Copyright (c) 2011-2016 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_DEBUG_MEMLEAK */
39
+ /* #define ONIG_DONT_OPTIMIZE */
40
+
41
+ /* for byte-code statistical data. */
42
+ /* #define ONIG_DEBUG_STATISTICS */
43
+
44
+ #if defined(ONIG_DEBUG_PARSE_TREE) || defined(ONIG_DEBUG_MATCH) || \
45
+ defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) || \
46
+ defined(ONIG_DEBUG_STATISTICS) || defined(ONIG_DEBUG_MEMLEAK)
47
+ # ifndef ONIG_DEBUG
48
+ # define ONIG_DEBUG
49
+ # endif
50
+ #endif
51
+
52
+ #ifndef UNALIGNED_WORD_ACCESS
53
+ # if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
54
+ defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
55
+ defined(__powerpc64__) || defined(__aarch64__) || \
56
+ defined(__mc68020__)
57
+ # define UNALIGNED_WORD_ACCESS 1
58
+ # else
59
+ # define UNALIGNED_WORD_ACCESS 0
60
+ # endif
61
+ #endif
62
+
63
+ #if UNALIGNED_WORD_ACCESS
64
+ # define PLATFORM_UNALIGNED_WORD_ACCESS
65
+ #endif
66
+
67
+ /* config */
68
+ /* spec. config */
69
+ #define USE_NAMED_GROUP
70
+ #define USE_SUBEXP_CALL
71
+ #define USE_PERL_SUBEXP_CALL
72
+ #define USE_CAPITAL_P_NAMED_GROUP
73
+ #define USE_BACKREF_WITH_LEVEL /* \k<name+n>, \k<name-n> */
74
+ #define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT /* /(?:()|())*\2/ */
75
+ #define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
76
+ #define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
77
+ /* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */
78
+ #define USE_NO_INVALID_QUANTIFIER
79
+
80
+ /* internal config */
81
+ /* #define USE_OP_PUSH_OR_JUMP_EXACT */
82
+ #define USE_QTFR_PEEK_NEXT
83
+ #define USE_ST_LIBRARY
84
+ #define USE_SUNDAY_QUICK_SEARCH
85
+
86
+ #define INIT_MATCH_STACK_SIZE 160
87
+ #define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
88
+ #define DEFAULT_PARSE_DEPTH_LIMIT 4096
89
+
90
+ #define OPT_EXACT_MAXLEN 24
91
+
92
+ /* check config */
93
+ #if defined(USE_PERL_SUBEXP_CALL) || defined(USE_CAPITAL_P_NAMED_GROUP)
94
+ # if !defined(USE_NAMED_GROUP) || !defined(USE_SUBEXP_CALL)
95
+ # error USE_NAMED_GROUP and USE_SUBEXP_CALL must be defined.
96
+ # endif
97
+ #endif
98
+
99
+ #if defined(__GNUC__)
100
+ # define ARG_UNUSED __attribute__ ((unused))
101
+ #else
102
+ # define ARG_UNUSED
103
+ #endif
104
+
105
+ #if !defined(RUBY) && defined(RUBY_EXPORT)
106
+ # define RUBY
107
+ #endif
108
+ #ifdef RUBY
109
+ # ifndef RUBY_DEFINES_H
110
+ # include "ruby/ruby.h"
111
+ # undef xmalloc
112
+ # undef xrealloc
113
+ # undef xcalloc
114
+ # undef xfree
115
+ # endif
116
+ #else /* RUBY */
117
+ # include "config.h"
118
+ # if SIZEOF_LONG_LONG > 0
119
+ # define LONG_LONG long long
120
+ # endif
121
+ #endif /* RUBY */
122
+
123
+ #include <stdarg.h>
124
+
125
+ /* */
126
+ /* escape other system UChar definition */
127
+ #ifdef ONIG_ESCAPE_UCHAR_COLLISION
128
+ # undef ONIG_ESCAPE_UCHAR_COLLISION
129
+ #endif
130
+
131
+ #define USE_WORD_BEGIN_END /* "\<": word-begin, "\>": word-end */
132
+ #ifdef RUBY
133
+ # undef USE_CAPTURE_HISTORY
134
+ #else
135
+ # define USE_CAPTURE_HISTORY
136
+ #endif
137
+ #define USE_VARIABLE_META_CHARS
138
+ #define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
139
+ /* #define USE_COMBINATION_EXPLOSION_CHECK */ /* (X*)* */
140
+
141
+
142
+ #ifndef xmalloc
143
+ # define xmalloc malloc
144
+ # define xrealloc realloc
145
+ # define xcalloc calloc
146
+ # define xfree free
147
+ #endif
148
+
149
+ #ifdef RUBY
150
+
151
+ # define CHECK_INTERRUPT_IN_MATCH_AT do { \
152
+ msa->counter++; \
153
+ if (msa->counter >= 128) { \
154
+ msa->counter = 0; \
155
+ rb_reg_check_timeout(reg, &msa->end_time); \
156
+ rb_thread_check_ints(); \
157
+ } \
158
+ } while(0)
159
+ # define onig_st_init_table st_init_table
160
+ # define onig_st_init_table_with_size st_init_table_with_size
161
+ # define onig_st_init_numtable st_init_numtable
162
+ # define onig_st_init_numtable_with_size st_init_numtable_with_size
163
+ # define onig_st_init_strtable st_init_strtable
164
+ # define onig_st_init_strtable_with_size st_init_strtable_with_size
165
+ # define onig_st_delete st_delete
166
+ # define onig_st_delete_safe st_delete_safe
167
+ # define onig_st_insert st_insert
168
+ # define onig_st_lookup st_lookup
169
+ # define onig_st_foreach st_foreach
170
+ # define onig_st_add_direct st_add_direct
171
+ # define onig_st_free_table st_free_table
172
+ # define onig_st_cleanup_safe st_cleanup_safe
173
+ # define onig_st_copy st_copy
174
+ # define onig_st_nothing_key_clone st_nothing_key_clone
175
+ # define onig_st_nothing_key_free st_nothing_key_free
176
+ # define onig_st_is_member st_is_member
177
+
178
+ # define USE_UPPER_CASE_TABLE
179
+ #else /* RUBY */
180
+
181
+ # define CHECK_INTERRUPT_IN_MATCH_AT
182
+
183
+ # define st_init_table onig_st_init_table
184
+ # define st_init_table_with_size onig_st_init_table_with_size
185
+ # define st_init_numtable onig_st_init_numtable
186
+ # define st_init_numtable_with_size onig_st_init_numtable_with_size
187
+ # define st_init_strtable onig_st_init_strtable
188
+ # define st_init_strtable_with_size onig_st_init_strtable_with_size
189
+ # define st_delete onig_st_delete
190
+ # define st_delete_safe onig_st_delete_safe
191
+ # define st_insert onig_st_insert
192
+ # define st_lookup onig_st_lookup
193
+ # define st_foreach onig_st_foreach
194
+ # define st_add_direct onig_st_add_direct
195
+ # define st_free_table onig_st_free_table
196
+ # define st_cleanup_safe onig_st_cleanup_safe
197
+ # define st_copy onig_st_copy
198
+ # define st_nothing_key_clone onig_st_nothing_key_clone
199
+ # define st_nothing_key_free onig_st_nothing_key_free
200
+ /* */
201
+ # define onig_st_is_member st_is_member
202
+
203
+ #endif /* RUBY */
204
+
205
+ #define STATE_CHECK_STRING_THRESHOLD_LEN 7
206
+ #define STATE_CHECK_BUFF_MAX_SIZE 0x4000
207
+
208
+ #define xmemset memset
209
+ #define xmemcpy memcpy
210
+ #define xmemmove memmove
211
+
212
+ #if ((defined(RUBY_MSVCRT_VERSION) && RUBY_MSVCRT_VERSION >= 90) \
213
+ || (!defined(RUBY_MSVCRT_VERSION) && defined(_WIN32))) \
214
+ && !defined(__GNUC__)
215
+ # define xalloca _alloca
216
+ # define xvsnprintf(buf,size,fmt,args) _vsnprintf_s(buf,size,_TRUNCATE,fmt,args)
217
+ # define xsnprintf sprintf_s
218
+ # define xstrcat(dest,src,size) strcat_s(dest,size,src)
219
+ #else
220
+ # define xalloca alloca
221
+ # define xvsnprintf vsnprintf
222
+ # define xsnprintf snprintf
223
+ # define xstrcat(dest,src,size) strcat(dest,src)
224
+ #endif
225
+
226
+ #if defined(ONIG_DEBUG_MEMLEAK) && defined(_MSC_VER)
227
+ # define _CRTDBG_MAP_ALLOC
228
+ # include <malloc.h>
229
+ # include <crtdbg.h>
230
+ #endif
231
+
232
+ #include <stdlib.h>
233
+
234
+ #if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
235
+ # include <alloca.h>
236
+ #endif
237
+
238
+ #include <string.h>
239
+
240
+ #include <ctype.h>
241
+ #ifdef HAVE_SYS_TYPES_H
242
+ # include <sys/types.h>
243
+ #endif
244
+
245
+ #ifdef HAVE_STDINT_H
246
+ # include <stdint.h>
247
+ #endif
248
+
249
+ #ifdef HAVE_INTTYPES_H
250
+ # include <inttypes.h>
251
+ #endif
252
+
253
+ #include <stddef.h>
254
+
255
+ #ifdef _WIN32
256
+ # include <malloc.h> /* for alloca() */
257
+ #endif
258
+
259
+ #ifdef ONIG_DEBUG
260
+ # include <stdio.h>
261
+ #endif
262
+
263
+ #ifdef _WIN32
264
+ # if defined(_MSC_VER) && (_MSC_VER < 1300)
265
+ # ifndef _INTPTR_T_DEFINED
266
+ # define _INTPTR_T_DEFINED
267
+ typedef int intptr_t;
268
+ # endif
269
+ # ifndef _UINTPTR_T_DEFINED
270
+ # define _UINTPTR_T_DEFINED
271
+ typedef unsigned int uintptr_t;
272
+ # endif
273
+ # endif
274
+ #endif /* _WIN32 */
275
+
276
+ #ifndef PRIdPTR
277
+ # ifdef _WIN64
278
+ # define PRIdPTR "I64d"
279
+ # define PRIuPTR "I64u"
280
+ # define PRIxPTR "I64x"
281
+ # else
282
+ # define PRIdPTR "ld"
283
+ # define PRIuPTR "lu"
284
+ # define PRIxPTR "lx"
285
+ # endif
286
+ #endif
287
+
288
+ #ifndef PRIdPTRDIFF
289
+ # define PRIdPTRDIFF PRIdPTR
290
+ #endif
291
+
292
+ #include "regenc.h"
293
+
294
+ RUBY_SYMBOL_EXPORT_BEGIN
295
+
296
+ #ifdef MIN
297
+ # undef MIN
298
+ #endif
299
+ #ifdef MAX
300
+ # undef MAX
301
+ #endif
302
+ #define MIN(a,b) (((a)>(b))?(b):(a))
303
+ #define MAX(a,b) (((a)<(b))?(b):(a))
304
+
305
+ #define IS_NULL(p) (((void*)(p)) == (void*)0)
306
+ #define IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
307
+ #define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL
308
+ #define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
309
+ #define NULL_UCHARP ((UChar* )0)
310
+
311
+ #define ONIG_LAST_CODE_POINT (~((OnigCodePoint )0))
312
+
313
+ #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
314
+
315
+ # define PLATFORM_GET_INC(val,p,type) do{\
316
+ val = *(type* )p;\
317
+ (p) += sizeof(type);\
318
+ } while(0)
319
+
320
+ #else
321
+
322
+ # define PLATFORM_GET_INC(val,p,type) do{\
323
+ xmemcpy(&val, (p), sizeof(type));\
324
+ (p) += sizeof(type);\
325
+ } while(0)
326
+
327
+ /* sizeof(OnigCodePoint) */
328
+ # define WORD_ALIGNMENT_SIZE SIZEOF_LONG
329
+
330
+ # define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
331
+ (pad_size) = WORD_ALIGNMENT_SIZE \
332
+ - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
333
+ if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
334
+ } while (0)
335
+
336
+ # define ALIGNMENT_RIGHT(addr) do {\
337
+ (addr) += (WORD_ALIGNMENT_SIZE - 1);\
338
+ (addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
339
+ } while (0)
340
+
341
+ #endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
342
+
343
+ /* stack pop level */
344
+ #define STACK_POP_LEVEL_FREE 0
345
+ #define STACK_POP_LEVEL_MEM_START 1
346
+ #define STACK_POP_LEVEL_ALL 2
347
+
348
+ /* optimize flags */
349
+ #define ONIG_OPTIMIZE_NONE 0
350
+ #define ONIG_OPTIMIZE_EXACT 1 /* Slow Search */
351
+ #define ONIG_OPTIMIZE_EXACT_BM 2 /* Boyer Moore Search */
352
+ #define ONIG_OPTIMIZE_EXACT_BM_NOT_REV 3 /* BM (applied to a multibyte string) */
353
+ #define ONIG_OPTIMIZE_EXACT_IC 4 /* Slow Search (ignore case) */
354
+ #define ONIG_OPTIMIZE_MAP 5 /* char map */
355
+ #define ONIG_OPTIMIZE_EXACT_BM_IC 6 /* BM (ignore case) */
356
+ #define ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC 7 /* BM (applied to a multibyte string) (ignore case) */
357
+
358
+ /* bit status */
359
+ typedef unsigned int BitStatusType;
360
+
361
+ #define BIT_STATUS_BITS_NUM (sizeof(BitStatusType) * 8)
362
+ #define BIT_STATUS_CLEAR(stats) (stats) = 0
363
+ #define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
364
+ #define BIT_STATUS_AT(stats,n) \
365
+ ((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & ((BitStatusType )1 << n)) : ((stats) & 1))
366
+
367
+ #define BIT_STATUS_ON_AT(stats,n) do {\
368
+ if ((n) < (int )BIT_STATUS_BITS_NUM)\
369
+ (stats) |= (1 << (n));\
370
+ else\
371
+ (stats) |= 1;\
372
+ } while (0)
373
+
374
+ #define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
375
+ if ((n) < (int )BIT_STATUS_BITS_NUM)\
376
+ (stats) |= (1 << (n));\
377
+ } while (0)
378
+
379
+
380
+ #define INT_MAX_LIMIT ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
381
+
382
+ #define DIGITVAL(code) ((code) - '0')
383
+ #define ODIGITVAL(code) DIGITVAL(code)
384
+ #define XDIGITVAL(enc,code) \
385
+ (ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
386
+ : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
387
+
388
+ #define IS_SINGLELINE(option) ((option) & ONIG_OPTION_SINGLELINE)
389
+ #define IS_MULTILINE(option) ((option) & ONIG_OPTION_MULTILINE)
390
+ #define IS_IGNORECASE(option) ((option) & ONIG_OPTION_IGNORECASE)
391
+ #define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND)
392
+ #define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST)
393
+ #define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
394
+ #define IS_FIND_CONDITION(option) ((option) & \
395
+ (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
396
+ #define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL)
397
+ #define IS_NOTEOL(option) ((option) & ONIG_OPTION_NOTEOL)
398
+ #define IS_NOTBOS(option) ((option) & ONIG_OPTION_NOTBOS)
399
+ #define IS_NOTEOS(option) ((option) & ONIG_OPTION_NOTEOS)
400
+ #define IS_ASCII_RANGE(option) ((option) & ONIG_OPTION_ASCII_RANGE)
401
+ #define IS_POSIX_BRACKET_ALL_RANGE(option) ((option) & ONIG_OPTION_POSIX_BRACKET_ALL_RANGE)
402
+ #define IS_WORD_BOUND_ALL_RANGE(option) ((option) & ONIG_OPTION_WORD_BOUND_ALL_RANGE)
403
+ #define IS_NEWLINE_CRLF(option) ((option) & ONIG_OPTION_NEWLINE_CRLF)
404
+
405
+ /* OP_SET_OPTION is required for these options.
406
+ #define IS_DYNAMIC_OPTION(option) \
407
+ (((option) & (ONIG_OPTION_MULTILINE | ONIG_OPTION_IGNORECASE)) != 0)
408
+ */
409
+ /* ignore-case and multibyte status are included in compiled code. */
410
+ #define IS_DYNAMIC_OPTION(option) 0
411
+
412
+ #define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
413
+ ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
414
+
415
+ #define REPEAT_INFINITE -1
416
+ #define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE)
417
+
418
+ /* bitset */
419
+ #define BITS_PER_BYTE 8
420
+ #define SINGLE_BYTE_SIZE (1 << BITS_PER_BYTE)
421
+ #define BITS_IN_ROOM ((int )sizeof(Bits) * BITS_PER_BYTE)
422
+ #define BITSET_SIZE (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
423
+
424
+ #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
425
+ typedef unsigned int Bits;
426
+ #else
427
+ typedef unsigned char Bits;
428
+ #endif
429
+ typedef Bits BitSet[BITSET_SIZE];
430
+ typedef Bits* BitSetRef;
431
+
432
+ #define SIZE_BITSET (int )sizeof(BitSet)
433
+
434
+ #define BITSET_CLEAR(bs) do {\
435
+ int i;\
436
+ for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; } \
437
+ } while (0)
438
+
439
+ #define BS_ROOM(bs,pos) (bs)[(int )(pos) / BITS_IN_ROOM]
440
+ #define BS_BIT(pos) (1U << ((int )(pos) % BITS_IN_ROOM))
441
+
442
+ #define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
443
+ #define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)
444
+ #define BITSET_CLEAR_BIT(bs, pos) BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
445
+ #define BITSET_INVERT_BIT(bs, pos) BS_ROOM(bs,pos) ^= BS_BIT(pos)
446
+
447
+ /* bytes buffer */
448
+ typedef struct _BBuf {
449
+ UChar* p;
450
+ unsigned int used;
451
+ unsigned int alloc;
452
+ } BBuf;
453
+
454
+ #define BBUF_INIT(buf,size) onig_bbuf_init((BBuf* )(buf), (size))
455
+
456
+ #define BBUF_SIZE_INC(buf,inc) do{\
457
+ UChar *tmp;\
458
+ (buf)->alloc += (inc);\
459
+ tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
460
+ if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
461
+ (buf)->p = tmp;\
462
+ } while (0)
463
+
464
+ #define BBUF_EXPAND(buf,low) do{\
465
+ UChar *tmp;\
466
+ do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
467
+ tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
468
+ if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
469
+ (buf)->p = tmp;\
470
+ } while (0)
471
+
472
+ #define BBUF_ENSURE_SIZE(buf,size) do{\
473
+ unsigned int new_alloc = (buf)->alloc;\
474
+ while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
475
+ if ((buf)->alloc != new_alloc) {\
476
+ UChar *tmp;\
477
+ tmp = (UChar* )xrealloc((buf)->p, new_alloc);\
478
+ if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
479
+ (buf)->p = tmp;\
480
+ (buf)->alloc = new_alloc;\
481
+ }\
482
+ } while (0)
483
+
484
+ #define BBUF_WRITE(buf,pos,bytes,n) do{\
485
+ int used = (pos) + (int )(n);\
486
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
487
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
488
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
489
+ } while (0)
490
+
491
+ #define BBUF_WRITE1(buf,pos,byte) do{\
492
+ int used = (pos) + 1;\
493
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
494
+ (buf)->p[(pos)] = (UChar )(byte);\
495
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
496
+ } while (0)
497
+
498
+ #define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
499
+ #define BBUF_ADD1(buf,byte) BBUF_WRITE1((buf),(buf)->used,(byte))
500
+ #define BBUF_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
501
+ #define BBUF_GET_OFFSET_POS(buf) ((buf)->used)
502
+
503
+ /* from < to */
504
+ #define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
505
+ if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
506
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
507
+ if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
508
+ } while (0)
509
+
510
+ /* from > to */
511
+ #define BBUF_MOVE_LEFT(buf,from,to,n) do {\
512
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
513
+ } while (0)
514
+
515
+ /* from > to */
516
+ #define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
517
+ xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
518
+ (buf)->used -= (from - to);\
519
+ } while (0)
520
+
521
+ #define BBUF_INSERT(buf,pos,bytes,n) do {\
522
+ if (pos >= (buf)->used) {\
523
+ BBUF_WRITE(buf,pos,bytes,n);\
524
+ }\
525
+ else {\
526
+ BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
527
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
528
+ }\
529
+ } while (0)
530
+
531
+ #define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
532
+
533
+
534
+ #define ANCHOR_BEGIN_BUF (1<<0)
535
+ #define ANCHOR_BEGIN_LINE (1<<1)
536
+ #define ANCHOR_BEGIN_POSITION (1<<2)
537
+ #define ANCHOR_END_BUF (1<<3)
538
+ #define ANCHOR_SEMI_END_BUF (1<<4)
539
+ #define ANCHOR_END_LINE (1<<5)
540
+
541
+ #define ANCHOR_WORD_BOUND (1<<6)
542
+ #define ANCHOR_NOT_WORD_BOUND (1<<7)
543
+ #define ANCHOR_WORD_BEGIN (1<<8)
544
+ #define ANCHOR_WORD_END (1<<9)
545
+ #define ANCHOR_PREC_READ (1<<10)
546
+ #define ANCHOR_PREC_READ_NOT (1<<11)
547
+ #define ANCHOR_LOOK_BEHIND (1<<12)
548
+ #define ANCHOR_LOOK_BEHIND_NOT (1<<13)
549
+
550
+ #define ANCHOR_ANYCHAR_STAR (1<<14) /* ".*" optimize info */
551
+ #define ANCHOR_ANYCHAR_STAR_ML (1<<15) /* ".*" optimize info (multi-line) */
552
+
553
+ #define ANCHOR_KEEP (1<<16)
554
+
555
+ /* operation code */
556
+ enum OpCode {
557
+ OP_FINISH = 0, /* matching process terminator (no more alternative) */
558
+ OP_END = 1, /* pattern code terminator (success end) */
559
+
560
+ OP_EXACT1 = 2, /* single byte, N = 1 */
561
+ OP_EXACT2, /* single byte, N = 2 */
562
+ OP_EXACT3, /* single byte, N = 3 */
563
+ OP_EXACT4, /* single byte, N = 4 */
564
+ OP_EXACT5, /* single byte, N = 5 */
565
+ OP_EXACTN, /* single byte */
566
+ OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
567
+ OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
568
+ OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
569
+ OP_EXACTMB2N, /* mb-length = 2 */
570
+ OP_EXACTMB3N, /* mb-length = 3 */
571
+ OP_EXACTMBN, /* other length */
572
+
573
+ OP_EXACT1_IC, /* single byte, N = 1, ignore case */
574
+ OP_EXACTN_IC, /* single byte, ignore case */
575
+
576
+ OP_CCLASS,
577
+ OP_CCLASS_MB,
578
+ OP_CCLASS_MIX,
579
+ OP_CCLASS_NOT,
580
+ OP_CCLASS_MB_NOT,
581
+ OP_CCLASS_MIX_NOT,
582
+
583
+ OP_ANYCHAR, /* "." */
584
+ OP_ANYCHAR_ML, /* "." multi-line */
585
+ OP_ANYCHAR_STAR, /* ".*" */
586
+ OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
587
+ OP_ANYCHAR_STAR_PEEK_NEXT,
588
+ OP_ANYCHAR_ML_STAR_PEEK_NEXT,
589
+
590
+ OP_WORD,
591
+ OP_NOT_WORD,
592
+ OP_WORD_BOUND,
593
+ OP_NOT_WORD_BOUND,
594
+ OP_WORD_BEGIN,
595
+ OP_WORD_END,
596
+
597
+ OP_ASCII_WORD,
598
+ OP_NOT_ASCII_WORD,
599
+ OP_ASCII_WORD_BOUND,
600
+ OP_NOT_ASCII_WORD_BOUND,
601
+ OP_ASCII_WORD_BEGIN,
602
+ OP_ASCII_WORD_END,
603
+
604
+ OP_BEGIN_BUF,
605
+ OP_END_BUF,
606
+ OP_BEGIN_LINE,
607
+ OP_END_LINE,
608
+ OP_SEMI_END_BUF,
609
+ OP_BEGIN_POSITION,
610
+
611
+ OP_BACKREF1,
612
+ OP_BACKREF2,
613
+ OP_BACKREFN,
614
+ OP_BACKREFN_IC,
615
+ OP_BACKREF_MULTI,
616
+ OP_BACKREF_MULTI_IC,
617
+ OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
618
+
619
+ OP_MEMORY_START,
620
+ OP_MEMORY_START_PUSH, /* push back-tracker to stack */
621
+ OP_MEMORY_END_PUSH, /* push back-tracker to stack */
622
+ OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
623
+ OP_MEMORY_END,
624
+ OP_MEMORY_END_REC, /* push marker to stack */
625
+
626
+ OP_KEEP,
627
+
628
+ OP_FAIL, /* pop stack and move */
629
+ OP_JUMP,
630
+ OP_PUSH,
631
+ OP_POP,
632
+ OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
633
+ OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
634
+ OP_REPEAT, /* {n,m} */
635
+ OP_REPEAT_NG, /* {n,m}? (non greedy) */
636
+ OP_REPEAT_INC,
637
+ OP_REPEAT_INC_NG, /* non greedy */
638
+ OP_REPEAT_INC_SG, /* search and get in stack */
639
+ OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
640
+ OP_NULL_CHECK_START, /* null loop checker start */
641
+ OP_NULL_CHECK_END, /* null loop checker end */
642
+ OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
643
+ OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
644
+
645
+ OP_PUSH_POS, /* (?=...) start */
646
+ OP_POP_POS, /* (?=...) end */
647
+ OP_PUSH_POS_NOT, /* (?!...) start */
648
+ OP_FAIL_POS, /* (?!...) end */
649
+ OP_PUSH_STOP_BT, /* (?>...) start */
650
+ OP_POP_STOP_BT, /* (?>...) end */
651
+ OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
652
+ OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
653
+ OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end */
654
+ OP_PUSH_ABSENT_POS, /* (?~...) start */
655
+ OP_ABSENT, /* (?~...) start of inner loop */
656
+ OP_ABSENT_END, /* (?~...) end */
657
+
658
+ OP_CALL, /* \g<name> */
659
+ OP_RETURN,
660
+
661
+ OP_CONDITION,
662
+
663
+ OP_STATE_CHECK_PUSH, /* combination explosion check and push */
664
+ OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */
665
+ OP_STATE_CHECK, /* check only */
666
+ OP_STATE_CHECK_ANYCHAR_STAR,
667
+ OP_STATE_CHECK_ANYCHAR_ML_STAR,
668
+
669
+ /* no need: IS_DYNAMIC_OPTION() == 0 */
670
+ OP_SET_OPTION_PUSH, /* set option and push recover option */
671
+ OP_SET_OPTION /* set option */
672
+ };
673
+
674
+ typedef int RelAddrType;
675
+ typedef int AbsAddrType;
676
+ typedef int LengthType;
677
+ typedef int RepeatNumType;
678
+ typedef short int MemNumType;
679
+ typedef short int StateCheckNumType;
680
+ typedef void* PointerType;
681
+
682
+ #define SIZE_OPCODE 1
683
+ #define SIZE_RELADDR (int )sizeof(RelAddrType)
684
+ #define SIZE_ABSADDR (int )sizeof(AbsAddrType)
685
+ #define SIZE_LENGTH (int )sizeof(LengthType)
686
+ #define SIZE_MEMNUM (int )sizeof(MemNumType)
687
+ #define SIZE_STATE_CHECK_NUM (int )sizeof(StateCheckNumType)
688
+ #define SIZE_REPEATNUM (int )sizeof(RepeatNumType)
689
+ #define SIZE_OPTION (int )sizeof(OnigOptionType)
690
+ #define SIZE_CODE_POINT (int )sizeof(OnigCodePoint)
691
+ #define SIZE_POINTER (int )sizeof(PointerType)
692
+
693
+
694
+ #define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
695
+ #define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
696
+ #define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
697
+ #define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
698
+ #define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
699
+ #define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
700
+ #define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
701
+ #define GET_STATE_CHECK_NUM_INC(num,p) PLATFORM_GET_INC(num, p, StateCheckNumType)
702
+
703
+ /* code point's address must be aligned address. */
704
+ #define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
705
+ #define GET_BYTE_INC(byte,p) do{\
706
+ byte = *(p);\
707
+ (p)++;\
708
+ } while(0)
709
+
710
+
711
+ /* op-code + arg size */
712
+ #define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
713
+ #define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
714
+ #define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
715
+ #define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
716
+ #define SIZE_OP_POP SIZE_OPCODE
717
+ #define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
718
+ #define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
719
+ #define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
720
+ #define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
721
+ #define SIZE_OP_PUSH_POS SIZE_OPCODE
722
+ #define SIZE_OP_PUSH_POS_NOT (SIZE_OPCODE + SIZE_RELADDR)
723
+ #define SIZE_OP_POP_POS SIZE_OPCODE
724
+ #define SIZE_OP_FAIL_POS SIZE_OPCODE
725
+ #define SIZE_OP_SET_OPTION (SIZE_OPCODE + SIZE_OPTION)
726
+ #define SIZE_OP_SET_OPTION_PUSH (SIZE_OPCODE + SIZE_OPTION)
727
+ #define SIZE_OP_FAIL SIZE_OPCODE
728
+ #define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
729
+ #define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
730
+ #define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
731
+ #define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
732
+ #define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
733
+ #define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
734
+ #define SIZE_OP_PUSH_STOP_BT SIZE_OPCODE
735
+ #define SIZE_OP_POP_STOP_BT SIZE_OPCODE
736
+ #define SIZE_OP_NULL_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
737
+ #define SIZE_OP_NULL_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
738
+ #define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
739
+ #define SIZE_OP_PUSH_LOOK_BEHIND_NOT (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
740
+ #define SIZE_OP_FAIL_LOOK_BEHIND_NOT SIZE_OPCODE
741
+ #define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
742
+ #define SIZE_OP_RETURN SIZE_OPCODE
743
+ #define SIZE_OP_CONDITION (SIZE_OPCODE + SIZE_MEMNUM + SIZE_RELADDR)
744
+ #define SIZE_OP_PUSH_ABSENT_POS SIZE_OPCODE
745
+ #define SIZE_OP_ABSENT (SIZE_OPCODE + SIZE_RELADDR)
746
+ #define SIZE_OP_ABSENT_END SIZE_OPCODE
747
+
748
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
749
+ # define SIZE_OP_STATE_CHECK (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
750
+ # define SIZE_OP_STATE_CHECK_PUSH (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
751
+ # define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
752
+ # define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
753
+ #endif
754
+
755
+ #define MC_ESC(syn) (syn)->meta_char_table.esc
756
+ #define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
757
+ #define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
758
+ #define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
759
+ #define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
760
+ #define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
761
+
762
+ #define IS_MC_ESC_CODE(code, syn) \
763
+ ((code) == MC_ESC(syn) && \
764
+ !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
765
+
766
+
767
+ #define SYN_POSIX_COMMON_OP \
768
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
769
+ ONIG_SYN_OP_DECIMAL_BACKREF | \
770
+ ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
771
+ ONIG_SYN_OP_LINE_ANCHOR | \
772
+ ONIG_SYN_OP_ESC_CONTROL_CHARS )
773
+
774
+ #define SYN_GNU_REGEX_OP \
775
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
776
+ ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
777
+ ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
778
+ ONIG_SYN_OP_VBAR_ALT | \
779
+ ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
780
+ ONIG_SYN_OP_QMARK_ZERO_ONE | \
781
+ ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
782
+ ONIG_SYN_OP_ESC_W_WORD | \
783
+ ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
784
+ ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
785
+ ONIG_SYN_OP_LINE_ANCHOR )
786
+
787
+ #define SYN_GNU_REGEX_BV \
788
+ ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
789
+ ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
790
+ ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
791
+
792
+
793
+ #define NCCLASS_FLAGS(cc) ((cc)->flags)
794
+ #define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
795
+ #define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
796
+ #define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
797
+
798
+ /* cclass node */
799
+ #define FLAG_NCCLASS_NOT (1<<0)
800
+
801
+ #define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
802
+ #define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
803
+ #define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
804
+
805
+ typedef struct {
806
+ int type;
807
+ /* struct _Node* next; */
808
+ /* unsigned int flags; */
809
+ } NodeBase;
810
+
811
+ typedef struct {
812
+ NodeBase base;
813
+ unsigned int flags;
814
+ BitSet bs;
815
+ BBuf* mbuf; /* multi-byte info or NULL */
816
+ } CClassNode;
817
+
818
+ typedef intptr_t OnigStackIndex;
819
+
820
+ typedef struct _OnigStackType {
821
+ unsigned int type;
822
+ union {
823
+ struct {
824
+ UChar *pcode; /* byte code position */
825
+ UChar *pstr; /* string position */
826
+ UChar *pstr_prev; /* previous char position of pstr */
827
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
828
+ unsigned int state_check;
829
+ #endif
830
+ UChar *pkeep; /* keep pattern position */
831
+ } state;
832
+ struct {
833
+ int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
834
+ UChar *pcode; /* byte code position (head of repeated target) */
835
+ int num; /* repeat id */
836
+ } repeat;
837
+ struct {
838
+ OnigStackIndex si; /* index of stack */
839
+ } repeat_inc;
840
+ struct {
841
+ int num; /* memory num */
842
+ UChar *pstr; /* start/end position */
843
+ /* Following information is set, if this stack type is MEM-START */
844
+ OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */
845
+ OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */
846
+ } mem;
847
+ struct {
848
+ int num; /* null check id */
849
+ UChar *pstr; /* start position */
850
+ } null_check;
851
+ #ifdef USE_SUBEXP_CALL
852
+ struct {
853
+ UChar *ret_addr; /* byte code position */
854
+ int num; /* null check id */
855
+ UChar *pstr; /* string position */
856
+ } call_frame;
857
+ #endif
858
+ struct {
859
+ UChar *abs_pstr; /* absent start position */
860
+ const UChar *end_pstr; /* end position */
861
+ } absent_pos;
862
+ } u;
863
+ } OnigStackType;
864
+
865
+ typedef struct {
866
+ void* stack_p;
867
+ size_t stack_n;
868
+ OnigOptionType options;
869
+ OnigRegion* region;
870
+ const UChar* start; /* search start position */
871
+ const UChar* gpos; /* global position (for \G: BEGIN_POSITION) */
872
+ #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
873
+ OnigPosition best_len; /* for ONIG_OPTION_FIND_LONGEST */
874
+ UChar* best_s;
875
+ #endif
876
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
877
+ void* state_check_buff;
878
+ int state_check_buff_size;
879
+ #endif
880
+ int counter;
881
+ /* rb_hrtime_t from hrtime.h */
882
+ #ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
883
+ int128_t end_time;
884
+ #else
885
+ uint64_t end_time;
886
+ #endif
887
+ } OnigMatchArg;
888
+
889
+
890
+ #define IS_CODE_SB_WORD(enc,code) \
891
+ (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
892
+
893
+ typedef struct OnigEndCallListItem {
894
+ struct OnigEndCallListItem* next;
895
+ void (*func)(void);
896
+ } OnigEndCallListItemType;
897
+
898
+ extern void onig_add_end_call(void (*func)(void));
899
+
900
+
901
+ #ifdef ONIG_DEBUG
902
+
903
+ typedef struct {
904
+ short int opcode;
905
+ const char* name;
906
+ short int arg_type;
907
+ } OnigOpInfoType;
908
+
909
+ extern OnigOpInfoType OnigOpInfo[];
910
+
911
+
912
+ extern void onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar* bpend, UChar** nextp, OnigEncoding enc);
913
+
914
+ # ifdef ONIG_DEBUG_STATISTICS
915
+ extern void onig_statistics_init(void);
916
+ extern void onig_print_statistics(FILE* f);
917
+ # endif
918
+ #endif
919
+
920
+ #ifndef PRINTF_ARGS
921
+ #define PRINTF_ARGS(func, fmt, vargs) func
922
+ #endif
923
+
924
+ extern UChar* onig_error_code_to_format(OnigPosition code);
925
+ PRINTF_ARGS(extern void onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const char *fmt, va_list args), 6, 0);
926
+ PRINTF_ARGS(extern void onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const char *fmt, ...), 6, 7);
927
+ extern int onig_bbuf_init(BBuf* buf, OnigDistance size);
928
+ extern int onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo);
929
+ #ifdef RUBY
930
+ extern int onig_compile_ruby(regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo, const char *sourcefile, int sourceline);
931
+ #endif
932
+ extern void onig_transfer(regex_t* to, regex_t* from);
933
+ extern int onig_is_code_in_cc(OnigEncoding enc, OnigCodePoint code, CClassNode* cc);
934
+ extern int onig_is_code_in_cc_len(int enclen, OnigCodePoint code, CClassNode* cc);
935
+
936
+ /* strend hash */
937
+ typedef void hash_table_type;
938
+ #ifdef RUBY
939
+ # include "ruby/st.h"
940
+ #else
941
+ # include "st.h"
942
+ #endif
943
+ typedef st_data_t hash_data_type;
944
+
945
+ extern hash_table_type* onig_st_init_strend_table_with_size(st_index_t size);
946
+ extern int onig_st_lookup_strend(hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value);
947
+ extern int onig_st_insert_strend(hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value);
948
+
949
+ #ifdef RUBY
950
+ extern size_t onig_memsize(const regex_t *reg);
951
+ extern size_t onig_region_memsize(const struct re_registers *regs);
952
+ void rb_reg_check_timeout(regex_t *reg, void *end_time);
953
+ #endif
954
+
955
+ RUBY_SYMBOL_EXPORT_END
956
+
957
+ #endif /* ONIGMO_REGINT_H */