Ruby  2.4.2p198(2017-09-14revision59899)
Data Structures | Macros | Typedefs | Functions | Variables
re.c File Reference
#include "internal.h"
#include "ruby/re.h"
#include "ruby/util.h"
#include "regint.h"
#include "encindex.h"
#include <ctype.h>
Include dependency graph for re.c:

Go to the source code of this file.

Data Structures

struct  pair_t
 
struct  backref_name_tag
 

Macros

#define errcpy(err, msg)   strlcpy((err), (msg), ONIG_MAX_ERROR_MESSAGE_LEN)
 
#define BEG(no)   (regs->beg[(no)])
 
#define END(no)   (regs->end[(no)])
 
#define REG_LITERAL   FL_USER5
 
#define REG_ENCODING_NONE   FL_USER6
 
#define KCODE_FIXED   FL_USER4
 
#define ARG_REG_OPTION_MASK   (ONIG_OPTION_IGNORECASE|ONIG_OPTION_MULTILINE|ONIG_OPTION_EXTEND)
 
#define ARG_ENCODING_FIXED   16
 
#define ARG_ENCODING_NONE   32
 
#define MATCH_BUSY   FL_USER2
 
#define NAME_TO_NUMBER(regs, re, name, name_ptr, name_end)
 
#define ASCGET(s, e, cl)   (acompat ? (*(cl)=1,ISASCII((s)[0])?(s)[0]:-1) : rb_enc_ascget((s), (e), (cl), str_enc))
 

Typedefs

typedef char onig_errmsg_buffer[ONIG_MAX_ERROR_MESSAGE_LEN]
 

Functions

int rb_memcicmp (const void *x, const void *y, long len)
 
int rb_memcmp (const void *p1, const void *p2, long len)
 
static long rb_memsearch_ss (const unsigned char *xs, long m, const unsigned char *ys, long n)
 
static long rb_memsearch_qs (const unsigned char *xs, long m, const unsigned char *ys, long n)
 
static unsigned int rb_memsearch_qs_utf8_hash (const unsigned char *x)
 
static long rb_memsearch_qs_utf8 (const unsigned char *xs, long m, const unsigned char *ys, long n)
 
static long rb_memsearch_wchar (const unsigned char *xs, long m, const unsigned char *ys, long n)
 
static long rb_memsearch_qchar (const unsigned char *xs, long m, const unsigned char *ys, long n)
 
long rb_memsearch (const void *x0, long m, const void *y0, long n, rb_encoding *enc)
 
static int char_to_option (int c)
 
static char * option_to_str (char str[4], int options)
 
int rb_char_to_option_kcode (int c, int *option, int *kcode)
 
static void rb_reg_check (VALUE re)
 
static void rb_reg_expr_str (VALUE str, const char *s, long len, rb_encoding *enc, rb_encoding *resenc)
 
static VALUE rb_reg_desc (const char *s, long len, VALUE re)
 
static VALUE rb_reg_source (VALUE re)
 
static VALUE rb_reg_inspect (VALUE re)
 
static VALUE rb_reg_to_s (VALUE re)
 
static void rb_reg_raise (const char *s, long len, const char *err, VALUE re)
 
static VALUE rb_enc_reg_error_desc (const char *s, long len, rb_encoding *enc, int options, const char *err)
 
static void rb_enc_reg_raise (const char *s, long len, rb_encoding *enc, int options, const char *err)
 
static VALUE rb_reg_error_desc (VALUE str, int options, const char *err)
 
static void rb_reg_raise_str (VALUE str, int options, const char *err)
 
static VALUE rb_reg_casefold_p (VALUE re)
 
static VALUE rb_reg_options_m (VALUE re)
 
static int reg_names_iter (const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg)
 
static VALUE rb_reg_names (VALUE re)
 
static int reg_named_captures_iter (const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg)
 
static VALUE rb_reg_named_captures (VALUE re)
 
static int onig_new_with_source (regex_t **reg, const UChar *pattern, const UChar *pattern_end, OnigOptionType option, OnigEncoding enc, const OnigSyntaxType *syntax, OnigErrorInfo *einfo, const char *sourcefile, int sourceline)
 
static Regexpmake_regexp (const char *s, long len, rb_encoding *enc, int flags, onig_errmsg_buffer err, const char *sourcefile, int sourceline)
 
static VALUE match_alloc (VALUE klass)
 
int rb_reg_region_copy (struct re_registers *to, const struct re_registers *from)
 
static int pair_byte_cmp (const void *pair1, const void *pair2)
 
static void update_char_offset (VALUE match)
 
static void match_check (VALUE match)
 
static VALUE match_init_copy (VALUE obj, VALUE orig)
 
static VALUE match_regexp (VALUE match)
 
static VALUE match_names (VALUE match)
 
static VALUE match_size (VALUE match)
 
static int name_to_backref_number (struct re_registers *, VALUE, const char *, const char *)
 
static int match_backref_number (VALUE match, VALUE backref)
 
int rb_reg_backref_number (VALUE match, VALUE backref)
 
static VALUE match_offset (VALUE match, VALUE n)
 
static VALUE match_begin (VALUE match, VALUE n)
 
static VALUE match_end (VALUE match, VALUE n)
 
void rb_match_busy (VALUE match)
 
int rb_match_count (VALUE match)
 
int rb_match_nth_defined (int nth, VALUE match)
 
static void match_set_string (VALUE m, VALUE string, long pos, long len)
 
void rb_backref_set_string (VALUE string, long pos, long len)
 
static VALUE rb_reg_fixed_encoding_p (VALUE re)
 
static VALUE rb_reg_preprocess (const char *p, const char *end, rb_encoding *enc, rb_encoding **fixed_enc, onig_errmsg_buffer err)
 
static void reg_enc_error (VALUE re, VALUE str)
 
static int str_coderange (VALUE str)
 
static rb_encodingrb_reg_prepare_enc (VALUE re, VALUE str, int warn)
 
regex_trb_reg_prepare_re0 (VALUE re, VALUE str, onig_errmsg_buffer err)
 
