Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

re.c File Reference

#include "ruby.h"
#include "re.h"
#include <ctype.h>

Go to the source code of this file.

Defines

#define BEG(no)   regs->beg[no]
#define END(no)   regs->end[no]
#define KR_REHASH(a, b, h)   (((h) << 1) - (((unsigned long)(a))<<d) + (b))
#define REG_CASESTATE   FL_USER0
#define KCODE_NONE   0
#define KCODE_EUC   FL_USER1
#define KCODE_SJIS   FL_USER2
#define KCODE_UTF8   FL_USER3
#define KCODE_FIXED   FL_USER4
#define KCODE_MASK   (KCODE_EUC|KCODE_SJIS|KCODE_UTF8)
#define MATCH_BUSY   FL_USER2

Functions

int rb_memcicmp (char *p1, char *p2, long len)
int rb_memcmp (char *p1, char *p2, long len)
long rb_memsearch (char *x0, long m, char *y0, long n)
void kcode_euc (struct RRegexp *re)
void kcode_sjis (struct RRegexp *re)
void kcode_utf8 (struct RRegexp *re)
void kcode_none (struct RRegexp *re)
void kcode_set_option (VALUE re)
void kcode_reset_option ()
int rb_reg_mbclen2 (unsigned int c, VALUE re)
void rb_reg_check (VALUE re)
void rb_reg_expr_str (VALUE str, const char *s, long len)
VALUE rb_reg_desc (char *s, long len, VALUE re) const
VALUE rb_reg_source (VALUE re)
VALUE rb_reg_inspect (VALUE re)
VALUE rb_reg_to_s (VALUE re)
void rb_reg_raise (char *s, long len, const char *err, VALUE re) const
VALUE rb_reg_casefold_p (VALUE re)
VALUE rb_reg_options_m (VALUE re)
VALUE rb_reg_kcode_m (VALUE re)
Regexpmake_regexp (char *s, long len, int flags) const
VALUE match_alloc (VALUE)
VALUE match_init_copy (VALUE obj, VALUE orig)
VALUE match_size (VALUE match)
VALUE match_offset (VALUE match, VALUE n)
VALUE match_begin (VALUE match, VALUE n)
VALUE match_end (VALUE match, VALUE n)
void rb_match_busy (VALUE match)
void rb_reg_prepare_re (VALUE re)
long rb_reg_adjust_startpos (VALUE re, VALUE str, long pos, long reverse)
long rb_reg_search (VALUE re, VALUE str, long pos, long 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)
VALUE last_match_getter ()
VALUE prematch_getter ()
VALUE postmatch_getter ()
VALUE last_paren_match_getter ()
VALUE match_array (VALUE match, int start)
VALUE match_to_a (VALUE match)
VALUE match_captures (VALUE match)
VALUE match_aref (int argc, VALUE *argv, VALUE match)
VALUE match_entry (VALUE, long)
VALUE match_values_at (int argc, VALUE *argv, VALUE match)
VALUE match_select (int argc, VALUE *argv, VALUE match)
VALUE match_to_s (VALUE match)
VALUE match_string (VALUE match)
void rb_reg_initialize (VALUE obj, const char *s, long len, int options)
VALUE rb_reg_s_alloc (VALUE)
VALUE rb_reg_new (char *s, long len, int options) const
VALUE rb_reg_regcomp (VALUE str)
int rb_reg_cur_kcode (VALUE re)
VALUE rb_reg_hash (VALUE re)
VALUE rb_reg_equal (VALUE re1, VALUE re2)
VALUE rb_reg_match (VALUE re, VALUE str)
VALUE rb_reg_eqq (VALUE re, VALUE str)
VALUE rb_reg_match2 (VALUE re)
VALUE rb_reg_match_m (VALUE re, VALUE str)
VALUE rb_reg_initialize_m (int argc, VALUE *argv, VALUE self)
VALUE rb_reg_quote (VALUE str)
VALUE rb_reg_s_quote (int argc, VALUE *argv)
int rb_kcode ()
int rb_reg_get_kcode (VALUE re)
int rb_reg_options (VALUE re)
VALUE rb_reg_s_union (int argc, VALUE *argv)
VALUE rb_reg_init_copy (VALUE copy, VALUE re)
VALUE rb_reg_regsub (VALUE str, VALUE src, struct re_registers *regs)
const char * rb_get_kcode ()
VALUE kcode_getter ()
void rb_set_kcode (char *code) const
void kcode_setter (VALUE val)
VALUE ignorecase_getter ()
void ignorecase_setter (VALUE val, ID id)
VALUE match_getter ()
void match_setter (VALUE val)
VALUE rb_reg_s_last_match (int argc, VALUE *argv)
void Init_Regexp ()

