Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

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 )

## ◆ 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 )

## ◆ CKN_ON

#define CKN_ON (ckn > 0)

Definition at line 722 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 2411 of file regcomp.c.

## ◆ GET_CHAR_LEN_VARLEN

#define GET_CHAR_LEN_VARLEN -1

Definition at line 2410 of file regcomp.c.

## ◆ IN_ALT

#define IN_ALT (1<<0)

Definition at line 3857 of file regcomp.c.

## ◆ IN_CALL

#define IN_CALL (1<<4)

Definition at line 3861 of file regcomp.c.

## ◆ IN_NOT

#define IN_NOT (1<<1)

Definition at line 3858 of file regcomp.c.

## ◆ IN_RECCALL

#define IN_RECCALL (1<<5)

Definition at line 3862 of file regcomp.c.

## ◆ IN_REPEAT

#define IN_REPEAT (1<<2)

Definition at line 3859 of file regcomp.c.

## ◆ IN_VAR_REPEAT

#define IN_VAR_REPEAT (1<<3)

Definition at line 3860 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)

Definition at line 315 of file regcomp.c.

## ◆ MAX_NODE_OPT_INFO_REF_COUNT

#define MAX_NODE_OPT_INFO_REF_COUNT 5

Definition at line 4952 of file regcomp.c.

## ◆ QUANTIFIER_EXPAND_LIMIT_SIZE

#define QUANTIFIER_EXPAND_LIMIT_SIZE 50

Definition at line 721 of file regcomp.c.

## ◆ RECURSION_EXIST

#define RECURSION_EXIST 1

Definition at line 2885 of file regcomp.c.

## ◆ RECURSION_INFINITE

#define RECURSION_INFINITE 2

Definition at line 2886 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)

Definition at line 5678 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 6025 of file regcomp.c.

References OnigEndCallListItem::next, and xmalloc.

## ◆ onig_bbuf_init()

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

Definition at line 142 of file regcomp.c.

References buf, int, IS_NULL, NULL, ONIGERR_MEMORY, size, UChar, and xmalloc.

## ◆ onig_compile()

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

Definition at line 5701 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 5710 of file regcomp.c.

References re_pattern_buffer::alloc, BBUF_INIT, COMPILE_INIT_SIZE, re_pattern_buffer::enc, err, fprintf(), IS_NOT_NULL, IS_SYNTAX_BV, NULL, re_pattern_buffer::num_comb_exp_check, ScanEnv::num_mem, re_pattern_buffer::num_mem, ScanEnv::num_named, re_pattern_buffer::num_null_check, re_pattern_buffer::num_repeat, ONIG_IS_OPTION_ON, ONIG_OPTION_CAPTURE_GROUP, onig_parse_make_tree(), ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP, re_pattern_buffer::options, OnigErrorInfo::par, re_pattern_buffer::repeat_range, re_pattern_buffer::repeat_range_alloc, ScanEnv::sourcefile, ScanEnv::sourceline, stderr, ScanEnv::syntax, UChar, and re_pattern_buffer::used.

Referenced by onig_compile().

## ◆ onig_end()

int onig_end | ( | void |  | ) |

Definition at line 6055 of file regcomp.c.

## ◆ onig_free()

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

Definition at line 5644 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 5627 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 6001 of file regcomp.c.

Referenced by onig_initialize().

## ◆ onig_initialize()

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

Definition at line 5995 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 6117 of file regcomp.c.

References cc, 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 6094 of file regcomp.c.

References BITSET_AT, cc, IS_NCCLASS_NOT, IS_NULL, onig_is_in_code_range(), 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 6073 of file regcomp.c.

References GET_CODE_POINT, and n.

Referenced by onig_is_code_in_cc_len().

## ◆ onig_memsize()

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

Definition at line 5654 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, re_pattern_buffer::p, re_pattern_buffer::repeat_range, re_pattern_buffer::repeat_range_alloc, and size.

## ◆ 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 5973 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 5959 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 5915 of file regcomp.c.

Referenced by onig_new(), and onig_new_without_alloc().

## ◆ onig_region_memsize()

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

Definition at line 5669 of file regcomp.c.

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

## ◆ 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().

ANCHOR_BEGIN_LINE
#define ANCHOR_BEGIN_LINE
Definition: regint.h:528
BIT_NT_ANCHOR
#define BIT_NT_ANCHOR
Definition: regparse.h:60
ANCHOR_LOOK_BEHIND
#define ANCHOR_LOOK_BEHIND
Definition: regint.h:540
BIT_NT_ENCLOSE
#define BIT_NT_ENCLOSE
Definition: regparse.h:59
OP_EXACTMBN
@ OP_EXACTMBN
Definition: regint.h:564
BIT_NT_LIST
#define BIT_NT_LIST
Definition: regparse.h:61
OP_EXACTN
@ OP_EXACTN
Definition: regint.h:558
ANCHOR_WORD_END
#define ANCHOR_WORD_END
Definition: regint.h:537
ANCHOR_NOT_WORD_BOUND
#define ANCHOR_NOT_WORD_BOUND
Definition: regint.h:535
BIT_NT_CTYPE
#define BIT_NT_CTYPE
Definition: regparse.h:55
BIT_NT_CCLASS
#define BIT_NT_CCLASS
Definition: regparse.h:54
OP_EXACTMB3N
@ OP_EXACTMB3N
Definition: regint.h:563
BIT_NT_CALL
#define BIT_NT_CALL
Definition: regparse.h:63
ANCHOR_BEGIN_POSITION
#define ANCHOR_BEGIN_POSITION
Definition: regint.h:529
re_pattern_buffer
Definition: onigmo.h:755
BIT_NT_STR
#define BIT_NT_STR
Definition: regparse.h:53
ANCHOR_KEEP
#define ANCHOR_KEEP
Definition: regint.h:546
BIT_NT_ALT
#define BIT_NT_ALT
Definition: regparse.h:62
ANCHOR_LOOK_BEHIND_NOT
#define ANCHOR_LOOK_BEHIND_NOT
Definition: regint.h:541
OP_EXACTN_IC
@ OP_EXACTN_IC
Definition: regint.h:567
ANCHOR_BEGIN_BUF
#define ANCHOR_BEGIN_BUF
Definition: regint.h:527
BIT_NT_QTFR
#define BIT_NT_QTFR
Definition: regparse.h:58
OP_EXACTMB2N
@ OP_EXACTMB2N
Definition: regint.h:562