regex_trb_reg_prepare_re (VALUE re, VALUE str)
 
long rb_reg_adjust_startpos (VALUE re, VALUE str, long pos, int reverse)
 
long rb_reg_search0 (VALUE re, VALUE str, long pos, int reverse, int set_backref_str)
 
long rb_reg_search (VALUE re, VALUE str, long pos, int reverse)
 
VALUE rb_reg_nth_defined (int nth, VALUE match)
 
VALUE rb_reg_nth_match (int nth, VALUE match)
 
VALUE rb_reg_last_match (VALUE match)
 
VALUE rb_reg_match_pre (VALUE match)
 
VALUE rb_reg_match_post (VALUE match)
 
VALUE rb_reg_match_last (VALUE match)
 
static VALUE last_match_getter (void)
 
static VALUE prematch_getter (void)
 
static VALUE postmatch_getter (void)
 
static VALUE last_paren_match_getter (void)
 
static VALUE match_array (VALUE match, int start)
 
static VALUE match_to_a (VALUE match)
 
static VALUE match_captures (VALUE match)
 
 NORETURN (static void name_to_backref_error(VALUE name))
 
static void name_to_backref_error (VALUE name)
 
static int namev_to_backref_number (struct re_registers *regs, VALUE re, VALUE name)
 
static VALUE match_ary_subseq (VALUE match, long beg, long len, VALUE result)
 
static VALUE match_ary_aref (VALUE match, VALUE idx, VALUE result)
 
static VALUE match_aref (int argc, VALUE *argv, VALUE match)
 
static VALUE match_values_at (int argc, VALUE *argv, VALUE match)
 
static VALUE match_to_s (VALUE match)
 
static int match_named_captures_iter (const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg)
 
static VALUE match_named_captures (VALUE match)
 
static VALUE match_string (VALUE match)
 
static int match_inspect_name_iter (const OnigUChar *name, const OnigUChar *name_end, int back_num, int *back_refs, OnigRegex regex, void *arg0)
 
static VALUE match_inspect (VALUE match)
 
static int read_escaped_byte (const char **pp, const char *end, onig_errmsg_buffer err)
 
static int unescape_escaped_nonascii (const char **pp, const char *end, rb_encoding *enc, VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
 
static int check_unicode_range (unsigned long code, onig_errmsg_buffer err)
 
static int append_utf8 (unsigned long uv, VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
 
static int unescape_unicode_list (const char **pp, const char *end, VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
 
static int unescape_unicode_bmp (const char **pp, const char *end, VALUE buf, rb_encoding **encp, onig_errmsg_buffer err)
 
static int unescape_nonascii (const char *p, const char *end, rb_encoding *enc, VALUE buf, rb_encoding **encp, int *has_property, onig_errmsg_buffer err)
 
VALUE rb_reg_check_preprocess (VALUE str)
 
static VALUE rb_reg_preprocess_dregexp (VALUE ary, int options)
 
static int rb_reg_initialize (VALUE obj, const char *s, long len, rb_encoding *enc, int options, onig_errmsg_buffer err, const char *sourcefile, int sourceline)
 
static void reg_set_source (VALUE reg, VALUE str, rb_encoding *enc)
 
static int rb_reg_initialize_str (VALUE obj, VALUE str, int options, onig_errmsg_buffer err, const char *sourcefile, int sourceline)
 
static VALUE rb_reg_s_alloc (VALUE klass)
 
VALUE rb_reg_alloc (void)
 
VALUE rb_reg_new_str (VALUE s, int options)
 
VALUE rb_reg_init_str (VALUE re, VALUE s, int options)
 
static VALUE rb_reg_init_str_enc (VALUE re, VALUE s, rb_encoding *enc, int options)
 
VALUE rb_reg_new_ary (VALUE ary, int opt)
 
VALUE rb_enc_reg_new (const char *s, long len, rb_encoding *enc, int options)
 
VALUE rb_reg_new (const char *s, long len, int options)
 
VALUE rb_reg_compile (VALUE str, int options, const char *sourcefile, int sourceline)
 
VALUE rb_reg_regcomp (VALUE str)
 
static st_index_t reg_hash (VALUE re)
 
static VALUE rb_reg_hash (VALUE re)
 
static VALUE rb_reg_equal (VALUE re1, VALUE re2)
 
static VALUE match_hash (VALUE match)
 
static VALUE match_equal (VALUE match1, VALUE match2)
 
static VALUE reg_operand (VALUE s, int check)
 
static long reg_match_pos (VALUE re, VALUE *strp, long pos)
 
VALUE rb_reg_match (VALUE re, VALUE str)
 
VALUE rb_reg_eqq (VALUE re, VALUE str)
 
VALUE rb_reg_match2 (VALUE re)
 
static VALUE rb_reg_match_m (int argc, VALUE *argv, VALUE re)
 
static VALUE rb_reg_match_m_p (int argc, VALUE *argv, VALUE re)
 
VALUE rb_reg_match_p (VALUE re, VALUE str, long pos)
 
static VALUE rb_reg_initialize_m (int argc, VALUE *argv, VALUE self)
 
VALUE rb_reg_quote (VALUE str)
 
static VALUE rb_reg_s_quote (VALUE c, VALUE str)
 
int rb_reg_options (VALUE re)
 
VALUE rb_check_regexp_type (VALUE re)
 
static VALUE rb_reg_s_try_convert (VALUE dummy, VALUE re)
 
static VALUE rb_reg_s_union (VALUE self, VALUE args0)
 
static VALUE rb_reg_s_union_m (VALUE self, VALUE args)
 
static VALUE rb_reg_init_copy (VALUE copy, VALUE re)
 
VALUE rb_reg_regsub (VALUE str, VALUE src, struct re_registers *regs, VALUE regexp)
 
static VALUE kcode_getter (void)
 
static void kcode_setter (VALUE val, ID id)
 
static VALUE ignorecase_getter (void)
 
static void ignorecase_setter (VALUE val, ID id)
 
static VALUE match_getter (void)
 
static void match_setter (VALUE val)
 
static VALUE rb_reg_s_last_match (int argc, VALUE *argv)
 
static void re_warn (const char *s)
 
void Init_Regexp (void)
 

Variables

VALUE rb_eRegexpError
 
VALUE rb_cMatch
 
VALUE rb_cRegexp
 
static VALUE reg_cache
 

Macro Definition Documentation

◆ ARG_ENCODING_FIXED

#define ARG_ENCODING_FIXED   16

Definition at line 295 of file re.c.

Referenced by Init_Regexp(), rb_char_to_option_kcode(), rb_reg_initialize(), and rb_reg_options().

◆ ARG_ENCODING_NONE

#define ARG_ENCODING_NONE   32

◆ ARG_REG_OPTION_MASK

Definition at line 293 of file re.c.

Referenced by rb_reg_initialize(), and rb_reg_options().

◆ ASCGET

#define ASCGET (   s,
  e,
  cl 
)    (acompat ? (*(cl)=1,ISASCII((s)[0])?(s)[0]:-1) : rb_enc_ascget((s), (e), (cl), str_enc))

Referenced by rb_reg_regsub().

◆ BEG

#define BEG (   no)    (regs->beg[(no)])

◆ END

#define END (   no)    (regs->end[(no)])

Definition at line 25 of file re.c.

Referenced by rb_reg_match_post(), rb_reg_nth_match(), rb_reg_regsub(), and update_char_offset().

◆ errcpy

#define errcpy (   err,
  msg 
)    strlcpy((err), (msg), ONIG_MAX_ERROR_MESSAGE_LEN)

◆ KCODE_FIXED

#define KCODE_FIXED   FL_USER4

Definition at line 291 of file re.c.

Referenced by rb_reg_equal(), rb_reg_fixed_encoding_p(), rb_reg_initialize(), and rb_reg_options().

◆ MATCH_BUSY

#define MATCH_BUSY   FL_USER2

Definition at line 1257 of file re.c.

Referenced by rb_backref_set_string(), rb_match_busy(), and rb_reg_search0().

◆ NAME_TO_NUMBER

#define NAME_TO_NUMBER (   regs,
  re,
  name,
  name_ptr,
  name_end 
)
Value:
(NIL_P(re) ? 0 : \
name_to_backref_number((regs), (re), (name_ptr), (name_end)))
rb_encoding * rb_enc_compatible(VALUE str1, VALUE str2)
Definition: encoding.c:962
#define NIL_P(v)
Definition: ruby.h:451
const char * name
Definition: nkf.c:208
#define RREGEXP_SRC(r)
Definition: ruby.h:1057