Variables

VALUE rb_eRegexpError
int reg_kcode = DEFAULT_KCODE
int curr_kcode
int ruby_in_compile
VALUE rb_cMatch
int ruby_ignorecase
int may_need_recompile
VALUE rb_cRegexp
int case_cache
int kcode_cache
VALUE reg_cache


Define Documentation

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

Definition at line 18 of file re.c.

Referenced by rb_reg_match_pre(), rb_reg_regsub(), rb_str_split_m(), rb_str_sub_bang(), scan_once(), and str_gsub().

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

Definition at line 19 of file re.c.

Referenced by rb_reg_regsub(), rb_str_split_m(), rb_str_sub_bang(), scan_once(), and str_gsub().

#define KCODE_EUC   FL_USER1
 

Definition at line 156 of file re.c.

Referenced by kcode_euc(), kcode_reset_option(), kcode_set_option(), rb_get_kcode(), rb_kcode(), rb_reg_desc(), rb_reg_get_kcode(), rb_reg_initialize_m(), rb_reg_kcode_m(), rb_reg_s_union(), and rb_set_kcode().

#define KCODE_FIXED   FL_USER4
 

Definition at line 159 of file re.c.

Referenced by kcode_euc(), kcode_none(), kcode_set_option(), kcode_sjis(), kcode_utf8(), rb_reg_adjust_startpos(), rb_reg_cur_kcode(), rb_reg_desc(), rb_reg_initialize_m(), rb_reg_kcode_m(), rb_reg_mbclen2(), rb_reg_options(), rb_reg_prepare_re(), rb_reg_s_union(), and rb_reg_search().

#define KCODE_MASK   (KCODE_EUC|KCODE_SJIS|KCODE_UTF8)
 

Definition at line 160 of file re.c.

Referenced by kcode_euc(), kcode_none(), kcode_set_option(), kcode_sjis(), kcode_utf8(), rb_reg_cur_kcode(), rb_reg_desc(), rb_reg_get_kcode(), rb_reg_initialize_m(), rb_reg_kcode_m(), rb_reg_prepare_re(), and rb_reg_s_union().

#define KCODE_NONE   0
 

Definition at line 155 of file re.c.

Referenced by kcode_reset_option(), kcode_set_option(), rb_kcode(), rb_reg_desc(), rb_reg_get_kcode(), rb_reg_initialize_m(), rb_reg_kcode_m(), rb_reg_s_union(), and rb_set_kcode().

#define KCODE_SJIS   FL_USER2
 

Definition at line 157 of file re.c.

Referenced by kcode_reset_option(), kcode_set_option(), kcode_sjis(), rb_get_kcode(), rb_kcode(), rb_reg_desc(), rb_reg_get_kcode(), rb_reg_initialize_m(), rb_reg_kcode_m(), rb_reg_s_union(), and rb_set_kcode().

#define KCODE_UTF8   FL_USER3
 

Definition at line 158 of file re.c.

Referenced by kcode_reset_option(), kcode_set_option(), kcode_utf8(), rb_get_kcode(), rb_kcode(), rb_reg_desc(), rb_reg_get_kcode(), rb_reg_initialize_m(), rb_reg_kcode_m(), rb_reg_s_union(), and rb_set_kcode().

#define KR_REHASH a,
b,
 )     (((h) << 1) - (((unsigned long)(a))<<d) + (b))
 

Referenced by rb_memsearch().

#define MATCH_BUSY   FL_USER2
 

