Ruby  2.1.10p492(2016-04-01revision54464)
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_ROOT   (1<<4)
 
#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 OPT_EXACT_MAXLEN   24
 
#define COMP_EM_BASE   20
 
#define MAX_NODE_OPT_INFO_REF_COUNT   5
 
#define REGEX_TRANSFER(to, from)
 
#define REGEX_CHAIN_HEAD(reg)
 
#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)
 
static void swap_node (Node *a, Node *b)
 
static OnigDistance distance_add (OnigDistance d1, OnigDistance d2)
 
static OnigDistance distance_multiply (OnigDistance d, int m)
 
static int bitset_is_empty (BitSetRef bs)
 
int onig_bbuf_init (BBuf *buf, OnigDistance size)
 
static int unset_addr_list_init (UnsetAddrList *uslist, int size)
 
static void unset_addr_list_end (UnsetAddrList *uslist)
 
static int unset_addr_list_add (UnsetAddrList *uslist, int offset, struct _Node *node)
 
static int add_opcode (regex_t *reg, int opcode)
 
static int add_rel_addr (regex_t *reg, int addr)
 
static int add_abs_addr (regex_t *reg, int addr)
 
static int add_length (regex_t *reg, OnigDistance len)
 
static int add_mem_num (regex_t *reg, int num)
 
static int add_pointer (regex_t *reg, void *addr)
 
static int add_option (regex_t *reg, OnigOptionType option)
 
static int add_opcode_rel_addr (regex_t *reg, int opcode, int addr)
 
static int add_bytes (regex_t *reg, UChar *bytes, OnigDistance len)
 
static int add_bitset (regex_t *reg, BitSetRef bs)
 
static int add_opcode_option (regex_t *reg, int opcode, OnigOptionType option)
 
static int compile_length_tree (Node *node, regex_t *reg)
 
static int compile_tree (Node *node, regex_t *reg)
 
static int select_str_opcode (int mb_len, OnigDistance str_len, int ignore_case)
 
static int compile_tree_empty_check (Node *node, regex_t *reg, int empty_info)
 
static int compile_call (CallNode *node, regex_t *reg)
 
static int compile_tree_n_times (Node *node, int n, regex_t *reg)
 
static int add_compile_string_length (UChar *s ARG_UNUSED, int mb_len, OnigDistance str_len, regex_t *reg ARG_UNUSED, int ignore_case)
 
static int add_compile_string (UChar *s, int mb_len, OnigDistance str_len, regex_t *reg, int ignore_case)
 
static int compile_length_string_node (Node *node, regex_t *reg)
 
static int compile_length_string_raw_node (StrNode *sn, regex_t *reg)
 
static int compile_string_node (Node *node, regex_t *reg)
 
static int compile_string_raw_node (StrNode *sn, regex_t *reg)
 
static int add_multi_byte_cclass (BBuf *mbuf, regex_t *reg)
 
static int compile_length_cclass_node (CClassNode *cc, regex_t *reg)
 
static int compile_cclass_node (CClassNode *cc, regex_t *reg)
 
static int entry_repeat_range (regex_t *reg, int id, int lower, int upper)
 
static int compile_range_repeat_node (QtfrNode *qn, int target_len, int empty_info, regex_t *reg)
 
static int is_anychar_star_quantifier (QtfrNode *qn)
 
static int compile_length_quantifier_node (QtfrNode *qn, regex_t *reg)
 
static int compile_quantifier_node (QtfrNode *qn, regex_t *reg)
 
static int compile_length_option_node (EncloseNode *node, regex_t *reg)
 
static int compile_option_node (EncloseNode *node, regex_t *reg)
 
static int compile_length_enclose_node (EncloseNode *node, regex_t *reg)
 
static int get_char_length_tree (Node *node, regex_t *reg, int *len)
 
static int compile_enclose_node (EncloseNode *node, regex_t *reg)
 
static int compile_length_anchor_node (AnchorNode *node, regex_t *reg)
 
static int compile_anchor_node (AnchorNode *node, regex_t *reg)
 
static int noname_disable_map (Node **plink, GroupNumRemap *map, int *counter)
 
static int renumber_node_backref (Node *node, GroupNumRemap *map)
 
static int renumber_by_map (Node *node, GroupNumRemap *map)
 
static int numbered_ref_check (Node *node)
 
static int disable_noname_group_capture (Node **root, regex_t *reg, ScanEnv *env)
 
static int unset_addr_list_fix (UnsetAddrList *uslist, regex_t *reg)
 
static int quantifiers_memory_node_info (Node *node)
 
static int get_min_match_length (Node *node, OnigDistance *min, ScanEnv *env)
 
static int get_max_match_length (Node *node, OnigDistance *max, ScanEnv *env)
 
static int get_char_length_tree1 (Node *node, regex_t *reg, int *len, int level)
 
static int is_not_included (Node *x, Node *y, regex_t *reg)
 
static Nodeget_head_value_node (Node *node, int exact, regex_t *reg)
 
static int check_type_tree (Node *node, int type_mask, int enclose_mask, int anchor_mask)
 
static int subexp_inf_recursive_check (Node *node, ScanEnv *env, int head)
 
static int subexp_inf_recursive_check_trav (Node *node, ScanEnv *env)
 
static int subexp_recursive_check (Node *node)
 
static int subexp_recursive_check_trav (Node *node, ScanEnv *env)
 
static int setup_subexp_call (Node *node, ScanEnv *env)
 
static int divide_look_behind_alternatives (Node *node)
 
