Ruby 3.5.0dev (2025-11-03 revision 4a3d8346a6d0e068508631541f6bc43e8b154ea1)
regint.h (4a3d8346a6d0e068508631541f6bc43e8b154ea1)
1#ifndef ONIGMO_REGINT_H
2#define ONIGMO_REGINT_H
3/**********************************************************************
4 regint.h - Onigmo (Oniguruma-mod) (regular expression library)
5**********************************************************************/
6/*-
7 * Copyright (c) 2002-2013 K.Kosako <sndgk393 AT ybb DOT ne DOT jp>
8 * Copyright (c) 2011-2016 K.Takata <kentkt AT csc DOT jp>
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33/* for debug */
34/* #define ONIG_DEBUG_PARSE_TREE */
35/* #define ONIG_DEBUG_COMPILE */
36/* #define ONIG_DEBUG_SEARCH */
37/* #define ONIG_DEBUG_MATCH */
38/* #define ONIG_DEBUG_MATCH_CACHE */
39/* #define ONIG_DEBUG_MEMLEAK */
40/* #define ONIG_DONT_OPTIMIZE */
41
42/* for byte-code statistical data. */
43/* #define ONIG_DEBUG_STATISTICS */
44
45/* enable the match optimization by using a cache. */
46#define USE_MATCH_CACHE
47
48#if defined(ONIG_DEBUG_PARSE_TREE) || defined(ONIG_DEBUG_MATCH) || \
49 defined(ONIG_DEBUG_SEARCH) || defined(ONIG_DEBUG_COMPILE) || \
50 defined(ONIG_DEBUG_STATISTICS) || defined(ONIG_DEBUG_MEMLEAK)
51# ifndef ONIG_DEBUG
52# define ONIG_DEBUG
53# endif
54#endif
55
56/* __POWERPC__ added to accommodate Darwin case. */
57#ifndef UNALIGNED_WORD_ACCESS
58# if defined(__i386) || defined(__i386__) || defined(_M_IX86) || \
59 defined(__x86_64) || defined(__x86_64__) || defined(_M_AMD64) || \
60 defined(__powerpc64__) || defined(__POWERPC__) || defined(__aarch64__) || \
61 defined(__mc68020__)
62# define UNALIGNED_WORD_ACCESS 1
63# else
64# define UNALIGNED_WORD_ACCESS 0
65# endif
66#endif
67
68#if UNALIGNED_WORD_ACCESS
69# define PLATFORM_UNALIGNED_WORD_ACCESS
70#endif
71
72/* config */
73/* spec. config */
74#define USE_NAMED_GROUP
75#define USE_SUBEXP_CALL
76#define USE_PERL_SUBEXP_CALL
77#define USE_CAPITAL_P_NAMED_GROUP
78#define USE_BACKREF_WITH_LEVEL /* \k<name+n>, \k<name-n> */
79#define USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT /* /(?:()|())*\2/ */
80#define USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE /* /\n$/ =~ "\n" */
81#define USE_WARNING_REDUNDANT_NESTED_REPEAT_OPERATOR
82/* !!! moved to regenc.h. */ /* #define USE_CRNL_AS_LINE_TERMINATOR */
83#define USE_NO_INVALID_QUANTIFIER
84
85/* internal config */
86/* #define USE_OP_PUSH_OR_JUMP_EXACT */
87#define USE_QTFR_PEEK_NEXT
88#define USE_ST_LIBRARY
89
90#define INIT_MATCH_STACK_SIZE 160
91#define DEFAULT_MATCH_STACK_LIMIT_SIZE 0 /* unlimited */
92#define DEFAULT_PARSE_DEPTH_LIMIT 4096
93
94#define OPT_EXACT_MAXLEN 24
95
96/* check config */
97#if defined(USE_PERL_SUBEXP_CALL) || defined(USE_CAPITAL_P_NAMED_GROUP)
98# if !defined(USE_NAMED_GROUP) || !defined(USE_SUBEXP_CALL)
99# error USE_NAMED_GROUP and USE_SUBEXP_CALL must be defined.
100# endif
101#endif
102
103#if defined(__GNUC__)
104# define ARG_UNUSED __attribute__ ((unused))
105#else
106# define ARG_UNUSED
107#endif
108
109#if !defined(RUBY) && defined(RUBY_EXPORT)
110# define RUBY
111#endif
112#ifdef RUBY
113# ifndef RUBY_DEFINES_H
114# include "ruby/ruby.h"
115# undef xmalloc
116# undef xrealloc
117# undef xcalloc
118# undef xfree
119# endif
120#else /* RUBY */
121# include "config.h"
122# if SIZEOF_LONG_LONG > 0
123# define LONG_LONG long long
124# endif
125#endif /* RUBY */
126
127#include <stdarg.h>
128
129/* */
130/* escape other system UChar definition */
131#ifdef ONIG_ESCAPE_UCHAR_COLLISION
132# undef ONIG_ESCAPE_UCHAR_COLLISION
133#endif
134
135#define USE_WORD_BEGIN_END /* "<": word-begin, ">": word-end */
136#ifdef RUBY
137# undef USE_CAPTURE_HISTORY
138#else
139# define USE_CAPTURE_HISTORY
140#endif
141#define USE_VARIABLE_META_CHARS
142#define USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
143/* #define USE_COMBINATION_EXPLOSION_CHECK */ /* (X*)* */
144
145
146#ifndef xmalloc
147# define xmalloc malloc
148# define xrealloc realloc
149# define xcalloc calloc
150# define xfree free
151#endif
152
153#ifdef RUBY
154
155# define CHECK_INTERRUPT_IN_MATCH_AT do { \
156 msa->counter++; \
157 if (msa->counter >= 128) { \
158 msa->counter = 0; \
159 if (rb_reg_timeout_p(reg, &msa->end_time)) { \
160 goto timeout; \
161 } \
162 rb_thread_check_ints(); \
163 } \
164} while(0)
165# define onig_st_init_table st_init_table
166# define onig_st_init_table_with_size st_init_table_with_size
167# define onig_st_init_numtable st_init_numtable
168# define onig_st_init_numtable_with_size st_init_numtable_with_size
169# define onig_st_init_strtable st_init_strtable
170# define onig_st_init_strtable_with_size st_init_strtable_with_size
171# define onig_st_delete st_delete
172# define onig_st_delete_safe st_delete_safe
173# define onig_st_insert st_insert
174# define onig_st_lookup st_lookup
175# define onig_st_foreach st_foreach
176# define onig_st_add_direct st_add_direct
177# define onig_st_free_table st_free_table
178# define onig_st_cleanup_safe st_cleanup_safe
179# define onig_st_copy st_copy
180# define onig_st_nothing_key_clone st_nothing_key_clone
181# define onig_st_nothing_key_free st_nothing_key_free
182# define onig_st_is_member st_is_member
183
184# define USE_UPPER_CASE_TABLE
185#else /* RUBY */
186
187# define CHECK_INTERRUPT_IN_MATCH_AT
188
189# define st_init_table onig_st_init_table
190# define st_init_table_with_size onig_st_init_table_with_size
191# define st_init_numtable onig_st_init_numtable
192# define st_init_numtable_with_size onig_st_init_numtable_with_size
193# define st_init_strtable onig_st_init_strtable
194# define st_init_strtable_with_size onig_st_init_strtable_with_size
195# define st_delete onig_st_delete
196# define st_delete_safe onig_st_delete_safe
197# define st_insert onig_st_insert
198# define st_lookup onig_st_lookup
199# define st_foreach onig_st_foreach
200# define st_add_direct onig_st_add_direct
201# define st_free_table onig_st_free_table
202# define st_cleanup_safe onig_st_cleanup_safe
203# define st_copy onig_st_copy
204# define st_nothing_key_clone onig_st_nothing_key_clone
205# define st_nothing_key_free onig_st_nothing_key_free
206/* */
207# define onig_st_is_member st_is_member
208
209#endif /* RUBY */
210
211#define STATE_CHECK_STRING_THRESHOLD_LEN 7
212#define STATE_CHECK_BUFF_MAX_SIZE 0x4000
213
214#define xmemset memset
215#define xmemcpy memcpy
216#define xmemmove memmove
217
218#if ((defined(RUBY_MSVCRT_VERSION) && RUBY_MSVCRT_VERSION >= 90) \
219 || (!defined(RUBY_MSVCRT_VERSION) && defined(_WIN32))) \
220 && !defined(__GNUC__)
221# define xalloca _alloca
222# define xvsnprintf(buf,size,fmt,args) _vsnprintf_s(buf,size,_TRUNCATE,fmt,args)
223# define xsnprintf sprintf_s
224# define xstrcat(dest,src,size) strcat_s(dest,size,src)
225#else
226# define xalloca alloca
227# define xvsnprintf vsnprintf
228# define xsnprintf snprintf
229# define xstrcat(dest,src,size) strcat(dest,src)
230#endif
231
232#if defined(ONIG_DEBUG_MEMLEAK) && defined(_MSC_VER)
233# define _CRTDBG_MAP_ALLOC
234# include <malloc.h>
235# include <crtdbg.h>
236#endif
237
238#include <stdlib.h>
239
240#if defined(HAVE_ALLOCA_H) && (defined(_AIX) || !defined(__GNUC__))
241# include <alloca.h>
242#endif
243
244#include <string.h>
245
246#include <ctype.h>
247#ifdef HAVE_SYS_TYPES_H
248# include <sys/types.h>
249#endif
250
251#ifdef HAVE_STDINT_H
252# include <stdint.h>
253#endif
254
255#ifdef HAVE_INTTYPES_H
256# include <inttypes.h>
257#endif
258
259#include <stddef.h>
260
261#ifdef _WIN32
262# include <malloc.h> /* for alloca() */
263#endif
264
265#ifdef ONIG_DEBUG
266# include <stdio.h>
267#endif
268
269#ifdef _WIN32
270# if defined(_MSC_VER) && (_MSC_VER < 1300)
271# ifndef _INTPTR_T_DEFINED
272# define _INTPTR_T_DEFINED
273typedef int intptr_t;
274# endif
275# ifndef _UINTPTR_T_DEFINED
276# define _UINTPTR_T_DEFINED
277typedef unsigned int uintptr_t;
278# endif
279# endif
280#endif /* _WIN32 */
281
282#ifndef PRIdPTR
283# ifdef _WIN64
284# define PRIdPTR "I64d"
285# define PRIuPTR "I64u"
286# define PRIxPTR "I64x"
287# else
288# define PRIdPTR "ld"
289# define PRIuPTR "lu"
290# define PRIxPTR "lx"
291# endif
292#endif
293
294#ifndef PRIdPTRDIFF
295# define PRIdPTRDIFF PRIdPTR
296#endif
297
298#include "regenc.h"
299
300RUBY_SYMBOL_EXPORT_BEGIN
301
302#ifdef MIN
303# undef MIN
304#endif
305#ifdef MAX
306# undef MAX
307#endif
308#define MIN(a,b) (((a)>(b))?(b):(a))
309#define MAX(a,b) (((a)<(b))?(b):(a))
310
311#define IS_NULL(p) (((void*)(p)) == (void*)0)
312#define IS_NOT_NULL(p) (((void*)(p)) != (void*)0)
313#define CHECK_NULL_RETURN(p) if (IS_NULL(p)) return NULL
314#define CHECK_NULL_RETURN_MEMERR(p) if (IS_NULL(p)) return ONIGERR_MEMORY
315#define NULL_UCHARP ((UChar* )0)
316
317#define ONIG_LAST_CODE_POINT (~((OnigCodePoint )0))
318
319#define PLATFORM_GET_INC_ARGUMENTS_ASSERT(val, type) \
320 ((void)sizeof(char[2 * (sizeof(val) == sizeof(type)) - 1]))
321
322#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
323
324# define PLATFORM_GET_INC(val,p,type) do{\
325 PLATFORM_GET_INC_ARGUMENTS_ASSERT(val, type);\
326 val = *(type* )p;\
327 (p) += sizeof(type);\
328} while(0)
329
330#else
331
332# define PLATFORM_GET_INC(val,p,type) do{\
333 PLATFORM_GET_INC_ARGUMENTS_ASSERT(val, type);\
334 type platform_get_value;\
335 xmemcpy(&platform_get_value, (p), sizeof(type));\
336 val = platform_get_value;\
337 (p) += sizeof(type);\
338} while(0)
339
340/* sizeof(OnigCodePoint) */
341# define WORD_ALIGNMENT_SIZE SIZEOF_LONG
342
343# define GET_ALIGNMENT_PAD_SIZE(addr,pad_size) do {\
344 (pad_size) = WORD_ALIGNMENT_SIZE \
345 - ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
346 if ((pad_size) == WORD_ALIGNMENT_SIZE) (pad_size) = 0;\
347} while (0)
348
349# define ALIGNMENT_RIGHT(addr) do {\
350 (addr) += (WORD_ALIGNMENT_SIZE - 1);\
351 (addr) -= ((uintptr_t )(addr) % WORD_ALIGNMENT_SIZE);\
352} while (0)
353
354#endif /* PLATFORM_UNALIGNED_WORD_ACCESS */
355
356/* stack pop level */
357#define STACK_POP_LEVEL_FREE 0
358#define STACK_POP_LEVEL_MEM_START 1
359#define STACK_POP_LEVEL_ALL 2
360
361/* optimize flags */
362#define ONIG_OPTIMIZE_NONE 0
363#define ONIG_OPTIMIZE_EXACT 1 /* Slow Search */
364#define ONIG_OPTIMIZE_EXACT_BM 2 /* Boyer Moore Search */
365#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV 3 /* BM (applied to a multibyte string) */
366#define ONIG_OPTIMIZE_EXACT_IC 4 /* Slow Search (ignore case) */
367#define ONIG_OPTIMIZE_MAP 5 /* char map */
368#define ONIG_OPTIMIZE_EXACT_BM_IC 6 /* BM (ignore case) */
369#define ONIG_OPTIMIZE_EXACT_BM_NOT_REV_IC 7 /* BM (applied to a multibyte string) (ignore case) */
370
371/* bit status */
372typedef unsigned int BitStatusType;
373
374#define BIT_STATUS_BITS_NUM (sizeof(BitStatusType) * 8)
375#define BIT_STATUS_CLEAR(stats) (stats) = 0
376#define BIT_STATUS_ON_ALL(stats) (stats) = ~((BitStatusType )0)
377#define BIT_STATUS_AT(stats,n) \
378 ((n) < (int )BIT_STATUS_BITS_NUM ? ((stats) & ((BitStatusType )1 << n)) : ((stats) & 1))
379
380#define BIT_STATUS_ON_AT(stats,n) do {\
381 if ((n) < (int )BIT_STATUS_BITS_NUM)\
382 (stats) |= (1 << (n));\
383 else\
384 (stats) |= 1;\
385} while (0)
386
387#define BIT_STATUS_ON_AT_SIMPLE(stats,n) do {\
388 if ((n) < (int )BIT_STATUS_BITS_NUM)\
389 (stats) |= (1 << (n));\
390} while (0)
391
392
393#define INT_MAX_LIMIT ((1UL << (SIZEOF_INT * 8 - 1)) - 1)
394#define LONG_MAX_LIMIT ((1UL << (SIZEOF_LONG * 8 - 1)) - 1)
395
396#define DIGITVAL(code) ((code) - '0')
397#define ODIGITVAL(code) DIGITVAL(code)
398#define XDIGITVAL(enc,code) \
399 (ONIGENC_IS_CODE_DIGIT(enc,code) ? DIGITVAL(code) \
400 : (ONIGENC_IS_CODE_UPPER(enc,code) ? (code) - 'A' + 10 : (code) - 'a' + 10))
401
402#define IS_SINGLELINE(option) ((option) & ONIG_OPTION_SINGLELINE)
403#define IS_MULTILINE(option) ((option) & ONIG_OPTION_MULTILINE)
404#define IS_IGNORECASE(option) ((option) & ONIG_OPTION_IGNORECASE)
405#define IS_EXTEND(option) ((option) & ONIG_OPTION_EXTEND)
406#define IS_FIND_LONGEST(option) ((option) & ONIG_OPTION_FIND_LONGEST)
407#define IS_FIND_NOT_EMPTY(option) ((option) & ONIG_OPTION_FIND_NOT_EMPTY)
408#define IS_FIND_CONDITION(option) ((option) & \
409 (ONIG_OPTION_FIND_LONGEST | ONIG_OPTION_FIND_NOT_EMPTY))
410#define IS_NOTBOL(option) ((option) & ONIG_OPTION_NOTBOL)
411#define IS_NOTEOL(option) ((option) & ONIG_OPTION_NOTEOL)
412#define IS_NOTBOS(option) ((option) & ONIG_OPTION_NOTBOS)
413#define IS_NOTEOS(option) ((option) & ONIG_OPTION_NOTEOS)
414#define IS_ASCII_RANGE(option) ((option) & ONIG_OPTION_ASCII_RANGE)
415#define IS_POSIX_BRACKET_ALL_RANGE(option) ((option) & ONIG_OPTION_POSIX_BRACKET_ALL_RANGE)
416#define IS_WORD_BOUND_ALL_RANGE(option) ((option) & ONIG_OPTION_WORD_BOUND_ALL_RANGE)
417#define IS_NEWLINE_CRLF(option) ((option) & ONIG_OPTION_NEWLINE_CRLF)
418
419/* OP_SET_OPTION is required for these options.
420#define IS_DYNAMIC_OPTION(option) \
421 (((option) & (ONIG_OPTION_MULTILINE | ONIG_OPTION_IGNORECASE)) != 0)
422*/
423/* ignore-case and multibyte status are included in compiled code. */
424#define IS_DYNAMIC_OPTION(option) 0
425
426#define DISABLE_CASE_FOLD_MULTI_CHAR(case_fold_flag) \
427 ((case_fold_flag) & ~INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR)
428
429#define REPEAT_INFINITE -1
430#define IS_REPEAT_INFINITE(n) ((n) == REPEAT_INFINITE)
431
432/* bitset */
433#define BITS_PER_BYTE 8
434#define SINGLE_BYTE_SIZE (1 << BITS_PER_BYTE)
435#define BITS_IN_ROOM ((int )sizeof(Bits) * BITS_PER_BYTE)
436#define BITSET_SIZE (SINGLE_BYTE_SIZE / BITS_IN_ROOM)
437
438#ifdef PLATFORM_UNALIGNED_WORD_ACCESS
439typedef unsigned int Bits;
440#else
441typedef unsigned char Bits;
442#endif
443typedef Bits BitSet[BITSET_SIZE];
444typedef Bits* BitSetRef;
445
446#define SIZE_BITSET (int )sizeof(BitSet)
447
448#define BITSET_CLEAR(bs) do {\
449 int i;\
450 for (i = 0; i < BITSET_SIZE; i++) { (bs)[i] = 0; } \
451} while (0)
452
453#define BS_ROOM(bs,pos) (bs)[(int )(pos) / BITS_IN_ROOM]
454#define BS_BIT(pos) (1U << ((int )(pos) % BITS_IN_ROOM))
455
456#define BITSET_AT(bs, pos) (BS_ROOM(bs,pos) & BS_BIT(pos))
457#define BITSET_SET_BIT(bs, pos) BS_ROOM(bs,pos) |= BS_BIT(pos)
458#define BITSET_CLEAR_BIT(bs, pos) BS_ROOM(bs,pos) &= ~(BS_BIT(pos))
459#define BITSET_INVERT_BIT(bs, pos) BS_ROOM(bs,pos) ^= BS_BIT(pos)
460
461/* bytes buffer */
462typedef struct _BBuf {
463 UChar* p;
464 unsigned int used;
465 unsigned int alloc;
466} BBuf;
467
468#define BBUF_INIT(buf,size) onig_bbuf_init((BBuf* )(buf), (size))
469
470#define BBUF_SIZE_INC(buf,inc) do{\
471 UChar *tmp;\
472 (buf)->alloc += (inc);\
473 tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
474 if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
475 (buf)->p = tmp;\
476} while (0)
477
478#define BBUF_EXPAND(buf,low) do{\
479 UChar *tmp;\
480 do { (buf)->alloc *= 2; } while ((buf)->alloc < (unsigned int )low);\
481 tmp = (UChar* )xrealloc((buf)->p, (buf)->alloc);\
482 if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
483 (buf)->p = tmp;\
484} while (0)
485
486#define BBUF_ENSURE_SIZE(buf,size) do{\
487 unsigned int new_alloc = (buf)->alloc;\
488 while (new_alloc < (unsigned int )(size)) { new_alloc *= 2; }\
489 if ((buf)->alloc != new_alloc) {\
490 UChar *tmp;\
491 tmp = (UChar* )xrealloc((buf)->p, new_alloc);\
492 if (IS_NULL(tmp)) return(ONIGERR_MEMORY);\
493 (buf)->p = tmp;\
494 (buf)->alloc = new_alloc;\
495 }\
496} while (0)
497
498#define BBUF_WRITE(buf,pos,bytes,n) do{\
499 int used = (pos) + (int )(n);\
500 if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
501 xmemcpy((buf)->p + (pos), (bytes), (n));\
502 if ((buf)->used < (unsigned int )used) (buf)->used = used;\
503} while (0)
504
505#define BBUF_WRITE1(buf,pos,byte) do{\
506 int used = (pos) + 1;\
507 if ((buf)->alloc < (unsigned int )used) BBUF_EXPAND((buf),used);\
508 (buf)->p[(pos)] = (UChar )(byte);\
509 if ((buf)->used < (unsigned int )used) (buf)->used = used;\
510} while (0)
511
512#define BBUF_ADD(buf,bytes,n) BBUF_WRITE((buf),(buf)->used,(bytes),(n))
513#define BBUF_ADD1(buf,byte) BBUF_WRITE1((buf),(buf)->used,(byte))
514#define BBUF_GET_ADD_ADDRESS(buf) ((buf)->p + (buf)->used)
515#define BBUF_GET_OFFSET_POS(buf) ((buf)->used)
516
517/* from < to */
518#define BBUF_MOVE_RIGHT(buf,from,to,n) do {\
519 if ((unsigned int )((to)+(n)) > (buf)->alloc) BBUF_EXPAND((buf),(to) + (n));\
520 xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
521 if ((unsigned int )((to)+(n)) > (buf)->used) (buf)->used = (to) + (n);\
522} while (0)
523
524/* from > to */
525#define BBUF_MOVE_LEFT(buf,from,to,n) do {\
526 xmemmove((buf)->p + (to), (buf)->p + (from), (n));\
527} while (0)
528
529/* from > to */
530#define BBUF_MOVE_LEFT_REDUCE(buf,from,to) do {\
531 xmemmove((buf)->p + (to), (buf)->p + (from), (buf)->used - (from));\
532 (buf)->used -= (from - to);\
533} while (0)
534
535#define BBUF_INSERT(buf,pos,bytes,n) do {\
536 if (pos >= (buf)->used) {\
537 BBUF_WRITE(buf,pos,bytes,n);\
538 }\
539 else {\
540 BBUF_MOVE_RIGHT((buf),(pos),(pos) + (n),((buf)->used - (pos)));\
541 xmemcpy((buf)->p + (pos), (bytes), (n));\
542 }\
543} while (0)
544
545#define BBUF_GET_BYTE(buf, pos) (buf)->p[(pos)]
546
547
548#define ANCHOR_BEGIN_BUF (1<<0)
549#define ANCHOR_BEGIN_LINE (1<<1)
550#define ANCHOR_BEGIN_POSITION (1<<2)
551#define ANCHOR_END_BUF (1<<3)
552#define ANCHOR_SEMI_END_BUF (1<<4)
553#define ANCHOR_END_LINE (1<<5)
554
555#define ANCHOR_WORD_BOUND (1<<6)
556#define ANCHOR_NOT_WORD_BOUND (1<<7)
557#define ANCHOR_WORD_BEGIN (1<<8)
558#define ANCHOR_WORD_END (1<<9)
559#define ANCHOR_PREC_READ (1<<10)
560#define ANCHOR_PREC_READ_NOT (1<<11)
561#define ANCHOR_LOOK_BEHIND (1<<12)
562#define ANCHOR_LOOK_BEHIND_NOT (1<<13)
563
564#define ANCHOR_ANYCHAR_STAR (1<<14) /* ".*" optimize info */
565#define ANCHOR_ANYCHAR_STAR_ML (1<<15) /* ".*" optimize info (multi-line) */
566
567#define ANCHOR_KEEP (1<<16)
568
569/* operation code */
570enum OpCode {
571 OP_FINISH = 0, /* matching process terminator (no more alternative) */
572 OP_END = 1, /* pattern code terminator (success end) */
573
574 OP_EXACT1 = 2, /* single byte, N = 1 */
575 OP_EXACT2, /* single byte, N = 2 */
576 OP_EXACT3, /* single byte, N = 3 */
577 OP_EXACT4, /* single byte, N = 4 */
578 OP_EXACT5, /* single byte, N = 5 */
579 OP_EXACTN, /* single byte */
580 OP_EXACTMB2N1, /* mb-length = 2 N = 1 */
581 OP_EXACTMB2N2, /* mb-length = 2 N = 2 */
582 OP_EXACTMB2N3, /* mb-length = 2 N = 3 */
583 OP_EXACTMB2N, /* mb-length = 2 */
584 OP_EXACTMB3N, /* mb-length = 3 */
585 OP_EXACTMBN, /* other length */
586
587 OP_EXACT1_IC, /* single byte, N = 1, ignore case */
588 OP_EXACTN_IC, /* single byte, ignore case */
589
590 OP_CCLASS,
591 OP_CCLASS_MB,
592 OP_CCLASS_MIX,
593 OP_CCLASS_NOT,
594 OP_CCLASS_MB_NOT,
595 OP_CCLASS_MIX_NOT,
596
597 OP_ANYCHAR, /* "." */
598 OP_ANYCHAR_ML, /* "." multi-line */
599 OP_ANYCHAR_STAR, /* ".*" */
600 OP_ANYCHAR_ML_STAR, /* ".*" multi-line */
601 OP_ANYCHAR_STAR_PEEK_NEXT,
602 OP_ANYCHAR_ML_STAR_PEEK_NEXT,
603
604 OP_WORD,
605 OP_NOT_WORD,
606 OP_WORD_BOUND,
607 OP_NOT_WORD_BOUND,
608 OP_WORD_BEGIN,
609 OP_WORD_END,
610
611 OP_ASCII_WORD,
612 OP_NOT_ASCII_WORD,
613 OP_ASCII_WORD_BOUND,
614 OP_NOT_ASCII_WORD_BOUND,
615 OP_ASCII_WORD_BEGIN,
616 OP_ASCII_WORD_END,
617
618 OP_BEGIN_BUF,
619 OP_END_BUF,
620 OP_BEGIN_LINE,
621 OP_END_LINE,
622 OP_SEMI_END_BUF,
623 OP_BEGIN_POSITION,
624
625 OP_BACKREF1,
626 OP_BACKREF2,
627 OP_BACKREFN,
628 OP_BACKREFN_IC,
629 OP_BACKREF_MULTI,
630 OP_BACKREF_MULTI_IC,
631 OP_BACKREF_WITH_LEVEL, /* \k<xxx+n>, \k<xxx-n> */
632
633 OP_MEMORY_START,
634 OP_MEMORY_START_PUSH, /* push back-tracker to stack */
635 OP_MEMORY_END_PUSH, /* push back-tracker to stack */
636 OP_MEMORY_END_PUSH_REC, /* push back-tracker to stack */
637 OP_MEMORY_END,
638 OP_MEMORY_END_REC, /* push marker to stack */
639
640 OP_KEEP,
641
642 OP_FAIL, /* pop stack and move */
643 OP_JUMP,
644 OP_PUSH,
645 OP_POP,
646 OP_PUSH_OR_JUMP_EXACT1, /* if match exact then push, else jump. */
647 OP_PUSH_IF_PEEK_NEXT, /* if match exact then push, else none. */
648 OP_REPEAT, /* {n,m} */
649 OP_REPEAT_NG, /* {n,m}? (non greedy) */
650 OP_REPEAT_INC,
651 OP_REPEAT_INC_NG, /* non greedy */
652 OP_REPEAT_INC_SG, /* search and get in stack */
653 OP_REPEAT_INC_NG_SG, /* search and get in stack (non greedy) */
654 OP_NULL_CHECK_START, /* null loop checker start */
655 OP_NULL_CHECK_END, /* null loop checker end */
656 OP_NULL_CHECK_END_MEMST, /* null loop checker end (with capture status) */
657 OP_NULL_CHECK_END_MEMST_PUSH, /* with capture status and push check-end */
658
659 OP_PUSH_POS, /* (?=...) start */
660 OP_POP_POS, /* (?=...) end */
661 OP_PUSH_POS_NOT, /* (?!...) start */
662 OP_FAIL_POS, /* (?!...) end */
663 OP_PUSH_STOP_BT, /* (?>...) start */
664 OP_POP_STOP_BT, /* (?>...) end */
665 OP_LOOK_BEHIND, /* (?<=...) start (no needs end opcode) */
666 OP_PUSH_LOOK_BEHIND_NOT, /* (?<!...) start */
667 OP_FAIL_LOOK_BEHIND_NOT, /* (?<!...) end */
668 OP_PUSH_ABSENT_POS, /* (?~...) start */
669 OP_ABSENT, /* (?~...) start of inner loop */
670 OP_ABSENT_END, /* (?~...) end */
671
672 OP_CALL, /* \g<name> */
673 OP_RETURN,
674
675 OP_CONDITION,
676
677 OP_STATE_CHECK_PUSH, /* combination explosion check and push */
678 OP_STATE_CHECK_PUSH_OR_JUMP, /* check ok -> push, else jump */
679 OP_STATE_CHECK, /* check only */
680 OP_STATE_CHECK_ANYCHAR_STAR,
681 OP_STATE_CHECK_ANYCHAR_ML_STAR,
682
683 /* no need: IS_DYNAMIC_OPTION() == 0 */
684 OP_SET_OPTION_PUSH, /* set option and push recover option */
685 OP_SET_OPTION /* set option */
686};
687
688typedef int RelAddrType;
689typedef int AbsAddrType;
690typedef int LengthType;
691typedef int RepeatNumType;
692typedef short int MemNumType;
693typedef short int StateCheckNumType;
694typedef void* PointerType;
695
696#define SIZE_OPCODE 1
697#define SIZE_RELADDR (int )sizeof(RelAddrType)
698#define SIZE_ABSADDR (int )sizeof(AbsAddrType)
699#define SIZE_LENGTH (int )sizeof(LengthType)
700#define SIZE_MEMNUM (int )sizeof(MemNumType)
701#define SIZE_STATE_CHECK_NUM (int )sizeof(StateCheckNumType)
702#define SIZE_REPEATNUM (int )sizeof(RepeatNumType)
703#define SIZE_OPTION (int )sizeof(OnigOptionType)
704#define SIZE_CODE_POINT (int )sizeof(OnigCodePoint)
705#define SIZE_POINTER (int )sizeof(PointerType)
706
707
708#define GET_RELADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, RelAddrType)
709#define GET_ABSADDR_INC(addr,p) PLATFORM_GET_INC(addr, p, AbsAddrType)
710#define GET_LENGTH_INC(len,p) PLATFORM_GET_INC(len, p, LengthType)
711#define GET_MEMNUM_INC(num,p) PLATFORM_GET_INC(num, p, MemNumType)
712#define GET_REPEATNUM_INC(num,p) PLATFORM_GET_INC(num, p, RepeatNumType)
713#define GET_OPTION_INC(option,p) PLATFORM_GET_INC(option, p, OnigOptionType)
714#define GET_POINTER_INC(ptr,p) PLATFORM_GET_INC(ptr, p, PointerType)
715#define GET_STATE_CHECK_NUM_INC(num,p) PLATFORM_GET_INC(num, p, StateCheckNumType)
716
717/* code point's address must be aligned address. */
718#define GET_CODE_POINT(code,p) code = *((OnigCodePoint* )(p))
719#define GET_BYTE_INC(byte,p) do{\
720 byte = *(p);\
721 (p)++;\
722} while(0)
723
724
725/* op-code + arg size */
726#define SIZE_OP_ANYCHAR_STAR SIZE_OPCODE
727#define SIZE_OP_ANYCHAR_STAR_PEEK_NEXT (SIZE_OPCODE + 1)
728#define SIZE_OP_JUMP (SIZE_OPCODE + SIZE_RELADDR)
729#define SIZE_OP_PUSH (SIZE_OPCODE + SIZE_RELADDR)
730#define SIZE_OP_POP SIZE_OPCODE
731#define SIZE_OP_PUSH_OR_JUMP_EXACT1 (SIZE_OPCODE + SIZE_RELADDR + 1)
732#define SIZE_OP_PUSH_IF_PEEK_NEXT (SIZE_OPCODE + SIZE_RELADDR + 1)
733#define SIZE_OP_REPEAT_INC (SIZE_OPCODE + SIZE_MEMNUM)
734#define SIZE_OP_REPEAT_INC_NG (SIZE_OPCODE + SIZE_MEMNUM)
735#define SIZE_OP_PUSH_POS SIZE_OPCODE
736#define SIZE_OP_PUSH_POS_NOT (SIZE_OPCODE + SIZE_RELADDR)
737#define SIZE_OP_POP_POS SIZE_OPCODE
738#define SIZE_OP_FAIL_POS SIZE_OPCODE
739#define SIZE_OP_SET_OPTION (SIZE_OPCODE + SIZE_OPTION)
740#define SIZE_OP_SET_OPTION_PUSH (SIZE_OPCODE + SIZE_OPTION)
741#define SIZE_OP_FAIL SIZE_OPCODE
742#define SIZE_OP_MEMORY_START (SIZE_OPCODE + SIZE_MEMNUM)
743#define SIZE_OP_MEMORY_START_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
744#define SIZE_OP_MEMORY_END_PUSH (SIZE_OPCODE + SIZE_MEMNUM)
745#define SIZE_OP_MEMORY_END_PUSH_REC (SIZE_OPCODE + SIZE_MEMNUM)
746#define SIZE_OP_MEMORY_END (SIZE_OPCODE + SIZE_MEMNUM)
747#define SIZE_OP_MEMORY_END_REC (SIZE_OPCODE + SIZE_MEMNUM)
748#define SIZE_OP_PUSH_STOP_BT SIZE_OPCODE
749#define SIZE_OP_POP_STOP_BT SIZE_OPCODE
750#define SIZE_OP_NULL_CHECK_START (SIZE_OPCODE + SIZE_MEMNUM)
751#define SIZE_OP_NULL_CHECK_END (SIZE_OPCODE + SIZE_MEMNUM)
752#define SIZE_OP_LOOK_BEHIND (SIZE_OPCODE + SIZE_LENGTH)
753#define SIZE_OP_PUSH_LOOK_BEHIND_NOT (SIZE_OPCODE + SIZE_RELADDR + SIZE_LENGTH)
754#define SIZE_OP_FAIL_LOOK_BEHIND_NOT SIZE_OPCODE
755#define SIZE_OP_CALL (SIZE_OPCODE + SIZE_ABSADDR)
756#define SIZE_OP_RETURN SIZE_OPCODE
757#define SIZE_OP_CONDITION (SIZE_OPCODE + SIZE_MEMNUM + SIZE_RELADDR)
758#define SIZE_OP_PUSH_ABSENT_POS SIZE_OPCODE
759#define SIZE_OP_ABSENT (SIZE_OPCODE + SIZE_RELADDR)
760#define SIZE_OP_ABSENT_END SIZE_OPCODE
761
762#ifdef USE_COMBINATION_EXPLOSION_CHECK
763# define SIZE_OP_STATE_CHECK (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
764# define SIZE_OP_STATE_CHECK_PUSH (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
765# define SIZE_OP_STATE_CHECK_PUSH_OR_JUMP (SIZE_OPCODE + SIZE_STATE_CHECK_NUM + SIZE_RELADDR)
766# define SIZE_OP_STATE_CHECK_ANYCHAR_STAR (SIZE_OPCODE + SIZE_STATE_CHECK_NUM)
767#endif
768
769#define MC_ESC(syn) (syn)->meta_char_table.esc
770#define MC_ANYCHAR(syn) (syn)->meta_char_table.anychar
771#define MC_ANYTIME(syn) (syn)->meta_char_table.anytime
772#define MC_ZERO_OR_ONE_TIME(syn) (syn)->meta_char_table.zero_or_one_time
773#define MC_ONE_OR_MORE_TIME(syn) (syn)->meta_char_table.one_or_more_time
774#define MC_ANYCHAR_ANYTIME(syn) (syn)->meta_char_table.anychar_anytime
775
776#define IS_MC_ESC_CODE(code, syn) \
777 ((code) == MC_ESC(syn) && \
778 !IS_SYNTAX_OP2((syn), ONIG_SYN_OP2_INEFFECTIVE_ESCAPE))
779
780
781#define SYN_POSIX_COMMON_OP \
782 ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_POSIX_BRACKET | \
783 ONIG_SYN_OP_DECIMAL_BACKREF | \
784 ONIG_SYN_OP_BRACKET_CC | ONIG_SYN_OP_ASTERISK_ZERO_INF | \
785 ONIG_SYN_OP_LINE_ANCHOR | \
786 ONIG_SYN_OP_ESC_CONTROL_CHARS )
787
788#define SYN_GNU_REGEX_OP \
789 ( ONIG_SYN_OP_DOT_ANYCHAR | ONIG_SYN_OP_BRACKET_CC | \
790 ONIG_SYN_OP_POSIX_BRACKET | ONIG_SYN_OP_DECIMAL_BACKREF | \
791 ONIG_SYN_OP_BRACE_INTERVAL | ONIG_SYN_OP_LPAREN_SUBEXP | \
792 ONIG_SYN_OP_VBAR_ALT | \
793 ONIG_SYN_OP_ASTERISK_ZERO_INF | ONIG_SYN_OP_PLUS_ONE_INF | \
794 ONIG_SYN_OP_QMARK_ZERO_ONE | \
795 ONIG_SYN_OP_ESC_AZ_BUF_ANCHOR | ONIG_SYN_OP_ESC_CAPITAL_G_BEGIN_ANCHOR | \
796 ONIG_SYN_OP_ESC_W_WORD | \
797 ONIG_SYN_OP_ESC_B_WORD_BOUND | ONIG_SYN_OP_ESC_LTGT_WORD_BEGIN_END | \
798 ONIG_SYN_OP_ESC_S_WHITE_SPACE | ONIG_SYN_OP_ESC_D_DIGIT | \
799 ONIG_SYN_OP_LINE_ANCHOR )
800
801#define SYN_GNU_REGEX_BV \
802 ( ONIG_SYN_CONTEXT_INDEP_ANCHORS | ONIG_SYN_CONTEXT_INDEP_REPEAT_OPS | \
803 ONIG_SYN_CONTEXT_INVALID_REPEAT_OPS | ONIG_SYN_ALLOW_INVALID_INTERVAL | \
804 ONIG_SYN_BACKSLASH_ESCAPE_IN_CC | ONIG_SYN_ALLOW_DOUBLE_RANGE_OP_IN_CC )
805
806
807#define NCCLASS_FLAGS(cc) ((cc)->flags)
808#define NCCLASS_FLAG_SET(cc,flag) (NCCLASS_FLAGS(cc) |= (flag))
809#define NCCLASS_FLAG_CLEAR(cc,flag) (NCCLASS_FLAGS(cc) &= ~(flag))
810#define IS_NCCLASS_FLAG_ON(cc,flag) ((NCCLASS_FLAGS(cc) & (flag)) != 0)
811
812/* cclass node */
813#define FLAG_NCCLASS_NOT (1<<0)
814
815#define NCCLASS_SET_NOT(nd) NCCLASS_FLAG_SET(nd, FLAG_NCCLASS_NOT)
816#define NCCLASS_CLEAR_NOT(nd) NCCLASS_FLAG_CLEAR(nd, FLAG_NCCLASS_NOT)
817#define IS_NCCLASS_NOT(nd) IS_NCCLASS_FLAG_ON(nd, FLAG_NCCLASS_NOT)
818
819typedef struct {
820 int type;
821 /* struct _Node* next; */
822 /* unsigned int flags; */
823} NodeBase;
824
825typedef struct {
826 NodeBase base;
827 unsigned int flags;
828 BitSet bs;
829 BBuf* mbuf; /* multi-byte info or NULL */
830} CClassNode;
831
832typedef intptr_t OnigStackIndex;
833
834typedef struct _OnigStackType {
835 unsigned int type;
836 OnigStackIndex null_check;
837 union {
838 struct {
839 UChar *pcode; /* byte code position */
840 UChar *pstr; /* string position */
841 UChar *pstr_prev; /* previous char position of pstr */
842#ifdef USE_COMBINATION_EXPLOSION_CHECK
843 unsigned int state_check;
844#endif
845 UChar *pkeep; /* keep pattern position */
846 } state;
847 struct {
848 int count; /* for OP_REPEAT_INC, OP_REPEAT_INC_NG */
849 UChar *pcode; /* byte code position (head of repeated target) */
850 int num; /* repeat id */
851 } repeat;
852 struct {
853 OnigStackIndex si; /* index of stack */
854 } repeat_inc;
855 struct {
856 int num; /* memory num */
857 UChar *pstr; /* start/end position */
858 /* Following information is set, if this stack type is MEM-START */
859 OnigStackIndex start; /* prev. info (for backtrack "(...)*" ) */
860 OnigStackIndex end; /* prev. info (for backtrack "(...)*" ) */
861 } mem;
862 struct {
863 int num; /* null check id */
864 UChar *pstr; /* start position */
865 } null_check;
866#ifdef USE_SUBEXP_CALL
867 struct {
868 UChar *ret_addr; /* byte code position */
869 int num; /* null check id */
870 UChar *pstr; /* string position */
871 } call_frame;
872#endif
873 struct {
874 UChar *abs_pstr; /* absent start position */
875 const UChar *end_pstr; /* end position */
876 } absent_pos;
877#ifdef USE_MATCH_CACHE
878 struct {
879 long index; /* index of the match cache buffer */
880 uint8_t mask; /* bit-mask for the match cache buffer */
881 } match_cache_point;
882#endif
883 } u;
885
886#ifdef USE_MATCH_CACHE
887typedef struct {
888 UChar *addr;
889 long cache_point;
890 int outer_repeat_mem;
891 long num_cache_points_at_outer_repeat;
892 long num_cache_points_in_outer_repeat;
893 int lookaround_nesting;
894 UChar *match_addr;
896#endif
897
898typedef struct {
899 void* stack_p;
900 size_t stack_n;
901 OnigOptionType options;
902 OnigRegion* region;
903 const UChar* start; /* search start position */
904 const UChar* gpos; /* global position (for \G: BEGIN_POSITION) */
905#ifdef USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE
906 OnigPosition best_len; /* for ONIG_OPTION_FIND_LONGEST */
907 UChar* best_s;
908#endif
909#ifdef USE_COMBINATION_EXPLOSION_CHECK
910 void* state_check_buff;
911 int state_check_buff_size;
912#endif
913 int counter;
914 /* rb_hrtime_t from hrtime.h */
915#ifdef MY_RUBY_BUILD_MAY_TIME_TRAVEL
916 int128_t end_time;
917#else
918 uint64_t end_time;
919#endif
920#ifdef USE_MATCH_CACHE
921 int match_cache_status;
922 long num_fails;
923 long num_cache_opcodes;
924 OnigCacheOpcode* cache_opcodes;
925 long num_cache_points;
926 uint8_t* match_cache_buf;
927#endif
929
930#define NUM_CACHE_OPCODES_UNINIT 1
931#define NUM_CACHE_OPCODES_IMPOSSIBLE -1
932
933#define MATCH_CACHE_STATUS_UNINIT 1
934#define MATCH_CACHE_STATUS_INIT 2
935#define MATCH_CACHE_STATUS_DISABLED -1
936#define MATCH_CACHE_STATUS_ENABLED 0
937
938#define IS_CODE_SB_WORD(enc,code) \
939 (ONIGENC_IS_CODE_ASCII(code) && ONIGENC_IS_CODE_WORD(enc,code))
940
941typedef struct OnigEndCallListItem {
942 struct OnigEndCallListItem* next;
943 void (*func)(void);
945
946extern void onig_add_end_call(void (*func)(void));
947
948
949#ifdef ONIG_DEBUG
950
951typedef struct {
952 short int opcode;
953 const char* name;
954 short int arg_type;
955} OnigOpInfoType;
956
957extern OnigOpInfoType OnigOpInfo[];
958
959
960extern void onig_print_compiled_byte_code(FILE* f, UChar* bp, UChar* bpend, UChar** nextp, OnigEncoding enc);
961
962# ifdef ONIG_DEBUG_STATISTICS
963extern void onig_statistics_init(void);
964extern void onig_print_statistics(FILE* f);
965# endif
966#endif
967
968#ifndef PRINTF_ARGS
969#define PRINTF_ARGS(func, fmt, vargs) func
970#endif
971
972extern UChar* onig_error_code_to_format(OnigPosition code);
973PRINTF_ARGS(extern void onig_vsnprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const char *fmt, va_list args), 6, 0);
974PRINTF_ARGS(extern void onig_snprintf_with_pattern(UChar buf[], int bufsize, OnigEncoding enc, UChar* pat, UChar* pat_end, const char *fmt, ...), 6, 7);
975extern int onig_bbuf_init(BBuf* buf, OnigDistance size);
976extern int onig_compile(regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo);
977#ifdef RUBY
978extern int onig_compile_ruby(regex_t* reg, const UChar* pattern, const UChar* pattern_end, OnigErrorInfo* einfo, const char *sourcefile, int sourceline);
979#endif
980extern void onig_transfer(regex_t* to, regex_t* from);
981extern int onig_is_code_in_cc(OnigEncoding enc, OnigCodePoint code, CClassNode* cc);
982extern int onig_is_code_in_cc_len(int enclen, OnigCodePoint code, CClassNode* cc);
983
984/* strend hash */
985typedef void hash_table_type;
986#ifdef RUBY
987# include "ruby/st.h"
988#else
989# include "st.h"
990#endif
991typedef st_data_t hash_data_type;
992
993extern hash_table_type* onig_st_init_strend_table_with_size(st_index_t size);
994extern int onig_st_lookup_strend(hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type *value);
995extern int onig_st_insert_strend(hash_table_type* table, const UChar* str_key, const UChar* end_key, hash_data_type value);
996
997#ifdef RUBY
998extern size_t onig_memsize(const regex_t *reg);
999extern size_t onig_region_memsize(const struct re_registers *regs);
1000bool rb_reg_timeout_p(regex_t *reg, void *end_time);
1001#endif
1002
1003RUBY_SYMBOL_EXPORT_END
1004
1005#endif /* ONIGMO_REGINT_H */
Defines old _.