Definition at line 1829 of file re.c.

Referenced by namev_to_backref_number(), and rb_reg_regsub().

◆ REG_ENCODING_NONE

#define REG_ENCODING_NONE   FL_USER6

Definition at line 289 of file re.c.

Referenced by rb_reg_desc(), rb_reg_initialize(), rb_reg_options(), and rb_reg_prepare_enc().

◆ REG_LITERAL

#define REG_LITERAL   FL_USER5

Definition at line 288 of file re.c.

Referenced by rb_reg_compile(), and rb_reg_initialize().

Typedef Documentation

◆ onig_errmsg_buffer

typedef char onig_errmsg_buffer[ONIG_MAX_ERROR_MESSAGE_LEN]

Definition at line 21 of file re.c.

Function Documentation

◆ append_utf8()

static int append_utf8 ( unsigned long  uv,
VALUE  buf,
rb_encoding **  encp,
onig_errmsg_buffer  err 
)
static

◆ char_to_option()

static int char_to_option ( int  c)
static

Definition at line 299 of file re.c.

References ONIG_OPTION_EXTEND, ONIG_OPTION_IGNORECASE, ONIG_OPTION_MULTILINE, and val.

Referenced by rb_char_to_option_kcode(), and rb_reg_to_s().

◆ check_unicode_range()

static int check_unicode_range ( unsigned long  code,
onig_errmsg_buffer  err 
)
static

Definition at line 2361 of file re.c.

References errcpy.

Referenced by append_utf8().

◆ ignorecase_getter()

static VALUE ignorecase_getter ( void  )
static

Definition at line 3806 of file re.c.

References Qfalse, and rb_warn().

Referenced by Init_Regexp().

◆ ignorecase_setter()

static void ignorecase_setter ( VALUE  val,
ID  id 
)
static

Definition at line 3813 of file re.c.

References rb_warn().

Referenced by Init_Regexp().

◆ Init_Regexp()

void Init_Regexp ( void  )

Definition at line 3910 of file re.c.

References ARG_ENCODING_FIXED, ARG_ENCODING_NONE, CLASS_OF, ignorecase_getter(), ignorecase_setter(), INT2FIX, kcode_getter(), kcode_setter(), last_match_getter(), last_paren_match_getter(), match_alloc(), match_aref(), match_begin(), match_captures(), match_end(), match_equal(), match_getter(), match_hash(), match_init_copy(), match_inspect(), match_named_captures(), match_names(), match_offset(), match_regexp(), match_setter(), match_size(), match_string(), match_to_a(), match_to_s(), match_values_at(), ONIG_ENCODING_ASCII, ONIG_OPTION_EXTEND, ONIG_OPTION_IGNORECASE, ONIG_OPTION_MULTILINE, onig_set_verb_warn_func(), onig_set_warn_func(), onigenc_set_default_encoding(), postmatch_getter(), prematch_getter(), rb_class_new_instance(), rb_cMatch, rb_cObject, rb_cRegexp, rb_define_alloc_func(), rb_define_class(), rb_define_const(), rb_define_method(), rb_define_singleton_method(), rb_define_virtual_variable(), rb_eRegexpError, rb_eStandardError, rb_global_variable(), rb_obj_encoding(), rb_reg_casefold_p(), rb_reg_eqq(), rb_reg_equal(), rb_reg_fixed_encoding_p(), rb_reg_hash(), rb_reg_init_copy(), rb_reg_initialize_m(), rb_reg_inspect(), rb_reg_match(), rb_reg_match2(), rb_reg_match_m(), rb_reg_match_m_p(), rb_reg_match_post(), rb_reg_match_pre(), rb_reg_named_captures(), rb_reg_names(), rb_reg_options_m(), rb_reg_s_alloc(), rb_reg_s_last_match(), rb_reg_s_quote(), rb_reg_s_try_convert(), rb_reg_s_union_m(), rb_reg_source(), rb_reg_to_s(), rb_undef_method(), re_warn(), and reg_cache.