Definition at line 806 of file re.c.

Referenced by rb_match_busy(), and rb_reg_search().

#define REG_CASESTATE   FL_USER0
 

Definition at line 154 of file re.c.

Referenced by rb_reg_initialize(), and rb_reg_prepare_re().


Function Documentation

VALUE ignorecase_getter  )  [static]
 

Definition at line 2145 of file re.c.

References Qfalse, Qtrue, and ruby_ignorecase.

Referenced by Init_Regexp().

void ignorecase_setter VALUE  val,
ID  id
[static]
 

Definition at line 2151 of file re.c.

References ID, may_need_recompile, rb_id2name(), rb_warn(), RTEST, ruby_ignorecase, and VALUE.

Referenced by Init_Regexp().

void Init_Regexp void   ) 
 

Definition at line 2222 of file re.c.

References 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_getter(), match_init_copy(), match_offset(), match_select(), match_setter(), match_size(), match_string(), match_to_a(), match_to_s(), match_values_at(), MBCTYPE_ASCII, MBCTYPE_EUC, MBCTYPE_SJIS, MBCTYPE_UTF8, postmatch_getter(), prematch_getter(), rb_any_to_s(), rb_class_new_instance(), rb_cMatch, rb_cObject, rb_cRegexp, rb_define_alloc_func(), rb_define_class(), rb_define_const(), rb_define_global_const(), rb_define_method(), rb_define_singleton_method(), rb_define_virtual_variable(), rb_eRegexpError, rb_eStandardError, rb_global_variable(), rb_reg_casefold_p(), rb_reg_eqq(), rb_reg_equal(), rb_reg_hash(), rb_reg_init_copy(), rb_reg_initialize_m(), rb_reg_inspect(), rb_reg_kcode_m(), rb_reg_match(), rb_reg_match2(), rb_reg_match_m(), rb_reg_match_post(), rb_reg_match_pre(), rb_reg_options_m(), rb_reg_s_alloc(), rb_reg_s_last_match(), rb_reg_s_quote(), rb_reg_s_union(), rb_reg_source(), rb_reg_to_s(), rb_undef_method(), re_mbcinit(), RE_OPTION_EXTENDED, RE_OPTION_IGNORECASE, RE_OPTION_MULTILINE, re_set_casetable(), and reg_cache.

Referenced by rb_call_inits().

void kcode_euc struct RRegexp re  )  [static]
 

Definition at line 165 of file re.c.

References FL_SET, FL_UNSET, KCODE_EUC, KCODE_FIXED, and KCODE_MASK.

Referenced by rb_reg_initialize().

VALUE kcode_getter  )  [static]
 

Definition at line 2097 of file re.c.

References rb_get_kcode(), and rb_str_new2().

Referenced by Init_Regexp().

void kcode_none struct RRegexp re  )  [static]
 

Definition at line 192 of file re.c.

References FL_SET, FL_UNSET, KCODE_FIXED, and KCODE_MASK.

Referenced by rb_reg_initialize().

void kcode_reset_option  )  [static]
 

Definition at line 226 of file re.c.

References curr_kcode, KCODE_EUC, KCODE_NONE, KCODE_SJIS, KCODE_UTF8, MBCTYPE_ASCII, MBCTYPE_EUC, MBCTYPE_SJIS, MBCTYPE_UTF8, re_mbcinit(), and reg_kcode.

Referenced by rb_reg_adjust_startpos(), rb_reg_initialize(), rb_reg_mbclen2(), rb_reg_s_quote(), rb_reg_search(), and rb_reg_to_s().

void kcode_set_option VALUE  re  )  [static]
 

Definition at line 202 of file re.c.

References curr_kcode, FL_TEST, KCODE_EUC, KCODE_FIXED, KCODE_MASK, KCODE_NONE, KCODE_SJIS, KCODE_UTF8, MBCTYPE_ASCII, MBCTYPE_EUC, MBCTYPE_SJIS, MBCTYPE_UTF8, RBASIC, re_mbcinit(), reg_kcode, and VALUE.

