Ruby: regint.h Source File

Ruby 3.3.4p94 (2024-07-09 revision be1089c8ec5ba40e09b1553e36b3174bf4014d9d)

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