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

* encoding.c (rb_enc_from_encoding, rb_enc_register): associate index

to self.

* encoding.c (enc_capable): Encoding objects are encoding capable.

* re.c (rb_reg_s_union): check if encoding matching by exact encoding
  objects.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13732 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-10-17 02:30:57 +00:00
parent 5daecbc0e1
commit 2d1d6c4705
3 changed files with 24 additions and 6 deletions

View file

@ -1,3 +1,13 @@
Wed Oct 17 11:30:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (rb_enc_from_encoding, rb_enc_register): associate index
to self.
* encoding.c (enc_capable): Encoding objects are encoding capable.
* re.c (rb_reg_s_union): check if encoding matching by exact encoding
objects.
Wed Oct 17 06:18:06 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (rb_enc_alias, rb_enc_find_index): changed

View file

@ -45,9 +45,14 @@ enc_new(rb_encoding *encoding)
}
VALUE
rb_enc_from_encoding(rb_encoding *enc)
rb_enc_from_encoding(rb_encoding *encoding)
{
return enc_initialized_p(enc) ? ENC_FROM_ENCODING(enc) : enc_new(enc);
VALUE enc;
if (enc_initialized_p(encoding))
return ENC_FROM_ENCODING(encoding);
enc = enc_new(encoding);
rb_enc_associate(enc, encoding);
return enc;
}
static rb_encoding *
@ -136,7 +141,8 @@ rb_enc_register(const char *name, rb_encoding *encoding)
encoding = ent->enc;
encoding->name = name;
if (rb_cEncoding) {
enc_new(encoding);
VALUE enc = enc_new(encoding);
rb_enc_associate_index(enc, newsize);
}
else {
encoding->auxiliary_data = ENC_UNINITIALIZED;
@ -229,6 +235,8 @@ enc_capable(VALUE obj)
case T_REGEXP:
case T_FILE:
return Qtrue;
case T_DATA:
if (RDATA(obj)->dmark == enc_mark) return Qtrue;
default:
return Qfalse;
}

6
re.c
View file

@ -1783,7 +1783,7 @@ rb_reg_s_union(VALUE self, VALUE args0)
else {
int i;
VALUE source = rb_str_buf_new(0);
VALUE tmp = rb_ary_entry(args0, 0);
VALUE enc0 = rb_obj_encoding(rb_ary_entry(args0, 0));
for (i = 0; i < argc; i++) {
volatile VALUE v;
@ -1792,12 +1792,12 @@ rb_reg_s_union(VALUE self, VALUE args0)
rb_str_buf_cat2(source, "|");
v = rb_check_regexp_type(e);
if (!NIL_P(v)) {
rb_enc_check(tmp, v);
rb_enc_check(enc0, v);
v = rb_reg_to_s(v);
}
else {
rb_enc_check(tmp, e);
v = rb_reg_s_quote(Qnil, e);
rb_enc_check(enc0, rb_obj_encoding(v));
}
rb_str_append(source, v);
}