Referenced by rb_reg_adjust_startpos(), rb_reg_initialize(), rb_reg_mbclen2(), rb_reg_prepare_re(), rb_reg_search(), and rb_reg_to_s().

void kcode_setter VALUE  val  )  [static]
 

Definition at line 2137 of file re.c.

References may_need_recompile, rb_set_kcode(), StringValuePtr, and VALUE.

Referenced by Init_Regexp().

void kcode_sjis struct RRegexp re  )  [static]
 

Definition at line 174 of file re.c.

References FL_SET, FL_UNSET, KCODE_FIXED, KCODE_MASK, and KCODE_SJIS.

Referenced by rb_reg_initialize().

void kcode_utf8 struct RRegexp re  )  [static]
 

Definition at line 183 of file re.c.

References FL_SET, FL_UNSET, KCODE_FIXED, KCODE_MASK, and KCODE_UTF8.

Referenced by rb_reg_initialize().

VALUE last_match_getter  )  [static]
 

Definition at line 1069 of file re.c.

References rb_backref_get(), and rb_reg_last_match().

Referenced by Init_Regexp().

VALUE last_paren_match_getter  )  [static]
 

Definition at line 1087 of file re.c.

References rb_backref_get(), and rb_reg_match_last().

Referenced by Init_Regexp().

Regexp* make_regexp char *  s,
long  len,
int  flags
const [static]
 

Definition at line 618 of file re.c.

References ALLOC, ALLOC_N, MEMZERO, NULL, rb_reg_raise(), re_compile_pattern(), re_free_pattern(), and Regexp.

Referenced by rb_reg_initialize().

VALUE match_alloc VALUE   )  [static]
 

Definition at line 669 of file re.c.

References ALLOC, MEMZERO, NEWOBJ, OBJSETUP, T_MATCH, and VALUE.

Referenced by Init_Regexp(), and rb_reg_search().

VALUE match_aref int  argc,
VALUE argv,
VALUE  match
[static]
 

Definition at line 1191 of file re.c.

References FIX2INT, FIXNUM_P, match_to_a(), NIL_P, rb_ary_aref(), rb_reg_nth_match(), rb_scan_args(), and VALUE.

Referenced by Init_Regexp().

VALUE match_array VALUE  match,
int  start
[static]
 

Definition at line 1093 of file re.c.

References OBJ_TAINT, OBJ_TAINTED, Qnil, rb_ary_new2(), rb_ary_push(), rb_str_substr(), RMATCH, and VALUE.

Referenced by match_captures(), and match_to_a().

VALUE match_begin VALUE  match,
VALUE  n
[static]
 

Definition at line 764 of file re.c.

References INT2FIX, NUM2INT, Qnil, rb_eIndexError, rb_raise(), RMATCH, and VALUE.

Referenced by Init_Regexp().

VALUE match_captures VALUE  match  )  [static]
 

Definition at line 1164 of file re.c.

References match_array(), and VALUE.

Referenced by Init_Regexp().

VALUE match_end VALUE  match,
VALUE  n
[static]
 

Definition at line 792 of file re.c.

References INT2FIX, NUM2INT, Qnil, rb_eIndexError, rb_raise(), RMATCH, and VALUE.

Referenced by Init_Regexp().

VALUE match_entry VALUE  ,
long 
[static]
 

Definition at line 1208 of file re.c.

References rb_reg_nth_match(), and VALUE.

Referenced by match_values_at().

VALUE match_getter  )  [static]
 

Definition at line 2161 of file re.c.

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

Referenced by Init_Regexp(), and rb_reg_s_last_match().

VALUE match_init_copy VALUE  obj,
VALUE  orig
[static]
 

Definition at line 685 of file re.c.

References rb_eTypeError, rb_obj_class(), rb_obj_is_instance_of(), rb_raise(), re_copy_registers(), re_free_registers(), RMATCH, and VALUE.

Referenced by Init_Regexp().

VALUE match_offset VALUE  match,
VALUE  n
[static]
 

Definition at line 735 of file re.c.

References INT2FIX, NUM2INT, Qnil, rb_assoc_new(), rb_eIndexError, rb_raise(), RMATCH, and VALUE.

