debase-ruby_core_source 0.9.5 → 0.9.6

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