Ruby: regcomp.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Functions | Variables
regcomp.c File Reference
`#include "regparse.h"`

Go to the source code of this file.

## Data Structures
struct | MinMaxLen
struct | OptEnv
struct | OptAncInfo
struct | OptExactInfo
struct | OptMapInfo
struct | NodeOptInfo

## Macros
#define | IS_NEED_STR_LEN_OP_EXACT(op)
#define | REPEAT_RANGE_ALLOC 4
#define | QUANTIFIER_EXPAND_LIMIT_SIZE 50
#define | CKN_ON (ckn > 0)
#define | GET_CHAR_LEN_VARLEN -1
#define | GET_CHAR_LEN_TOP_ALT_VARLEN -2
#define | RECURSION_EXIST 1
#define | RECURSION_INFINITE 2
#define | FOUND_CALLED_NODE 1
#define | THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION 8
#define | IN_ALT (1<<0)
#define | IN_NOT (1<<1)
#define | IN_REPEAT (1<<2)
#define | IN_VAR_REPEAT (1<<3)
#define | IN_CALL (1<<4)
#define | IN_RECCALL (1<<5)
#define | EXPAND_STRING_MAX_LENGTH 100
#define | ALLOWED_TYPE_IN_LB
#define | ALLOWED_ENCLOSE_IN_LB ( ENCLOSE_MEMORY | ENCLOSE_OPTION )
#define | ALLOWED_ENCLOSE_IN_LB_NOT ENCLOSE_OPTION
#define | ALLOWED_ANCHOR_IN_LB
#define | ALLOWED_ANCHOR_IN_LB_NOT
#define | COMP_EM_BASE 20
#define | MAX_NODE_OPT_INFO_REF_COUNT 5
#define | REGEX_TRANSFER(to, from)
#define | COMPILE_INIT_SIZE 20

## Functions
OnigCaseFoldType | onig_get_default_case_fold_flag (void)
int | onig_set_default_case_fold_flag (OnigCaseFoldType case_fold_flag)
int | onig_bbuf_init (BBuf *buf, OnigDistance size)
void | onig_free_body (regex_t *reg)
void | onig_free (regex_t *reg)
size_t | onig_memsize (const regex_t *reg)
size_t | onig_region_memsize (const OnigRegion *regs)
int | onig_compile (regex_t *reg, const UChar *pattern, const UChar *pattern_end, OnigErrorInfo *einfo)
int | onig_compile_ruby (regex_t *reg, const UChar *pattern, const UChar *pattern_end, OnigErrorInfo *einfo, const char *sourcefile, int sourceline)
int | onig_reg_init (regex_t *reg, OnigOptionType option, OnigCaseFoldType case_fold_flag, OnigEncoding enc, const OnigSyntaxType *syntax)
int | onig_new_without_alloc (regex_t *reg, const UChar *pattern, const UChar *pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType *syntax, OnigErrorInfo *einfo)
int | onig_new (regex_t **reg, const UChar *pattern, const UChar *pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType *syntax, OnigErrorInfo *einfo)
int | onig_initialize (OnigEncoding encodings[] ARG_UNUSED, int n ARG_UNUSED)
int | onig_init (void)
void | onig_add_end_call (void(*func)(void))
int | onig_end (void)
int | onig_is_in_code_range (const UChar *p, OnigCodePoint code)
int | onig_is_code_in_cc_len (int elen, OnigCodePoint code, CClassNode *cc)
int | onig_is_code_in_cc (OnigEncoding enc, OnigCodePoint code, CClassNode *cc)

## Variables
OnigCaseFoldType | OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN

## Macro Definition Documentation

## ◆ ALLOWED_ANCHOR_IN_LB

#define ALLOWED_ANCHOR_IN_LB