Referenced by Init_Regexp().

VALUE match_select int  argc,
VALUE argv,
VALUE  match
[static]
 

Definition at line 1251 of file re.c.

References OBJ_TAINT, OBJ_TAINTED, rb_ary_new(), rb_ary_push(), rb_eArgError, rb_raise(), rb_str_substr(), rb_yield(), RMATCH, RTEST, and VALUE.

Referenced by Init_Regexp().

void match_setter VALUE  val  )  [static]
 

Definition at line 2171 of file re.c.

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

Referenced by Init_Regexp().

VALUE match_size VALUE  match  )  [static]
 

Definition at line 715 of file re.c.

References INT2FIX, RMATCH, and VALUE.

Referenced by Init_Regexp().

VALUE match_string VALUE  match  )  [static]
 

Definition at line 1312 of file re.c.

References RMATCH, and VALUE.

Referenced by Init_Regexp().

VALUE match_to_a VALUE  match  )  [static]
 

Definition at line 1144 of file re.c.

References match_array(), and VALUE.

Referenced by Init_Regexp(), and match_aref().

VALUE match_to_s VALUE  match  )  [static]
 

Definition at line 1289 of file re.c.

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

Referenced by Init_Regexp().

VALUE match_values_at int  argc,
VALUE argv,
VALUE  match
[static]
 

Definition at line 1229 of file re.c.

References match_entry(), rb_values_at(), RMATCH, and VALUE.

Referenced by Init_Regexp().

VALUE postmatch_getter  )  [static]
 

Definition at line 1081 of file re.c.

References rb_backref_get(), and rb_reg_match_post().

Referenced by Init_Regexp().

VALUE prematch_getter  )  [static]
 

Definition at line 1075 of file re.c.

References rb_backref_get(), and rb_reg_match_pre().

Referenced by Init_Regexp().

int rb_kcode  ) 
 

Definition at line 1840 of file re.c.

References KCODE_EUC, KCODE_NONE, KCODE_SJIS, KCODE_UTF8, MBCTYPE_ASCII, MBCTYPE_EUC, MBCTYPE_SJIS, MBCTYPE_UTF8, rb_bug(), and reg_kcode.

void rb_match_busy VALUE  match  ) 
 

Definition at line 809 of file re.c.

References FL_SET, MATCH_BUSY, and VALUE.

Referenced by match_getter(), rb_reg_match_m(), rb_str_scan(), rb_str_sub_bang(), and str_gsub().

long rb_reg_adjust_startpos VALUE  re,
VALUE  str,
long  pos,
long  reverse
 

Definition at line 861 of file re.c.

References curr_kcode, FL_TEST, KCODE_FIXED, kcode_reset_option(), kcode_set_option(), may_need_recompile, rb_reg_check(), rb_reg_prepare_re(), re_adjust_startpos(), reg_kcode, RREGEXP, RSTRING, and VALUE.

Referenced by rb_str_index_m(), and rb_str_rindex_m().

VALUE rb_reg_casefold_p VALUE  re  )  [static]
 

Definition at line 544 of file re.c.

References Qfalse, Qtrue, rb_reg_check(), RE_OPTION_IGNORECASE, RREGEXP, and VALUE.

Referenced by Init_Regexp().

void rb_reg_check VALUE  re  )  [static]
 

Definition at line 261 of file re.c.

References rb_eTypeError, rb_raise(), RREGEXP, and VALUE.

Referenced by rb_reg_adjust_startpos(), rb_reg_casefold_p(), rb_reg_desc(), rb_reg_equal(), rb_reg_hash(), rb_reg_init_copy(), rb_reg_initialize_m(), rb_reg_inspect(), rb_reg_options(), rb_reg_prepare_re(), rb_reg_search(), rb_reg_source(), and rb_reg_to_s().

int rb_reg_cur_kcode VALUE  re  )  [static]
 

Definition at line 1425 of file re.c.

References FL_TEST, KCODE_FIXED, KCODE_MASK, RBASIC, and VALUE.

Referenced by rb_reg_equal().

VALUE rb_reg_desc char *  s,
long  len,
VALUE  re
const [static]
 