◆ kcode_getter()

static VALUE kcode_getter ( void  )
static

Definition at line 3793 of file re.c.

References Qnil, and rb_warn().

Referenced by Init_Regexp().

◆ kcode_setter()

static void kcode_setter ( VALUE  val,
ID  id 
)
static

Definition at line 3800 of file re.c.

References rb_warn().

Referenced by Init_Regexp().

◆ last_match_getter()

static VALUE last_match_getter ( void  )
static

Definition at line 1716 of file re.c.

References rb_backref_get(), and rb_reg_last_match().

Referenced by Init_Regexp().

◆ last_paren_match_getter()

static VALUE last_paren_match_getter ( void  )
static

Definition at line 1734 of file re.c.

References rb_backref_get(), and rb_reg_match_last().

Referenced by Init_Regexp().

◆ make_regexp()

static Regexp* make_regexp ( const char *  s,
long  len,
rb_encoding enc,
int  flags,
onig_errmsg_buffer  err,
const char *  sourcefile,
int  sourceline 
)
static

Definition at line 860 of file re.c.

References onig_error_code_to_str(), onig_new_with_source(), OnigDefaultSyntax, and UChar.

Referenced by rb_reg_initialize().

◆ match_alloc()

static VALUE match_alloc ( VALUE  klass)
static

Definition at line 899 of file re.c.

References match(), NEWOBJ_OF, T_MATCH, and ZALLOC.

Referenced by Init_Regexp(), rb_backref_set_string(), and rb_reg_search0().

◆ match_aref()

static VALUE match_aref ( int  argc,
VALUE argv,
VALUE  match 
)
static

◆ match_array()

static VALUE match_array ( VALUE  match,
int  start 
)
static

◆ match_ary_aref()

static VALUE match_ary_aref ( VALUE  match,
VALUE  idx,
VALUE  result 
)
static

◆ match_ary_subseq()

static VALUE match_ary_subseq ( VALUE  match,
long  beg,
long  len,
VALUE  result 
)
static

◆ match_backref_number()

static int match_backref_number ( VALUE  match,
VALUE  backref 
)
static

◆ match_begin()

static VALUE match_begin ( VALUE  match,
VALUE  n 
)
static

◆ match_captures()

static VALUE match_captures ( VALUE  match)
static

Definition at line 1809 of file re.c.

References match_array().

Referenced by Init_Regexp().

◆ match_check()

static void match_check ( VALUE  match)
static

◆ match_end()

static VALUE match_end ( VALUE  match,
VALUE  n 
)
static

◆ match_equal()

static VALUE match_equal ( VALUE  match1,
VALUE  match2 
)
static

◆ match_getter()

static VALUE match_getter ( void  )
static

Definition at line 3819 of file re.c.

References match(), NIL_P, Qnil, rb_backref_get(), and rb_match_busy().

Referenced by Init_Regexp(), and rb_reg_s_last_match().

◆ match_hash()

static VALUE match_hash ( VALUE  match)
static

◆ match_init_copy()

static VALUE match_init_copy ( VALUE  obj,
VALUE  orig 
)
static

◆ match_inspect()

static VALUE match_inspect ( VALUE  match)
static

◆ match_inspect_name_iter()

static int match_inspect_name_iter ( const OnigUChar name,
const OnigUChar name_end,
int  back_num,
int *  back_refs,
OnigRegex  regex,
void *  arg0 
)
static

Definition at line 2117 of file re.c.

References backref_name_tag::len, name, and backref_name_tag::name.

Referenced by match_inspect().

◆ match_named_captures()

static VALUE match_named_captures ( VALUE  match)
static

◆ match_named_captures_iter()

static int match_named_captures_iter ( const OnigUChar name,
const OnigUChar name_end,
int  back_num,
int *  back_refs,
OnigRegex  regex,
void *  arg 
)
static

◆ match_names()

static VALUE match_names ( VALUE  match)
static

Definition at line 1089 of file re.c.

References match_check(), NIL_P, rb_ary_new_capa(), rb_reg_names(), and RMATCH.

Referenced by Init_Regexp().

◆ match_offset()

static VALUE match_offset ( VALUE  match,
VALUE  n 
)
static

◆ match_regexp()

static VALUE match_regexp ( VALUE  match)
static

Definition at line 1061 of file re.c.

References match_check(), NIL_P, rb_reg_nth_match(), rb_reg_quote(), rb_reg_regcomp(), and RMATCH.

Referenced by Init_Regexp(), match_equal(), and match_hash().

◆ match_set_string()

static void match_set_string ( VALUE  m,
VALUE  string,
long  pos,
long  len 
)
static

◆ match_setter()

static void match_setter ( VALUE  val)
static

Definition at line 3829 of file re.c.

References Check_Type, NIL_P, rb_backref_set(), and T_MATCH.

Referenced by Init_Regexp().

◆ match_size()

static VALUE match_size ( VALUE  match)
static

Definition at line 1110 of file re.c.

References INT2FIX, match_check(), name_to_backref_number(), and RMATCH_REGS.

Referenced by Init_Regexp().

◆ match_string()

static VALUE match_string ( VALUE  match)
static

Definition at line 2105 of file re.c.

References match_check(), and RMATCH.

Referenced by cParser_initialize(), Init_Regexp(), and JSON_parse_string().

◆ match_to_a()

static VALUE match_to_a ( VALUE  match)
static

Definition at line 1790 of file re.c.

References match_array().

Referenced by Init_Regexp().

