Ruby  2.5.0dev(2017-10-22revision60238)
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
regparse.c File Reference
#include "regparse.h"
#include <stdarg.h>
#include "ruby/st.h"

Go to the source code of this file.

Data Structures

struct  st_str_end_key
 
struct  NameEntry
 
struct  INamesArg
 
struct  OnigToken
 
struct  IApplyCaseFoldArg
 

Macros

#define WARN_BUFSIZE   256
 
#define CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS
 
#define BACKREF_REL_TO_ABS(rel_no, env)   ((env)->num_mem + 1 + (rel_no))
 
#define ONOFF(v, f, negative)   (negative) ? ((v) &= ~(f)) : ((v) |= (f))
 
#define MBCODE_START_POS(enc)   (OnigCodePoint )(ONIGENC_MBC_MINLEN(enc) > 1 ? 0 : 0x80)
 
#define SET_ALL_MULTI_BYTE_RANGE(enc, pbuf)   add_code_range_to_buf(pbuf, env, MBCODE_START_POS(enc), ONIG_LAST_CODE_POINT)
 
#define ADD_ALL_MULTI_BYTE_RANGE(enc, mbuf)
 
#define BITSET_SET_BIT_CHKDUP(bs, pos)
 
#define BITSET_IS_EMPTY(bs, empty)
 
#define PEND_VALUE   0
 
#define PFETCH_READY   UChar* pfetch_prev
 
#define PEND   (p < end ? 0 : 1)
 
#define PUNFETCH   p = pfetch_prev
 
#define PINC
 
#define PFETCH(c)
 
#define PINC_S
 
#define PFETCH_S(c)
 
#define PPEEK   (p < end ? ONIGENC_MBC_TO_CODE(enc, p, end) : PEND_VALUE)
 
#define PPEEK_IS(c)   (PPEEK == (OnigCodePoint )c)
 
#define INIT_NAME_BACKREFS_ALLOC_NUM   8
 
#define INIT_SCANENV_MEMNODES_ALLOC_SIZE   16
 
#define BBUF_WRITE_CODE_POINT(bbuf, pos, code)   BBUF_WRITE(bbuf, pos, &(code), SIZE_CODE_POINT)
 
#define INIT_MULTI_BYTE_RANGE_SIZE   (SIZE_CODE_POINT * 5)
 
#define SWAP_BBUF_NOT(bbuf1, not1, bbuf2, not2)
 
#define is_invalid_quantifier_target(node)   0
 
#define ONIGENC_IS_CODE_NAME(enc, c)   TRUE
 
#define POSIX_BRACKET_CHECK_LIMIT_LENGTH   20
 
#define POSIX_BRACKET_NAME_MIN_LEN   4
 
#define NEWLINE_CODE   0x0a
 

Typedefs

typedef st_table NameTable
 
typedef st_data_t HashDataType
 

Enumerations

enum  ReduceType {
  RQ_ASIS = 0, RQ_DEL = 1, RQ_A, RQ_AQ,
  RQ_QQ, RQ_P_QQ, RQ_PQ_Q
}
 
enum  TokenSyms {
  TK_EOT = 0, TK_RAW_BYTE = 1, TK_CHAR, TK_STRING,
  TK_CODE_POINT, TK_ANYCHAR, TK_CHAR_TYPE, TK_BACKREF,
  TK_CALL, TK_ANCHOR, TK_OP_REPEAT, TK_INTERVAL,
  TK_ANYCHAR_ANYTIME, TK_ALT, TK_SUBEXP_OPEN, TK_SUBEXP_CLOSE,
  TK_CC_OPEN, TK_QUOTE_OPEN, TK_CHAR_PROPERTY, TK_LINEBREAK,
  TK_EXTENDED_GRAPHEME_CLUSTER, TK_KEEP, TK_CC_CLOSE, TK_CC_RANGE,
  TK_POSIX_BRACKET_OPEN, TK_CC_AND, TK_CC_CC_OPEN
}
 
enum  CCSTATE { CCS_VALUE, CCS_RANGE, CCS_COMPLETE, CCS_START }
 
enum  CCVALTYPE { CCV_SB, CCV_CODE_POINT, CCV_CLASS }
 

Functions

void onig_null_warn (const char *s ARG_UNUSED)
 
void onig_set_warn_func (OnigWarnFunc f)
 
void onig_set_verb_warn_func (OnigWarnFunc f)
 
unsigned int onig_get_parse_depth_limit (void)
 
