1 #ifndef ONIGURUMA_REGINT_H
2 #define ONIGURUMA_REGINT_H
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)
51 #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
52 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
54 #define PLATFORM_UNALIGNED_WORD_ACCESS
59 #define USE_NAMED_GROUP
60 #define USE_SUBEXP_CALL
61 #define USE_PERL_SUBEXP_CALL
62 #define USE_CAPITAL_P_NAMED_GROUP
63 #define USE_BACKREF_WITH_LEVEL
64 #define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT
65 #define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE
66 #define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
69 #define USE_NO_INVALID_QUANTIFIER
72 #define USE_PARSE_TREE_NODE_RECYCLE
73 #define USE_OP_PUSH_OR_JUMP_EXACT
74 #define USE_QTFR_PEEK_NEXT
75 #define USE_ST_LIBRARY
76 #define USE_SHARED_CCLASS_TABLE
77 #define USE_SUNDAY_QUICK_SEARCH
79 #define INIT_MATCH_STACK_SIZE 160
80 #define DEFAULT_MATCH_STACK_LIMIT_SIZE 0
83 #if defined(USE_PERL_SUBEXP_CALL) || defined(USE_CAPITAL_P_NAMED_GROUP)
84 #if !defined(USE_NAMED_GROUP) || !defined(USE_SUBEXP_CALL)
85 #error USE_NAMED_GROUP and USE_SUBEXP_CALL must be defined.
90 # define ARG_UNUSED __attribute__ ((unused))
97 #ifndef RUBY_DEFINES_H
104 #ifdef ONIG_ESCAPE_UCHAR_COLLISION
105 #undef ONIG_ESCAPE_UCHAR_COLLISION
107 #define USE_WORD_BEGIN_END
108 #undef USE_MATCH_RANGE_IS_COMPLETE_RANGE
109 #undef USE_CAPTURE_HISTORY
110 #define USE_VARIABLE_META_CHARS
111 #define USE_POSIX_API_REGION_OPTION
112 #define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
116 #define THREAD_SYSTEM_INIT
117 #define THREAD_SYSTEM_END
118 #define THREAD_ATOMIC_START
119 #define THREAD_ATOMIC_END
122 #define xmalloc malloc
123 #define xrealloc realloc
124 #define xcalloc calloc
130 #define CHECK_INTERRUPT_IN_MATCH_AT rb_thread_check_ints()
131 #define onig_st_init_table st_init_table
132 #define onig_st_init_table_with_size st_init_table_with_size
133 #define onig_st_init_numtable st_init_numtable
134 #define onig_st_init_numtable_with_size st_init_numtable_with_size
135 #define onig_st_init_strtable st_init_strtable
136 #define onig_st_init_strtable_with_size st_init_strtable_with_size
137 #define onig_st_delete st_delete
138 #define onig_st_delete_safe st_delete_safe
139 #define onig_st_insert st_insert
140 #define onig_st_lookup st_lookup
141 #define onig_st_foreach st_foreach
142 #define onig_st_add_direct st_add_direct
143 #define onig_st_free_table st_free_table
144 #define onig_st_cleanup_safe st_cleanup_safe
145 #define onig_st_copy st_copy
146 #define onig_st_nothing_key_clone st_nothing_key_clone
147 #define onig_st_nothing_key_free st_nothing_key_free
148 #define onig_st_is_member st_is_member
150 #define USE_UPPER_CASE_TABLE
153 #define st_init_table onig_st_init_table
154 #define st_init_table_with_size onig_st_init_table_with_size
155 #define st_init_numtable onig_st_init_numtable
156 #define st_init_numtable_with_size onig_st_init_numtable_with_size
157 #define st_init_strtable onig_st_init_strtable
158 #define st_init_strtable_with_size onig_st_init_strtable_with_size
159 #define st_delete onig_st_delete
160 #define st_delete_safe onig_st_delete_safe
161 #define st_insert onig_st_insert
162 #define st_lookup onig_st_lookup
163 #define st_foreach onig_st_foreach
164 #define st_add_direct onig_st_add_direct
165 #define st_free_table onig_st_free_table
166 #define st_cleanup_safe onig_st_cleanup_safe
167 #define st_copy onig_st_copy
168 #define st_nothing_key_clone onig_st_nothing_key_clone
169 #define st_nothing_key_free onig_st_nothing_key_free
171 #define onig_st_is_member st_is_member
173 #define CHECK_INTERRUPT_IN_MATCH_AT
177 #define STATE_CHECK_STRING_THRESHOLD_LEN 7
178 #define STATE_CHECK_BUFF_MAX_SIZE 0x4000
180 #define THREAD_PASS_LIMIT_COUNT 8
181 #define xmemset memset
182 #define xmemcpy memcpy
183 #define xmemmove memmove
185 #if defined(_WIN32) && !defined(__GNUC__)
186 #define xalloca _alloca
187 #define xvsnprintf _vsnprintf
189 #define xalloca alloca
190 #define xvsnprintf vsnprintf
194 #if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
195 #define ONIG_STATE_INC(reg) (reg)->state++
196 #define ONIG_STATE_DEC(reg) (reg)->state--
198 #define ONIG_STATE_INC_THREAD(reg) do {\
199 THREAD_ATOMIC_START;\
203 #define ONIG_STATE_DEC_THREAD(reg) do {\
204 THREAD_ATOMIC_START;\
209 #define ONIG_STATE_INC(reg)
210 #define ONIG_STATE_DEC(reg)
211 #define ONIG_STATE_INC_THREAD(reg)
212 #define ONIG_STATE_DEC_THREAD(reg)
219 #if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
226 # include <strings.h>
230 #ifdef HAVE_SYS_TYPES_H
231 #include <sys/types.h>
251 #if defined(_MSC_VER) && (_MSC_VER < 1300)
252 #ifndef _INTPTR_T_DEFINED
253 #define _INTPTR_T_DEFINED
256 #ifndef _UINTPTR_T_DEFINED
257 #define _UINTPTR_T_DEFINED
273 #define MIN(a,b) (((a)>(b))?(b):(a))
274 #define MAX(a,b) (((a)<(b))?(b):(a))
276 #define IS_NULL(p) (((void*)(p)) == (void*)0)
277 #define IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
278 #define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL
279 #define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
280 #define NULL_UCHARP ((UChar* )0)
282 #define ONIG_LAST_CODE_POINT (~((OnigCodePoint )0))
284 #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
286 #define PLATFORM_GET_INC(val,p,type) do{\
288 (p) += sizeof(type);\
293 #define PLATFORM_GET_INC(val,p,type) do{\
294 xmemcpy(&val, (p), sizeof(type));\
295 (p) += sizeof(type);\
299 #define WORD_ALIGNMENT_SIZE SIZEOF_LONG
301 #define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
302 (pad_size) = WORD_ALIGNMENT_SIZE \
303 - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
304 if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
307 #define ALIGNMENT_RIGHT(addr) do {\
308 (addr) += (WORD_ALIGNMENT_SIZE - 1);\
309 (addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
315 #define STACK_POP_LEVEL_FREE 0
316 #define STACK_POP_LEVEL_MEM_START 1
317 #define STACK_POP_LEVEL_ALL 2
320 #define ONIG_OPTIMIZE_NONE 0
321 #define ONIG_OPTIMIZE_EXACT 1
322 #define ONIG_OPTIMIZE_EXACT_BM 2
323 #define ONIG_OPTIMIZE_EXACT_BM_NOT_REV 3
324 #define ONIG_OPTIMIZE_EXACT_IC 4
325 #define ONIG_OPTIMIZE_MAP 5
326 #define ONIG_OPTIMIZE_EXACT_BM_IC 6
327 #define ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC 7
332 #define BIT_STATUS_BITS_NUM (sizeof(BitStatusType) * 8)
333 #define BIT_STATUS_CLEAR(stats) (stats) = 0
334 #define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
335 #define BIT_STATUS_AT(stats,n) \
336 ((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & (1 << n)) : ((stats) & 1))
338 #define BIT_STATUS_ON_AT(stats,n) do {\
339 if ((n) < (int )BIT_STATUS_BITS_NUM) \
340 (stats) |= (1 << (n));\
345 #define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
346 if ((n) < (int )BIT_STATUS_BITS_NUM)\
347 (stats) |= (1 << (n));\
351 #define INT_MAX_LIMIT ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
353 #define DIGITVAL(code) ((code) - '0')
354 #define ODIGITVAL(code) DIGITVAL(code)
355 #define XDIGITVAL(enc,code) \
356 (ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
357 : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
359 #define IS_SINGLELINE(option) ((option) & ONIG_OPTION_SINGLELINE)
360 #define IS_MULTILINE(option) ((option) & ONIG_OPTION_MULTILINE)
361 #define IS_IGNORECASE(option) ((option) & ONIG_OPTION_IGNORECASE)
362 #define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND)
363 #define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST)
364 #define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
365 #define IS_FIND_CONDITION(option) ((option) & \
366 (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
367 #define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL)
368 #define IS_NOTEOL(option) ((option) & ONIG_OPTION_NOTEOL)
369 #define IS_POSIX_REGION(option) ((option) & ONIG_OPTION_POSIX_REGION)
370 #define IS_ASCII_RANGE(option) ((option) & ONIG_OPTION_ASCII_RANGE)
371 #define IS_POSIX_BRACKET_ALL_RANGE(option) ((option) & ONIG_OPTION_POSIX_BRACKET_ALL_RANGE)
372 #define IS_WORD_BOUND_ALL_RANGE(option) ((option) & ONIG_OPTION_WORD_BOUND_ALL_RANGE)
373 #define IS_NEWLINE_CRLF(option) ((option) & ONIG_OPTION_NEWLINE_CRLF)
380 #define IS_DYNAMIC_OPTION(option) 0
382 #define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
383 ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
385 #define REPEAT_INFINITE -1
386 #define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE)
389 #define BITS_PER_BYTE 8
390 #define SINGLE_BYTE_SIZE (1 << BITS_PER_BYTE)
391 #define BITS_IN_ROOM ((int )sizeof(Bits) * BITS_PER_BYTE)
392 #define BITSET_SIZE (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
394 #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
395 typedef unsigned int Bits;
402 #define SIZE_BITSET (int )sizeof(BitSet)
404 #define BITSET_CLEAR(bs) do {\
406 for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; } \
409 #define BS_ROOM(bs,pos) (bs)[(int )(pos) / BITS_IN_ROOM]
410 #define BS_BIT(pos) (1 << ((int )(pos) % BITS_IN_ROOM))
412 #define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
413 #define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)
414 #define BITSET_CLEAR_BIT(bs, pos) BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
415 #define BITSET_INVERT_BIT(bs, pos) BS_ROOM(bs,pos) ^= BS_BIT(pos)
424 #define BBUF_INIT(buf,size) onig_bbuf_init((BBuf* )(buf), (size))
426 #define BBUF_SIZE_INC(buf,inc) do{\
427 (buf)->alloc += (inc);\
428 (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
429 if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
432 #define BBUF_EXPAND(buf,low) do{\
433 do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
434 (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
435 if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
438 #define BBUF_ENSURE_SIZE(buf,size) do{\
439 unsigned int new_alloc = (buf)->alloc;\
440 while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
441 if ((buf)->alloc != new_alloc) {\
442 (buf)->p = (UChar* )xrealloc((buf)->p, new_alloc);\
443 if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
444 (buf)->alloc = new_alloc;\
448 #define BBUF_WRITE(buf,pos,bytes,n) do{\
449 int used = (pos) + (int )(n);\
450 if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
451 xmemcpy((buf)->p + (pos), (bytes), (n));\
452 if ((buf)->used < (unsigned int )used) (buf)->used = used;\
455 #define BBUF_WRITE1(buf,pos,byte) do{\
456 int used = (pos) + 1;\
457 if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
458 (buf)->p[(pos)] = (UChar )(byte);\
459 if ((buf)->used < (unsigned int )used) (buf)->used = used;\
462 #define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
463 #define BBUF_ADD1(buf,byte) BBUF_WRITE1((buf),(buf)->used,(byte))
464 #define BBUF_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
465 #define BBUF_GET_OFFSET_POS(buf) ((buf)->used)
468 #define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
469 if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
470 xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
471 if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
475 #define BBUF_MOVE_LEFT(buf,from,to,n) do {\
476 xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
480 #define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
481 xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
482 (buf)->used -= (from - to);\
485 #define BBUF_INSERT(buf,pos,bytes,n) do {\
486 if (pos >= (buf)->used) {\
487 BBUF_WRITE(buf,pos,bytes,n);\
490 BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
491 xmemcpy((buf)->p + (pos), (bytes), (n));\
495 #define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
498 #define ANCHOR_BEGIN_BUF (1<<0)
499 #define ANCHOR_BEGIN_LINE (1<<1)
500 #define ANCHOR_BEGIN_POSITION (1<<2)
501 #define ANCHOR_END_BUF (1<<3)
502 #define ANCHOR_SEMI_END_BUF (1<<4)
503 #define ANCHOR_END_LINE (1<<5)
505 #define ANCHOR_WORD_BOUND (1<<6)
506 #define ANCHOR_NOT_WORD_BOUND (1<<7)
507 #define ANCHOR_WORD_BEGIN (1<<8)
508 #define ANCHOR_WORD_END (1<<9)
509 #define ANCHOR_PREC_READ (1<<10)
510 #define ANCHOR_PREC_READ_NOT (1<<11)
511 #define ANCHOR_LOOK_BEHIND (1<<12)
512 #define ANCHOR_LOOK_BEHIND_NOT (1<<13)
514 #define ANCHOR_ANYCHAR_STAR (1<<14)
515 #define ANCHOR_ANYCHAR_STAR_ML (1<<15)
517 #define ANCHOR_KEEP (1<<16)
645 #define SIZE_OPCODE 1
646 #define SIZE_RELADDR (int )sizeof(RelAddrType)
647 #define SIZE_ABSADDR (int )sizeof(AbsAddrType)
648 #define SIZE_LENGTH (int )sizeof(LengthType)
649 #define SIZE_MEMNUM (int )sizeof(MemNumType)
650 #define SIZE_STATE_CHECK_NUM (int )sizeof(StateCheckNumType)
651 #define SIZE_REPEATNUM (int )sizeof(RepeatNumType)
652 #define SIZE_OPTION (int )sizeof(OnigOptionType)
653 #define SIZE_CODE_POINT (int )sizeof(OnigCodePoint)
654 #define SIZE_POINTER (int )sizeof(PointerType)
657 #define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
658 #define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
659 #define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
660 #define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
661 #define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
662 #define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
663 #define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
664 #define GET_STATE_CHECK_NUM_INC(num,p) PLATFORM_GET_INC(num, p, StateCheckNumType)
667 #define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
668 #define GET_BYTE_INC(byte,p) do{\
675 #define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
676 #define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
677 #define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
678 #define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
679 #define SIZE_OP_POP SIZE_OPCODE
680 #define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
681 #define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
682 #define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
683 #define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
684 #define SIZE_OP_PUSH_POS SIZE_OPCODE
685 #define SIZE_OP_PUSH_POS_NOT (SIZE_OPCODE + SIZE_RELADDR)
686 #define SIZE_OP_POP_POS SIZE_OPCODE
687 #define SIZE_OP_FAIL_POS SIZE_OPCODE
688 #define SIZE_OP_SET_OPTION (SIZE_OPCODE + SIZE_OPTION)
689 #define SIZE_OP_SET_OPTION_PUSH (SIZE_OPCODE + SIZE_OPTION)
690 #define SIZE_OP_FAIL SIZE_OPCODE
691 #define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
692 #define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
693 #define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
694 #define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
695 #define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
696 #define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
697 #define SIZE_OP_PUSH_STOP_BT SIZE_OPCODE
698 #define SIZE_OP_POP_STOP_BT SIZE_OPCODE
699 #define SIZE_OP_NULL_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
700 #define SIZE_OP_NULL_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
701 #define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
702 #define SIZE_OP_PUSH_LOOK_BEHIND_NOT (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
703 #define SIZE_OP_FAIL_LOOK_BEHIND_NOT SIZE_OPCODE
704 #define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
705 #define SIZE_OP_RETURN SIZE_OPCODE
706 #define SIZE_OP_CONDITION (SIZE_OPCODE + SIZE_MEMNUM + SIZE_RELADDR)
708 #ifdef USE_COMBINATION_EXPLOSION_CHECK
709 #define SIZE_OP_STATE_CHECK (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
710 #define SIZE_OP_STATE_CHECK_PUSH (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
711 #define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
712 #define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
715 #define MC_ESC(syn) (syn)->meta_char_table.esc
716 #define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
717 #define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
718 #define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
719 #define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
720 #define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
722 #define IS_MC_ESC_CODE(code, syn) \
723 ((code) == MC_ESC(syn) && \
724 !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
727 #define SYN_POSIX_COMMON_OP \
728 ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
729 ONIG_SYN_OP_DECIMAL_BACKREF | \
730 ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
731 ONIG_SYN_OP_LINE_ANCHOR | \
732 ONIG_SYN_OP_ESC_CONTROL_CHARS )
734 #define SYN_GNU_REGEX_OP \
735 ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
736 ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
737 ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
738 ONIG_SYN_OP_VBAR_ALT | \
739 ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
740 ONIG_SYN_OP_QMARK_ZERO_ONE | \
741 ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
742 ONIG_SYN_OP_ESC_W_WORD | \
743 ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
744 ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
745 ONIG_SYN_OP_LINE_ANCHOR )
747 #define SYN_GNU_REGEX_BV \
748 ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
749 ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
750 ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
753 #define NCCLASS_FLAGS(cc) ((cc)->flags)
754 #define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
755 #define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
756 #define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
759 #define FLAG_NCCLASS_NOT (1<<0)
760 #define FLAG_NCCLASS_SHARE (1<<1)
762 #define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
763 #define NCCLASS_SET_SHARE(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_SHARE)
764 #define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
765 #define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
766 #define IS_NCCLASS_SHARE(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_SHARE)
790 #ifdef USE_COMBINATION_EXPLOSION_CHECK
791 unsigned int state_check;
814 #ifdef USE_SUBEXP_CALL
831 #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
835 #ifdef USE_COMBINATION_EXPLOSION_CHECK
836 void* state_check_buff;
837 int state_check_buff_size;
842 #define IS_CODE_SB_WORD(enc,code) \
843 (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
853 extern OnigOpInfoType OnigOpInfo[];
857 #ifdef ONIG_DEBUG_STATISTICS
858 extern void onig_statistics_init
P_((
void));
859 extern void onig_print_statistics
P_((
FILE*
f));
888 #define PROPERTY_LIST_ADD_PROP(Name, CR) \
889 r = onigenc_property_list_add_property((UChar* )Name, CR,\
890 &PropertyNameTable, &PropertyList, &PropertyListNum,\
894 #define PROPERTY_LIST_INIT_CHECK \
895 if (PropertyInited == 0) {\
896 int r = onigenc_property_list_init(init_property_list);\
897 if (r != 0) return r;\
void onig_transfer(regex_t *to, regex_t *from)
RUBY_SYMBOL_EXPORT_BEGIN typedef unsigned long st_data_t
struct _OnigStackType::@158::@164 call_frame
UChar * onig_error_code_to_format(OnigPosition code)
unsigned int OnigOptionType
int onig_st_lookup_strend(hash_table_type *table, const UChar *str_key, const UChar *end_key, hash_data_type *value)
unsigned int OnigCodePoint
size_t onig_memsize(const regex_t *reg)
union _OnigStackType::@158 u
hash_table_type * onig_st_init_strend_table_with_size(st_index_t size)
int onig_st_insert_strend(hash_table_type *table, const UChar *str_key, const UChar *end_key, hash_data_type value)
void onig_chain_link_add(regex_t *to, regex_t *add)
unsigned int BitStatusType
struct _OnigStackType::@158::@159 state
int onig_compile(regex_t *reg, const UChar *pattern, const UChar *pattern_end, OnigErrorInfo *einfo, const char *sourcefile, int sourceline)
void onig_chain_reduce(regex_t *reg)
#define enclen(enc, p, e)
int onig_bbuf_init(BBuf *buf, OnigDistance size)
struct _OnigStackType::@158::@162 mem
size_t onig_region_memsize(const OnigRegion *regs)
unsigned char buf[MIME_BUF_SIZE]
short int StateCheckNumType
struct _OnigStackType::@158::@163 null_check
#define RUBY_SYMBOL_EXPORT_END
int onigenc_property_list_init(int(*f)(void))
int onig_is_code_in_cc(OnigEncoding enc, OnigCodePoint code, CClassNode *cc)
struct _OnigStackType::@158::@160 repeat
struct _OnigStackType::@158::@161 repeat_inc
#define RUBY_SYMBOL_EXPORT_BEGIN
int onig_is_code_in_cc_len(int elen, OnigCodePoint code, CClassNode *cc)
struct _OnigStackType OnigStackType
int onigenc_property_list_add_property(UChar *name, const OnigCodePoint *prop, hash_table_type **table, const OnigCodePoint ***plist, int *pnum, int *psize)
int(* ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void)