◆ match_to_s()

static VALUE match_to_s ( VALUE  match)
static

Definition at line 2014 of file re.c.

References match_check(), NIL_P, OBJ_TAINT, OBJ_TAINTED, rb_reg_last_match(), rb_str_new(), and RMATCH.

Referenced by Init_Regexp().

◆ match_values_at()

static VALUE match_values_at ( int  argc,
VALUE argv,
VALUE  match 
)
static

◆ name_to_backref_error()

static void name_to_backref_error ( VALUE  name)
static

Definition at line 1823 of file re.c.

References PRIsVALUE, rb_eIndexError, and rb_raise().

Referenced by name_to_backref_number(), namev_to_backref_number(), and rb_reg_regsub().

◆ name_to_backref_number()

static int name_to_backref_number ( struct re_registers regs,
VALUE  regexp,
const char *  name,
const char *  name_end 
)
static

◆ namev_to_backref_number()

static int namev_to_backref_number ( struct re_registers regs,
VALUE  re,
VALUE  name 
)
static

◆ NORETURN()

NORETURN ( static void   name_to_backref_errorVALUE name)

Referenced by name_to_backref_number().

◆ onig_new_with_source()

static int onig_new_with_source ( regex_t **  reg,
const UChar pattern,
const UChar pattern_end,
OnigOptionType  option,
OnigEncoding  enc,
const OnigSyntaxType syntax,
OnigErrorInfo einfo,
const char *  sourcefile,
int  sourceline 
)
static

◆ option_to_str()

static char* option_to_str ( char  str[4],
int  options 
)
static

◆ pair_byte_cmp()

static int pair_byte_cmp ( const void *  pair1,
const void *  pair2 
)
static

Definition at line 928 of file re.c.

References diff().

Referenced by update_char_offset().

◆ postmatch_getter()

static VALUE postmatch_getter ( void  )
static

Definition at line 1728 of file re.c.

References rb_backref_get(), and rb_reg_match_post().

Referenced by Init_Regexp().

◆ prematch_getter()

static VALUE prematch_getter ( void  )
static

Definition at line 1722 of file re.c.

References rb_backref_get(), and rb_reg_match_pre().

Referenced by Init_Regexp().

◆ rb_backref_set_string()

void rb_backref_set_string ( VALUE  string,
long  pos,
long  len 
)

◆ rb_char_to_option_kcode()

int rb_char_to_option_kcode ( int  c,
int *  option,
int *  kcode 
)

◆ rb_check_regexp_type()

VALUE rb_check_regexp_type ( VALUE  re)

Definition at line 3486 of file re.c.

References rb_check_convert_type(), and T_REGEXP.

Referenced by rb_reg_s_try_convert(), and rb_reg_s_union().

◆ rb_enc_reg_error_desc()

static VALUE rb_enc_reg_error_desc ( const char *  s,
long  len,
rb_encoding enc,
int  options,
const char *  err 
)
static

◆ rb_enc_reg_new()

VALUE rb_enc_reg_new ( const char *  s,
long  len,
rb_encoding enc,
int  options 
)

◆ rb_enc_reg_raise()

static void rb_enc_reg_raise ( const char *  s,
long  len,
rb_encoding enc,
int  options,
const char *  err 
)
static

Definition at line 686 of file re.c.

References rb_enc_reg_error_desc(), and rb_exc_raise().

Referenced by rb_enc_reg_new().

◆ rb_match_busy()

void rb_match_busy ( VALUE  match)

◆ rb_match_count()

int rb_match_count ( VALUE  match)

Definition at line 1266 of file re.c.

References NIL_P, re_registers::num_regs, and RMATCH_REGS.

Referenced by rb_f_global_variables().

◆ rb_match_nth_defined()

int rb_match_nth_defined ( int  nth,
VALUE  match 
)

Definition at line 1276 of file re.c.

References BEG, FALSE, NIL_P, re_registers::num_regs, and RMATCH_REGS.

Referenced by rb_f_global_variables().

◆ rb_memcicmp()

int rb_memcicmp ( const void *  x,
const void *  y,
long  len 
)

Definition at line 79 of file re.c.

Referenced by parser_encode_length(), and rb_num_get_rounding_option().

◆ rb_memcmp()

int rb_memcmp ( const void *  p1,
const void *  p2,
long  len 
)

Definition at line 94 of file re.c.

References memcmp(), and rb_memsearch_ss().

◆ rb_memsearch()

long rb_memsearch ( const void *  x0,
long  m,
const void *  y0,
long  n,
rb_encoding enc 
)

◆ rb_memsearch_qchar()

static long rb_memsearch_qchar ( const unsigned char *  xs,
long  m,
const unsigned char *  ys,
long  n 
)
inlinestatic

Definition at line 239 of file re.c.

References char_size, and memcmp().

Referenced by rb_memsearch().

◆ rb_memsearch_qs()

static long rb_memsearch_qs ( const unsigned char *  xs,
long  m,
const unsigned char *  ys,
long  n 
)
inlinestatic

Definition at line 152 of file re.c.

References memcmp().

Referenced by rb_memsearch().

◆ rb_memsearch_qs_utf8()

static long rb_memsearch_qs_utf8 ( const unsigned char *  xs,
long  m,
const unsigned char *  ys,
long  n 
)
inlinestatic

Definition at line 204 of file re.c.

References memcmp(), and rb_memsearch_qs_utf8_hash().

Referenced by rb_memsearch().

◆ rb_memsearch_qs_utf8_hash()

static unsigned int rb_memsearch_qs_utf8_hash ( const unsigned char *  x)
inlinestatic

Definition at line 172 of file re.c.

Referenced by rb_memsearch_qs_utf8().

◆ rb_memsearch_ss()

static long rb_memsearch_ss ( const unsigned char *  xs,
long  m,
const unsigned char *  ys,
long  n 
)
inlinestatic

Definition at line 112 of file re.c.

References CHAR_BIT, rb_bug(), and SIZEOF_VALUE.

Referenced by rb_memcmp(), and rb_memsearch().

