debase-ruby_core_source 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -1
  3. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/addr2line.h +21 -0
  4. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/build_assert/build_assert.h +40 -0
  5. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/check_type/check_type.h +63 -0
  6. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/container_of/container_of.h +142 -0
  7. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/list/list.h +773 -0
  8. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ccan/str/str.h +16 -0
  9. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/constant.h +50 -0
  10. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/dln.h +51 -0
  11. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/encindex.h +67 -0
  12. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/eval_intern.h +304 -0
  13. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/gc.h +114 -0
  14. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/id.h +211 -0
  15. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/id_table.h +30 -0
  16. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/insns.inc +110 -0
  17. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/insns_info.inc +776 -0
  18. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/internal.h +1407 -0
  19. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/iseq.h +249 -0
  20. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/known_errors.inc +746 -0
  21. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/method.h +213 -0
  22. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/node.h +520 -0
  23. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/node_name.inc +208 -0
  24. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/opt_sc.inc +758 -0
  25. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/optinsn.inc +83 -0
  26. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/optunifs.inc +127 -0
  27. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/parse.h +185 -0
  28. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/probes_helper.h +43 -0
  29. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/regenc.h +237 -0
  30. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/regint.h +987 -0
  31. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/regparse.h +367 -0
  32. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/revision.h +1 -0
  33. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/ruby_atomic.h +233 -0
  34. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/siphash.h +48 -0
  35. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/symbol.h +108 -0
  36. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/thread_pthread.h +54 -0
  37. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/thread_win32.h +36 -0
  38. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/timev.h +42 -0
  39. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/transcode_data.h +139 -0
  40. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/version.h +55 -0
  41. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm.inc +3414 -0
  42. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_call_iseq_optimized.inc +212 -0
  43. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_core.h +1240 -0
  44. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_debug.h +37 -0
  45. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_exec.h +182 -0
  46. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_insnhelper.h +227 -0
  47. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vm_opts.h +57 -0
  48. data/lib/debase/ruby_core_source/ruby-2.3.4-p301/vmtc.inc +108 -0
  49. data/lib/debase/ruby_core_source/version.rb +1 -1
  50. metadata +48 -2