int onig_set_parse_depth_limit (unsigned int depth)
 
void onig_strcpy (UChar *dest, const UChar *src, const UChar *end)
 
hash_table_typeonig_st_init_strend_table_with_size (st_index_t size)
 
int onig_st_lookup_strend (hash_table_type *table, const UChar *str_key, const UChar *end_key, hash_data_type *value)
 
int onig_st_insert_strend (hash_table_type *table, const UChar *str_key, const UChar *end_key, hash_data_type value)
 
int onig_names_free (regex_t *reg)
 
int onig_foreach_name (regex_t *reg, int(*func)(const UChar *, const UChar *, int, int *, regex_t *, void *), void *arg)
 
int onig_renumber_name_table (regex_t *reg, GroupNumRemap *map)
 
int onig_number_of_names (const regex_t *reg)
 
int onig_name_to_group_numbers (regex_t *reg, const UChar *name, const UChar *name_end, int **nums)
 
int onig_name_to_backref_number (regex_t *reg, const UChar *name, const UChar *name_end, const OnigRegion *region)
 
int onig_noname_group_capture_is_active (const regex_t *reg)
 
void onig_node_free (Node *node)
 
Nodeonig_node_new_list (Node *left, Node *right)
 
Nodeonig_node_list_add (Node *list, Node *x)
 
Nodeonig_node_new_alt (Node *left, Node *right)
 
Nodeonig_node_new_anchor (int type)
 
Nodeonig_node_new_enclose (int type)
 
int onig_node_str_cat (Node *node, const UChar *s, const UChar *end)
 
int onig_node_str_set (Node *node, const UChar *s, const UChar *end)
 
void onig_node_str_clear (Node *node)
 
Nodeonig_node_new_str (const UChar *s, const UChar *end)
 
int onig_scan_unsigned_number (UChar **src, const UChar *end, OnigEncoding enc)
 
void onig_reduce_nested_quantifier (Node *pnode, Node *cnode)
 
int onig_parse_make_tree (Node **root, const UChar *pattern, const UChar *end, regex_t *reg, ScanEnv *env)
 
void onig_scan_env_set_error_string (ScanEnv *env, int ecode ARG_UNUSED, UChar *arg, UChar *arg_end)
 

Variables

const OnigSyntaxType OnigSyntaxRuby
 
const OnigSyntaxTypeOnigDefaultSyntax = ONIG_SYNTAX_RUBY
 

Macro Definition Documentation

◆ ADD_ALL_MULTI_BYTE_RANGE

#define ADD_ALL_MULTI_BYTE_RANGE (   enc,
  mbuf 
)
Value:
do {\
if (! ONIGENC_IS_SINGLEBYTE(enc)) {\
r = SET_ALL_MULTI_BYTE_RANGE(enc, &(mbuf));\
if (r) return r;\
}\
} while (0)
#define SET_ALL_MULTI_BYTE_RANGE(enc, pbuf)
Definition: regparse.c:165
#define ONIGENC_IS_SINGLEBYTE(enc)
Definition: onigmo.h:318

Definition at line 168 of file regparse.c.

◆ BACKREF_REL_TO_ABS

#define BACKREF_REL_TO_ABS (   rel_no,
  env 
)    ((env)->num_mem + 1 + (rel_no))

Definition at line 157 of file regparse.c.

◆ BBUF_WRITE_CODE_POINT

#define BBUF_WRITE_CODE_POINT (   bbuf,
  pos,
  code 
)    BBUF_WRITE(bbuf, pos, &(code), SIZE_CODE_POINT)

Definition at line 1644 of file regparse.c.

◆ BITSET_IS_EMPTY

#define BITSET_IS_EMPTY (   bs,
  empty 
)
Value:
do {\
int i;\
empty = 1;\
for (i = 0; i < BITSET_SIZE; i++) {\
if ((bs)[i] != 0) {\
empty = 0; break;\
}\
}\
} while (0)
#define BITSET_SIZE
Definition: regint.h:415

Definition at line 181 of file regparse.c.

◆ BITSET_SET_BIT_CHKDUP

#define BITSET_SET_BIT_CHKDUP (   bs,
  pos 
)
Value:
do { \
if (BITSET_AT(bs, pos)) CC_DUP_WARN(env); \
BS_ROOM(bs, pos) |= BS_BIT(pos); \
} while (0)
#define BS_BIT(pos)
Definition: regint.h:433
#define BITSET_AT(bs, pos)
Definition: regint.h:435
#define env

Definition at line 176 of file regparse.c.