◆ rb_memsearch_wchar()

static long rb_memsearch_wchar ( const unsigned char *  xs,
long  m,
const unsigned char *  ys,
long  n 
)
inlinestatic

Definition at line 226 of file re.c.

References char_size, and memcmp().

Referenced by rb_memsearch().

◆ rb_reg_adjust_startpos()

long rb_reg_adjust_startpos ( VALUE  re,
VALUE  str,
long  pos,
int  reverse 
)

◆ rb_reg_alloc()

VALUE rb_reg_alloc ( void  )

Definition at line 2786 of file re.c.

References rb_cRegexp, and rb_reg_s_alloc().

Referenced by rb_enc_reg_new(), rb_reg_compile(), and rb_reg_new_str().

◆ rb_reg_backref_number()

int rb_reg_backref_number ( VALUE  match,
VALUE  backref 
)

Definition at line 1146 of file re.c.

References match_backref_number().

Referenced by rb_str_subpat(), and rb_str_subpat_set().

◆ rb_reg_casefold_p()

static VALUE rb_reg_casefold_p ( VALUE  re)
static

Definition at line 717 of file re.c.

References ONIG_OPTION_IGNORECASE, options(), Qfalse, Qtrue, rb_reg_check(), and RREGEXP_PTR.

Referenced by Init_Regexp().

◆ rb_reg_check()

static void rb_reg_check ( VALUE  re)
static

◆ rb_reg_check_preprocess()

VALUE rb_reg_check_preprocess ( VALUE  str)

◆ rb_reg_compile()

VALUE rb_reg_compile ( VALUE  str,
int  options,
const char *  sourcefile,
int  sourceline 
)

◆ rb_reg_desc()

static VALUE rb_reg_desc ( const char *  s,
long  len,
VALUE  re 
)
static

◆ rb_reg_eqq()

VALUE rb_reg_eqq ( VALUE  re,
VALUE  str 
)

Definition at line 3104 of file re.c.

References FALSE, NIL_P, Qfalse, Qnil, Qtrue, rb_backref_set(), rb_reg_search(), and reg_operand().

Referenced by Init_Regexp().

◆ rb_reg_equal()

static VALUE rb_reg_equal ( VALUE  re1,
VALUE  re2 
)
static

◆ rb_reg_error_desc()

static VALUE rb_reg_error_desc ( VALUE  str,
int  options,
const char *  err 
)
static

◆ rb_reg_expr_str()

static void rb_reg_expr_str ( VALUE  str,
const char *  s,
long  len,
rb_encoding enc,
rb_encoding resenc 
)
static

◆ rb_reg_fixed_encoding_p()

static VALUE rb_reg_fixed_encoding_p ( VALUE  re)
static

Definition at line 1348 of file re.c.

References err, FL_TEST, KCODE_FIXED, Qfalse, Qtrue, and rb_reg_preprocess().

Referenced by Init_Regexp(), rb_reg_prepare_enc(), and rb_reg_s_union().

◆ rb_reg_hash()

static VALUE rb_reg_hash ( VALUE  re)
static

Definition at line 2888 of file re.c.

References reg_hash(), and ST2FIX.

Referenced by Init_Regexp().

◆ rb_reg_init_copy()

static VALUE rb_reg_init_copy ( VALUE  copy,
VALUE  re 
)
static

Definition at line 3662 of file re.c.

References OBJ_INIT_COPY, rb_reg_check(), rb_reg_init_str(), rb_reg_options(), and RREGEXP_SRC.

Referenced by Init_Regexp().

◆ rb_reg_init_str()

VALUE rb_reg_init_str ( VALUE  re,
VALUE  s,
int  options 
)

Definition at line 2798 of file re.c.

References err, NULL, rb_reg_initialize_str(), and rb_reg_raise_str().

Referenced by rb_reg_init_copy(), rb_reg_initialize_m(), and rb_reg_new_str().

◆ rb_reg_init_str_enc()

static VALUE rb_reg_init_str_enc ( VALUE  re,
VALUE  s,
rb_encoding enc,
int  options 
)
static

Definition at line 2810 of file re.c.

References err, NULL, rb_reg_initialize(), rb_reg_raise_str(), reg_set_source(), RSTRING_LEN, and RSTRING_PTR.

Referenced by rb_reg_initialize_m().

◆ rb_reg_initialize()

static int rb_reg_initialize ( VALUE  obj,
const char *  s,
long  len,
rb_encoding enc,
int  options,
onig_errmsg_buffer  err,
const char *  sourcefile,
int  sourceline 
)
static

◆ rb_reg_initialize_m()

static VALUE rb_reg_initialize_m ( int  argc,
VALUE argv,
VALUE  self 
)
static

◆ rb_reg_initialize_str()

static int rb_reg_initialize_str ( VALUE  obj,
VALUE  str,
int  options,
onig_errmsg_buffer  err,
const char *  sourcefile,
int  sourceline 
)
static

◆ rb_reg_inspect()

static VALUE rb_reg_inspect ( VALUE  re)
static

Definition at line 521 of file re.c.

References rb_any_to_s(), rb_reg_desc(), RREGEXP_PTR, RREGEXP_SRC, RREGEXP_SRC_LEN, and RREGEXP_SRC_PTR.

Referenced by Init_Regexp().

◆ rb_reg_last_match()

VALUE rb_reg_last_match ( VALUE  match)

Definition at line 1636 of file re.c.

References rb_reg_nth_match().

Referenced by last_match_getter(), match_to_s(), and vm_getspecial().

◆ rb_reg_match()

VALUE rb_reg_match ( VALUE  re,
VALUE  str 
)

Definition at line 3074 of file re.c.

References LONG2FIX, Qnil, rb_str_sublen(), and reg_match_pos().

Referenced by Init_Regexp(), and rb_str_match().

◆ rb_reg_match2()

VALUE rb_reg_match2 ( VALUE  re)

Definition at line 3133 of file re.c.