Definition at line 328 of file re.c.

References FL_TEST, KCODE_EUC, KCODE_FIXED, KCODE_MASK, KCODE_NONE, KCODE_SJIS, KCODE_UTF8, OBJ_INFECT, rb_reg_check(), rb_reg_expr_str(), rb_str_buf_cat2(), rb_str_buf_new2(), RBASIC, RE_OPTION_EXTENDED, RE_OPTION_IGNORECASE, RE_OPTION_MULTILINE, RREGEXP, and VALUE.

Referenced by rb_reg_inspect(), and rb_reg_raise().

VALUE rb_reg_eqq VALUE  re,
VALUE  str
 

Definition at line 1541 of file re.c.

References NIL_P, Qfalse, Qnil, Qtrue, rb_backref_set(), rb_check_string_type(), rb_reg_search(), StringValue, T_STRING, TYPE, and VALUE.

Referenced by Init_Regexp().

VALUE rb_reg_equal VALUE  re1,
VALUE  re2
[static]
 

Definition at line 1476 of file re.c.

References Qfalse, Qtrue, rb_reg_check(), rb_reg_cur_kcode(), RREGEXP, T_REGEXP, TYPE, and VALUE.

Referenced by Init_Regexp().

void rb_reg_expr_str VALUE  str,
const char *  s,
long  len
[static]
 

Definition at line 272 of file re.c.

References ismbchar, ISPRINT, ISSPACE, mbclen, rb_str_buf_cat(), and VALUE.

Referenced by rb_reg_desc(), and rb_reg_to_s().

int rb_reg_get_kcode VALUE  re  )  [static]
 

Definition at line 1856 of file re.c.

References KCODE_EUC, KCODE_MASK, KCODE_NONE, KCODE_SJIS, KCODE_UTF8, RBASIC, and VALUE.

Referenced by rb_reg_options().

VALUE rb_reg_hash VALUE  re  )  [static]
 

Definition at line 1442 of file re.c.

References INT2FIX, rb_reg_check(), RREGEXP, and VALUE.

Referenced by Init_Regexp().

VALUE rb_reg_init_copy VALUE  copy,
VALUE  re
[static]
 

Definition at line 1981 of file re.c.

References rb_check_frozen(), rb_eTypeError, rb_obj_class(), rb_obj_is_instance_of(), rb_raise(), rb_reg_check(), rb_reg_initialize(), rb_reg_options(), RREGEXP, and VALUE.

Referenced by Init_Regexp().

void rb_reg_initialize VALUE  obj,
const char *  s,
long  len,
int  options
[static]
 

Definition at line 1321 of file re.c.

References ALLOC_N, FL_SET, free, kcode_euc(), kcode_none(), kcode_reset_option(), kcode_set_option(), kcode_sjis(), kcode_utf8(), make_regexp(), re_free_pattern(), RE_OPTION_IGNORECASE, REG_CASESTATE, reg_kcode, RREGEXP, ruby_ignorecase, and VALUE.

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

VALUE rb_reg_initialize_m int  argc,
VALUE argv,
VALUE  self
[static]
 

Definition at line 1647 of file re.c.

References FIX2INT, FIXNUM_P, FL_TEST, KCODE_EUC, KCODE_FIXED, KCODE_MASK, KCODE_NONE, KCODE_SJIS, KCODE_UTF8, NIL_P, rb_check_frozen(), rb_eArgError, rb_raise(), rb_reg_check(), rb_reg_initialize(), rb_warn(), RBASIC, RE_OPTION_IGNORECASE, RREGEXP, RSTRING, RTEST, StringValuePtr, T_REGEXP, TYPE, and VALUE.

Referenced by Init_Regexp().

VALUE rb_reg_inspect VALUE  re  )  [static]
 

Definition at line 401 of file re.c.

References rb_reg_check(), rb_reg_desc(), RREGEXP, and VALUE.

Referenced by Init_Regexp().

VALUE rb_reg_kcode_m VALUE  re  )  [static]
 

Definition at line 593 of file re.c.

References FL_TEST, KCODE_EUC,