diff options
-rw-r--r-- | ChangeLog | 14 | ||||
-rw-r--r-- | include/ruby/encoding.h | 3 | ||||
-rw-r--r-- | include/ruby/intern.h | 4 | ||||
-rw-r--r-- | insns.def | 2 | ||||
-rw-r--r-- | marshal.c | 2 | ||||
-rw-r--r-- | re.c | 44 | ||||
-rw-r--r-- | version.h | 6 |
7 files changed, 62 insertions, 13 deletions
@@ -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] diff --git a/include/ruby/encoding.h b/include/ruby/encoding.h index 89f3ec36b8..2c247c99e9 100644 --- a/include/ruby/encoding.h +++ b/include/ruby/encoding.h @@ -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*); diff --git a/include/ruby/intern.h b/include/ruby/intern.h index eaacc96052..9ccba10498 100644 --- a/include/ruby/intern.h +++ b/include/ruby/intern.h @@ -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); @@ -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); } /** @@ -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; @@ -460,14 +460,14 @@ 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); @@ -475,6 +475,19 @@ rb_reg_error_desc(VALUE str, int options, const char *err) } 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) { rb_exc_raise(rb_reg_error_desc(str, options, 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; @@ -2053,6 +2066,25 @@ rb_reg_new(VALUE s, int options) } 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) { VALUE re = rb_reg_s_alloc(rb_cRegexp); @@ -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 { @@ -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[]; |