References LONG2FIX, Qnil, rb_backref_set(), rb_lastline_get(), rb_reg_search(), rb_str_sublen(), RB_TYPE_P, and T_STRING.

Referenced by Init_Regexp().

◆ rb_reg_match_last()

VALUE rb_reg_match_last ( VALUE  match)

◆ rb_reg_match_m()

static VALUE rb_reg_match_m ( int  argc,
VALUE argv,
VALUE  re 
)
static

◆ rb_reg_match_m_p()

static VALUE rb_reg_match_m_p ( int  argc,
VALUE argv,
VALUE  re 
)
static

Definition at line 3227 of file re.c.

References NUM2LONG, rb_check_arity, and rb_reg_match_p().

Referenced by Init_Regexp().

◆ rb_reg_match_p()

VALUE rb_reg_match_p ( VALUE  re,
VALUE  str,
long  pos 
)

◆ rb_reg_match_post()

VALUE rb_reg_match_post ( VALUE  match)

◆ rb_reg_match_pre()

VALUE rb_reg_match_pre ( VALUE  match)

Definition at line 1654 of file re.c.

References BEG, match_check(), NIL_P, OBJ_TAINT, OBJ_TAINTED, Qnil, rb_str_subseq(), RMATCH, and RMATCH_REGS.

Referenced by Init_Regexp(), prematch_getter(), and vm_getspecial().

◆ rb_reg_named_captures()

static VALUE rb_reg_named_captures ( VALUE  re)
static

Definition at line 829 of file re.c.

References hash(), onig_foreach_name(), rb_hash_new(), rb_reg_check(), reg_named_captures_iter(), and RREGEXP_PTR.

Referenced by Init_Regexp().

◆ rb_reg_names()

static VALUE rb_reg_names ( VALUE  re)
static

◆ rb_reg_new()

VALUE rb_reg_new ( const char *  s,
long  len,
int  options 
)

Definition at line 2844 of file re.c.

References rb_ascii8bit_encoding(), and rb_enc_reg_new().

Referenced by date__strptime_internal(), proc_options(), and regcomp().

◆ rb_reg_new_ary()

VALUE rb_reg_new_ary ( VALUE  ary,
int  opt 
)

Definition at line 2824 of file re.c.

References rb_reg_new_str(), and rb_reg_preprocess_dregexp().

◆ rb_reg_new_str()

VALUE rb_reg_new_str ( VALUE  s,
int  options 
)

Definition at line 2792 of file re.c.

References rb_reg_alloc(), and rb_reg_init_str().

Referenced by r_object0(), rb_reg_new_ary(), rb_reg_regcomp(), and rb_reg_s_union().

◆ rb_reg_nth_defined()

VALUE rb_reg_nth_defined ( int  nth,
VALUE  match 
)

Definition at line 1592 of file re.c.

References BEG, match_check(), NIL_P, re_registers::num_regs, Qfalse, Qnil, Qtrue, and RMATCH_REGS.

◆ rb_reg_nth_match()

VALUE rb_reg_nth_match ( int  nth,
VALUE  match 
)

◆ rb_reg_options()

int rb_reg_options ( VALUE  re)

◆ rb_reg_options_m()

static VALUE rb_reg_options_m ( VALUE  re)
static

Definition at line 749 of file re.c.

References INT2NUM, options(), and rb_reg_options().

Referenced by Init_Regexp().

◆ rb_reg_prepare_enc()

static rb_encoding* rb_reg_prepare_enc ( VALUE  re,
VALUE  str,
int  warn 
)
static

◆ rb_reg_prepare_re()

regex_t* rb_reg_prepare_re ( VALUE  re,
VALUE  str 
)

Definition at line 1458 of file re.c.

References err, and rb_reg_prepare_re0().

Referenced by strscan_do_scan().

◆ rb_reg_prepare_re0()

regex_t* rb_reg_prepare_re0 ( VALUE  re,
VALUE  str,
onig_errmsg_buffer  err 
)

◆ rb_reg_preprocess()

static VALUE rb_reg_preprocess ( const char *  p,
const char *  end,
rb_encoding enc,
rb_encoding **  fixed_enc,
onig_errmsg_buffer  err 
)
static

◆ rb_reg_preprocess_dregexp()

static VALUE rb_reg_preprocess_dregexp ( VALUE  ary,
int  options 
)
static

◆ rb_reg_quote()

VALUE rb_reg_quote ( VALUE  str)

◆ rb_reg_raise()

static void rb_reg_raise ( const char *  s,
long  len,
const char *  err,
VALUE  re 
)
static

Definition at line 661 of file re.c.

References PRIsVALUE, rb_eRegexpError, rb_raise(), and rb_reg_desc().

Referenced by rb_reg_match_p(), rb_reg_prepare_re0(), and rb_reg_search0().

◆ rb_reg_raise_str()

static void rb_reg_raise_str ( VALUE  str,
int  options,
const char *  err 
)
static

Definition at line 699 of file re.c.

References rb_exc_raise(), and rb_reg_error_desc().

Referenced by rb_reg_init_str(), and rb_reg_init_str_enc().

◆ rb_reg_regcomp()

VALUE rb_reg_regcomp ( VALUE  str)

◆ rb_reg_region_copy()

int rb_reg_region_copy ( struct re_registers to,
const struct re_registers from 
)

◆ rb_reg_regsub()

VALUE rb_reg_regsub ( VALUE  str,
VALUE  src,
struct re_registers regs,
VALUE  regexp 
)

◆ rb_reg_s_alloc()

static VALUE rb_reg_s_alloc ( VALUE  klass)
static

Definition at line 2774 of file re.c.

References FL_WB_PROTECTED, NEWOBJ_OF, RB_OBJ_WRITE, RGENGC_WB_PROTECTED_REGEXP, and T_REGEXP.

Referenced by Init_Regexp(), and rb_reg_alloc().

◆ rb_reg_s_last_match()

static VALUE rb_reg_s_last_match ( int  argc,
VALUE argv 
)
static

◆ rb_reg_s_quote()

static VALUE rb_reg_s_quote ( VALUE  c,
VALUE  str 
)
static