static int setup_look_behind (Node *node, regex_t *reg, ScanEnv *env)
 
static int next_setup (Node *node, Node *next_node, int in_root, regex_t *reg)
 
static int update_string_node_case_fold (regex_t *reg, Node *node)
 
static int expand_case_fold_make_rem_string (Node **rnode, UChar *s, UChar *end, regex_t *reg)
 
static int expand_case_fold_string_alt (int item_num, OnigCaseFoldCodeItem items[], UChar *p, int slen, UChar *end, regex_t *reg, Node **rnode)
 
static int expand_case_fold_string (Node *node, regex_t *reg)
 
static int setup_tree (Node *node, regex_t *reg, int state, ScanEnv *env)
 
static int set_bm_skip (UChar *s, UChar *end, regex_t *reg, UChar skip[], int **int_skip, int ignore_case)
 
static int map_position_value (OnigEncoding enc, int i)
 
static int distance_value (MinMaxLen *mm)
 
static int comp_distance_value (MinMaxLen *d1, MinMaxLen *d2, int v1, int v2)
 
static int is_equal_mml (MinMaxLen *a, MinMaxLen *b)
 
static void set_mml (MinMaxLen *mml, OnigDistance min, OnigDistance max)
 
static void clear_mml (MinMaxLen *mml)
 
static void copy_mml (MinMaxLen *to, MinMaxLen *from)
 
static void add_mml (MinMaxLen *to, MinMaxLen *from)
 
static void alt_merge_mml (MinMaxLen *to, MinMaxLen *from)
 
static void copy_opt_env (OptEnv *to, OptEnv *from)
 
static void clear_opt_anc_info (OptAncInfo *anc)
 
static void copy_opt_anc_info (OptAncInfo *to, OptAncInfo *from)
 
static void concat_opt_anc_info (OptAncInfo *to, OptAncInfo *left, OptAncInfo *right, OnigDistance left_len, OnigDistance right_len)
 
static int is_left_anchor (int anc)
 
static int is_set_opt_anc_info (OptAncInfo *to, int anc)
 
static void add_opt_anc_info (OptAncInfo *to, int anc)
 
static void remove_opt_anc_info (OptAncInfo *to, int anc)
 
static void alt_merge_opt_anc_info (OptAncInfo *to, OptAncInfo *add)
 
static int is_full_opt_exact_info (OptExactInfo *ex)
 
static void clear_opt_exact_info (OptExactInfo *ex)
 
static void copy_opt_exact_info (OptExactInfo *to, OptExactInfo *from)
 
static void concat_opt_exact_info (OptExactInfo *to, OptExactInfo *add, OnigEncoding enc)
 
static void concat_opt_exact_info_str (OptExactInfo *to, UChar *s, UChar *end, int raw ARG_UNUSED, OnigEncoding enc)
 
static void alt_merge_opt_exact_info (OptExactInfo *to, OptExactInfo *add, OptEnv *env)
 
static void select_opt_exact_info (OnigEncoding enc, OptExactInfo *now, OptExactInfo *alt)
 
static void clear_opt_map_info (OptMapInfo *map)
 
static void copy_opt_map_info (OptMapInfo *to, OptMapInfo *from)
 
static void add_char_opt_map_info (OptMapInfo *map, UChar c, OnigEncoding enc)
 
static int add_char_amb_opt_map_info (OptMapInfo *map, UChar *p, UChar *end, OnigEncoding enc, OnigCaseFoldType case_fold_flag)
 
static void select_opt_map_info (OptMapInfo *now, OptMapInfo *alt)
 
static int comp_opt_exact_or_map_info (OptExactInfo *e, OptMapInfo *m)
 
static void alt_merge_opt_map_info (OnigEncoding enc, OptMapInfo *to, OptMapInfo *add)
 
static void set_bound_node_opt_info (NodeOptInfo *opt, MinMaxLen *mmd)
 
static void clear_node_opt_info (NodeOptInfo *opt)
 
static void copy_node_opt_info (NodeOptInfo *to, NodeOptInfo *from)
 
static void concat_left_node_opt_info (OnigEncoding enc, NodeOptInfo *to, NodeOptInfo *add)
 
static void alt_merge_node_opt_info (NodeOptInfo *to, NodeOptInfo *add, OptEnv *env)
 
static int optimize_node_left (Node *node, NodeOptInfo *opt, OptEnv *env)
 
static int set_optimize_exact_info (regex_t *reg, OptExactInfo *e)
 
static void set_optimize_map_info (regex_t *reg, OptMapInfo *m)
 
static void set_sub_anchor (regex_t *reg, OptAncInfo *anc)
 
static int set_optimize_info_from_tree (Node *node, regex_t *reg, ScanEnv *scan_env)
 
static void clear_optimize_info (regex_t *reg)
 
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)
 
void onig_transfer (regex_t *to, regex_t *from)
 
void onig_chain_link_add (regex_t *to, regex_t *add)
 
void onig_chain_reduce (regex_t *reg)
 
