debase-ruby_core_source 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/debase/ruby_core_source.rb +2 -1
  4. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/addr2line.h +21 -0
  5. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/ccan/build_assert/build_assert.h +40 -0
  6. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/ccan/check_type/check_type.h +63 -0
  7. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/ccan/container_of/container_of.h +142 -0
  8. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/ccan/list/list.h +635 -0
  9. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/ccan/str/str.h +16 -0
  10. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/constant.h +43 -0
  11. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/dln.h +51 -0
  12. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/eval_intern.h +275 -0
  13. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/gc.h +107 -0
  14. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/id.h +210 -0
  15. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/insns.inc +107 -0
  16. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/insns_info.inc +752 -0
  17. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/internal.h +1179 -0
  18. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/iseq.h +158 -0
  19. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/known_errors.inc +746 -0
  20. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/method.h +141 -0
  21. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/node.h +544 -0
  22. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/node_name.inc +212 -0
  23. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/opt_sc.inc +734 -0
  24. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/optinsn.inc +83 -0
  25. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/optunifs.inc +124 -0
  26. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/parse.h +203 -0
  27. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/probes_helper.h +67 -0
  28. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/regenc.h +234 -0
  29. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/regint.h +972 -0
  30. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/regparse.h +363 -0
  31. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/revision.h +1 -0
  32. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/ruby_atomic.h +170 -0
  33. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/siphash.h +48 -0
  34. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/symbol.h +87 -0
  35. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/thread_pthread.h +54 -0
  36. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/thread_win32.h +36 -0
  37. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/timev.h +42 -0
  38. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/transcode_data.h +123 -0
  39. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/version.h +53 -0
  40. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/vm.inc +3353 -0
  41. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/vm_core.h +1159 -0
  42. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/vm_debug.h +37 -0
  43. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/vm_exec.h +182 -0
  44. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/vm_insnhelper.h +233 -0
  45. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/vm_opts.h +56 -0
  46. data/lib/debase/ruby_core_source/ruby-2.2.0-rc1/vmtc.inc +105 -0
  47. data/lib/debase/ruby_core_source/version.rb +1 -1
  48. metadata +45 -2
@@ -0,0 +1,234 @@
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
+
173
+ #define ONIGENC_ISO_8859_1_TO_LOWER_CASE(c) \
174
+ OnigEncISO_8859_1_ToLowerCaseTable[c]
175
+ #define ONIGENC_ISO_8859_1_TO_UPPER_CASE(c) \
176
+ OnigEncISO_8859_1_ToUpperCaseTable[c]
177
+
178
+ ONIG_EXTERN const UChar OnigEncISO_8859_1_ToLowerCaseTable[];
179
+ ONIG_EXTERN const UChar OnigEncISO_8859_1_ToUpperCaseTable[];
180
+
181
+ ONIG_EXTERN int
182
+ onigenc_with_ascii_strncmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
183
+ ONIG_EXTERN int
184
+ onigenc_with_ascii_strnicmp P_((OnigEncoding enc, const UChar* p, const UChar* end, const UChar* sascii /* ascii */, int n));
185
+ ONIG_EXTERN UChar*
186
+ onigenc_step P_((OnigEncoding enc, const UChar* p, const UChar* end, int n));
187
+
188
+ /* defined in regexec.c, but used in enc/xxx.c */
189
+ extern int onig_is_in_code_range P_((const UChar* p, OnigCodePoint code));
190
+
191
+ ONIG_EXTERN OnigEncoding OnigEncDefaultCharEncoding;
192
+ ONIG_EXTERN const UChar OnigEncAsciiToLowerCaseTable[];
193
+ ONIG_EXTERN const UChar OnigEncAsciiToUpperCaseTable[];
194
+ ONIG_EXTERN const unsigned short OnigEncAsciiCtypeTable[];
195
+
196
+ #define ONIGENC_IS_ASCII_CODE(code) ((code) < 0x80)
197
+ #define ONIGENC_ASCII_CODE_TO_LOWER_CASE(c) OnigEncAsciiToLowerCaseTable[c]
198
+ #define ONIGENC_ASCII_CODE_TO_UPPER_CASE(c) OnigEncAsciiToUpperCaseTable[c]
199
+ #define ONIGENC_IS_ASCII_CODE_CTYPE(code,ctype) \
200
+ ((OnigEncAsciiCtypeTable[code] & CTYPE_TO_BIT(ctype)) != 0)
201
+ #define ONIGENC_IS_ASCII_CODE_CASE_AMBIG(code) \
202
+ (ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_UPPER) ||\
203
+ ONIGENC_IS_ASCII_CODE_CTYPE(code, ONIGENC_CTYPE_LOWER))
204
+
205
+ /* Check if the code is in the range. (from <= code && code <= to) */
206
+ #define ONIGENC_IS_IN_RANGE(code, from, to) \
207
+ ((OnigCodePoint )((code) - (from)) <= (OnigCodePoint )((to) - (from)))
208
+
209
+
210
+ #ifdef ONIG_ENC_REGISTER
211
+ extern int ONIG_ENC_REGISTER(const char *, OnigEncoding);
212
+ #define OnigEncodingName(n) encoding_##n
213
+ #define OnigEncodingDeclare(n) static const OnigEncodingType OnigEncodingName(n)
214
+ #define OnigEncodingDefine(f,n) \
215
+ OnigEncodingDeclare(n); \
216
+ void Init_##f(void) { \
217
+ ONIG_ENC_REGISTER(OnigEncodingName(n).name, \
218
+ &OnigEncodingName(n)); \
219
+ } \
220
+ OnigEncodingDeclare(n)
221
+ #else
222
+ #define OnigEncodingName(n) OnigEncoding##n
223
+ #define OnigEncodingDeclare(n) const OnigEncodingType OnigEncodingName(n)
224
+ #define OnigEncodingDefine(f,n) OnigEncodingDeclare(n)
225
+ #endif
226
+
227
+ /* macros for define replica encoding and encoding alias */
228
+ #define ENC_REPLICATE(name, orig)
229
+ #define ENC_ALIAS(name, orig)
230
+ #define ENC_DUMMY(name)
231
+
232
+ RUBY_SYMBOL_EXPORT_END
233
+
234
+ #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 */