1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* include/ruby/intern.h, re.c (rb_reg_new): keep interface same as

1.8.  [ruby-core:14583]

* include/ruby/intern.h, re.c (rb_reg_new_str): renamed, and defines
  HAVE_RB_REG_NEW_STR macro to tell if it is available.

* include/ruby/encoding.h (rb_enc_reg_new): added.

* insns.def (toregexp), marshal.c (r_object0): use rb_reg_new_str().

* re.c (rb_reg_regcomp, rb_reg_s_union): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2008-01-04 16:30:33 +00:00
parent 91f9acdfee
commit 8638ee26e7
7 changed files with 62 additions and 13 deletions

View file

@ -1,3 +1,17 @@
Sat Jan 5 01:30:30 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* include/ruby/intern.h, re.c (rb_reg_new): keep interface same as
1.8. [ruby-core:14583]
* include/ruby/intern.h, re.c (rb_reg_new_str): renamed, and defines
HAVE_RB_REG_NEW_STR macro to tell if it is available.
* include/ruby/encoding.h (rb_enc_reg_new): added.
* insns.def (toregexp), marshal.c (r_object0): use rb_reg_new_str().
* re.c (rb_reg_regcomp, rb_reg_s_union): ditto.
Fri Jan 4 23:08:48 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* time.c (time_arg): use converted object. [ruby-core:14759]

View file

@ -58,7 +58,8 @@ void rb_enc_associate_index(VALUE, int);
void rb_enc_associate(VALUE, rb_encoding*);
void rb_enc_copy(VALUE dst, VALUE src);
VALUE rb_enc_str_new(const char*, long len, rb_encoding*);
VALUE rb_enc_str_new(const char*, long, rb_encoding*);
VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);
long rb_enc_strlen(const char*, const char*, rb_encoding*);

View file

@ -454,7 +454,9 @@ VALUE rb_reg_last_match(VALUE);
VALUE rb_reg_match_pre(VALUE);
VALUE rb_reg_match_post(VALUE);
VALUE rb_reg_match_last(VALUE);
VALUE rb_reg_new(VALUE, int);
#define HAVE_RB_REG_NEW_STR 1
VALUE rb_reg_new_str(VALUE, int);
VALUE rb_reg_new(const char *, long, int);
VALUE rb_reg_match(VALUE, VALUE);
VALUE rb_reg_match2(VALUE);
int rb_reg_options(VALUE);

View file

@ -403,7 +403,7 @@ toregexp
(VALUE val)
{
volatile VALUE tmp = str; /* for GC */
val = rb_reg_new(str, opt);
val = rb_reg_new_str(str, opt);
}
/**

View file

@ -1307,7 +1307,7 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
{
volatile VALUE str = r_bytes(arg);
int options = r_byte(arg);
v = r_entry(rb_reg_new(str, options), arg);
v = r_entry(rb_reg_new_str(str, options), arg);
v = r_leave(v, arg);
}
break;

44
re.c
View file

@ -460,20 +460,33 @@ rb_reg_raise(const char *s, long len, const char *err, VALUE re)
}
static VALUE
rb_reg_error_desc(VALUE str, int options, const char *err)
rb_enc_reg_error_desc(const char *s, long len, rb_encoding *enc, int options, const char *err)
{
char opts[6];
VALUE desc = rb_str_buf_new2(err);
rb_enc_copy(desc, str);
rb_enc_associate(desc, enc);
rb_str_buf_cat2(desc, ": /");
rb_reg_expr_str(desc, RSTRING_PTR(str), RSTRING_LEN(str));
rb_reg_expr_str(desc, s, len);
opts[0] = '/';
option_to_str(opts + 1, options);
rb_str_buf_cat2(desc, opts);
return rb_exc_new3(rb_eRegexpError, desc);
}
static void
rb_enc_reg_raise(const char *s, long len, rb_encoding *enc, int options, const char *err)
{
rb_exc_raise(rb_enc_reg_error_desc(s, len, enc, options, err));
}
static VALUE
rb_reg_error_desc(VALUE str, int options, const char *err)
{
return rb_enc_reg_error_desc(RSTRING_PTR(str), RSTRING_LEN(str),
rb_enc_get(str), options, err);
}
static void
rb_reg_raise_str(VALUE str, int options, const char *err)
{
@ -2040,7 +2053,7 @@ rb_reg_s_alloc(VALUE klass)
}
VALUE
rb_reg_new(VALUE s, int options)
rb_reg_new_str(VALUE s, int options)
{
VALUE re = rb_reg_s_alloc(rb_cRegexp);
onig_errmsg_buffer err;
@ -2052,6 +2065,25 @@ rb_reg_new(VALUE s, int options)
return re;
}
VALUE
rb_enc_reg_new(const char *s, long len, rb_encoding *enc, int options)
{
VALUE re = rb_reg_s_alloc(rb_cRegexp);
onig_errmsg_buffer err;
if (rb_reg_initialize(re, s, len, enc, options, err) != 0) {
rb_enc_reg_raise(s, len, enc, options, err);
}
return re;
}
VALUE
rb_reg_new(const char *s, long len, int options)
{
return rb_enc_reg_new(s, len, rb_ascii8bit_encoding(), options);
}
VALUE
rb_reg_compile(VALUE str, int options)
{
@ -2078,7 +2110,7 @@ rb_reg_regcomp(VALUE str)
&& memcmp(RREGEXP(reg_cache)->str, RSTRING_PTR(str), RSTRING_LEN(str)) == 0)
return reg_cache;
return reg_cache = rb_reg_new(save_str, 0);
return reg_cache = rb_reg_new_str(save_str, 0);
}
/*
@ -2607,7 +2639,7 @@ rb_reg_s_union(VALUE self, VALUE args0)
else {
VALUE quoted;
quoted = rb_reg_s_quote(Qnil, arg);
return rb_reg_new(quoted, 0);
return rb_reg_new_str(quoted, 0);
}
}
else {

View file

@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
#define RUBY_RELEASE_DATE "2008-01-04"
#define RUBY_RELEASE_DATE "2008-01-05"
#define RUBY_VERSION_CODE 190
#define RUBY_RELEASE_CODE 20080104
#define RUBY_RELEASE_CODE 20080105
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 1
#define RUBY_RELEASE_DAY 4
#define RUBY_RELEASE_DAY 5
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];