Value:
( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE | \
ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION | ANCHOR_KEEP | \
ANCHOR_WORD_BOUND | ANCHOR_NOT_WORD_BOUND | \
ANCHOR_WORD_BEGIN | ANCHOR_WORD_END )
ANCHOR_BEGIN_LINE
#define ANCHOR_BEGIN_LINE
Definition: regint.h:528
ANCHOR_BEGIN_POSITION
#define ANCHOR_BEGIN_POSITION
Definition: regint.h:529
ANCHOR_LOOK_BEHIND
#define ANCHOR_LOOK_BEHIND
Definition: regint.h:540
ANCHOR_END_LINE
#define ANCHOR_END_LINE
Definition: regint.h:532
ANCHOR_BEGIN_BUF
#define ANCHOR_BEGIN_BUF
Definition: regint.h:527
ANCHOR_WORD_BOUND
#define ANCHOR_WORD_BOUND
Definition: regint.h:534
ANCHOR_WORD_BEGIN
#define ANCHOR_WORD_BEGIN
Definition: regint.h:536
ANCHOR_LOOK_BEHIND_NOT
#define ANCHOR_LOOK_BEHIND_NOT
Definition: regint.h:541
ANCHOR_KEEP
#define ANCHOR_KEEP
Definition: regint.h:546
ANCHOR_NOT_WORD_BOUND
#define ANCHOR_NOT_WORD_BOUND
Definition: regint.h:535
ANCHOR_WORD_END
#define ANCHOR_WORD_END
Definition: regint.h:537

## ◆ ALLOWED_ANCHOR_IN_LB_NOT

#define ALLOWED_ANCHOR_IN_LB_NOT

Value:
( ANCHOR_LOOK_BEHIND | ANCHOR_LOOK_BEHIND_NOT | ANCHOR_BEGIN_LINE | \
ANCHOR_END_LINE | ANCHOR_BEGIN_BUF | ANCHOR_BEGIN_POSITION | ANCHOR_KEEP | \
ANCHOR_WORD_BOUND | ANCHOR_NOT_WORD_BOUND | \
ANCHOR_WORD_BEGIN | ANCHOR_WORD_END )

## ◆ ALLOWED_ENCLOSE_IN_LB

#define ALLOWED_ENCLOSE_IN_LB ( ENCLOSE_MEMORY | ENCLOSE_OPTION )

## ◆ ALLOWED_ENCLOSE_IN_LB_NOT

#define ALLOWED_ENCLOSE_IN_LB_NOT ENCLOSE_OPTION

## ◆ ALLOWED_TYPE_IN_LB

#define ALLOWED_TYPE_IN_LB

Value:
( BIT_NT_LIST | BIT_NT_ALT | BIT_NT_STR | BIT_NT_CCLASS | BIT_NT_CTYPE | \
BIT_NT_CANY | BIT_NT_ANCHOR | BIT_NT_ENCLOSE | BIT_NT_QTFR | BIT_NT_CALL )
BIT_NT_CCLASS
#define BIT_NT_CCLASS
Definition: regparse.h:54
BIT_NT_STR
#define BIT_NT_STR
Definition: regparse.h:53
BIT_NT_ANCHOR
#define BIT_NT_ANCHOR
Definition: regparse.h:60
BIT_NT_CALL
#define BIT_NT_CALL
Definition: regparse.h:63
BIT_NT_CTYPE
#define BIT_NT_CTYPE
Definition: regparse.h:55
BIT_NT_LIST
#define BIT_NT_LIST
Definition: regparse.h:61
BIT_NT_CANY
#define BIT_NT_CANY
Definition: regparse.h:56
BIT_NT_ALT
#define BIT_NT_ALT
Definition: regparse.h:62
BIT_NT_ENCLOSE
#define BIT_NT_ENCLOSE
Definition: regparse.h:59
BIT_NT_QTFR
#define BIT_NT_QTFR
Definition: regparse.h:58

## ◆ CKN_ON

#define CKN_ON (ckn > 0)

Definition at line 743 of file regcomp.c.

## ◆ COMP_EM_BASE

#define COMP_EM_BASE 20

## ◆ COMPILE_INIT_SIZE

#define COMPILE_INIT_SIZE 20

## ◆ EXPAND_STRING_MAX_LENGTH

#define EXPAND_STRING_MAX_LENGTH 100

## ◆ FOUND_CALLED_NODE

#define FOUND_CALLED_NODE 1

## ◆ GET_CHAR_LEN_TOP_ALT_VARLEN