◆ CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS

#define CASE_FOLD_IS_APPLIED_INSIDE_NEGATIVE_CCLASS

Definition at line 36 of file regparse.c.

◆ INIT_MULTI_BYTE_RANGE_SIZE

#define INIT_MULTI_BYTE_RANGE_SIZE   (SIZE_CODE_POINT * 5)

◆ INIT_NAME_BACKREFS_ALLOC_NUM

#define INIT_NAME_BACKREFS_ALLOC_NUM   8

Definition at line 451 of file regparse.c.

◆ INIT_SCANENV_MEMNODES_ALLOC_SIZE

#define INIT_SCANENV_MEMNODES_ALLOC_SIZE   16

Definition at line 980 of file regparse.c.

◆ is_invalid_quantifier_target

#define is_invalid_quantifier_target (   node)    0

Definition at line 2122 of file regparse.c.

◆ MBCODE_START_POS

#define MBCODE_START_POS (   enc)    (OnigCodePoint )(ONIGENC_MBC_MINLEN(enc) > 1 ? 0 : 0x80)

Definition at line 162 of file regparse.c.

◆ NEWLINE_CODE

#define NEWLINE_CODE   0x0a

◆ ONIGENC_IS_CODE_NAME

#define ONIGENC_IS_CODE_NAME (   enc,
 
)    TRUE

Definition at line 2510 of file regparse.c.

◆ ONOFF

#define ONOFF (   v,
  f,
  negative 
)    (negative) ? ((v) &= ~(f)) : ((v) |= (f))

Definition at line 160 of file regparse.c.

◆ PEND

#define PEND   (p < end ? 0 : 1)

Definition at line 299 of file regparse.c.

Referenced by onig_scan_unsigned_number().

◆ PEND_VALUE

#define PEND_VALUE   0

Definition at line 291 of file regparse.c.

◆ PFETCH

#define PFETCH (   c)
Value:
do { \
c = ((enc->max_enc_len == 1) ? *p : ONIGENC_MBC_TO_CODE(enc, p, end)); \
pfetch_prev = p; \
p += enclen(enc, p, end); \
} while (0)
#define ONIGENC_MBC_TO_CODE(enc, p, end)
Definition: onigmo.h:366
#define enclen(enc, p, e)
Definition: regenc.h:93

Definition at line 305 of file regparse.c.

Referenced by onig_scan_unsigned_number().

◆ PFETCH_READY

#define PFETCH_READY   UChar* pfetch_prev

Definition at line 297 of file regparse.c.

Referenced by onig_scan_unsigned_number().

◆ PFETCH_S

#define PFETCH_S (   c)
Value:
do { \
c = ((enc->max_enc_len == 1) ? *p : ONIGENC_MBC_TO_CODE(enc, p, end)); \
p += enclen(enc, p, end); \
} while (0)
#define ONIGENC_MBC_TO_CODE(enc, p, end)
Definition: onigmo.h:366
#define enclen(enc, p, e)
Definition: regenc.h:93

Definition at line 314 of file regparse.c.

◆ PINC

#define PINC
Value:
do { \
pfetch_prev = p; \
p += enclen(enc, p, end); \
} while (0)
#define enclen(enc, p, e)
Definition: regenc.h:93

Definition at line 301 of file regparse.c.

◆ PINC_S

#define PINC_S
Value:
do { \
p += enclen(enc, p, end); \
} while (0)
#define enclen(enc, p, e)
Definition: regenc.h:93

Definition at line 311 of file regparse.c.

◆ POSIX_BRACKET_CHECK_LIMIT_LENGTH

#define POSIX_BRACKET_CHECK_LIMIT_LENGTH   20

◆ POSIX_BRACKET_NAME_MIN_LEN

#define POSIX_BRACKET_NAME_MIN_LEN   4

◆ PPEEK

#define PPEEK   (p < end ? ONIGENC_MBC_TO_CODE(enc, p, end) : PEND_VALUE)

Definition at line 319 of file regparse.c.

◆ PPEEK_IS

#define PPEEK_IS (   c)    (PPEEK == (OnigCodePoint )c)

Definition at line 320 of file regparse.c.

◆ PUNFETCH

#define PUNFETCH   p = pfetch_prev

Definition at line 300 of file regparse.c.

Referenced by onig_scan_unsigned_number().

◆ SET_ALL_MULTI_BYTE_RANGE