int onig_compile (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, 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_init (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
 
static unsigned char PadBuf [WORD_ALIGNMENT_SIZE]
 
static int onig_inited = 0
 

Macro Definition Documentation

#define ALLOWED_ANCHOR_IN_LB
Value:
#define ANCHOR_WORD_BEGIN
Definition: regint.h:507
#define ANCHOR_BEGIN_LINE
Definition: regint.h:499
#define ANCHOR_END_LINE
Definition: regint.h:503
#define ANCHOR_BEGIN_POSITION
Definition: regint.h:500
#define ANCHOR_NOT_WORD_BOUND
Definition: regint.h:506
#define ANCHOR_WORD_END
Definition: regint.h:508
#define ANCHOR_LOOK_BEHIND_NOT
Definition: regint.h:512
#define ANCHOR_BEGIN_BUF
Definition: regint.h:498
#define ANCHOR_LOOK_BEHIND
Definition: regint.h:511
#define ANCHOR_WORD_BOUND
Definition: regint.h:505
#define ANCHOR_KEEP
Definition: regint.h:517

Referenced by setup_tree().

#define ALLOWED_ANCHOR_IN_LB_NOT
Value:
#define ANCHOR_WORD_BEGIN
Definition: regint.h:507
#define ANCHOR_BEGIN_LINE
Definition: regint.h:499
#define ANCHOR_END_LINE
Definition: regint.h:503
#define ANCHOR_BEGIN_POSITION
Definition: regint.h:500
#define ANCHOR_NOT_WORD_BOUND
Definition: regint.h:506
#define ANCHOR_WORD_END
Definition: regint.h:508
#define ANCHOR_LOOK_BEHIND_NOT
Definition: regint.h:512
#define ANCHOR_BEGIN_BUF
Definition: regint.h:498
#define ANCHOR_LOOK_BEHIND
Definition: regint.h:511
#define ANCHOR_WORD_BOUND
Definition: regint.h:505
#define ANCHOR_KEEP
Definition: regint.h:517

Referenced by setup_tree().

#define ALLOWED_ENCLOSE_IN_LB   ( ENCLOSE_MEMORY | ENCLOSE_OPTION )

Referenced by setup_tree().

#define ALLOWED_ENCLOSE_IN_LB_NOT   ENCLOSE_OPTION

Referenced by setup_tree().

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

Referenced by setup_tree().

#define CKN_ON   (ckn > 0)

Definition at line 736 of file regcomp.c.

#define COMP_EM_BASE   20
#define COMPILE_INIT_SIZE   20

Referenced by onig_compile().

#define EXPAND_STRING_MAX_LENGTH   100

Referenced by setup_tree().

#define FOUND_CALLED_NODE   1
#define GET_CHAR_LEN_TOP_ALT_VARLEN   -2

Definition at line 2384 of file regcomp.c.

Referenced by get_char_length_tree1(), and setup_look_behind().

#define GET_CHAR_LEN_VARLEN   -1

Definition at line 2383 of file regcomp.c.

Referenced by get_char_length_tree1(), and setup_look_behind().

#define IN_ALT   (1<<0)

Definition at line 3834 of file regcomp.c.

Referenced by setup_tree().

#define IN_NOT   (1<<1)

Definition at line 3835 of file regcomp.c.

Referenced by setup_tree().

#define IN_REPEAT   (1<<2)

Definition at line 3836 of file regcomp.c.

Referenced by setup_tree().

#define IN_ROOT   (1<<4)

Definition at line 3838 of file regcomp.c.

Referenced by onig_compile(), and setup_tree().

#define IN_VAR_REPEAT   (1<<3)

Definition at line 3837 of file regcomp.c.

Referenced by setup_tree().

#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 319 of file regcomp.c.

Referenced by add_compile_string(), and add_compile_string_length().

#define MAX_NODE_OPT_INFO_REF_COUNT   5

Definition at line 4907 of file regcomp.c.

Referenced by optimize_node_left().

#define OPT_EXACT_MAXLEN   24
#define QUANTIFIER_EXPAND_LIMIT_SIZE   50

Definition at line 735 of file regcomp.c.

Referenced by compile_length_quantifier_node(), and compile_quantifier_node().

#define RECURSION_EXIST   1

Definition at line 2851 of file regcomp.c.

Referenced by subexp_inf_recursive_check().

#define RECURSION_INFINITE   2

Definition at line 2852 of file regcomp.c.

Referenced by subexp_inf_recursive_check().

#define REGEX_CHAIN_HEAD (   reg)
Value:
do {\
while (IS_NOT_NULL((reg)->chain)) {\
(reg) = (reg)->chain;\
}\
} while (0)
while(a->frac[0]/shift==0)
Definition: bigdecimal.c:5241
#define IS_NOT_NULL(p)
Definition: regint.h:277

Definition at line 5634 of file regcomp.c.

Referenced by onig_chain_link_add().

#define REGEX_TRANSFER (   to,
  from 
)
Value:
do {\
xmemcpy(to, from, sizeof(regex_t));\
xfree(from);\
} while (0)
#define xfree
#define ONIG_STATE_MODIFY
memo state
Definition: enum.c:2432
void onig_free_body(regex_t *reg)
Definition: regcomp.c:5570
#define xmemcpy
Definition: regint.h:182

Definition at line 5619 of file regcomp.c.

Referenced by onig_chain_reduce(), and onig_transfer().

#define REPEAT_RANGE_ALLOC   4

Referenced by entry_repeat_range().

#define THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION   8

Referenced by expand_case_fold_string().

Function Documentation

static int add_abs_addr ( regex_t reg,
int  addr 
)
static

Definition at line 237 of file regcomp.c.

References BBUF_ADD, and SIZE_ABSADDR.

Referenced by compile_call(), and compile_enclose_node().

static int add_bitset ( regex_t reg,
BitSetRef  bs 
)
static

Definition at line 298 of file regcomp.c.

References BBUF_ADD, and SIZE_BITSET.

Referenced by compile_cclass_node().

static int add_bytes ( regex_t reg,
UChar bytes,
OnigDistance  len 
)
static

Definition at line 291 of file regcomp.c.

References BBUF_ADD.

Referenced by add_compile_string(), add_multi_byte_cclass(), and compile_quantifier_node().

static int add_char_amb_opt_map_info ( OptMapInfo map,
UChar p,
UChar end,
OnigEncoding  enc,
OnigCaseFoldType  case_fold_flag 
)
static
static void add_char_opt_map_info ( OptMapInfo map,
UChar  c,
OnigEncoding  enc 
)
static

Definition at line 4721 of file regcomp.c.

References c, OptMapInfo::map, map_position_value(), and OptMapInfo::value.

Referenced by add_char_amb_opt_map_info(), and optimize_node_left().

static int add_compile_string ( UChar s,
int  mb_len,
OnigDistance  str_len,
regex_t reg,
int  ignore_case 
)
static
static int add_compile_string_length ( UChar *s  ARG_UNUSED,
int  mb_len,
OnigDistance  str_len,
regex_t *reg  ARG_UNUSED,
int  ignore_case 
)
static
static int add_length ( regex_t reg,
OnigDistance  len 
)
static

Definition at line 246 of file regcomp.c.

References BBUF_ADD, and SIZE_LENGTH.

Referenced by add_compile_string(), add_multi_byte_cclass(), compile_anchor_node(), and compile_tree().

static int add_mem_num ( regex_t reg,
int  num 
)
static
static void add_mml ( MinMaxLen to,
MinMaxLen from 
)
static

Definition at line 4442 of file regcomp.c.

References distance_add(), MinMaxLen::max, and MinMaxLen::min.

Referenced by concat_left_node_opt_info(), and optimize_node_left().

static int add_multi_byte_cclass ( BBuf mbuf,
regex_t reg 
)
static
static int add_opcode ( regex_t reg,
int  opcode 
)
static
static int add_opcode_option ( regex_t reg,
int  opcode,
OnigOptionType  option 
)
static

Definition at line 305 of file regcomp.c.

References add_opcode(), add_option(), and r.

Referenced by compile_option_node().

static int add_opcode_rel_addr ( regex_t reg,
int  opcode,
int  addr 
)
static
static void add_opt_anc_info ( OptAncInfo to,
int  anc 
)
static

Definition at line 4523 of file regcomp.c.

References is_left_anchor(), OptAncInfo::left_anchor, and OptAncInfo::right_anchor.

Referenced by optimize_node_left().

static int add_option ( regex_t reg,
OnigOptionType  option 
)
static

Definition at line 273 of file regcomp.c.

References BBUF_ADD, and SIZE_OPTION.

Referenced by add_opcode_option(), and compile_tree().

static int add_pointer ( regex_t reg,
void addr 
)
static

Definition at line 264 of file regcomp.c.

References BBUF_ADD, ptr, and SIZE_POINTER.

Referenced by compile_cclass_node().

static int add_rel_addr ( regex_t reg,
int  addr 
)
static

Definition at line 228 of file regcomp.c.

References BBUF_ADD, and SIZE_RELADDR.

Referenced by add_opcode_rel_addr(), compile_enclose_node(), and compile_range_repeat_node().

static void alt_merge_mml ( MinMaxLen to,
MinMaxLen from 
)
static

Definition at line 4458 of file regcomp.c.

References MinMaxLen::max, and MinMaxLen::min.

Referenced by alt_merge_node_opt_info(), and alt_merge_opt_map_info().

static void alt_merge_node_opt_info ( NodeOptInfo to,
NodeOptInfo add,
OptEnv env 
)
static
static void alt_merge_opt_anc_info ( OptAncInfo to,
OptAncInfo add 
)
static
static void alt_merge_opt_exact_info ( OptExactInfo to,
OptExactInfo add,
OptEnv env 
)
static
static void alt_merge_opt_map_info ( OnigEncoding  enc,
OptMapInfo to,
OptMapInfo add 
)
static
static int bitset_is_empty ( BitSetRef  bs)
static

Definition at line 118 of file regcomp.c.

References BITSET_SIZE, and i.

Referenced by compile_cclass_node(), and compile_length_cclass_node().

static int check_type_tree ( Node node,
int  type_mask,
int  enclose_mask,
int  anchor_mask 
)
static
static void clear_mml ( MinMaxLen mml)
static
static void clear_node_opt_info ( NodeOptInfo opt)
static
static void clear_opt_anc_info ( OptAncInfo anc)
static
static void clear_opt_exact_info ( OptExactInfo ex)
static
static void clear_opt_map_info ( OptMapInfo map)
static

Definition at line 4687 of file regcomp.c.

References xmemcpy.

Referenced by alt_merge_opt_map_info(), and clear_node_opt_info().

static void clear_optimize_info ( regex_t reg)
static
static int comp_distance_value ( MinMaxLen d1,
MinMaxLen d2,
int  v1,
int  v2 
)
static
static int comp_opt_exact_or_map_info ( OptExactInfo e,
OptMapInfo m 
)
static
static int compile_anchor_node ( AnchorNode node,
regex_t reg 
)
static
static int compile_call ( CallNode node,
regex_t reg 
)
static
static int compile_cclass_node ( CClassNode cc,
regex_t reg 
)
static
static int compile_enclose_node ( EncloseNode node,
regex_t reg 
)
static
static int compile_length_anchor_node ( AnchorNode node,
regex_t reg 
)
static
static int compile_length_cclass_node ( CClassNode cc,
regex_t reg 
)
static
static int compile_length_enclose_node ( EncloseNode node,
regex_t reg 
)
static
static int compile_length_option_node ( EncloseNode node,
regex_t reg 
)
static
static int compile_length_quantifier_node ( QtfrNode qn,
regex_t reg 
)
static
static int compile_length_string_node ( Node node,
regex_t reg 
)
static
static int compile_length_string_raw_node ( StrNode sn,
regex_t reg 
)
static

Definition at line 506 of file regcomp.c.

References add_compile_string_length(), StrNode::end, and StrNode::s.

Referenced by compile_length_tree().

static int compile_length_tree ( Node node,
regex_t reg 
)
static
static int compile_option_node ( EncloseNode node,
regex_t reg 
)
static
static int compile_quantifier_node ( QtfrNode qn,
regex_t reg 
)
static
static int compile_range_repeat_node ( QtfrNode qn,
int  target_len,
int  empty_info,
regex_t reg 
)
static
static int compile_string_node ( Node node,
regex_t reg 
)
static

Definition at line 515 of file regcomp.c.

References add_compile_string(), re_pattern_buffer::enc, enc, enclen, StrNode::end, end, len, NSTR, NSTRING_IS_AMBIG, p, r, StrNode::s, and UChar.

Referenced by compile_tree().

static int compile_string_raw_node ( StrNode sn,
regex_t reg 
)
static

Definition at line 554 of file regcomp.c.

References add_compile_string(), StrNode::end, and StrNode::s.

Referenced by compile_tree().

static int compile_tree ( Node node,
regex_t reg 
)
static
static int compile_tree_empty_check ( Node node,
regex_t reg,
int  empty_info 
)
static
static int compile_tree_n_times ( Node node,
int  n,
regex_t reg 
)
static

Definition at line 416 of file regcomp.c.

References compile_tree(), i, n, and r.

Referenced by compile_enclose_node(), and compile_quantifier_node().

static void concat_left_node_opt_info ( OnigEncoding  enc,
NodeOptInfo to,
NodeOptInfo add 
)
static
static void concat_opt_anc_info ( OptAncInfo to,
OptAncInfo left,
OptAncInfo right,
OnigDistance  left_len,
OnigDistance  right_len 
)
static
static void concat_opt_exact_info ( OptExactInfo to,
OptExactInfo add,
OnigEncoding  enc 
)
static
static void concat_opt_exact_info_str ( OptExactInfo to,
UChar s,
UChar end,
int raw  ARG_UNUSED,
OnigEncoding  enc 
)
static

Definition at line 4600 of file regcomp.c.

References enclen, end, i, j, len, OptExactInfo::len, OPT_EXACT_MAXLEN, p, OptExactInfo::s, and UChar.

Referenced by optimize_node_left().

static void copy_mml ( MinMaxLen to,
MinMaxLen from 
)
static

Definition at line 4435 of file regcomp.c.

References MinMaxLen::max, and MinMaxLen::min.

Referenced by set_bound_node_opt_info().

static void copy_node_opt_info ( NodeOptInfo to,
NodeOptInfo from 
)
static

Definition at line 4830 of file regcomp.c.

Referenced by optimize_node_left().

static void copy_opt_anc_info ( OptAncInfo to,
OptAncInfo from 
)
static

Definition at line 4478 of file regcomp.c.

Referenced by concat_left_node_opt_info(), and concat_opt_exact_info().

static void copy_opt_env ( OptEnv to,
OptEnv from 
)
static

Definition at line 4465 of file regcomp.c.

Referenced by optimize_node_left().

static void copy_opt_exact_info ( OptExactInfo to,
OptExactInfo from 
)
static
static void copy_opt_map_info ( OptMapInfo to,
OptMapInfo from 
)
static

Definition at line 4715 of file regcomp.c.

Referenced by optimize_node_left(), and select_opt_map_info().

static int disable_noname_group_capture ( Node **  root,
regex_t reg,
ScanEnv env 
)
static
static OnigDistance distance_add ( OnigDistance  d1,
OnigDistance  d2 
)
static

Definition at line 96 of file regcomp.c.

References ONIG_INFINITE_DISTANCE.

Referenced by add_mml(), get_char_length_tree1(), and get_max_match_length().

static OnigDistance distance_multiply ( OnigDistance  d,
int  m 
)
static
static int distance_value ( MinMaxLen mm)
static

Definition at line 4369 of file regcomp.c.

References d, MinMaxLen::max, MinMaxLen::min, and ONIG_INFINITE_DISTANCE.

Referenced by comp_distance_value().

static int divide_look_behind_alternatives ( Node node)
static
static int entry_repeat_range ( regex_t reg,
int  id,
int  lower,
int  upper 
)
static
static int expand_case_fold_make_rem_string ( Node **  rnode,
UChar s,
UChar end,
regex_t reg 
)
static
static int expand_case_fold_string ( Node node,
regex_t reg 
)
static
static int expand_case_fold_string_alt ( int  item_num,
OnigCaseFoldCodeItem  items[],
UChar p,
int  slen,
UChar end,
regex_t reg,
Node **  rnode 
)
static
static int get_char_length_tree ( Node node,
regex_t reg,
int len 
)
static

Definition at line 2512 of file regcomp.c.

References get_char_length_tree1().

Referenced by compile_anchor_node(), and setup_look_behind().

static int get_char_length_tree1 ( Node node,
regex_t reg,
int len,
int  level 
)
static
static Node* get_head_value_node ( Node node,
int  exact,
regex_t reg 
)
static
static int get_max_match_length ( Node node,
OnigDistance max,
ScanEnv env 
)
static
static int get_min_match_length ( Node node,
OnigDistance min,
ScanEnv env 
)
static
static int is_anychar_star_quantifier ( QtfrNode qn)
static
static int is_equal_mml ( MinMaxLen a,
MinMaxLen b 
)
static

Definition at line 4415 of file regcomp.c.

References MinMaxLen::max, and MinMaxLen::min.

Referenced by alt_merge_opt_exact_info().

static int is_full_opt_exact_info ( OptExactInfo ex)
static

Definition at line 4548 of file regcomp.c.

References OptExactInfo::len, and OPT_EXACT_MAXLEN.

Referenced by optimize_node_left().

static int is_left_anchor ( int  anc)
static
static int is_not_included ( Node x,
Node y,
regex_t reg 
)
static
static int is_set_opt_anc_info ( OptAncInfo to,
int  anc 
)
static

Definition at line 4515 of file regcomp.c.

References OptAncInfo::left_anchor, and OptAncInfo::right_anchor.

Referenced by optimize_node_left().

static int map_position_value ( OnigEncoding  enc,
int  i 
)
static

Definition at line 4345 of file regcomp.c.

References i, and ONIGENC_MBC_MINLEN.

Referenced by add_char_opt_map_info(), alt_merge_opt_map_info(), and select_opt_exact_info().

static int next_setup ( Node node,
Node next_node,
int  in_root,
regex_t reg 
)
static
static int noname_disable_map ( Node **  plink,
GroupNumRemap map,
int counter 
)
static
static int numbered_ref_check ( Node node)
static
int onig_bbuf_init ( BBuf buf,
OnigDistance  size 
)

Definition at line 148 of file regcomp.c.

References _BBuf::alloc, int, IS_NULL, NULL, ONIGERR_MEMORY, _BBuf::p, UChar, _BBuf::used, and xmalloc.

void onig_chain_link_add ( regex_t to,
regex_t add 
)
void onig_chain_reduce ( regex_t reg)
int onig_compile ( regex_t reg,
const UChar pattern,
const UChar pattern_end,
OnigErrorInfo einfo,
const char *  sourcefile,
int  sourceline 
)

Definition at line 5675 of file regcomp.c.

References add_opcode(), re_pattern_buffer::alloc, ScanEnv::backrefed_mem, BBUF_INIT, BIT_STATUS_AT, BIT_STATUS_ON_ALL, ScanEnv::bt_mem_end, re_pattern_buffer::bt_mem_end, ScanEnv::bt_mem_start, re_pattern_buffer::bt_mem_start, ScanEnv::capture_history, re_pattern_buffer::capture_history, clear_optimize_info(), COMPILE_INIT_SIZE, compile_tree(), disable_noname_group_capture(), ScanEnv::enc, OnigErrorInfo::enc, re_pattern_buffer::enc, end, err, ScanEnv::error, ScanEnv::error_end, i, IN_ROOT, IS_FIND_CONDITION, IS_NOT_NULL, IS_SYNTAX_BV, ScanEnv::mem_nodes_dynamic, NULL, ScanEnv::num_call, re_pattern_buffer::num_call, 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, numbered_ref_check(), ONIG_IS_OPTION_ON, onig_node_free(), ONIG_OPTION_CAPTURE_GROUP, onig_parse_make_tree(), ONIG_STATE_COMPILING, ONIG_STATE_NORMAL, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP, OP_END, re_pattern_buffer::options, OnigErrorInfo::par, OnigErrorInfo::par_end, r, re_pattern_buffer::repeat_range, re_pattern_buffer::repeat_range_alloc, set_optimize_info_from_tree(), setup_subexp_call(), setup_tree(), ScanEnv::sourcefile, ScanEnv::sourceline, re_pattern_buffer::stack_pop_level, STACK_POP_LEVEL_ALL, STACK_POP_LEVEL_FREE, STACK_POP_LEVEL_MEM_START, re_pattern_buffer::state, subexp_inf_recursive_check_trav(), subexp_recursive_check_trav(), ScanEnv::syntax, UChar, ScanEnv::unset_addr_list, unset_addr_list_end(), unset_addr_list_fix(), unset_addr_list_init(), USE_SUBEXP_CALL, re_pattern_buffer::used, and xfree.

Referenced by onig_new(), onig_new_with_source(), and onig_new_without_alloc().

int onig_end ( void  )
void onig_free ( regex_t reg)
void onig_free_body ( regex_t reg)
OnigCaseFoldType onig_get_default_case_fold_flag ( void  )

Definition at line 36 of file regcomp.c.

References OnigDefaultCaseFoldFlag.

int onig_init ( void  )

Definition at line 5981 of file regcomp.c.

References onigenc_init(), THREAD_ATOMIC_END, THREAD_ATOMIC_START, and THREAD_SYSTEM_INIT.

Referenced by onig_reg_init().

int onig_is_code_in_cc ( OnigEncoding  enc,
OnigCodePoint  code,
CClassNode cc 
)
int onig_is_code_in_cc_len ( int  elen,
OnigCodePoint  code,
CClassNode cc 
)
int onig_is_in_code_range ( const UChar p,
OnigCodePoint  code 
)

Definition at line 6028 of file regcomp.c.

References data, GET_CODE_POINT, and n.

Referenced by match_at(), and onig_is_code_in_cc_len().

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

Definition at line 5944 of file regcomp.c.

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

int onig_reg_init ( regex_t reg,
OnigOptionType  option,
OnigCaseFoldType  case_fold_flag,
OnigEncoding  enc,
const OnigSyntaxType syntax 
)
size_t onig_region_memsize ( const OnigRegion regs)

Definition at line 5611 of file regcomp.c.

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

Referenced by obj_memsize_of(), and strscan_memsize().

int onig_set_default_case_fold_flag ( OnigCaseFoldType  case_fold_flag)

Definition at line 42 of file regcomp.c.

References OnigDefaultCaseFoldFlag.

void onig_transfer ( regex_t to,
regex_t from 
)

Definition at line 5627 of file regcomp.c.

References REGEX_TRANSFER, THREAD_ATOMIC_END, and THREAD_ATOMIC_START.

static int optimize_node_left ( Node node,
NodeOptInfo opt,
OptEnv env 
)
static

Definition at line 4910 of file regcomp.c.

References add_char_amb_opt_map_info(), add_char_opt_map_info(), add_mml(), add_opt_anc_info(), alt_merge_node_opt_info(), NodeOptInfo::anc, ANCHOR_ANYCHAR_STAR, ANCHOR_ANYCHAR_STAR_MASK, ANCHOR_ANYCHAR_STAR_ML, ANCHOR_BEGIN_BUF, ANCHOR_BEGIN_LINE, ANCHOR_BEGIN_POSITION, ANCHOR_END_BUF, ANCHOR_END_LINE, ANCHOR_LOOK_BEHIND, ANCHOR_LOOK_BEHIND_NOT, ANCHOR_PREC_READ, ANCHOR_PREC_READ_NOT, ANCHOR_SEMI_END_BUF, BRefNode::back_num, ScanEnv::backrefed_mem, BACKREFS_P, BIT_STATUS_AT, BITSET_AT, CClassNode::bs, OptEnv::case_fold_flag, clear_node_opt_info(), concat_left_node_opt_info(), concat_opt_exact_info(), concat_opt_exact_info_str(), copy_node_opt_info(), copy_opt_env(), copy_opt_exact_info(), copy_opt_map_info(), distance_multiply(), OptEnv::enc, ENCLOSE_CONDITION, ENCLOSE_MEMORY, ENCLOSE_OPTION, ENCLOSE_STOP_BACKTRACK, StrNode::end, NodeOptInfo::exb, NodeOptInfo::exm, NodeOptInfo::expr, get_max_match_length(), get_min_match_length(), QtfrNode::greedy, i, OptExactInfo::ignore_case, IS_CALL_RECURSION, IS_ENCLOSE_MAX_FIXED, IS_ENCLOSE_MIN_FIXED, is_full_opt_exact_info(), IS_MULTILINE, IS_NCCLASS_NOT, IS_NOT_NULL, IS_REPEAT_INFINITE, is_set_opt_anc_info(), OptExactInfo::len, NodeOptInfo::len, QtfrNode::lower, NodeOptInfo::map, max(), MinMaxLen::max, EncloseNode::max_len, MAX_NODE_OPT_INFO_REF_COUNT, CClassNode::mbuf, min(), MinMaxLen::min, EncloseNode::min_len, OptEnv::mmd, n, NANCHOR, NBREF, NCALL, NCAR, NCCLASS, NCDR, NCTYPE, NENCLOSE, NQTFR, NST_RECURSION, NSTR, NSTRING_IS_AMBIG, NSTRING_IS_DONT_GET_OPT_INFO, NSTRING_IS_RAW, NT_ALT, NT_ANCHOR, NT_BREF, NT_CALL, NT_CANY, NT_CCLASS, NT_CTYPE, NT_ENCLOSE, NT_LIST, NT_QTFR, NT_STR, NTYPE, ONIG_INFINITE_DISTANCE, ONIGENC_CTYPE_WORD, ONIGENC_IS_CODE_WORD, ONIGENC_MBC_MAXLEN_DIST, ONIGENC_MBC_MINLEN, onigenc_strlen(), ONIGERR_TYPE_BUG, EncloseNode::opt_count, EncloseNode::option, OptEnv::options, r, OptExactInfo::reach_end, EncloseNode::regnum, remove_opt_anc_info(), StrNode::s, OptEnv::scan_env, SCANENV_MEM_NODES, set_bound_node_opt_info(), set_mml(), SINGLE_BYTE_SIZE, BRefNode::state, QtfrNode::target, EncloseNode::target, type, EncloseNode::type, UChar, QtfrNode::upper, and OptMapInfo::value.

Referenced by set_optimize_info_from_tree().

static int quantifiers_memory_node_info ( Node node)
static
static void remove_opt_anc_info ( OptAncInfo to,
int  anc 
)
static

Definition at line 4532 of file regcomp.c.

References is_left_anchor(), OptAncInfo::left_anchor, and OptAncInfo::right_anchor.

Referenced by optimize_node_left().

static int renumber_by_map ( Node node,
GroupNumRemap map 
)
static
static int renumber_node_backref ( Node node,
GroupNumRemap map 
)
static
static void select_opt_exact_info ( OnigEncoding  enc,
OptExactInfo now,
OptExactInfo alt 
)
static
static void select_opt_map_info ( OptMapInfo now,
OptMapInfo alt 
)
static
static int select_str_opcode ( int  mb_len,
OnigDistance  str_len,
int  ignore_case 
)
static
static int set_bm_skip ( UChar s,
UChar end,
regex_t reg,
UChar  skip[],
int **  int_skip,
int  ignore_case 
)
static
static void set_bound_node_opt_info ( NodeOptInfo opt,
MinMaxLen mmd 
)
static
static void set_mml ( MinMaxLen mml,
OnigDistance  min,
OnigDistance  max 
)
static

Definition at line 4422 of file regcomp.c.

References max(), MinMaxLen::max, min(), and MinMaxLen::min.

Referenced by optimize_node_left().

static int set_optimize_exact_info ( regex_t reg,
OptExactInfo e 
)
static
static int set_optimize_info_from_tree ( Node node,
regex_t reg,
ScanEnv scan_env 
)
static
static void set_optimize_map_info ( regex_t reg,
OptMapInfo m 
)
static
static void set_sub_anchor ( regex_t reg,
OptAncInfo anc 
)
static
static int setup_look_behind ( Node node,
regex_t reg,
ScanEnv env 
)
static
static int setup_subexp_call ( Node node,
ScanEnv env 
)
static
static int setup_tree ( Node node,
regex_t reg,
int  state,
ScanEnv env 
)
static

Definition at line 3849 of file regcomp.c.

References ALLOWED_ANCHOR_IN_LB, ALLOWED_ANCHOR_IN_LB_NOT, ALLOWED_ENCLOSE_IN_LB, ALLOWED_ENCLOSE_IN_LB_NOT, ALLOWED_TYPE_IN_LB, ANCHOR_LOOK_BEHIND, ANCHOR_LOOK_BEHIND_NOT, ANCHOR_PREC_READ, ANCHOR_PREC_READ_NOT, BRefNode::back_num, ScanEnv::backrefed_mem, BACKREFS_P, BIT_STATUS_ON_AT, ScanEnv::bt_mem_end, ScanEnv::bt_mem_start, check_type_tree(), d, ENCLOSE_CONDITION, ENCLOSE_MEMORY, ENCLOSE_OPTION, ENCLOSE_STOP_BACKTRACK, StrNode::end, expand_case_fold_string(), EXPAND_STRING_MAX_LENGTH, StrNode::flag, get_head_value_node(), get_max_match_length(), get_min_match_length(), QtfrNode::greedy, QtfrNode::head_exact, i, IN_ALT, IN_NOT, IN_REPEAT, IN_ROOT, IN_VAR_REPEAT, IS_BACKREF_NEST_LEVEL, IS_ENCLOSE_NAME_REF, IS_IGNORECASE, IS_NODE_TYPE_SIMPLE, IS_NOT_NULL, IS_NULL, IS_REPEAT_INFINITE, IS_SYNTAX_BV, len, QtfrNode::lower, NANCHOR, NBREF, NCAR, NCDR, NENCLOSE, next_setup(), NQ_TARGET_IS_EMPTY, NQTFR, NST_IN_REPEAT, NST_MEM_BACKREFED, NST_STOP_BT_SIMPLE_REPEAT, NSTR, NSTRING_IS_RAW, NSTRING_LEN, NT_ALT, NT_ANCHOR, NT_BREF, NT_CALL, NT_CANY, NT_CCLASS, NT_CTYPE, NT_ENCLOSE, NT_LIST, NT_QTFR, NT_STR, NTYPE, NULL, NULL_NODE, ScanEnv::num_mem, ScanEnv::num_named, ONIG_IS_OPTION_ON, onig_node_free(), onig_node_list_add(), onig_node_new_list(), onig_node_new_str(), onig_node_str_cat(), ONIG_OPTION_CAPTURE_GROUP, ONIG_SYN_CAPTURE_ONLY_NAMED_GROUP, ONIGERR_INVALID_BACKREF, ONIGERR_INVALID_LOOK_BEHIND_PATTERN, ONIGERR_MEMORY, ONIGERR_NUMBERED_BACKREF_OR_CALL_NOT_ALLOWED, ScanEnv::option, re_pattern_buffer::options, p, quantifiers_memory_node_info(), r, EncloseNode::regnum, StrNode::s, SCANENV_MEM_NODES, SET_ENCLOSE_STATUS, setup_look_behind(), QtfrNode::state, swap_node(), ScanEnv::syntax, QtfrNode::target, EncloseNode::target, AnchorNode::target, QtfrNode::target_empty_info, type, EncloseNode::type, AnchorNode::type, and QtfrNode::upper.

Referenced by onig_compile().

static int subexp_inf_recursive_check ( Node node,
ScanEnv env,
int  head 
)
static
static int subexp_inf_recursive_check_trav ( Node node,
ScanEnv env 
)
static
static int subexp_recursive_check ( Node node)
static
static int subexp_recursive_check_trav ( Node node,
ScanEnv env 
)
static
static void swap_node ( Node a,
Node b 
)
static
static int unset_addr_list_add ( UnsetAddrList uslist,
int  offset,
struct _Node node 
)
static
static void unset_addr_list_end ( UnsetAddrList uslist)
static

Definition at line 181 of file regcomp.c.

References IS_NOT_NULL, UnsetAddrList::us, and xfree.

Referenced by onig_compile().

static int unset_addr_list_fix ( UnsetAddrList uslist,
regex_t reg 
)
static
static int unset_addr_list_init ( UnsetAddrList uslist,
int  size 
)
static
static int update_string_node_case_fold ( regex_t reg,
Node node 
)
static

Variable Documentation

int onig_inited = 0
static

Definition at line 5895 of file regcomp.c.

OnigCaseFoldType OnigDefaultCaseFoldFlag = ONIGENC_CASE_FOLD_MIN

Definition at line 33 of file regcomp.c.

unsigned char PadBuf[WORD_ALIGNMENT_SIZE]
static

Definition at line 50 of file regcomp.c.

Referenced by add_multi_byte_cclass().