#define GET_CHAR_LEN_TOP_ALT_VARLEN -2

Definition at line 2435 of file regcomp.c.

## ◆ GET_CHAR_LEN_VARLEN

#define GET_CHAR_LEN_VARLEN -1

Definition at line 2434 of file regcomp.c.

## ◆ IN_ALT

#define IN_ALT (1<<0)

Definition at line 3881 of file regcomp.c.

## ◆ IN_CALL

#define IN_CALL (1<<4)

Definition at line 3885 of file regcomp.c.

## ◆ IN_NOT

#define IN_NOT (1<<1)

Definition at line 3882 of file regcomp.c.

## ◆ IN_RECCALL

#define IN_RECCALL (1<<5)

Definition at line 3886 of file regcomp.c.

## ◆ IN_REPEAT

#define IN_REPEAT (1<<2)

Definition at line 3883 of file regcomp.c.

## ◆ IN_VAR_REPEAT

#define IN_VAR_REPEAT (1<<3)

Definition at line 3884 of file regcomp.c.

## ◆ IS_NEED_STR_LEN_OP_EXACT

#define IS_NEED_STR_LEN_OP_EXACT | ( |  | op | ) |

Value:
((op) == OP_EXACTN || (op) == OP_EXACTMB2N ||\
(op) == OP_EXACTMB3N || (op) == OP_EXACTMBN || (op) == OP_EXACTN_IC)
OP_EXACTMB3N
@ OP_EXACTMB3N
Definition: regint.h:563
OP_EXACTMBN
@ OP_EXACTMBN
Definition: regint.h:564
OP_EXACTMB2N
@ OP_EXACTMB2N
Definition: regint.h:562
OP_EXACTN
@ OP_EXACTN
Definition: regint.h:558
OP_EXACTN_IC
@ OP_EXACTN_IC
Definition: regint.h:567

Definition at line 336 of file regcomp.c.

## ◆ MAX_NODE_OPT_INFO_REF_COUNT

#define MAX_NODE_OPT_INFO_REF_COUNT 5

Definition at line 4976 of file regcomp.c.

## ◆ QUANTIFIER_EXPAND_LIMIT_SIZE

#define QUANTIFIER_EXPAND_LIMIT_SIZE 50

Definition at line 742 of file regcomp.c.

## ◆ RECURSION_EXIST

#define RECURSION_EXIST 1

Definition at line 2909 of file regcomp.c.

## ◆ RECURSION_INFINITE

#define RECURSION_INFINITE 2

Definition at line 2910 of file regcomp.c.

## ◆ REGEX_TRANSFER

#define REGEX_TRANSFER | ( |  | to,
|  |  | from
| ) |  |

Value:
do {\
onig_free_body(to);\
xmemcpy(to, from, sizeof(regex_t));\
xfree(from);\
} while (0)
re_pattern_buffer
Definition: onigmo.h:755

Definition at line 5702 of file regcomp.c.

## ◆ REPEAT_RANGE_ALLOC

#define REPEAT_RANGE_ALLOC 4

## ◆ THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION

#define THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION 8

## Function Documentation

## ◆ onig_add_end_call()

void onig_add_end_call | ( | void(*)(void) | func | ) |

Definition at line 6050 of file regcomp.c.

References OnigEndCallListItem::func, OnigEndCallListItem::next, and xmalloc.

## ◆ onig_bbuf_init()

int onig_bbuf_init | ( | BBuf * | buf,
|  | OnigDistance | size
| ) |  |

Definition at line 163 of file regcomp.c.

References int(), IS_NULL, NULL, ONIGERR_MEMORY, UChar, and xmalloc.

## ◆ onig_compile()

int onig_compile | ( | regex_t * | reg,
|  | const UChar * | pattern,
|  | const UChar * | pattern_end,
|  | OnigErrorInfo * | einfo
| ) |  |

Definition at line 5725 of file regcomp.c.

References NULL, and onig_compile_ruby().

Referenced by onig_new(), and onig_new_without_alloc().

## ◆ onig_compile_ruby()

