]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/RegularExpressionDxe/Oniguruma/regint.h
MdeModulePkg RegularExpressionDxe: Update Oniguruma to 6.9.0
[mirror_edk2.git] / MdeModulePkg / Universal / RegularExpressionDxe / Oniguruma / regint.h
1 #ifndef REGINT_H
2 #define REGINT_H
3 /**********************************************************************
4 regint.h - Oniguruma (regular expression library)
5 **********************************************************************/
6 /*-
7 * Copyright (c) 2002-2018 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 */
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) || 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__) || \
53 defined(__mc68020__)
54 #define PLATFORM_UNALIGNED_WORD_ACCESS
55 #endif
56
57 /* config */
58 /* spec. config */
59 #define USE_CALL
60 #define USE_CALLOUT
61 #define USE_BACKREF_WITH_LEVEL /* \k<name+n>, \k<name-n> */
62 #define USE_INSISTENT_CHECK_CAPTURES_IN_EMPTY_REPEAT /* /(?:()|())*\2/ */
63 #define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
64 #define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
65
66 #define USE_RETRY_LIMIT_IN_MATCH
67
68 /* internal config */
69 #define USE_OP_PUSH_OR_JUMP_EXACT
70 #define USE_QUANT_PEEK_NEXT
71 #define USE_ST_LIBRARY
72
73 #include "regenc.h"
74
75 #ifdef __cplusplus
76 # ifndef HAVE_STDARG_PROTOTYPES
77 # define HAVE_STDARG_PROTOTYPES 1
78 # endif
79 #endif
80
81 /* escape Mac OS X/Xcode 2.4/gcc 4.0.1 problem */
82 #if defined(__APPLE__) && defined(__GNUC__) && __GNUC__ >= 4
83 # ifndef HAVE_STDARG_PROTOTYPES
84 # define HAVE_STDARG_PROTOTYPES 1
85 # endif
86 #endif
87
88 #ifdef HAVE_STDARG_H
89 # ifndef HAVE_STDARG_PROTOTYPES
90 # define HAVE_STDARG_PROTOTYPES 1
91 # endif
92 #endif
93
94
95 #define INIT_MATCH_STACK_SIZE 160
96 #define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
97 #define DEFAULT_RETRY_LIMIT_IN_MATCH 10000000
98 #define DEFAULT_PARSE_DEPTH_LIMIT 4096
99
100 /* */
101 /* escape other system UChar definition */
102 #ifdef ONIG_ESCAPE_UCHAR_COLLISION
103 #undef ONIG_ESCAPE_UCHAR_COLLISION
104 #endif
105
106 #define USE_WORD_BEGIN_END /* "\<", "\>" */
107 #define USE_CAPTURE_HISTORY
108 #define USE_VARIABLE_META_CHARS
109 #define USE_POSIX_API_REGION_OPTION
110 #define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
111
112 #define xmalloc malloc
113 #define xrealloc realloc
114 #define xcalloc calloc
115 #define xfree free
116
117 #define st_init_table onig_st_init_table
118 #define st_init_table_with_size onig_st_init_table_with_size
119 #define st_init_numtable onig_st_init_numtable
120 #define st_init_numtable_with_size onig_st_init_numtable_with_size
121 #define st_init_strtable onig_st_init_strtable
122 #define st_init_strtable_with_size onig_st_init_strtable_with_size
123 #define st_delete onig_st_delete
124 #define st_delete_safe onig_st_delete_safe
125 #define st_insert onig_st_insert
126 #define st_lookup onig_st_lookup
127 #define st_foreach onig_st_foreach
128 #define st_add_direct onig_st_add_direct
129 #define st_free_table onig_st_free_table
130 #define st_cleanup_safe onig_st_cleanup_safe
131 #define st_copy onig_st_copy
132 #define st_nothing_key_clone onig_st_nothing_key_clone
133 #define st_nothing_key_free onig_st_nothing_key_free
134 /* */
135 #define onig_st_is_member st_is_member
136
137 //#define xmemset memset
138 //#define xmemcpy memcpy
139 //#define xmemmove memmove
140
141 #if defined(_WIN32) && !defined(__GNUC__)
142 #define xalloca _alloca
143 #define xvsnprintf(buf,size,fmt,args) _vsnprintf_s(buf,size,_TRUNCATE,fmt,args)
144 #define xsnprintf sprintf_s
145 #define xstrcat(dest,src,size) strcat_s(dest,size,src)
146 #else
147 #define xalloca alloca
148 #define xvsnprintf vsnprintf
149 #define xsnprintf snprintf
150 #define xstrcat(dest,src,size) strcat(dest,src)
151 #endif
152
153
154 // #include <stddef.h>
155
156 #ifdef HAVE_LIMITS_H
157 #include <limits.h>
158 #endif
159
160 #if 0
161 #ifdef HAVE_STDLIB_H
162 #include <stdlib.h>
163 #endif
164
165 #ifdef HAVE_STDINT_H
166 #include <stdint.h>
167 #endif
168
169 #if defined(HAVE_ALLOCA_H) && !defined(__GNUC__)
170 #include <alloca.h>
171 #endif
172
173 #ifdef HAVE_STRING_H
174 # include <string.h>
175 #else
176 # include <strings.h>
177 #endif
178
179 #include <ctype.h>
180 #ifdef HAVE_SYS_TYPES_H
181 #ifndef __BORLANDC__
182 #include <sys/types.h>
183 #endif
184 #endif
185
186 #ifdef HAVE_INTTYPES_H
187 #include <inttypes.h>
188 #endif
189
190 #ifdef __BORLANDC__
191 #include <malloc.h>
192 #endif
193
194 #ifdef ONIG_DEBUG
195 # include <stdio.h>
196 #endif
197 #endif
198
199 #ifdef _WIN32
200 #if defined(_MSC_VER) && (_MSC_VER < 1300)
201 typedef int intptr_t;
202 typedef unsigned int uintptr_t;
203 #endif
204 #endif
205
206 typedef INTN intptr_t;
207 typedef UINTN uintptr_t;
208
209 #ifndef offsetof
210 #define offsetof OFFSET_OF
211 #endif
212
213 #ifdef MIN
214 #undef MIN
215 #endif
216 #ifdef MAX
217 #undef MAX
218 #endif
219
220 #define MIN(a,b) (((a)>(b))?(b):(a))
221 #define MAX(a,b) (((a)<(b))?(b):(a))
222
223 #define IS_NULL(p) (((void*)(p)) == (void*)0)
224 #define IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
225 #define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL
226 #define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
227 #define NULL_UCHARP ((UChar* )0)
228
229 #define INFINITE_LEN ONIG_INFINITE_DISTANCE
230
231 #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
232
233 #define PLATFORM_GET_INC(val,p,type) do{\
234 val = *(type* )p;\
235 (p) += sizeof(type);\
236 } while(0)
237
238 #else
239
240 #define PLATFORM_GET_INC(val,p,type) do{\
241 xmemcpy(&val, (p), sizeof(type));\
242 (p) += sizeof(type);\
243 } while(0)
244
245 /* sizeof(OnigCodePoint) */
246 #ifdef SIZEOF_SIZE_T
247 # define WORD_ALIGNMENT_SIZE SIZEOF_SIZE_T
248 #else
249 # define WORD_ALIGNMENT_SIZE SIZEOF_LONG
250 #endif
251
252 #define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
253 (pad_size) = WORD_ALIGNMENT_SIZE - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
254 if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
255 } while (0)
256
257 #define ALIGNMENT_RIGHT(addr) do {\
258 (addr) += (WORD_ALIGNMENT_SIZE - 1);\
259 (addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
260 } while (0)
261
262 #endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
263
264
265 #ifdef USE_CALLOUT
266
267 typedef struct {
268 int flag;
269 OnigCalloutOf of;
270 int in;
271 int name_id;
272 const UChar* tag_start;
273 const UChar* tag_end;
274 OnigCalloutType type;
275 OnigCalloutFunc start_func;
276 OnigCalloutFunc end_func;
277 union {
278 struct {
279 const UChar* start;
280 const UChar* end;
281 } content;
282 struct {
283 int num;
284 int passed_num;
285 OnigType types[ONIG_CALLOUT_MAX_ARGS_NUM];
286 OnigValue vals[ONIG_CALLOUT_MAX_ARGS_NUM];
287 } arg;
288 } u;
289 } CalloutListEntry;
290
291 #endif
292
293 typedef struct {
294 const UChar* pattern;
295 const UChar* pattern_end;
296 #ifdef USE_CALLOUT
297 void* tag_table;
298 int callout_num;
299 int callout_list_alloc;
300 CalloutListEntry* callout_list; /* index: callout num */
301 #endif
302 } RegexExt;
303
304 #define REG_EXTP(reg) ((RegexExt* )((reg)->chain))
305 #define REG_EXTPL(reg) ((reg)->chain)
306
307 struct re_pattern_buffer {
308 /* common members of BBuf(bytes-buffer) */
309 unsigned char* p; /* compiled pattern */
310 unsigned int used; /* used space for p */
311 unsigned int alloc; /* allocated space for p */
312
313 int num_mem; /* used memory(...) num counted from 1 */
314 int num_repeat; /* OP_REPEAT/OP_REPEAT_NG id-counter */
315 int num_null_check; /* OP_EMPTY_CHECK_START/END id counter */
316 int num_comb_exp_check; /* no longer used (combination explosion check) */
317 int num_call; /* number of subexp call */
318 unsigned int capture_history; /* (?@...) flag (1-31) */
319 unsigned int bt_mem_start; /* need backtrack flag */
320 unsigned int bt_mem_end; /* need backtrack flag */
321 int stack_pop_level;
322 int repeat_range_alloc;
323 OnigRepeatRange* repeat_range;
324
325 OnigEncoding enc;
326 OnigOptionType options;
327 OnigSyntaxType* syntax;
328 OnigCaseFoldType case_fold_flag;
329 void* name_table;
330
331 /* optimization info (string search, char-map and anchors) */
332 int optimize; /* optimize flag */
333 int threshold_len; /* search str-length for apply optimize */
334 int anchor; /* BEGIN_BUF, BEGIN_POS, (SEMI_)END_BUF */
335 OnigLen anchor_dmin; /* (SEMI_)END_BUF anchor distance */
336 OnigLen anchor_dmax; /* (SEMI_)END_BUF anchor distance */
337 int sub_anchor; /* start-anchor for exact or map */
338 unsigned char *exact;
339 unsigned char *exact_end;
340 unsigned char map[ONIG_CHAR_TABLE_SIZE]; /* used as BM skip or char-map */
341 int *int_map; /* BM skip for exact_len > 255 */
342 int *int_map_backward; /* BM skip for backward search */
343 OnigLen dmin; /* min-distance of exact or map */
344 OnigLen dmax; /* max-distance of exact or map */
345
346 /* regex_t link chain */
347 struct re_pattern_buffer* chain; /* escape compile-conflict */
348 };
349
350
351 /* stack pop level */
352 enum StackPopLevel {
353 STACK_POP_LEVEL_FREE = 0,
354 STACK_POP_LEVEL_MEM_START = 1,
355 STACK_POP_LEVEL_ALL = 2
356 };
357
358 /* optimize flags */
359 enum OptimizeType {
360 OPTIMIZE_NONE = 0,
361 OPTIMIZE_EXACT = 1, /* Slow Search */
362 OPTIMIZE_EXACT_BM = 2, /* Boyer Moore Search */
363 OPTIMIZE_EXACT_BM_NO_REV = 3, /* BM (but not simple match) */
364 OPTIMIZE_EXACT_IC = 4, /* Slow Search (ignore case) */
365 OPTIMIZE_MAP = 5 /* char map */
366 };
367
368 /* bit status */
369 typedef unsigned int MemStatusType;
370
371 #define MEM_STATUS_BITS_NUM (sizeof(MemStatusType) * 8)
372 #define MEM_STATUS_CLEAR(stats) (stats) = 0
373 #define MEM_STATUS_ON_ALL(stats) (stats) = ~((MemStatusType )0)
374 #define MEM_STATUS_AT(stats,n) \
375 ((n) < (int )MEM_STATUS_BITS_NUM ? ((stats) & ((MemStatusType )1 << n)) : ((stats) & 1))
376 #define MEM_STATUS_AT0(stats,n) \
377 ((n) > 0 && (n) < (int )MEM_STATUS_BITS_NUM ? ((stats) & ((MemStatusType )1 << n)) : ((stats) & 1))
378
379 #define MEM_STATUS_ON(stats,n) do {\
380 if ((n) < (int )MEM_STATUS_BITS_NUM) {\
381 if ((n) != 0)\
382 (stats) |= ((MemStatusType )1 << (n));\
383 }\
384 else\
385 (stats) |= 1;\
386 } while (0)
387
388 #define MEM_STATUS_ON_SIMPLE(stats,n) do {\
389 if ((n) < (int )MEM_STATUS_BITS_NUM)\
390 (stats) |= ((MemStatusType )1 << (n));\
391 } while (0)
392
393
394 #define INT_MAX_LIMIT ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
395
396 #define IS_CODE_WORD_ASCII(enc,code) \
397 (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
398 #define IS_CODE_DIGIT_ASCII(enc, code) \
399 (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_DIGIT(enc,code))
400 #define IS_CODE_XDIGIT_ASCII(enc, code) \
401 (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_XDIGIT(enc,code))
402
403 #define DIGITVAL(code) ((code) - '0')
404 #define ODIGITVAL(code) DIGITVAL(code)
405 #define XDIGITVAL(enc,code) \
406 (IS_CODE_DIGIT_ASCII(enc,code) ? DIGITVAL(code) \
407 : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
408
409 #define IS_SINGLELINE(option) ((option) & ONIG_OPTION_SINGLELINE)
410 #define IS_MULTILINE(option) ((option) & ONIG_OPTION_MULTILINE)
411 #define IS_IGNORECASE(option) ((option) & ONIG_OPTION_IGNORECASE)
412 #define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND)
413 #define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST)
414 #define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
415 #define IS_FIND_CONDITION(option) ((option) & \
416 (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
417 #define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL)
418 #define IS_NOTEOL(option) ((option) & ONIG_OPTION_NOTEOL)
419 #define IS_POSIX_REGION(option) ((option) & ONIG_OPTION_POSIX_REGION)
420
421 #define IS_WORD_ASCII(option) \
422 ((option) & (ONIG_OPTION_WORD_IS_ASCII | ONIG_OPTION_POSIX_IS_ASCII))
423 #define IS_DIGIT_ASCII(option) \
424 ((option) & (ONIG_OPTION_DIGIT_IS_ASCII | ONIG_OPTION_POSIX_IS_ASCII))
425 #define IS_SPACE_ASCII(option) \
426 ((option) & (ONIG_OPTION_SPACE_IS_ASCII | ONIG_OPTION_POSIX_IS_ASCII))
427 #define IS_POSIX_ASCII(option) ((option) & ONIG_OPTION_POSIX_IS_ASCII)
428
429 #define IS_ASCII_MODE_CTYPE_OPTION(ctype, options) \
430 ((ctype) >= 0 && \
431 (((ctype) < ONIGENC_CTYPE_ASCII && IS_POSIX_ASCII(options)) ||\
432 ((ctype) == ONIGENC_CTYPE_WORD && IS_WORD_ASCII(options)) ||\
433 ((ctype) == ONIGENC_CTYPE_DIGIT && IS_DIGIT_ASCII(options)) ||\
434 ((ctype) == ONIGENC_CTYPE_SPACE && IS_SPACE_ASCII(options))))
435
436 #define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
437 ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
438
439 #define REPEAT_INFINITE -1
440 #define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE)
441
442 /* bitset */
443 #define BITS_PER_BYTE 8
444 #define SINGLE_BYTE_SIZE (1 << BITS_PER_BYTE)
445 #define BITS_IN_ROOM (sizeof(Bits) * BITS_PER_BYTE)
446 #define BITSET_SIZE (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
447
448 #ifdef PLATFORM_UNALIGNED_WORD_ACCESS
449 typedef unsigned int Bits;
450 #else
451 typedef unsigned char Bits;
452 #endif
453 typedef Bits BitSet[BITSET_SIZE];
454 typedef Bits* BitSetRef;
455
456 #define SIZE_BITSET sizeof(BitSet)
457
458 #define BITSET_CLEAR(bs) do {\
459 int i;\
460 for (i = 0; i < (int )BITSET_SIZE; i++) { (bs)[i] = 0; } \
461 } while (0)
462
463 #define BS_ROOM(bs,pos) (bs)[pos / BITS_IN_ROOM]
464 #define BS_BIT(pos) (1 << (pos % BITS_IN_ROOM))
465
466 #define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
467 #define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)
468 #define BITSET_CLEAR_BIT(bs, pos) BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
469 #define BITSET_INVERT_BIT(bs, pos) BS_ROOM(bs,pos) ^= BS_BIT(pos)
470
471 /* bytes buffer */
472 typedef struct _BBuf {
473 UChar* p;
474 unsigned int used;
475 unsigned int alloc;
476 } BBuf;
477
478 #define BB_INIT(buf,size) onig_bbuf_init((BBuf* )(buf), (size))
479
480 #define BB_SIZE_INC(buf,inc) do{\
481 (buf)->alloc += (inc);\
482 (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
483 if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
484 } while (0)
485
486 #define BB_EXPAND(buf,low) do{\
487 unsigned int OldSize_ = (buf)->alloc * sizeof((buf)->p[0]);\
488 do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
489 (buf)->p = (UChar* )xrealloc((buf)->p, (buf)->alloc, OldSize_);\
490 if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
491 } while (0)
492
493 #define BB_ENSURE_SIZE(buf,size) do{\
494 unsigned int new_alloc = (buf)->alloc;\
495 while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
496 if ((buf)->alloc != new_alloc) {\
497 (buf)->p = (UChar* )xrealloc((buf)->p, new_alloc, (buf)->alloc);\
498 if (IS_NULL((buf)->p)) return(ONIGERR_MEMORY);\
499 (buf)->alloc = new_alloc;\
500 }\
501 } while (0)
502
503 #define BB_WRITE(buf,pos,bytes,n) do{\
504 int used = (pos) + (n);\
505 if ((buf)->alloc < (unsigned int )used) BB_EXPAND((buf),used);\
506 xmemcpy((buf)->p + (pos), (bytes), (n));\
507 if ((buf)->used < (unsigned int )used) (buf)->used = used;\
508 } while (0)
509
510 #define BB_WRITE1(buf,pos,byte) do{\
511 int used = (pos) + 1;\
512 if ((buf)->alloc < (unsigned int )used) BB_EXPAND((buf),used);\
513 (buf)->p[(pos)] = (byte);\
514 if ((buf)->used < (unsigned int )used) (buf)->used = used;\
515 } while (0)
516
517 #define BB_ADD(buf,bytes,n) BB_WRITE((buf),(buf)->used,(bytes),(n))
518 #define BB_ADD1(buf,byte) BB_WRITE1((buf),(buf)->used,(byte))
519 #define BB_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
520 #define BB_GET_OFFSET_POS(buf) ((buf)->used)
521
522 /* from < to */
523 #define BB_MOVE_RIGHT(buf,from,to,n) do {\
524 if ((unsigned int )((to)+(n)) > (buf)->alloc) BB_EXPAND((buf),(to) + (n));\
525 xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
526 if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
527 } while (0)
528
529 /* from > to */
530 #define BB_MOVE_LEFT(buf,from,to,n) do {\
531 xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
532 } while (0)
533
534 /* from > to */
535 #define BB_MOVE_LEFT_REDUCE(buf,from,to) do {\
536 xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
537 (buf)->used -= (from - to);\
538 } while (0)
539
540 #define BB_INSERT(buf,pos,bytes,n) do {\
541 if (pos >= (buf)->used) {\
542 BB_WRITE(buf,pos,bytes,n);\
543 }\
544 else {\
545 BB_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
546 xmemcpy((buf)->p + (pos), (bytes), (n));\
547 }\
548 } while (0)
549
550 #define BB_GET_BYTE(buf, pos) (buf)->p[(pos)]
551
552
553 /* has body */
554 #define ANCHOR_PREC_READ (1<<0)
555 #define ANCHOR_PREC_READ_NOT (1<<1)
556 #define ANCHOR_LOOK_BEHIND (1<<2)
557 #define ANCHOR_LOOK_BEHIND_NOT (1<<3)
558 /* no body */
559 #define ANCHOR_BEGIN_BUF (1<<4)
560 #define ANCHOR_BEGIN_LINE (1<<5)
561 #define ANCHOR_BEGIN_POSITION (1<<6)
562 #define ANCHOR_END_BUF (1<<7)
563 #define ANCHOR_SEMI_END_BUF (1<<8)
564 #define ANCHOR_END_LINE (1<<9)
565 #define ANCHOR_WORD_BOUNDARY (1<<10)
566 #define ANCHOR_NO_WORD_BOUNDARY (1<<11)
567 #define ANCHOR_WORD_BEGIN (1<<12)
568 #define ANCHOR_WORD_END (1<<13)
569 #define ANCHOR_ANYCHAR_INF (1<<14)
570 #define ANCHOR_ANYCHAR_INF_ML (1<<15)
571 #define ANCHOR_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY (1<<16)
572 #define ANCHOR_NO_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY (1<<17)
573
574
575 #define ANCHOR_HAS_BODY(a) ((a)->type < ANCHOR_BEGIN_BUF)
576
577 #define IS_WORD_ANCHOR_TYPE(type) \
578 ((type) == ANCHOR_WORD_BOUNDARY || (type) == ANCHOR_NO_WORD_BOUNDARY || \
579 (type) == ANCHOR_WORD_BEGIN || (type) == ANCHOR_WORD_END)
580
581 /* operation code */
582 enum OpCode {
583 OP_FINISH = 0, /* matching process terminator (no more alternative) */
584 OP_END = 1, /* pattern code terminator (success end) */
585
586 OP_EXACT1 = 2, /* single byte, N = 1 */
587 OP_EXACT2, /* single byte, N = 2 */
588 OP_EXACT3, /* single byte, N = 3 */
589 OP_EXACT4, /* single byte, N = 4 */
590 OP_EXACT5, /* single byte, N = 5 */
591 OP_EXACTN, /* single byte */
592 OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
593 OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
594 OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
595 OP_EXACTMB2N, /* mb-length = 2 */
596 OP_EXACTMB3N, /* mb-length = 3 */
597 OP_EXACTMBN, /* other length */
598
599 OP_EXACT1_IC, /* single byte, N = 1, ignore case */
600 OP_EXACTN_IC, /* single byte, ignore case */
601
602 OP_CCLASS,
603 OP_CCLASS_MB,
604 OP_CCLASS_MIX,
605 OP_CCLASS_NOT,
606 OP_CCLASS_MB_NOT,
607 OP_CCLASS_MIX_NOT,
608 #ifdef USE_OP_CCLASS_NODE
609 OP_CCLASS_NODE, /* pointer to CClassNode node */
610 #endif
611
612 OP_ANYCHAR, /* "." */
613 OP_ANYCHAR_ML, /* "." multi-line */
614 OP_ANYCHAR_STAR, /* ".*" */
615 OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
616 OP_ANYCHAR_STAR_PEEK_NEXT,
617 OP_ANYCHAR_ML_STAR_PEEK_NEXT,
618
619 OP_WORD,
620 OP_WORD_ASCII,
621 OP_NO_WORD,
622 OP_NO_WORD_ASCII,
623 OP_WORD_BOUNDARY,
624 OP_NO_WORD_BOUNDARY,
625 OP_WORD_BEGIN,
626 OP_WORD_END,
627
628 OP_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY,
629 OP_NO_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY,
630
631 OP_BEGIN_BUF,
632 OP_END_BUF,
633 OP_BEGIN_LINE,
634 OP_END_LINE,
635 OP_SEMI_END_BUF,
636 OP_BEGIN_POSITION,
637
638 OP_BACKREF1,
639 OP_BACKREF2,
640 OP_BACKREF_N,
641 OP_BACKREF_N_IC,
642 OP_BACKREF_MULTI,
643 OP_BACKREF_MULTI_IC,
644 OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
645 OP_BACKREF_CHECK, /* (?(n)), (?('name')) */
646 OP_BACKREF_CHECK_WITH_LEVEL, /* (?(n-level)), (?('name-level')) */
647
648 OP_MEMORY_START,
649 OP_MEMORY_START_PUSH, /* push back-tracker to stack */
650 OP_MEMORY_END_PUSH, /* push back-tracker to stack */
651 OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
652 OP_MEMORY_END,
653 OP_MEMORY_END_REC, /* push marker to stack */
654
655 OP_FAIL, /* pop stack and move */
656 OP_JUMP,
657 OP_PUSH,
658 OP_PUSH_SUPER,
659 OP_POP_OUT,
660 OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
661 OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
662 OP_REPEAT, /* {n,m} */
663 OP_REPEAT_NG, /* {n,m}? (non greedy) */
664 OP_REPEAT_INC,
665 OP_REPEAT_INC_NG, /* non greedy */
666 OP_REPEAT_INC_SG, /* search and get in stack */
667 OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
668 OP_EMPTY_CHECK_START, /* null loop checker start */
669 OP_EMPTY_CHECK_END, /* null loop checker end */
670 OP_EMPTY_CHECK_END_MEMST, /* null loop checker end (with capture status) */
671 OP_EMPTY_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
672
673 OP_PREC_READ_START, /* (?=...) start */
674 OP_PREC_READ_END, /* (?=...) end */
675 OP_PREC_READ_NOT_START, /* (?!...) start */
676 OP_PREC_READ_NOT_END, /* (?!...) end */
677 OP_ATOMIC_START, /* (?>...) start */
678 OP_ATOMIC_END, /* (?>...) end */
679 OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
680 OP_LOOK_BEHIND_NOT_START, /* (?<!...) start */
681 OP_LOOK_BEHIND_NOT_END, /* (?<!...) end */
682
683 OP_CALL, /* \g<name> */
684 OP_RETURN,
685 OP_PUSH_SAVE_VAL,
686 OP_UPDATE_VAR,
687 #ifdef USE_CALLOUT
688 OP_CALLOUT_CONTENTS, /* (?{...}) (?{{...}}) */
689 OP_CALLOUT_NAME, /* (*name) (*name[tag](args...)) */
690 #endif
691 };
692
693 enum SaveType {
694 SAVE_KEEP = 0, /* SAVE S */
695 SAVE_S = 1,
696 SAVE_RIGHT_RANGE = 2,
697 };
698
699 enum UpdateVarType {
700 UPDATE_VAR_KEEP_FROM_STACK_LAST = 0,
701 UPDATE_VAR_S_FROM_STACK = 1,
702 UPDATE_VAR_RIGHT_RANGE_FROM_STACK = 2,
703 UPDATE_VAR_RIGHT_RANGE_FROM_S_STACK = 3,
704 UPDATE_VAR_RIGHT_RANGE_INIT = 4,
705 };
706
707 typedef int RelAddrType;
708 typedef int AbsAddrType;
709 typedef int LengthType;
710 typedef int RepeatNumType;
711 typedef int MemNumType;
712 typedef void* PointerType;
713 typedef int SaveType;
714 typedef int UpdateVarType;
715 typedef int ModeType;
716
717 #define SIZE_OPCODE 1
718 #define SIZE_RELADDR sizeof(RelAddrType)
719 #define SIZE_ABSADDR sizeof(AbsAddrType)
720 #define SIZE_LENGTH sizeof(LengthType)
721 #define SIZE_MEMNUM sizeof(MemNumType)
722 #define SIZE_REPEATNUM sizeof(RepeatNumType)
723 #define SIZE_OPTION sizeof(OnigOptionType)
724 #define SIZE_CODE_POINT sizeof(OnigCodePoint)
725 #define SIZE_POINTER sizeof(PointerType)
726 #define SIZE_SAVE_TYPE sizeof(SaveType)
727 #define SIZE_UPDATE_VAR_TYPE sizeof(UpdateVarType)
728 #define SIZE_MODE sizeof(ModeType)
729
730 #define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
731 #define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
732 #define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
733 #define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
734 #define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
735 #define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
736 #define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
737 #define GET_SAVE_TYPE_INC(type,p) PLATFORM_GET_INC(type, p, SaveType)
738 #define GET_UPDATE_VAR_TYPE_INC(type,p) PLATFORM_GET_INC(type, p, UpdateVarType)
739 #define GET_MODE_INC(mode,p) PLATFORM_GET_INC(mode, p, ModeType)
740
741 /* code point's address must be aligned address. */
742 #define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
743 #define GET_BYTE_INC(byte,p) do{\
744 byte = *(p);\
745 (p)++;\
746 } while(0)
747
748
749 /* op-code + arg size */
750 #define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
751 #define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
752 #define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
753 #define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
754 #define SIZE_OP_PUSH_SUPER (SIZE_OPCODE + SIZE_RELADDR)
755 #define SIZE_OP_POP_OUT SIZE_OPCODE
756 #define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
757 #define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
758 #define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
759 #define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
760 #define SIZE_OP_WORD_BOUNDARY (SIZE_OPCODE + SIZE_MODE)
761 #define SIZE_OP_PREC_READ_START SIZE_OPCODE
762 #define SIZE_OP_PREC_READ_NOT_START (SIZE_OPCODE + SIZE_RELADDR)
763 #define SIZE_OP_PREC_READ_END SIZE_OPCODE
764 #define SIZE_OP_PREC_READ_NOT_END SIZE_OPCODE
765 #define SIZE_OP_FAIL SIZE_OPCODE
766 #define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
767 #define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
768 #define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
769 #define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
770 #define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
771 #define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
772 #define SIZE_OP_ATOMIC_START SIZE_OPCODE
773 #define SIZE_OP_ATOMIC_END SIZE_OPCODE
774 #define SIZE_OP_EMPTY_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
775 #define SIZE_OP_EMPTY_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
776 #define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
777 #define SIZE_OP_LOOK_BEHIND_NOT_START (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
778 #define SIZE_OP_LOOK_BEHIND_NOT_END SIZE_OPCODE
779 #define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
780 #define SIZE_OP_RETURN SIZE_OPCODE
781 #define SIZE_OP_PUSH_SAVE_VAL (SIZE_OPCODE + SIZE_SAVE_TYPE + SIZE_MEMNUM)
782 #define SIZE_OP_UPDATE_VAR (SIZE_OPCODE + SIZE_UPDATE_VAR_TYPE + SIZE_MEMNUM)
783
784 #ifdef USE_CALLOUT
785 #define SIZE_OP_CALLOUT_CONTENTS (SIZE_OPCODE + SIZE_MEMNUM)
786 #define SIZE_OP_CALLOUT_NAME (SIZE_OPCODE + SIZE_MEMNUM + SIZE_MEMNUM)
787 #endif
788
789 #define MC_ESC(syn) (syn)->meta_char_table.esc
790 #define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
791 #define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
792 #define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
793 #define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
794 #define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
795
796 #define IS_MC_ESC_CODE(code, syn) \
797 ((code) == MC_ESC(syn) && \
798 !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
799
800
801 #define SYN_POSIX_COMMON_OP \
802 ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
803 ONIG_SYN_OP_DECIMAL_BACKREF | \
804 ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
805 ONIG_SYN_OP_LINE_ANCHOR | \
806 ONIG_SYN_OP_ESC_CONTROL_CHARS )
807
808 #define SYN_GNU_REGEX_OP \
809 ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
810 ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
811 ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
812 ONIG_SYN_OP_VBAR_ALT | \
813 ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
814 ONIG_SYN_OP_QMARK_ZERO_ONE | \
815 ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
816 ONIG_SYN_OP_ESC_W_WORD | \
817 ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
818 ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
819 ONIG_SYN_OP_LINE_ANCHOR )
820
821 #define SYN_GNU_REGEX_BV \
822 ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
823 ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
824 ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
825
826
827 #define NCCLASS_FLAGS(cc) ((cc)->flags)
828 #define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
829 #define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
830 #define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
831
832 /* cclass node */
833 #define FLAG_NCCLASS_NOT (1<<0)
834 #define FLAG_NCCLASS_SHARE (1<<1)
835
836 #define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
837 #define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
838 #define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
839
840 extern void onig_add_end_call(void (*func)(void));
841
842
843 #ifdef ONIG_DEBUG
844
845 #ifdef ONIG_DEBUG_COMPILE
846 extern void onig_print_compiled_byte_code_list(FILE* f, regex_t* reg);
847 #endif
848
849 #ifdef ONIG_DEBUG_STATISTICS
850 extern void onig_statistics_init P_((void));
851 extern int onig_print_statistics P_((FILE* f));
852 #endif
853 #endif
854
855 extern void onig_warning(const char* s);
856 extern UChar* onig_error_code_to_format P_((int code));
857 extern void EFIAPI onig_snprintf_with_pattern PV_((UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const UChar *fmt, ...));
858 extern int onig_bbuf_init P_((BBuf* buf, int size));
859 extern int onig_compile P_((regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo));
860 extern void onig_transfer P_((regex_t* to, regex_t* from));
861 extern int onig_is_code_in_cc_len P_((int enclen, OnigCodePoint code, void* /* CClassNode* */ cc));
862 extern RegexExt* onig_get_regex_ext(regex_t* reg);
863 extern int onig_ext_set_pattern(regex_t* reg, const UChar* pattern, const UChar* pattern_end);
864
865 #ifdef USE_CALLOUT
866
867 extern OnigCalloutType onig_get_callout_type_by_name_id(int name_id);
868 extern OnigCalloutFunc onig_get_callout_start_func_by_name_id(int id);
869 extern OnigCalloutFunc onig_get_callout_end_func_by_name_id(int id);
870 extern int onig_callout_tag_table_free(void* table);
871 extern void onig_free_reg_callout_list(int n, CalloutListEntry* list);
872 extern CalloutListEntry* onig_reg_callout_list_at(regex_t* reg, int num);
873 extern OnigCalloutFunc onig_get_callout_start_func(regex_t* reg, int callout_num);
874
875 /* for definition of builtin callout */
876 #define BC0_P(name, func) do {\
877 int len = onigenc_str_bytelen_null(enc, (UChar* )name);\
878 id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,\
879 (UChar* )(name), (UChar* )((name) + len),\
880 ONIG_CALLOUT_IN_PROGRESS,\
881 onig_builtin_ ## func, 0, 0, 0, 0, 0);\
882 if (id < 0) return id;\
883 } while(0)
884
885 #define BC0_R(name, func) do {\
886 int len = onigenc_str_bytelen_null(enc, (UChar* )name);\
887 id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,\
888 (UChar* )(name), (UChar* )((name) + len),\
889 ONIG_CALLOUT_IN_RETRACTION,\
890 onig_builtin_ ## func, 0, 0, 0, 0, 0);\
891 if (id < 0) return id;\
892 } while(0)
893
894 #define BC0_B(name, func) do {\
895 int len = onigenc_str_bytelen_null(enc, (UChar* )name);\
896 id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,\
897 (UChar* )(name), (UChar* )((name) + len),\
898 ONIG_CALLOUT_IN_BOTH,\
899 onig_builtin_ ## func, 0, 0, 0, 0, 0);\
900 if (id < 0) return id;\
901 } while(0)
902
903 #define BC_P(name, func, na, ts) do {\
904 int len = onigenc_str_bytelen_null(enc, (UChar* )name);\
905 id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,\
906 (UChar* )(name), (UChar* )((name) + len),\
907 ONIG_CALLOUT_IN_PROGRESS,\
908 onig_builtin_ ## func, 0, (na), (ts), 0, 0); \
909 if (id < 0) return id;\
910 } while(0)
911
912 #define BC_P_O(name, func, nts, ts, nopts, opts) do {\
913 int len = onigenc_str_bytelen_null(enc, (UChar* )name);\
914 id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,\
915 (UChar* )(name), (UChar* )((name) + len),\
916 ONIG_CALLOUT_IN_PROGRESS,\
917 onig_builtin_ ## func, 0, (nts), (ts), (nopts), (opts));\
918 if (id < 0) return id;\
919 } while(0)
920
921 #define BC_B(name, func, na, ts) do {\
922 int len = onigenc_str_bytelen_null(enc, (UChar* )name);\
923 id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,\
924 (UChar* )(name), (UChar* )((name) + len),\
925 ONIG_CALLOUT_IN_BOTH,\
926 onig_builtin_ ## func, 0, (na), (ts), 0, 0);\
927 if (id < 0) return id;\
928 } while(0)
929
930 #define BC_B_O(name, func, nts, ts, nopts, opts) do {\
931 int len = onigenc_str_bytelen_null(enc, (UChar* )name);\
932 id = onig_set_callout_of_name(enc, ONIG_CALLOUT_TYPE_SINGLE,\
933 (UChar* )(name), (UChar* )((name) + len),\
934 ONIG_CALLOUT_IN_BOTH,\
935 onig_builtin_ ## func, 0, (nts), (ts), (nopts), (opts));\
936 if (id < 0) return id;\
937 } while(0)
938
939 #endif /* USE_CALLOUT */
940
941
942 /* strend hash */
943 typedef void hash_table_type;
944
945 #ifdef _WIN32
946 # include <windows.h>
947 typedef ULONG_PTR hash_data_type;
948 #else
949 //typedef unsigned long hash_data_type;
950 #endif
951
952 typedef UINTN hash_data_type;
953
954 extern hash_table_type* onig_st_init_strend_table_with_size P_((int size));
955 extern int onig_st_lookup_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value));
956 extern int onig_st_insert_strend P_((hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value));
957
958 typedef int (*ONIGENC_INIT_PROPERTY_LIST_FUNC_TYPE)(void);
959
960 #endif /* REGINT_H */
961 #include <ProcessorBind.h>
962 #define INT_MAX MAX_INTN
963 #define LONG_MAX MAX_UINTN