@@ -0,0 +1,987 @@
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-2013 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
+ UChar *tmp;\
489
+ (buf)->alloc += (inc);\
490
+ tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
491
+ if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
492
+ (buf)->p = tmp;\
493
+ } while (0)
494
+
495
+ #define BBUF_EXPAND(buf,low) do{\
496
+ UChar *tmp;\
497
+ do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
498
+ tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
499
+ if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
500
+ (buf)->p = tmp;\
501
+ } while (0)
502
+
503
+ #define BBUF_ENSURE_SIZE(buf,size) do{\
504
+ unsigned int new_alloc = (buf)->alloc;\
505
+ while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
506
+ if ((buf)->alloc != new_alloc) {\
507
+ UChar *tmp;\
508
+ tmp = (UChar* )xrealloc((buf)->p, new_alloc);\
509
+ if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
510
+ (buf)->p = tmp;\
511
+ (buf)->alloc = new_alloc;\
512
+ }\
513
+ } while (0)
514
+
515
+ #define BBUF_WRITE(buf,pos,bytes,n) do{\
516
+ int used = (pos) + (int )(n);\
517
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
518
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
519
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
520
+ } while (0)
521
+
522
+ #define BBUF_WRITE1(buf,pos,byte) do{\
523
+ int used = (pos) + 1;\
524
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
525
+ (buf)->p[(pos)] = (UChar )(byte);\
526
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
527
+ } while (0)
528
+
529
+ #define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
530
+ #define BBUF_ADD1(buf,byte) BBUF_WRITE1((buf),(buf)->used,(byte))
531
+ #define BBUF_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
532
+ #define BBUF_GET_OFFSET_POS(buf) ((buf)->used)
533
+
534
+ /* from < to */
535
+ #define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
536
+ if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
537
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
538
+ if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
539
+ } while (0)
540
+
541
+ /* from > to */
542
+ #define BBUF_MOVE_LEFT(buf,from,to,n) do {\
543
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
544
+ } while (0)
545
+
546
+ /* from > to */
547
+ #define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
548
+ xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
549
+ (buf)->used -= (from - to);\
550
+ } while (0)
551
+
552
+ #define BBUF_INSERT(buf,pos,bytes,n) do {\
553
+ if (pos >= (buf)->used) {\
554
+ BBUF_WRITE(buf,pos,bytes,n);\
555
+ }\
556
+ else {\
557
+ BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
558
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
559
+ }\
560
+ } while (0)
561
+
562
+ #define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
563
+
564
+
565
+ #define ANCHOR_BEGIN_BUF (1<<0)
566
+ #define ANCHOR_BEGIN_LINE (1<<1)
567
+ #define ANCHOR_BEGIN_POSITION (1<<2)
568
+ #define ANCHOR_END_BUF (1<<3)
569
+ #define ANCHOR_SEMI_END_BUF (1<<4)
570
+ #define ANCHOR_END_LINE (1<<5)
571
+
572
+ #define ANCHOR_WORD_BOUND (1<<6)
573
+ #define ANCHOR_NOT_WORD_BOUND (1<<7)
574
+ #define ANCHOR_WORD_BEGIN (1<<8)
575
+ #define ANCHOR_WORD_END (1<<9)
576
+ #define ANCHOR_PREC_READ (1<<10)
577
+ #define ANCHOR_PREC_READ_NOT (1<<11)
578
+ #define ANCHOR_LOOK_BEHIND (1<<12)
579
+ #define ANCHOR_LOOK_BEHIND_NOT (1<<13)
580
+
581
+ #define ANCHOR_ANYCHAR_STAR (1<<14) /* ".*" optimize info */
582
+ #define ANCHOR_ANYCHAR_STAR_ML (1<<15) /* ".*" optimize info (multi-line) */
583
+
584
+ #define ANCHOR_KEEP (1<<16)
585
+
586
+ /* operation code */
587
+ enum OpCode {
588
+ OP_FINISH = 0, /* matching process terminator (no more alternative) */
589
+ OP_END = 1, /* pattern code terminator (success end) */
590
+
591
+ OP_EXACT1 = 2, /* single byte, N = 1 */
592
+ OP_EXACT2, /* single byte, N = 2 */
593
+ OP_EXACT3, /* single byte, N = 3 */
594
+ OP_EXACT4, /* single byte, N = 4 */
595
+ OP_EXACT5, /* single byte, N = 5 */
596
+ OP_EXACTN, /* single byte */
597
+ OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
598
+ OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
599
+ OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
600
+ OP_EXACTMB2N, /* mb-length = 2 */
601
+ OP_EXACTMB3N, /* mb-length = 3 */
602
+ OP_EXACTMBN, /* other length */
603
+
604
+ OP_EXACT1_IC, /* single byte, N = 1, ignore case */
605
+ OP_EXACTN_IC, /* single byte, ignore case */
606
+
607
+ OP_CCLASS,
608
+ OP_CCLASS_MB,
609
+ OP_CCLASS_MIX,
610
+ OP_CCLASS_NOT,
611
+ OP_CCLASS_MB_NOT,
612
+ OP_CCLASS_MIX_NOT,
613
+ OP_CCLASS_NODE, /* pointer to CClassNode node */
614
+
615
+ OP_ANYCHAR, /* "." */
616
+ OP_ANYCHAR_ML, /* "." multi-line */
617
+ OP_ANYCHAR_STAR, /* ".*" */
618
+ OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
619
+ OP_ANYCHAR_STAR_PEEK_NEXT,
620
+ OP_ANYCHAR_ML_STAR_PEEK_NEXT,
621
+
622
+ OP_WORD,
623
+ OP_NOT_WORD,
624
+ OP_WORD_BOUND,
625
+ OP_NOT_WORD_BOUND,
626
+ OP_WORD_BEGIN,
627
+ OP_WORD_END,
628
+
629
+ OP_ASCII_WORD,
630
+ OP_NOT_ASCII_WORD,
631
+ OP_ASCII_WORD_BOUND,
632
+ OP_NOT_ASCII_WORD_BOUND,
633
+ OP_ASCII_WORD_BEGIN,
634
+ OP_ASCII_WORD_END,
635
+
636
+ OP_BEGIN_BUF,
637
+ OP_END_BUF,
638
+ OP_BEGIN_LINE,
639
+ OP_END_LINE,
640
+ OP_SEMI_END_BUF,
641
+ OP_BEGIN_POSITION,
642
+ OP_BEGIN_POS_OR_LINE, /* used for implicit anchor optimization */
643
+
644
+ OP_BACKREF1,
645
+ OP_BACKREF2,
646
+ OP_BACKREFN,
647
+ OP_BACKREFN_IC,
648
+ OP_BACKREF_MULTI,
649
+ OP_BACKREF_MULTI_IC,
650
+ OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
651
+
652
+ OP_MEMORY_START,
653
+ OP_MEMORY_START_PUSH, /* push back-tracker to stack */
654
+ OP_MEMORY_END_PUSH, /* push back-tracker to stack */
655
+ OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
656
+ OP_MEMORY_END,
657
+ OP_MEMORY_END_REC, /* push marker to stack */
658
+
659
+ OP_KEEP,
660
+
661
+ OP_FAIL, /* pop stack and move */
662
+ OP_JUMP,
663
+ OP_PUSH,
664
+ OP_POP,
665
+ OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
666
+ OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
667
+ OP_REPEAT, /* {n,m} */
668
+ OP_REPEAT_NG, /* {n,m}? (non greedy) */
669
+ OP_REPEAT_INC,
670
+ OP_REPEAT_INC_NG, /* non greedy */
671
+ OP_REPEAT_INC_SG, /* search and get in stack */
672
+ OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
673
+ OP_NULL_CHECK_START, /* null loop checker start */
674
+ OP_NULL_CHECK_END, /* null loop checker end */
675
+ OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
676
+ OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
677
+
678
+ OP_PUSH_POS, /* (?=...) start */
679
+ OP_POP_POS, /* (?=...) end */
680
+ OP_PUSH_POS_NOT, /* (?!...) start */
681
+ OP_FAIL_POS, /* (?!...) end */
682
+ OP_PUSH_STOP_BT, /* (?>...) start */
683
+ OP_POP_STOP_BT, /* (?>...) end */
684
+ OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
685
+ OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
686
+ OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end */
687
+
688
+ OP_CALL, /* \g<name> */
689
+ OP_RETURN,
690
+
691
+ OP_CONDITION,
692
+
693
+ OP_STATE_CHECK_PUSH, /* combination explosion check and push */
694
+ OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */
695
+ OP_STATE_CHECK, /* check only */
696
+ OP_STATE_CHECK_ANYCHAR_STAR,
697
+ OP_STATE_CHECK_ANYCHAR_ML_STAR,
698
+
699
+ /* no need: IS_DYNAMIC_OPTION() == 0 */
700
+ OP_SET_OPTION_PUSH, /* set option and push recover option */
701
+ OP_SET_OPTION /* set option */
702
+ };
703
+
704
+ typedef int RelAddrType;
705
+ typedef int AbsAddrType;
706
+ typedef int LengthType;
707
+ typedef int RepeatNumType;
708
+ typedef short int MemNumType;
709
+ typedef short int StateCheckNumType;
710
+ typedef void* PointerType;
711
+
712
+ #define SIZE_OPCODE 1
713
+ #define SIZE_RELADDR (int )sizeof(RelAddrType)
714
+ #define SIZE_ABSADDR (int )sizeof(AbsAddrType)
715
+ #define SIZE_LENGTH (int )sizeof(LengthType)
716
+ #define SIZE_MEMNUM (int )sizeof(MemNumType)
717
+ #define SIZE_STATE_CHECK_NUM (int )sizeof(StateCheckNumType)
718
+ #define SIZE_REPEATNUM (int )sizeof(RepeatNumType)
719
+ #define SIZE_OPTION (int )sizeof(OnigOptionType)
720
+ #define SIZE_CODE_POINT (int )sizeof(OnigCodePoint)
721
+ #define SIZE_POINTER (int )sizeof(PointerType)
722
+
723
+
724
+ #define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
725
+ #define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
726
+ #define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
727
+ #define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
728
+ #define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
729
+ #define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
730
+ #define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
731
+ #define GET_STATE_CHECK_NUM_INC(num,p) PLATFORM_GET_INC(num, p, StateCheckNumType)
732
+
733
+ /* code point's address must be aligned address. */
734
+ #define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
735
+ #define GET_BYTE_INC(byte,p) do{\
736
+ byte = *(p);\
737
+ (p)++;\
738
+ } while(0)
739
+
740
+
741
+ /* op-code + arg size */
742
+ #define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
743
+ #define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
744
+ #define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
745
+ #define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
746
+ #define SIZE_OP_POP SIZE_OPCODE
747
+ #define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
748
+ #define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
749
+ #define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
750
+ #define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
751
+ #define SIZE_OP_PUSH_POS SIZE_OPCODE
752
+ #define SIZE_OP_PUSH_POS_NOT (SIZE_OPCODE + SIZE_RELADDR)
753
+ #define SIZE_OP_POP_POS SIZE_OPCODE
754
+ #define SIZE_OP_FAIL_POS SIZE_OPCODE
755
+ #define SIZE_OP_SET_OPTION (SIZE_OPCODE + SIZE_OPTION)
756
+ #define SIZE_OP_SET_OPTION_PUSH (SIZE_OPCODE + SIZE_OPTION)
757
+ #define SIZE_OP_FAIL SIZE_OPCODE
758
+ #define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
759
+ #define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
760
+ #define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
761
+ #define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
762
+ #define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
763
+ #define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
764
+ #define SIZE_OP_PUSH_STOP_BT SIZE_OPCODE
765
+ #define SIZE_OP_POP_STOP_BT SIZE_OPCODE
766
+ #define SIZE_OP_NULL_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
767
+ #define SIZE_OP_NULL_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
768
+ #define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
769
+ #define SIZE_OP_PUSH_LOOK_BEHIND_NOT (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
770
+ #define SIZE_OP_FAIL_LOOK_BEHIND_NOT SIZE_OPCODE
771
+ #define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
772
+ #define SIZE_OP_RETURN SIZE_OPCODE
773
+ #define SIZE_OP_CONDITION (SIZE_OPCODE + SIZE_MEMNUM + SIZE_RELADDR)
774
+
775
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
776
+ #define SIZE_OP_STATE_CHECK (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
777
+ #define SIZE_OP_STATE_CHECK_PUSH (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
778
+ #define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
779
+ #define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
780
+ #endif
781
+
782
+ #define MC_ESC(syn) (syn)->meta_char_table.esc
783
+ #define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
784
+ #define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
785
+ #define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
786
+ #define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
787
+ #define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
788
+
789
+ #define IS_MC_ESC_CODE(code, syn) \
790
+ ((code) == MC_ESC(syn) && \
791
+ !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
792
+
793
+
794
+ #define SYN_POSIX_COMMON_OP \
795
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
796
+ ONIG_SYN_OP_DECIMAL_BACKREF | \
797
+ ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
798
+ ONIG_SYN_OP_LINE_ANCHOR | \
799
+ ONIG_SYN_OP_ESC_CONTROL_CHARS )
800
+
801
+ #define SYN_GNU_REGEX_OP \
802
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
803
+ ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
804
+ ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
805
+ ONIG_SYN_OP_VBAR_ALT | \
806
+ ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
807
+ ONIG_SYN_OP_QMARK_ZERO_ONE | \
808
+ ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
809
+ ONIG_SYN_OP_ESC_W_WORD | \
810
+ ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
811
+ ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
812
+ ONIG_SYN_OP_LINE_ANCHOR )
813
+
814
+ #define SYN_GNU_REGEX_BV \
815
+ ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
816
+ ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
817
+ ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
818
+
819
+
820
+ #define NCCLASS_FLAGS(cc) ((cc)->flags)
821
+ #define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
822
+ #define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
823
+ #define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
824
+
825
+ /* cclass node */
826
+ #define FLAG_NCCLASS_NOT (1<<0)
827
+ #define FLAG_NCCLASS_SHARE (1<<1)
828
+
829
+ #define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
830
+ #define NCCLASS_SET_SHARE(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_SHARE)
831
+ #define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
832
+ #define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
833
+ #define IS_NCCLASS_SHARE(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_SHARE)
834
+
835
+ typedef struct {
836
+ int type;
837
+ /* struct _Node* next; */
838
+ /* unsigned int flags; */
839
+ } NodeBase;
840
+
841
+ typedef struct {
842
+ NodeBase base;
843
+ unsigned int flags;
844
+ BitSet bs;
845
+ BBuf* mbuf; /* multi-byte info or NULL */
846
+ } CClassNode;
847
+
848
+ typedef intptr_t OnigStackIndex;
849
+
850
+ typedef struct _OnigStackType {
851
+ unsigned int type;
852
+ union {
853
+ struct {
854
+ UChar *pcode; /* byte code position */
855
+ UChar *pstr; /* string position */
856
+ UChar *pstr_prev; /* previous char position of pstr */
857
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
858
+ unsigned int state_check;
859
+ #endif
860
+ UChar *pkeep; /* keep pattern position */
861
+ } state;
862
+ struct {
863
+ int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
864
+ UChar *pcode; /* byte code position (head of repeated target) */
865
+ int num; /* repeat id */
866
+ } repeat;
867
+ struct {
868
+ OnigStackIndex si; /* index of stack */
869
+ } repeat_inc;
870
+ struct {
871
+ int num; /* memory num */
872
+ UChar *pstr; /* start/end position */
873
+ /* Following information is set, if this stack type is MEM-START */
874
+ OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */
875
+ OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */
876
+ } mem;
877
+ struct {
878
+ int num; /* null check id */
879
+ UChar *pstr; /* start position */
880
+ } null_check;
881
+ #ifdef USE_SUBEXP_CALL
882
+ struct {
883
+ UChar *ret_addr; /* byte code position */
884
+ int num; /* null check id */
885
+ UChar *pstr; /* string position */
886
+ } call_frame;
887
+ #endif
888
+ } u;
889
+ } OnigStackType;
890
+
891
+ typedef struct {
892
+ void* stack_p;
893
+ size_t stack_n;
894
+ OnigOptionType options;
895
+ OnigRegion* region;
896
+ const UChar* start; /* search start position */
897
+ const UChar* gpos; /* global position (for \G: BEGIN_POSITION) */
898
+ #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
899
+ OnigPosition best_len; /* for ONIG_OPTION_FIND_LONGEST */
900
+ UChar* best_s;
901
+ #endif
902
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
903
+ void* state_check_buff;
904
+ int state_check_buff_size;
905
+ #endif
906
+ } OnigMatchArg;
907
+
908
+
909
+ #define IS_CODE_SB_WORD(enc,code) \
910
+ (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
911
+
912
+ typedef struct OnigEndCallListItem {
913
+ struct OnigEndCallListItem* next;
914
+ void (*func)(void);
915
+ } OnigEndCallListItemType;
916
+
917
+ extern void onig_add_end_call(void (*func)(void));
918
+
919
+
920
+ #ifdef ONIG_DEBUG
921
+
922
+ typedef struct {
923
+ short int opcode;
924
+ const char* name;
925
+ short int arg_type;
926
+ } OnigOpInfoType;
927
+
928
+ extern OnigOpInfoType OnigOpInfo[];
929
+
930
+
931
+ extern void onig_print_compiled_byte_code P_((FILE* f, UChar* bp, UChar* bpend, UChar** nextp, OnigEncoding enc));
932
+
933
+ #ifdef ONIG_DEBUG_STATISTICS
934
+ extern void onig_statistics_init P_((void));
935
+ extern void onig_print_statistics P_((FILE* f));
936
+ #endif
937
+ #endif
938
+
939
+ extern UChar* onig_error_code_to_format P_((OnigPosition code));
940
+ extern void onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...));
941
+ extern int onig_bbuf_init P_((BBuf* buf, OnigDistance size));
942
+ extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo, const char *sourcefile, int sourceline));
943
+ extern void onig_chain_reduce P_((regex_t* reg));
944
+ extern void onig_chain_link_add P_((regex_t* to, regex_t* add));
945
+ extern void onig_transfer P_((regex_t* to, regex_t* from));
946
+ extern int onig_is_code_in_cc P_((OnigEncoding enc, OnigCodePoint code, CClassNode* cc));
947
+ extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, CClassNode* cc));
948
+
949
+ /* strend hash */
950
+ typedef void hash_table_type;
951
+ #ifdef RUBY
952
+ #include "ruby/st.h"
953
+ typedef st_data_t hash_data_type;
954
+ #else
955
+ #include "st.h"
956
+ typedef uintptr_t hash_data_type;
957
+ #endif
958
+
959
+ extern hash_table_type* onig_st_init_strend_table_with_size P_((st_index_t size));
960
+ extern int onig_st_lookup_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value));
961
+ extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value));
962
+
963
+ /* encoding property management */
964
+ #define PROPERTY_LIST_ADD_PROP(Name, CR) \
965
+ r = onigenc_property_list_add_property((UChar* )Name, CR,\
966
+ &PropertyNameTable, &PropertyList, &PropertyListNum,\
967
+ &PropertyListSize);\
968
+ if (r != 0) goto end
969
+
970
+ #define PROPERTY_LIST_INIT_CHECK \
971
+ if (PropertyInited == 0) {\
972
+ int r = onigenc_property_list_init(init_property_list);\
973
+ if (r != 0) return r;\
974
+ }
975
+
976
+ extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize));
977
+
978
+ typedef int (*ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void);
979
+
980
+ extern int onigenc_property_list_init P_((ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE));
981
+
982
+ extern size_t onig_memsize P_((const regex_t *reg));
983
+ extern size_t onig_region_memsize P_((const struct re_registers *regs));
984
+
985
+ RUBY_SYMBOL_EXPORT_END
986
+
987
+ #endif /* ONIGURUMA_REGINT_H */