int onig_compile_ruby | ( | regex_t * | reg,
|  | const UChar * | pattern,
|  | const UChar * | pattern_end,
|  | OnigErrorInfo * | einfo,
|  | const char * | sourcefile,
|  | int | sourceline
| ) |  |

Definition at line 5734 of file regcomp.c.

References re_pattern_buffer::alloc, ScanEnv::backrefed_mem, BBUF_INIT, BIT_STATUS_AT, BIT_STATUS_ON_ALL, re_pattern_buffer::bt_mem_end, ScanEnv::bt_mem_end, re_pattern_buffer::bt_mem_start, ScanEnv::bt_mem_start, re_pattern_buffer::capture_history, ScanEnv::capture_history, COMPILE_INIT_SIZE, OnigErrorInfo::enc, re_pattern_buffer::enc, ScanEnv::enc, err, ScanEnv::error, ScanEnv::error_end, IS_FIND_CONDITION, IS_NOT_NULL, IS_SYNTAX_BV, ScanEnv::mem_nodes_dynamic, NULL, re_pattern_buffer::num_call, ScanEnv::num_call, re_pattern_buffer::num_comb_exp_check, re_pattern_buffer::num_mem, ScanEnv::num_mem, ScanEnv::num_named, re_pattern_buffer::num_null_check, re_pattern_buffer::num_repeat, ONIG_IS_OPTION_ON, onig_node_free(), ONIG_OPTION_CAPTURE_GROUP, onig_parse_make_tree(), ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP, OP_END, re_pattern_buffer::options, OnigErrorInfo::par, OnigErrorInfo::par_end, re_pattern_buffer::repeat_range, re_pattern_buffer::repeat_range_alloc, root, ScanEnv::sourcefile, ScanEnv::sourceline, re_pattern_buffer::stack_pop_level, STACK_POP_LEVEL_ALL, STACK_POP_LEVEL_FREE, STACK_POP_LEVEL_MEM_START, ScanEnv::syntax, UChar, ScanEnv::unset_addr_list, USE_SUBEXP_CALL, re_pattern_buffer::used, and xfree.

Referenced by onig_compile().

## ◆ onig_end()

int onig_end | ( | void |  | ) |

Definition at line 6080 of file regcomp.c.

## ◆ onig_free()

void onig_free | ( | regex_t * | reg | ) |

Definition at line 5668 of file regcomp.c.

References IS_NOT_NULL, onig_free_body(), and xfree.

Referenced by onig_free_body(), and onig_new().

## ◆ onig_free_body()

void onig_free_body | ( | regex_t * | reg | ) |

Definition at line 5651 of file regcomp.c.

References re_pattern_buffer::chain, re_pattern_buffer::exact, re_pattern_buffer::int_map, re_pattern_buffer::int_map_backward, IS_NOT_NULL, onig_free(), onig_names_free(), re_pattern_buffer::p, re_pattern_buffer::repeat_range, and xfree.

Referenced by onig_free().

## ◆ onig_get_default_case_fold_flag()

OnigCaseFoldType onig_get_default_case_fold_flag | ( | void |  | ) |

Definition at line 36 of file regcomp.c.

References OnigDefaultCaseFoldFlag.

## ◆ onig_init()

int onig_init | ( | void |  | ) |

Definition at line 6026 of file regcomp.c.

References onigenc_init().

Referenced by onig_initialize(), and onig_reg_init().

## ◆ onig_initialize()

int onig_initialize | ( | OnigEncoding encodings[] | ARG_UNUSED,
|  | int n | ARG_UNUSED
| ) |  |

Definition at line 6020 of file regcomp.c.

References onig_init().

## ◆ onig_is_code_in_cc()

int onig_is_code_in_cc | ( | OnigEncoding | enc,
|  | OnigCodePoint | code,
|  | CClassNode * | cc
| ) |  |

Definition at line 6142 of file regcomp.c.

References len, onig_is_code_in_cc_len(), ONIGENC_CODE_TO_MBCLEN, and ONIGENC_MBC_MINLEN.

## ◆ onig_is_code_in_cc_len()

