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

* re.c (rb_reg_s_union): the last check was not complete.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13733 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2007-10-17 05:21:10 +00:00
parent 2d1d6c4705
commit 05737c3500
2 changed files with 13 additions and 3 deletions

View file

@ -1,3 +1,7 @@
Wed Oct 17 13:54:28 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* re.c (rb_reg_s_union): the last check was not complete.
Wed Oct 17 11:30:55 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* encoding.c (rb_enc_from_encoding, rb_enc_register): associate index

12
re.c
View file

@ -1783,7 +1783,8 @@ rb_reg_s_union(VALUE self, VALUE args0)
else {
int i;
VALUE source = rb_str_buf_new(0);
VALUE enc0 = rb_obj_encoding(rb_ary_entry(args0, 0));
int mbs = Qfalse;
rb_encoding *enc = 0;
for (i = 0; i < argc; i++) {
volatile VALUE v;
@ -1792,12 +1793,17 @@ 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(enc0, v);
v = rb_reg_to_s(v);
}
else {
v = rb_reg_s_quote(Qnil, e);
rb_enc_check(enc0, rb_obj_encoding(v));
}
if (mbs || rb_enc_str_coderange(v) != ENC_CODERANGE_SINGLE) {
if (!enc) enc = rb_enc_get(v);
else if (mbs && enc != rb_enc_get(v)) {
rb_raise(rb_eArgError, "regexp encodings differ");
}
mbs = Qtrue;
}
rb_str_append(source, v);
}