debugger-ruby_core_source 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (121) hide show
  1. data/LEGAL +534 -0
  2. data/LICENSE +23 -0
  3. data/LICENSE.txt +22 -0
  4. data/OLD_README +29 -0
  5. data/README.md +27 -0
  6. data/RUBY_LICENSE +56 -0
  7. data/Rakefile +32 -0
  8. data/debugger-ruby_core_source.gemspec +18 -0
  9. data/lib/contrib/progressbar.rb +237 -0
  10. data/lib/contrib/uri_ext.rb +289 -0
  11. data/lib/debugger/ruby_core_source.rb +7 -0
  12. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/debug.h +36 -0
  13. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/dln.h +41 -0
  14. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/encdb.h +163 -0
  15. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/eval_intern.h +232 -0
  16. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/gc.h +77 -0
  17. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/id.h +170 -0
  18. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/insns.inc +179 -0
  19. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/insns_info.inc +695 -0
  20. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/iseq.h +104 -0
  21. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/known_errors.inc +731 -0
  22. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/method.h +103 -0
  23. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/node.h +483 -0
  24. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/node_name.inc +208 -0
  25. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/opt_sc.inc +670 -0
  26. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/optinsn.inc +30 -0
  27. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/optunifs.inc +116 -0
  28. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/parse.h +187 -0
  29. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/regenc.h +211 -0
  30. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/regint.h +841 -0
  31. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/regparse.h +354 -0
  32. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/revision.h +1 -0
  33. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/thread_pthread.h +27 -0
  34. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/thread_win32.h +33 -0
  35. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/timev.h +21 -0
  36. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/transcode_data.h +109 -0
  37. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/transdb.h +179 -0
  38. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/version.h +55 -0
  39. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm.inc +3055 -0
  40. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm_core.h +707 -0
  41. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm_exec.h +184 -0
  42. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm_insnhelper.h +208 -0
  43. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vm_opts.h +51 -0
  44. data/lib/debugger/ruby_core_source/ruby-1.9.2-p290/vmtc.inc +97 -0
  45. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/addr2line.h +21 -0
  46. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/atomic.h +56 -0
  47. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/constant.h +34 -0
  48. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/debug.h +41 -0
  49. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/dln.h +50 -0
  50. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/encdb.h +167 -0
  51. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/eval_intern.h +234 -0
  52. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/gc.h +98 -0
  53. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/id.h +175 -0
  54. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/insns.inc +179 -0
  55. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/insns_info.inc +695 -0
  56. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/internal.h +227 -0
  57. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/iseq.h +125 -0
  58. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/known_errors.inc +731 -0
  59. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/method.h +105 -0
  60. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/node.h +503 -0
  61. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/node_name.inc +208 -0
  62. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/opt_sc.inc +670 -0
  63. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/optinsn.inc +30 -0
  64. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/optunifs.inc +116 -0
  65. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/parse.h +186 -0
  66. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/regenc.h +219 -0
  67. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/regint.h +851 -0
  68. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/regparse.h +362 -0
  69. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/revision.h +1 -0
  70. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/thread_pthread.h +51 -0
  71. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/thread_win32.h +40 -0
  72. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/timev.h +21 -0
  73. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/transcode_data.h +117 -0
  74. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/transdb.h +189 -0
  75. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/version.h +52 -0
  76. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm.inc +3067 -0
  77. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm_core.h +756 -0
  78. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm_exec.h +184 -0
  79. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm_insnhelper.h +220 -0
  80. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vm_opts.h +51 -0
  81. data/lib/debugger/ruby_core_source/ruby-1.9.3-p0/vmtc.inc +97 -0
  82. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/addr2line.h +21 -0
  83. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/atomic.h +56 -0
  84. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/constant.h +34 -0
  85. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/debug.h +41 -0
  86. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/dln.h +50 -0
  87. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/encdb.h +167 -0
  88. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/eval_intern.h +234 -0
  89. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/gc.h +98 -0
  90. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/id.h +175 -0
  91. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/insns.inc +179 -0
  92. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/insns_info.inc +695 -0
  93. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/internal.h +231 -0
  94. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/iseq.h +125 -0
  95. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/known_errors.inc +731 -0
  96. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/method.h +105 -0
  97. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/node.h +503 -0
  98. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/node_name.inc +208 -0
  99. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/opt_sc.inc +670 -0
  100. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/optinsn.inc +30 -0
  101. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/optunifs.inc +116 -0
  102. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/parse.h +186 -0
  103. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/regenc.h +219 -0
  104. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/regint.h +850 -0
  105. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/regparse.h +362 -0
  106. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/revision.h +1 -0
  107. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/thread_pthread.h +51 -0
  108. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/thread_win32.h +40 -0
  109. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/timev.h +21 -0
  110. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/transcode_data.h +117 -0
  111. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/transdb.h +189 -0
  112. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/version.h +52 -0
  113. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm.inc +3067 -0
  114. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm_core.h +756 -0
  115. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm_exec.h +184 -0
  116. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm_insnhelper.h +220 -0
  117. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vm_opts.h +51 -0
  118. data/lib/debugger/ruby_core_source/ruby-1.9.3-p125/vmtc.inc +97 -0
  119. data/lib/debugger/ruby_core_source/version.rb +5 -0
  120. data/lib/ruby_core_source.rb +62 -0
  121. metadata +198 -0