#define SET_ALL_MULTI_BYTE_RANGE (   enc,
  pbuf 
)    add_code_range_to_buf(pbuf, env, MBCODE_START_POS(enc), ONIG_LAST_CODE_POINT)

Definition at line 165 of file regparse.c.

◆ SWAP_BBUF_NOT

#define SWAP_BBUF_NOT (   bbuf1,
  not1,
  bbuf2,
  not2 
)
Value:
do {\
BBuf *tbuf; \
int tnot; \
tnot = not1; not1 = not2; not2 = tnot; \
tbuf = bbuf1; bbuf1 = bbuf2; bbuf2 = tbuf; \
} while (0)

Definition at line 1815 of file regparse.c.

◆ WARN_BUFSIZE

#define WARN_BUFSIZE   256

Definition at line 34 of file regparse.c.

Typedef Documentation

◆ HashDataType

Definition at line 465 of file regparse.c.

◆ NameTable

Definition at line 464 of file regparse.c.

Enumeration Type Documentation

◆ CCSTATE

enum CCSTATE
Enumerator
CCS_VALUE 
CCS_RANGE 
CCS_COMPLETE 
CCS_START 

Definition at line 4397 of file regparse.c.

◆ CCVALTYPE

enum CCVALTYPE
Enumerator
CCV_SB 
CCV_CODE_POINT 
CCV_CLASS 

Definition at line 4404 of file regparse.c.

◆ ReduceType

enum ReduceType
Enumerator
RQ_ASIS 
RQ_DEL 
RQ_A 
RQ_AQ 
RQ_QQ 
RQ_P_QQ 
RQ_PQ_Q 

Definition at line 2183 of file regparse.c.

◆ TokenSyms

enum TokenSyms
Enumerator
TK_EOT 
TK_RAW_BYTE 
TK_CHAR 
TK_STRING 
TK_CODE_POINT 
TK_ANYCHAR 
TK_CHAR_TYPE 
TK_BACKREF 
TK_CALL 
TK_ANCHOR 
TK_OP_REPEAT 
TK_INTERVAL 
TK_ANYCHAR_ANYTIME 
TK_ALT 
TK_SUBEXP_OPEN 
TK_SUBEXP_CLOSE 
TK_CC_OPEN 
TK_QUOTE_OPEN 
TK_CHAR_PROPERTY 
TK_LINEBREAK 
TK_EXTENDED_GRAPHEME_CLUSTER 
TK_KEEP 
TK_CC_CLOSE 
TK_CC_RANGE 
TK_POSIX_BRACKET_OPEN 
TK_CC_AND 
TK_CC_CC_OPEN 

Definition at line 2254 of file regparse.c.

Function Documentation

◆ onig_foreach_name()

int onig_foreach_name ( regex_t reg,
int(*)(const UChar *, const UChar *, int, int *, regex_t *, void *)  func,
void *  arg 
)

◆ onig_get_parse_depth_limit()

unsigned int onig_get_parse_depth_limit ( void  )

Definition at line 117 of file regparse.c.

◆ onig_name_to_backref_number()

int onig_name_to_backref_number ( regex_t reg,
const UChar name,
const UChar name_end,
const OnigRegion region 
)

◆ onig_name_to_group_numbers()

int onig_name_to_group_numbers ( regex_t reg,
const UChar name,
const UChar name_end,
int **  nums 
)

Definition at line 887 of file regparse.c.

Referenced by onig_name_to_backref_number().

◆ onig_names_free()

int onig_names_free ( regex_t reg)

Definition at line 525 of file regparse.c.

Referenced by onig_free_body().

◆ onig_node_free()

void onig_node_free ( Node node)

◆ onig_node_list_add()

Node* onig_node_list_add ( Node list,
Node x 
)

Definition at line 1192 of file regparse.c.

References IS_NOT_NULL, IS_NULL, NCDR, NULL, NULL_NODE, and onig_node_new_list().

◆ onig_node_new_alt()

Node* onig_node_new_alt ( Node left,
Node right 
)

Definition at line 1210 of file regparse.c.

◆ onig_node_new_anchor()

Node* onig_node_new_anchor ( int  type)

Definition at line 1222 of file regparse.c.

◆ onig_node_new_enclose()

Node* onig_node_new_enclose ( int  type)

Definition at line 1347 of file regparse.c.

◆ onig_node_new_list()

Node* onig_node_new_list ( Node left,
Node right 
)

Definition at line 1186 of file regparse.c.

Referenced by onig_node_list_add().

◆ onig_node_new_str()

Node* onig_node_new_str ( const UChar s,
const UChar end 
)