int onig_is_code_in_cc_len | ( | int | elen,
|  | OnigCodePoint | code,
|  | CClassNode * | cc
| ) |  |

Definition at line 6119 of file regcomp.c.

References BITSET_AT, CClassNode::bs, IS_NCCLASS_NOT, IS_NULL, CClassNode::mbuf, onig_is_in_code_range(), _BBuf::p, and SINGLE_BYTE_SIZE.

Referenced by onig_is_code_in_cc().

## ◆ onig_is_in_code_range()

int onig_is_in_code_range | ( | const UChar * | p,
|  | OnigCodePoint | code
| ) |  |

Definition at line 6098 of file regcomp.c.

References GET_CODE_POINT.

Referenced by onig_is_code_in_cc_len().

## ◆ onig_memsize()

size_t onig_memsize | ( | const regex_t * | reg | ) |

Definition at line 5678 of file regcomp.c.

References re_pattern_buffer::alloc, re_pattern_buffer::chain, re_pattern_buffer::exact, re_pattern_buffer::exact_end, if(), re_pattern_buffer::int_map, re_pattern_buffer::int_map_backward, IS_NOT_NULL, IS_NULL, ONIG_CHAR_TABLE_SIZE, onig_memsize(), re_pattern_buffer::p, re_pattern_buffer::repeat_range, and re_pattern_buffer::repeat_range_alloc.

Referenced by onig_memsize().

## ◆ onig_new()

int onig_new | ( | regex_t ** | reg,
|  | const UChar * | pattern,
|  | const UChar * | pattern_end,
|  | OnigOptionType | option,
|  | OnigEncoding | enc,
|  | const OnigSyntaxType * | syntax,
|  | OnigErrorInfo * | einfo
| ) |  |

Definition at line 5998 of file regcomp.c.

References err, IS_NULL, NULL, onig_compile(), onig_free(), onig_reg_init(), ONIGENC_CASE_FOLD_DEFAULT, ONIGERR_MEMORY, and xmalloc.

## ◆ onig_new_without_alloc()

int onig_new_without_alloc | ( | regex_t * | reg,
|  | const UChar * | pattern,
|  | const UChar * | pattern_end,
|  | OnigOptionType | option,
|  | OnigEncoding | enc,
|  | const OnigSyntaxType * | syntax,
|  | OnigErrorInfo * | einfo
| ) |  |

Definition at line 5984 of file regcomp.c.

References onig_compile(), onig_reg_init(), and ONIGENC_CASE_FOLD_DEFAULT.

## ◆ onig_reg_init()

int onig_reg_init | ( | regex_t * | reg,
|  | OnigOptionType | option,
|  | OnigCaseFoldType | case_fold_flag,
|  | OnigEncoding | enc,
|  | const OnigSyntaxType * | syntax
| ) |  |

Definition at line 5940 of file regcomp.c.

References IS_NULL, NULL, onig_init(), ONIG_OPTION_CAPTURE_GROUP, ONIG_OPTION_DONT_CAPTURE_GROUP, ONIG_OPTION_NEGATE_SINGLELINE, ONIGENC_IS_UNDEF, ONIGERR_DEFAULT_ENCODING_IS_NOT_SET, ONIGERR_INVALID_ARGUMENT, ONIGERR_INVALID_COMBINATION_OF_OPTIONS, OnigSyntaxType::options, and UChar.

Referenced by onig_new(), and onig_new_without_alloc().

## ◆ onig_region_memsize()

size_t onig_region_memsize | ( | const OnigRegion * | regs | ) |

Definition at line 5693 of file regcomp.c.

References re_registers::allocated, re_registers::beg, re_registers::end, and IS_NULL.

## ◆ onig_set_default_case_fold_flag()

int onig_set_default_case_fold_flag | ( | OnigCaseFoldType | case_fold_flag | ) |

Definition at line 42 of file regcomp.c.

References OnigDefaultCaseFoldFlag.

## Variable Documentation

## ◆ OnigDefaultCaseFoldFlag

OnigCaseFoldType OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN

Definition at line 33 of file regcomp.c.

Referenced by onig_get_default_case_fold_flag(), and onig_set_default_case_fold_flag().