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