Definition at line 1481 of file regparse.c.

◆ onig_node_str_cat()

int onig_node_str_cat ( Node node,
const UChar s,
const UChar end 
)

Definition at line 1376 of file regparse.c.

References buf, len, NODE_STR_BUF_SIZE, NODE_STR_MARGIN, NSTR, onig_strcpy(), and UChar.

Referenced by onig_node_str_set().

◆ onig_node_str_clear()

void onig_node_str_clear ( Node node)

Definition at line 1449 of file regparse.c.

References buf, IS_NOT_NULL, NSTR, and xfree().

Referenced by onig_node_str_set().

◆ onig_node_str_set()

int onig_node_str_set ( Node node,
const UChar s,
const UChar end 
)

Definition at line 1412 of file regparse.c.

References onig_node_str_cat(), and onig_node_str_clear().

◆ onig_noname_group_capture_is_active()

int onig_noname_group_capture_is_active ( const regex_t reg)

◆ onig_null_warn()

void onig_null_warn ( const char *s  ARG_UNUSED)

Definition at line 87 of file regparse.c.

◆ onig_number_of_names()

int onig_number_of_names ( const regex_t reg)

◆ onig_parse_make_tree()

int onig_parse_make_tree ( Node **  root,
const UChar pattern,
const UChar end,
regex_t reg,
ScanEnv env 
)

Definition at line 7013 of file regparse.c.

References UChar.

Referenced by onig_compile_ruby().

◆ onig_reduce_nested_quantifier()

void onig_reduce_nested_quantifier ( Node pnode,
Node cnode 
)

Definition at line 2204 of file regparse.c.

References NQTFR.

◆ onig_renumber_name_table()

int onig_renumber_name_table ( regex_t reg,
GroupNumRemap map 
)

Definition at line 611 of file regparse.c.

References if(), IS_NOT_NULL, and re_pattern_buffer::name_table.

◆ onig_scan_env_set_error_string()

void onig_scan_env_set_error_string ( ScanEnv env,
int ecode  ARG_UNUSED,
UChar arg,
UChar arg_end 
)

Definition at line 7040 of file regparse.c.

References ScanEnv::error, and ScanEnv::error_end.

◆ onig_scan_unsigned_number()

int onig_scan_unsigned_number ( UChar **  src,
const UChar end,
OnigEncoding  enc 
)

Definition at line 1556 of file regparse.c.

References DIGITVAL, INT_MAX_LIMIT, ONIGENC_IS_CODE_DIGIT, PEND, PFETCH, PFETCH_READY, PUNFETCH, UChar, and val.

◆ onig_set_parse_depth_limit()

int onig_set_parse_depth_limit ( unsigned int  depth)

Definition at line 123 of file regparse.c.

◆ onig_set_verb_warn_func()

void onig_set_verb_warn_func ( OnigWarnFunc  f)

Definition at line 106 of file regparse.c.

◆ onig_set_warn_func()

void onig_set_warn_func ( OnigWarnFunc  f)

Definition at line 101 of file regparse.c.

Referenced by Init_Regexp().

◆ onig_st_init_strend_table_with_size()

hash_table_type* onig_st_init_strend_table_with_size ( st_index_t  size)

Definition at line 406 of file regparse.c.

Referenced by onigenc_with_ascii_strnicmp().

◆ onig_st_insert_strend()

int onig_st_insert_strend ( hash_table_type table,
const UChar str_key,
const UChar end_key,
hash_data_type  value 
)

Definition at line 430 of file regparse.c.

References key.

Referenced by onigenc_with_ascii_strnicmp().

◆ onig_st_lookup_strend()

int onig_st_lookup_strend ( hash_table_type table,
const UChar str_key,
const UChar end_key,
hash_data_type value 
)

Definition at line 418 of file regparse.c.

References st_str_end_key::end, key, st_str_end_key::s, st_data_t, and UChar.

◆ onig_strcpy()

void onig_strcpy ( UChar dest,
const UChar src,
const UChar end 
)

Definition at line 259 of file regparse.c.

References len, UChar, and xmemcpy.

Referenced by onig_node_str_cat().

Variable Documentation

◆ OnigDefaultSyntax

const OnigSyntaxType* OnigDefaultSyntax = ONIG_SYNTAX_RUBY

Definition at line 85 of file regparse.c.

◆ OnigSyntaxRuby

const OnigSyntaxType OnigSyntaxRuby

Definition at line 39 of file regparse.c.