@@ -0,0 +1,851 @@
1
+ #ifndef ONIGURUMA_REGINT_H
2
+ #define ONIGURUMA_REGINT_H
3
+ /**********************************************************************
4
+ regint.h - Oniguruma (regular expression library)
5
+ **********************************************************************/
6
+ /*-
7
+ * Copyright (c) 2002-2008 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
8
+ * All rights reserved.
9
+ *
10
+ * Redistribution and use in source and binary forms, with or without
11
+ * modification, are permitted provided that the following conditions
12
+ * are met:
13
+ * 1. Redistributions of source code must retain the above copyright
14
+ * notice, this list of conditions and the following disclaimer.
15
+ * 2. Redistributions in binary form must reproduce the above copyright
16
+ * notice, this list of conditions and the following disclaimer in the
17
+ * documentation and/or other materials provided with the distribution.
18
+ *
19
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29
+ * SUCH DAMAGE.
30
+ */
31
+
32
+ /* for debug */
33
+ /* #define ONIG_DEBUG_PARSE_TREE */
34
+ /* #define ONIG_DEBUG_COMPILE */
35
+ /* #define ONIG_DEBUG_SEARCH */
36
+ /* #define ONIG_DEBUG_MATCH */
37
+ /* #define ONIG_DONT_OPTIMIZE */
38
+
39
+ /* for byte-code statistical data. */
40
+ /* #define ONIG_DEBUG_STATISTICS */
41
+
42
+ #if defined(ONIG_DEBUG_PARSE_TREE) || defined(ONIG_DEBUG_MATCH) || \
43
+ defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) || \
44
+ defined(ONIG_DEBUG_STATISTICS)
45
+ #ifndef ONIG_DEBUG
46
+ #define ONIG_DEBUG
47
+ #endif
48
+ #endif
49
+
50
+ #if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
51
+ (defined(__ppc__) && defined(__APPLE__)) || \
52
+ defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD86) || \
53
+ defined(__mc68020__)
54
+ #define PLATFORM_UNALIGNED_WORD_ACCESS
55
+ #endif
56
+
57
+ /* config */
58
+ /* spec. config */
59
+ #define USE_NAMED_GROUP
60
+ #define USE_SUBEXP_CALL
61
+ #define USE_BACKREF_WITH_LEVEL /* \k<name+n>, \k<name-n> */
62
+ #define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT /* /(?:()|())*\2/ */
63
+ #define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
64
+ #define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
65
+ /* #define USE_RECOMPILE_API */
66
+ /* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */
67
+
68
+ /* internal config */
69
+ #define USE_PARSE_TREE_NODE_RECYCLE
70
+ #define USE_OP_PUSH_OR_JUMP_EXACT
71
+ #define USE_QTFR_PEEK_NEXT
72
+ #define USE_ST_LIBRARY
73
+ #define USE_SHARED_CCLASS_TABLE
74
+
75
+ #define INIT_MATCH_STACK_SIZE 160
76
+ #define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
77
+
78
+ #if defined(__GNUC__)
79
+ # define ARG_UNUSED __attribute__ ((unused))
80
+ #else
81
+ # define ARG_UNUSED
82
+ #endif
83
+
84
+ /* */
85
+ /* escape other system UChar definition */
86
+ #ifndef RUBY_DEFINES_H
87
+ #include "ruby/ruby.h"
88
+ #undef xmalloc
89
+ #undef xrealloc
90
+ #undef xcalloc
91
+ #undef xfree
92
+ #endif
93
+ #ifdef ONIG_ESCAPE_UCHAR_COLLISION
94
+ #undef ONIG_ESCAPE_UCHAR_COLLISION
95
+ #endif
96
+ #undef USE_MATCH_RANGE_IS_COMPLETE_RANGE
97
+ #undef USE_CAPTURE_HISTORY
98
+ #define USE_VARIABLE_META_CHARS
99
+ #define USE_WORD_BEGIN_END /* "\<": word-begin, "\>": word-end */
100
+ #define USE_POSIX_REGION_OPTION /* needed for POSIX API support */
101
+ #define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
102
+ /* #define USE_COMBINATION_EXPLOSION_CHECK */ /* (X*)* */
103
+ /* #define USE_MULTI_THREAD_SYSTEM */
104
+ #define THREAD_SYSTEM_INIT /* depend on thread system */
105
+ #define THREAD_SYSTEM_END /* depend on thread system */
106
+ #define THREAD_ATOMIC_START /* depend on thread system */
107
+ #define THREAD_ATOMIC_END /* depend on thread system */
108
+ #define THREAD_PASS /* depend on thread system */
109
+ #ifndef xmalloc
110
+ #define xmalloc malloc
111
+ #define xrealloc realloc
112
+ #define xcalloc calloc
113
+ #define xfree free
114
+ #endif
115
+
116
+ #ifdef RUBY
117
+
118
+ #define CHECK_INTERRUPT_IN_MATCH_AT rb_thread_check_ints()
119
+ #define onig_st_init_table st_init_table
120
+ #define onig_st_init_table_with_size st_init_table_with_size
121
+ #define onig_st_init_numtable st_init_numtable
122
+ #define onig_st_init_numtable_with_size st_init_numtable_with_size
123
+ #define onig_st_init_strtable st_init_strtable
124
+ #define onig_st_init_strtable_with_size st_init_strtable_with_size
125
+ #define onig_st_delete st_delete
126
+ #define onig_st_delete_safe st_delete_safe
127
+ #define onig_st_insert st_insert
128
+ #define onig_st_lookup st_lookup
129
+ #define onig_st_foreach st_foreach
130
+ #define onig_st_add_direct st_add_direct
131
+ #define onig_st_free_table st_free_table
132
+ #define onig_st_cleanup_safe st_cleanup_safe
133
+ #define onig_st_copy st_copy
134
+ #define onig_st_nothing_key_clone st_nothing_key_clone
135
+ #define onig_st_nothing_key_free st_nothing_key_free
136
+ #define onig_st_is_member st_is_member
137
+
138
+ #define USE_UPPER_CASE_TABLE
139
+ #else
140
+
141
+ #define st_init_table onig_st_init_table
142
+ #define st_init_table_with_size onig_st_init_table_with_size
143
+ #define st_init_numtable onig_st_init_numtable
144
+ #define st_init_numtable_with_size onig_st_init_numtable_with_size
145
+ #define st_init_strtable onig_st_init_strtable
146
+ #define st_init_strtable_with_size onig_st_init_strtable_with_size
147
+ #define st_delete onig_st_delete
148
+ #define st_delete_safe onig_st_delete_safe
149
+ #define st_insert onig_st_insert
150
+ #define st_lookup onig_st_lookup
151
+ #define st_foreach onig_st_foreach
152
+ #define st_add_direct onig_st_add_direct
153
+ #define st_free_table onig_st_free_table
154
+ #define st_cleanup_safe onig_st_cleanup_safe
155
+ #define st_copy onig_st_copy
156
+ #define st_nothing_key_clone onig_st_nothing_key_clone
157
+ #define st_nothing_key_free onig_st_nothing_key_free
158
+ /* */
159
+ #define onig_st_is_member st_is_member
160
+
161
+ #define CHECK_INTERRUPT_IN_MATCH_AT
162
+
163
+ #endif
164
+
165
+ #define STATE_CHECK_STRING_THRESHOLD_LEN 7
166
+ #define STATE_CHECK_BUFF_MAX_SIZE 0x4000
167
+
168
+ #define THREAD_PASS_LIMIT_COUNT 8
169
+ #define xmemset memset
170
+ #define xmemcpy memcpy
171
+ #define xmemmove memmove
172
+
173
+ #if defined(_WIN32) && !defined(__GNUC__)
174
+ #define xalloca _alloca
175
+ #define xvsnprintf _vsnprintf
176
+ #else
177
+ #define xalloca alloca
178
+ #define xvsnprintf vsnprintf
179
+ #endif
180
+
181
+
182
+ #if defined(USE_RECOMPILE_API) && defined(USE_MULTI_THREAD_SYSTEM)
183
+ #define ONIG_STATE_INC(reg) (reg)->state++
184
+ #define ONIG_STATE_DEC(reg) (reg)->state--
185
+
186
+ #define ONIG_STATE_INC_THREAD(reg) do {\
187
+ THREAD_ATOMIC_START;\
188
+ (reg)->state++;\
189
+ THREAD_ATOMIC_END;\
190
+ } while(0)
191
+ #define ONIG_STATE_DEC_THREAD(reg) do {\
192
+ THREAD_ATOMIC_START;\
193
+ (reg)->state--;\
194
+ THREAD_ATOMIC_END;\
195
+ } while(0)
196
+ #else
197
+ #define ONIG_STATE_INC(reg) /* Nothing */
198
+ #define ONIG_STATE_DEC(reg) /* Nothing */
199
+ #define ONIG_STATE_INC_THREAD(reg) /* Nothing */
200
+ #define ONIG_STATE_DEC_THREAD(reg) /* Nothing */
201
+ #endif /* USE_RECOMPILE_API && USE_MULTI_THREAD_SYSTEM */
202
+
203
+ #ifdef HAVE_STDLIB_H
204
+ #include <stdlib.h>
205
+ #endif
206
+
207
+ #if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
208
+ #include <alloca.h>
209
+ #endif
210
+
211
+ #ifdef HAVE_STRING_H
212
+ # include <string.h>
213
+ #else
214
+ # include <strings.h>
215
+ #endif
216
+
217
+ #include <ctype.h>
218
+ #ifdef HAVE_SYS_TYPES_H
219
+ #include <sys/types.h>
220
+ #endif
221
+
222
+ #ifdef ONIG_DEBUG
223
+ # include <stdio.h>
224
+ #endif
225
+
226
+ #include "regenc.h"
227
+
228
+ #if defined __GNUC__ && __GNUC__ >= 4
229
+ #pragma GCC visibility push(default)
230
+ #endif
231
+
232
+ #ifdef MIN
233
+ #undef MIN
234
+ #endif
235
+ #ifdef MAX
236
+ #undef MAX
237
+ #endif
238
+ #define MIN(a,b) (((a)>(b))?(b):(a))
239
+ #define MAX(a,b) (((a)<(b))?(b):(a))
240
+
241
+ #define IS_NULL(p) (((void*)(p)) == (void*)0)
242
+ #define IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
243
+ #define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL
244
+ #define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
245
+ #define NULL_UCHARP ((UChar* )0)
246
+
247
+ #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
248
+
249
+ #define PLATFORM_GET_INC(val,p,type) do{\
250
+ val = *(type* )p;\
251
+ (p) += sizeof(type);\
252
+ } while(0)
253
+
254
+ #else
255
+
256
+ #define PLATFORM_GET_INC(val,p,type) do{\
257
+ xmemcpy(&val, (p), sizeof(type));\
258
+ (p) += sizeof(type);\
259
+ } while(0)
260
+
261
+ /* sizeof(OnigCodePoint) */
262
+ #define WORD_ALIGNMENT_SIZE SIZEOF_LONG
263
+
264
+ #define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
265
+ (pad_size) = WORD_ALIGNMENT_SIZE \
266
+ - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
267
+ if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
268
+ } while (0)
269
+
270
+ #define ALIGNMENT_RIGHT(addr) do {\
271
+ (addr) += (WORD_ALIGNMENT_SIZE - 1);\
272
+ (addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
273
+ } while (0)
274
+
275
+ #endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
276
+
277
+ /* stack pop level */
278
+ #define STACK_POP_LEVEL_FREE 0
279
+ #define STACK_POP_LEVEL_MEM_START 1
280
+ #define STACK_POP_LEVEL_ALL 2
281
+
282
+ /* optimize flags */
283
+ #define ONIG_OPTIMIZE_NONE 0
284
+ #define ONIG_OPTIMIZE_EXACT 1 /* Slow Search */
285
+ #define ONIG_OPTIMIZE_EXACT_BM 2 /* Boyer Moore Search */
286
+ #define ONIG_OPTIMIZE_EXACT_BM_NOT_REV 3 /* BM (but not simple match) */
287
+ #define ONIG_OPTIMIZE_EXACT_IC 4 /* Slow Search (ignore case) */
288
+ #define ONIG_OPTIMIZE_MAP 5 /* char map */
289
+
290
+ /* bit status */
291
+ typedef unsigned int BitStatusType;
292
+
293
+ #define BIT_STATUS_BITS_NUM (sizeof(BitStatusType) * 8)
294
+ #define BIT_STATUS_CLEAR(stats) (stats) = 0
295
+ #define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
296
+ #define BIT_STATUS_AT(stats,n) \
297
+ ((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & (1 << n)) : ((stats) & 1))
298
+
299
+ #define BIT_STATUS_ON_AT(stats,n) do {\
300
+ if ((n) < (int )BIT_STATUS_BITS_NUM) \
301
+ (stats) |= (1 << (n));\
302
+ else\
303
+ (stats) |= 1;\
304
+ } while (0)
305
+
306
+ #define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
307
+ if ((n) < (int )BIT_STATUS_BITS_NUM)\
308
+ (stats) |= (1 << (n));\
309
+ } while (0)
310
+
311
+
312
+ #define INT_MAX_LIMIT ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
313
+
314
+ #define DIGITVAL(code) ((code) - '0')
315
+ #define ODIGITVAL(code) DIGITVAL(code)
316
+ #define XDIGITVAL(enc,code) \
317
+ (ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
318
+ : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
319
+
320
+ #define IS_SINGLELINE(option) ((option) & ONIG_OPTION_SINGLELINE)
321
+ #define IS_MULTILINE(option) ((option) & ONIG_OPTION_MULTILINE)
322
+ #define IS_IGNORECASE(option) ((option) & ONIG_OPTION_IGNORECASE)
323
+ #define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND)
324
+ #define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST)
325
+ #define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
326
+ #define IS_FIND_CONDITION(option) ((option) & \
327
+ (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
328
+ #define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL)
329
+ #define IS_NOTEOL(option) ((option) & ONIG_OPTION_NOTEOL)
330
+ #define IS_POSIX_REGION(option) ((option) & ONIG_OPTION_POSIX_REGION)
331
+
332
+ /* OP_SET_OPTION is required for these options.
333
+ #define IS_DYNAMIC_OPTION(option) \
334
+ (((option) & (ONIG_OPTION_MULTILINE | ONIG_OPTION_IGNORECASE)) != 0)
335
+ */
336
+ /* ignore-case and multibyte status are included in compiled code. */
337
+ #define IS_DYNAMIC_OPTION(option) 0
338
+
339
+ #define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
340
+ ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
341
+
342
+ #define REPEAT_INFINITE -1
343
+ #define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE)
344
+
345
+ /* bitset */
346
+ #define BITS_PER_BYTE 8
347
+ #define SINGLE_BYTE_SIZE (1 << BITS_PER_BYTE)
348
+ #define BITS_IN_ROOM (sizeof(Bits) * BITS_PER_BYTE)
349
+ #define BITSET_SIZE (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
350
+
351
+ #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
352
+ typedef unsigned int Bits;
353
+ #else
354
+ typedef unsigned char Bits;
355
+ #endif
356
+ typedef Bits BitSet[BITSET_SIZE];
357
+ typedef Bits* BitSetRef;
358
+
359
+ #define SIZE_BITSET (int)sizeof(BitSet)
360
+
361
+ #define BITSET_CLEAR(bs) do {\
362
+ int i;\
363
+ for (i = 0; i < (int )BITSET_SIZE; i++) { (bs)[i] = 0; } \
364
+ } while (0)
365
+
366
+ #define BS_ROOM(bs,pos) (bs)[pos / BITS_IN_ROOM]
367
+ #define BS_BIT(pos) (1 << (pos % BITS_IN_ROOM))
368
+
369
+ #define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
370
+ #define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)
371
+ #define BITSET_CLEAR_BIT(bs, pos) BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
372
+ #define BITSET_INVERT_BIT(bs, pos) BS_ROOM(bs,pos) ^= BS_BIT(pos)
373
+
374
+ /* bytes buffer */
375
+ typedef struct _BBuf {
376
+ UChar* p;
377
+ unsigned int used;
378
+ unsigned int alloc;
379
+ } BBuf;
380
+
381
+ #define BBUF_INIT(buf,size) onig_bbuf_init((BBuf* )(buf), (size))
382
+
383
+ #define BBUF_SIZE_INC(buf,inc) do{\
384
+ (buf)->alloc += (inc);\
385
+ (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
386
+ if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
387
+ } while (0)
388
+
389
+ #define BBUF_EXPAND(buf,low) do{\
390
+ do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
391
+ (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
392
+ if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
393
+ } while (0)
394
+
395
+ #define BBUF_ENSURE_SIZE(buf,size) do{\
396
+ unsigned int new_alloc = (buf)->alloc;\
397
+ while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
398
+ if ((buf)->alloc != new_alloc) {\
399
+ (buf)->p = (UChar* )xrealloc((buf)->p, new_alloc);\
400
+ if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
401
+ (buf)->alloc = new_alloc;\
402
+ }\
403
+ } while (0)
404
+
405
+ #define BBUF_WRITE(buf,pos,bytes,n) do{\
406
+ int used = (pos) + (int)(n);\
407
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
408
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
409
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
410
+ } while (0)
411
+
412
+ #define BBUF_WRITE1(buf,pos,byte) do{\
413
+ int used = (pos) + 1;\
414
+ if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
415
+ (buf)->p[(pos)] = (byte);\
416
+ if ((buf)->used < (unsigned int )used) (buf)->used = used;\
417
+ } while (0)
418
+
419
+ #define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
420
+ #define BBUF_ADD1(buf,byte) BBUF_WRITE1((buf),(buf)->used,(byte))
421
+ #define BBUF_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
422
+ #define BBUF_GET_OFFSET_POS(buf) ((buf)->used)
423
+
424
+ /* from < to */
425
+ #define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
426
+ if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
427
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
428
+ if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
429
+ } while (0)
430
+
431
+ /* from > to */
432
+ #define BBUF_MOVE_LEFT(buf,from,to,n) do {\
433
+ xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
434
+ } while (0)
435
+
436
+ /* from > to */
437
+ #define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
438
+ xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
439
+ (buf)->used -= (from - to);\
440
+ } while (0)
441
+
442
+ #define BBUF_INSERT(buf,pos,bytes,n) do {\
443
+ if (pos >= (buf)->used) {\
444
+ BBUF_WRITE(buf,pos,bytes,n);\
445
+ }\
446
+ else {\
447
+ BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
448
+ xmemcpy((buf)->p + (pos), (bytes), (n));\
449
+ }\
450
+ } while (0)
451
+
452
+ #define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
453
+
454
+
455
+ #define ANCHOR_BEGIN_BUF (1<<0)
456
+ #define ANCHOR_BEGIN_LINE (1<<1)
457
+ #define ANCHOR_BEGIN_POSITION (1<<2)
458
+ #define ANCHOR_END_BUF (1<<3)
459
+ #define ANCHOR_SEMI_END_BUF (1<<4)
460
+ #define ANCHOR_END_LINE (1<<5)
461
+
462
+ #define ANCHOR_WORD_BOUND (1<<6)
463
+ #define ANCHOR_NOT_WORD_BOUND (1<<7)
464
+ #define ANCHOR_WORD_BEGIN (1<<8)
465
+ #define ANCHOR_WORD_END (1<<9)
466
+ #define ANCHOR_PREC_READ (1<<10)
467
+ #define ANCHOR_PREC_READ_NOT (1<<11)
468
+ #define ANCHOR_LOOK_BEHIND (1<<12)
469
+ #define ANCHOR_LOOK_BEHIND_NOT (1<<13)
470
+
471
+ #define ANCHOR_ANYCHAR_STAR (1<<14) /* ".*" optimize info */
472
+ #define ANCHOR_ANYCHAR_STAR_ML (1<<15) /* ".*" optimize info (multi-line) */
473
+
474
+ /* operation code */
475
+ enum OpCode {
476
+ OP_FINISH = 0, /* matching process terminator (no more alternative) */
477
+ OP_END = 1, /* pattern code terminator (success end) */
478
+
479
+ OP_EXACT1 = 2, /* single byte, N = 1 */
480
+ OP_EXACT2, /* single byte, N = 2 */
481
+ OP_EXACT3, /* single byte, N = 3 */
482
+ OP_EXACT4, /* single byte, N = 4 */
483
+ OP_EXACT5, /* single byte, N = 5 */
484
+ OP_EXACTN, /* single byte */
485
+ OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
486
+ OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
487
+ OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
488
+ OP_EXACTMB2N, /* mb-length = 2 */
489
+ OP_EXACTMB3N, /* mb-length = 3 */
490
+ OP_EXACTMBN, /* other length */
491
+
492
+ OP_EXACT1_IC, /* single byte, N = 1, ignore case */
493
+ OP_EXACTN_IC, /* single byte, ignore case */
494
+
495
+ OP_CCLASS,
496
+ OP_CCLASS_MB,
497
+ OP_CCLASS_MIX,
498
+ OP_CCLASS_NOT,
499
+ OP_CCLASS_MB_NOT,
500
+ OP_CCLASS_MIX_NOT,
501
+ OP_CCLASS_NODE, /* pointer to CClassNode node */
502
+
503
+ OP_ANYCHAR, /* "." */
504
+ OP_ANYCHAR_ML, /* "." multi-line */
505
+ OP_ANYCHAR_STAR, /* ".*" */
506
+ OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
507
+ OP_ANYCHAR_STAR_PEEK_NEXT,
508
+ OP_ANYCHAR_ML_STAR_PEEK_NEXT,
509
+
510
+ OP_WORD,
511
+ OP_NOT_WORD,
512
+ OP_WORD_BOUND,
513
+ OP_NOT_WORD_BOUND,
514
+ OP_WORD_BEGIN,
515
+ OP_WORD_END,
516
+
517
+ OP_BEGIN_BUF,
518
+ OP_END_BUF,
519
+ OP_BEGIN_LINE,
520
+ OP_END_LINE,
521
+ OP_SEMI_END_BUF,
522
+ OP_BEGIN_POSITION,
523
+
524
+ OP_BACKREF1,
525
+ OP_BACKREF2,
526
+ OP_BACKREFN,
527
+ OP_BACKREFN_IC,
528
+ OP_BACKREF_MULTI,
529
+ OP_BACKREF_MULTI_IC,
530
+ OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
531
+
532
+ OP_MEMORY_START,
533
+ OP_MEMORY_START_PUSH, /* push back-tracker to stack */
534
+ OP_MEMORY_END_PUSH, /* push back-tracker to stack */
535
+ OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
536
+ OP_MEMORY_END,
537
+ OP_MEMORY_END_REC, /* push marker to stack */
538
+
539
+ OP_FAIL, /* pop stack and move */
540
+ OP_JUMP,
541
+ OP_PUSH,
542
+ OP_POP,
543
+ OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
544
+ OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
545
+ OP_REPEAT, /* {n,m} */
546
+ OP_REPEAT_NG, /* {n,m}? (non greedy) */
547
+ OP_REPEAT_INC,
548
+ OP_REPEAT_INC_NG, /* non greedy */
549
+ OP_REPEAT_INC_SG, /* search and get in stack */
550
+ OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
551
+ OP_NULL_CHECK_START, /* null loop checker start */
552
+ OP_NULL_CHECK_END, /* null loop checker end */
553
+ OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
554
+ OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
555
+
556
+ OP_PUSH_POS, /* (?=...) start */
557
+ OP_POP_POS, /* (?=...) end */
558
+ OP_PUSH_POS_NOT, /* (?!...) start */
559
+ OP_FAIL_POS, /* (?!...) end */
560
+ OP_PUSH_STOP_BT, /* (?>...) start */
561
+ OP_POP_STOP_BT, /* (?>...) end */
562
+ OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
563
+ OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
564
+ OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end */
565
+
566
+ OP_CALL, /* \g<name> */
567
+ OP_RETURN,
568
+
569
+ OP_STATE_CHECK_PUSH, /* combination explosion check and push */
570
+ OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */
571
+ OP_STATE_CHECK, /* check only */
572
+ OP_STATE_CHECK_ANYCHAR_STAR,
573
+ OP_STATE_CHECK_ANYCHAR_ML_STAR,
574
+
575
+ /* no need: IS_DYNAMIC_OPTION() == 0 */
576
+ OP_SET_OPTION_PUSH, /* set option and push recover option */
577
+ OP_SET_OPTION /* set option */
578
+ };
579
+
580
+ typedef int RelAddrType;
581
+ typedef int AbsAddrType;
582
+ typedef int LengthType;
583
+ typedef int RepeatNumType;
584
+ typedef short int MemNumType;
585
+ typedef short int StateCheckNumType;
586
+ typedef void* PointerType;
587
+
588
+ #define SIZE_OPCODE 1
589
+ #define SIZE_RELADDR (int)sizeof(RelAddrType)
590
+ #define SIZE_ABSADDR (int)sizeof(AbsAddrType)
591
+ #define SIZE_LENGTH (int)sizeof(LengthType)
592
+ #define SIZE_MEMNUM (int)sizeof(MemNumType)
593
+ #define SIZE_STATE_CHECK_NUM (int)sizeof(StateCheckNumType)
594
+ #define SIZE_REPEATNUM (int)sizeof(RepeatNumType)
595
+ #define SIZE_OPTION (int)sizeof(OnigOptionType)
596
+ #define SIZE_CODE_POINT (int)sizeof(OnigCodePoint)
597
+ #define SIZE_POINTER (int)sizeof(PointerType)
598
+
599
+
600
+ #define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
601
+ #define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
602
+ #define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
603
+ #define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
604
+ #define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
605
+ #define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
606
+ #define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
607
+ #define GET_STATE_CHECK_NUM_INC(num,p) PLATFORM_GET_INC(num, p, StateCheckNumType)
608
+
609
+ /* code point's address must be aligned address. */
610
+ #define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
611
+ #define GET_BYTE_INC(byte,p) do{\
612
+ byte = *(p);\
613
+ (p)++;\
614
+ } while(0)
615
+
616
+
617
+ /* op-code + arg size */
618
+ #define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
619
+ #define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
620
+ #define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
621
+ #define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
622
+ #define SIZE_OP_POP SIZE_OPCODE
623
+ #define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
624
+ #define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
625
+ #define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
626
+ #define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
627
+ #define SIZE_OP_PUSH_POS SIZE_OPCODE
628
+ #define SIZE_OP_PUSH_POS_NOT (SIZE_OPCODE + SIZE_RELADDR)
629
+ #define SIZE_OP_POP_POS SIZE_OPCODE
630
+ #define SIZE_OP_FAIL_POS SIZE_OPCODE
631
+ #define SIZE_OP_SET_OPTION (SIZE_OPCODE + SIZE_OPTION)
632
+ #define SIZE_OP_SET_OPTION_PUSH (SIZE_OPCODE + SIZE_OPTION)
633
+ #define SIZE_OP_FAIL SIZE_OPCODE
634
+ #define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
635
+ #define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
636
+ #define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
637
+ #define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
638
+ #define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
639
+ #define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
640
+ #define SIZE_OP_PUSH_STOP_BT SIZE_OPCODE
641
+ #define SIZE_OP_POP_STOP_BT SIZE_OPCODE
642
+ #define SIZE_OP_NULL_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
643
+ #define SIZE_OP_NULL_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
644
+ #define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
645
+ #define SIZE_OP_PUSH_LOOK_BEHIND_NOT (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
646
+ #define SIZE_OP_FAIL_LOOK_BEHIND_NOT SIZE_OPCODE
647
+ #define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
648
+ #define SIZE_OP_RETURN SIZE_OPCODE
649
+
650
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
651
+ #define SIZE_OP_STATE_CHECK (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
652
+ #define SIZE_OP_STATE_CHECK_PUSH (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
653
+ #define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
654
+ #define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
655
+ #endif
656
+
657
+ #define MC_ESC(syn) (syn)->meta_char_table.esc
658
+ #define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
659
+ #define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
660
+ #define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
661
+ #define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
662
+ #define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
663
+
664
+ #define IS_MC_ESC_CODE(code, syn) \
665
+ ((code) == MC_ESC(syn) && \
666
+ !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
667
+
668
+
669
+ #define SYN_POSIX_COMMON_OP \
670
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
671
+ ONIG_SYN_OP_DECIMAL_BACKREF | \
672
+ ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
673
+ ONIG_SYN_OP_LINE_ANCHOR | \
674
+ ONIG_SYN_OP_ESC_CONTROL_CHARS )
675
+
676
+ #define SYN_GNU_REGEX_OP \
677
+ ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
678
+ ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
679
+ ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
680
+ ONIG_SYN_OP_VBAR_ALT | \
681
+ ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
682
+ ONIG_SYN_OP_QMARK_ZERO_ONE | \
683
+ ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
684
+ ONIG_SYN_OP_ESC_W_WORD | \
685
+ ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
686
+ ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
687
+ ONIG_SYN_OP_LINE_ANCHOR )
688
+
689
+ #define SYN_GNU_REGEX_BV \
690
+ ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
691
+ ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
692
+ ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
693
+
694
+
695
+ #define NCCLASS_FLAGS(cc) ((cc)->flags)
696
+ #define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
697
+ #define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
698
+ #define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
699
+
700
+ /* cclass node */
701
+ #define FLAG_NCCLASS_NOT (1<<0)
702
+ #define FLAG_NCCLASS_SHARE (1<<1)
703
+
704
+ #define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
705
+ #define NCCLASS_SET_SHARE(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_SHARE)
706
+ #define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
707
+ #define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
708
+ #define IS_NCCLASS_SHARE(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_SHARE)
709
+
710
+ typedef struct {
711
+ int type;
712
+ /* struct _Node* next; */
713
+ /* unsigned int flags; */
714
+ } NodeBase;
715
+
716
+ typedef struct {
717
+ NodeBase base;
718
+ unsigned int flags;
719
+ BitSet bs;
720
+ BBuf* mbuf; /* multi-byte info or NULL */
721
+ } CClassNode;
722
+
723
+ typedef intptr_t OnigStackIndex;
724
+
725
+ typedef struct _OnigStackType {
726
+ unsigned int type;
727
+ union {
728
+ struct {
729
+ UChar *pcode; /* byte code position */
730
+ UChar *pstr; /* string position */
731
+ UChar *pstr_prev; /* previous char position of pstr */
732
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
733
+ unsigned int state_check;
734
+ #endif
735
+ } state;
736
+ struct {
737
+ int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
738
+ UChar *pcode; /* byte code position (head of repeated target) */
739
+ int num; /* repeat id */
740
+ } repeat;
741
+ struct {
742
+ OnigStackIndex si; /* index of stack */
743
+ } repeat_inc;
744
+ struct {
745
+ int num; /* memory num */
746
+ UChar *pstr; /* start/end position */
747
+ /* Following information is setted, if this stack type is MEM-START */
748
+ OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */
749
+ OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */
750
+ } mem;
751
+ struct {
752
+ int num; /* null check id */
753
+ UChar *pstr; /* start position */
754
+ } null_check;
755
+ #ifdef USE_SUBEXP_CALL
756
+ struct {
757
+ UChar *ret_addr; /* byte code position */
758
+ int num; /* null check id */
759
+ UChar *pstr; /* string position */
760
+ } call_frame;
761
+ #endif
762
+ } u;
763
+ } OnigStackType;
764
+
765
+ typedef struct {
766
+ void* stack_p;
767
+ size_t stack_n;
768
+ OnigOptionType options;
769
+ OnigRegion* region;
770
+ const UChar* start; /* search start position (for \G: BEGIN_POSITION) */
771
+ #ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
772
+ int best_len; /* for ONIG_OPTION_FIND_LONGEST */
773
+ UChar* best_s;
774
+ #endif
775
+ #ifdef USE_COMBINATION_EXPLOSION_CHECK
776
+ void* state_check_buff;
777
+ int state_check_buff_size;
778
+ #endif
779
+ } OnigMatchArg;
780
+
781
+
782
+ #define IS_CODE_SB_WORD(enc,code) \
783
+ (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
784
+
785
+ #ifdef ONIG_DEBUG
786
+
787
+ typedef struct {
788
+ short int opcode;
789
+ const char* name;
790
+ short int arg_type;
791
+ } OnigOpInfoType;
792
+
793
+ extern OnigOpInfoType OnigOpInfo[];
794
+
795
+ /* extern void onig_print_compiled_byte_code P_((FILE* f, UChar* bp, UChar* bpend, UChar** nextp, OnigEncoding enc)); */
796
+
797
+ #ifdef ONIG_DEBUG_STATISTICS
798
+ extern void onig_statistics_init P_((void));
799
+ extern void onig_print_statistics P_((FILE* f));
800
+ #endif
801
+ #endif
802
+
803
+ extern UChar* onig_error_code_to_format P_((int code));
804
+ extern void onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...));
805
+ extern int onig_bbuf_init P_((BBuf* buf, OnigDistance size));
806
+ extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo, const char *sourcefile, int sourceline));
807
+ extern void onig_chain_reduce P_((regex_t* reg));
808
+ extern void onig_chain_link_add P_((regex_t* to, regex_t* add));
809
+ extern void onig_transfer P_((regex_t* to, regex_t* from));
810
+ extern int onig_is_code_in_cc P_((OnigEncoding enc, OnigCodePoint code, CClassNode* cc));
811
+ extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, CClassNode* cc));
812
+
813
+ /* strend hash */
814
+ typedef void hash_table_type;
815
+ #ifdef RUBY
816
+ #include "ruby/st.h"
817
+ typedef st_data_t hash_data_type;
818
+ #else
819
+ typedef unsigned long hash_data_type;
820
+ #endif
821
+
822
+ extern hash_table_type* onig_st_init_strend_table_with_size P_((st_index_t size));
823
+ extern int onig_st_lookup_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value));
824
+ extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value));
825
+
826
+ /* encoding property management */
827
+ #define PROPERTY_LIST_ADD_PROP(Name, CR) \
828
+ r = onigenc_property_list_add_property((UChar* )Name, CR,\
829
+ &PropertyNameTable, &PropertyList, &PropertyListNum,\
830
+ &PropertyListSize);\
831
+ if (r != 0) goto end
832
+
833
+ #define PROPERTY_LIST_INIT_CHECK \
834
+ if (PropertyInited == 0) {\
835
+ int r = onigenc_property_list_init(init_property_list);\
836
+ if (r != 0) return r;\
837
+ }
838
+
839
+ extern int onigenc_property_list_add_property P_((UChar* name, const OnigCodePoint* prop, hash_table_type **table, const OnigCodePoint*** plist, int *pnum, int *psize));
840
+
841
+ typedef int (*ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void);
842
+
843
+ extern int onigenc_property_list_init P_((ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE));
844
+
845
+ extern size_t onig_memsize P_((const regex_t *reg));
846
+
847
+ #if defined __GNUC__ && __GNUC__ >= 4
848
+ #pragma GCC visibility pop
849
+ #endif
850
+
851
+ #endif /* ONIGURUMA_REGINT_H */