Definition at line 3468 of file re.c.

References rb_reg_quote(), reg_operand(), and TRUE.

Referenced by Init_Regexp(), and rb_reg_s_union().

◆ rb_reg_s_try_convert()

static VALUE rb_reg_s_try_convert ( VALUE  dummy,
VALUE  re 
)
static

Definition at line 3509 of file re.c.

References rb_check_regexp_type().

Referenced by Init_Regexp().

◆ rb_reg_s_union()

static VALUE rb_reg_s_union ( VALUE  self,
VALUE  args0 
)
static

◆ rb_reg_s_union_m()

static VALUE rb_reg_s_union_m ( VALUE  self,
VALUE  args 
)
static

Definition at line 3650 of file re.c.

References NIL_P, RARRAY_LEN, rb_ary_entry(), rb_check_array_type(), and rb_reg_s_union().

Referenced by Init_Regexp().

◆ rb_reg_search()

long rb_reg_search ( VALUE  re,
VALUE  str,
long  pos,
int  reverse 
)

◆ rb_reg_search0()

long rb_reg_search0 ( VALUE  re,
VALUE  str,
long  pos,
int  reverse,
int  set_backref_str 
)

◆ rb_reg_source()

static VALUE rb_reg_source ( VALUE  re)
static

Definition at line 498 of file re.c.

References OBJ_TAINT, OBJ_TAINTED, rb_reg_check(), rb_str_dup(), and RREGEXP_SRC.

Referenced by Init_Regexp().

◆ rb_reg_to_s()

static VALUE rb_reg_to_s ( VALUE  re)
static

◆ re_warn()

static void re_warn ( const char *  s)
static

Definition at line 3881 of file re.c.

References rb_warn().

Referenced by Init_Regexp().

◆ read_escaped_byte()

static int read_escaped_byte ( const char **  pp,
const char *  end,
onig_errmsg_buffer  err 
)
static

Definition at line 2203 of file re.c.

References errcpy, len, scan_hex, and scan_oct.

Referenced by unescape_escaped_nonascii(), and unescape_nonascii().

◆ reg_enc_error()

static void reg_enc_error ( VALUE  re,
VALUE  str 
)
static

Definition at line 1362 of file re.c.

References rb_eEncCompatError, rb_enc_get(), rb_enc_name, and rb_raise().

Referenced by rb_reg_prepare_enc().

◆ reg_hash()

static st_index_t reg_hash ( VALUE  re)
static

◆ reg_match_pos()

static long reg_match_pos ( VALUE  re,
VALUE strp,
long  pos 
)
static

◆ reg_named_captures_iter()

static int reg_named_captures_iter ( const OnigUChar name,
const OnigUChar name_end,
int  back_num,
int *  back_refs,
OnigRegex  regex,
void *  arg 
)
static

Definition at line 791 of file re.c.

References hash(), INT2NUM, rb_ary_new2, rb_ary_store(), rb_hash_aset(), and rb_str_new().

Referenced by rb_reg_named_captures().

◆ reg_names_iter()

static int reg_names_iter ( const OnigUChar name,
const OnigUChar name_end,
int  back_num,
int *  back_refs,
OnigRegex  regex,
void *  arg 
)
static

Definition at line 756 of file re.c.

References re_pattern_buffer::enc, rb_ary_push(), and rb_enc_str_new().

Referenced by rb_reg_names().

◆ reg_operand()

static VALUE reg_operand ( VALUE  s,
int  check 
)
static

Definition at line 2992 of file re.c.

References rb_check_string_type(), rb_str_to_str(), rb_sym2str, and SYMBOL_P.

Referenced by rb_reg_eqq(), rb_reg_s_quote(), and reg_match_pos().

◆ reg_set_source()

static void reg_set_source ( VALUE  reg,
VALUE  str,
rb_encoding enc 
)
static

◆ str_coderange()

static int str_coderange ( VALUE  str)
inlinestatic

◆ unescape_escaped_nonascii()

static int unescape_escaped_nonascii ( const char **  pp,
const char *  end,
rb_encoding enc,
VALUE  buf,
rb_encoding **  encp,
onig_errmsg_buffer  err 
)
static

◆ unescape_nonascii()

static int unescape_nonascii ( const char *  p,
const char *  end,
rb_encoding enc,
VALUE  buf,
rb_encoding **  encp,
int *  has_property,
onig_errmsg_buffer  err 
)
static

◆ unescape_unicode_bmp()

static int unescape_unicode_bmp ( const char **  pp,
const char *  end,
VALUE  buf,
rb_encoding **  encp,
onig_errmsg_buffer  err 
)
static

Definition at line 2436 of file re.c.

References append_utf8(), errcpy, len, and ruby_scan_hex().

Referenced by unescape_nonascii().

◆ unescape_unicode_list()

static int unescape_unicode_list ( const char **  pp,
const char *  end,
VALUE  buf,
rb_encoding **  encp,
onig_errmsg_buffer  err 
)
static

Definition at line 2399 of file re.c.

References append_utf8(), errcpy, ISSPACE, len, and ruby_scan_hex().

Referenced by unescape_nonascii().

◆ update_char_offset()

static void update_char_offset ( VALUE  match)
static

Variable Documentation

◆ rb_cMatch

VALUE rb_cMatch

Definition at line 896 of file re.c.

Referenced by Init_Regexp(), rb_backref_set_string(), and rb_reg_search0().

◆ rb_cRegexp

VALUE rb_cRegexp

Definition at line 2200 of file re.c.

Referenced by Init_Regexp(), rb_reg_alloc(), and rb_reg_s_union().

◆ rb_eRegexpError

VALUE rb_eRegexpError

Definition at line 19 of file re.c.

Referenced by Init_Regexp(), rb_enc_reg_error_desc(), rb_reg_preprocess_dregexp(), and rb_reg_raise().

◆ reg_cache

VALUE reg_cache
static

Definition at line 2864 of file re.c.

Referenced by Init_Regexp(), and rb_reg_regcomp().