mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* re.c (rb_reg_s_union): show encodings in error message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
ce2b982cd2
commit
fd640aec82
2 changed files with 21 additions and 6 deletions
|
@ -1,3 +1,7 @@
|
|||
Thu Dec 27 16:37:06 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* re.c (rb_reg_s_union): show encodings in error message.
|
||||
|
||||
Thu Dec 27 15:25:16 2007 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* encoding.c (rb_enc_codelen): show codepoint in error message.
|
||||
|
|
23
re.c
23
re.c
|
@ -2631,13 +2631,15 @@ rb_reg_s_union(VALUE self, VALUE args0)
|
|||
if (!has_ascii_incompat)
|
||||
has_ascii_incompat = enc;
|
||||
else if (has_ascii_incompat != enc)
|
||||
rb_raise(rb_eArgError, "regexp encodings differ");
|
||||
rb_raise(rb_eArgError, "incompatible encodings: %s and %s",
|
||||
rb_enc_name(has_ascii_incompat), rb_enc_name(enc));
|
||||
}
|
||||
else if (rb_reg_fixed_encoding_p(v)) {
|
||||
if (!has_ascii_compat_fixed)
|
||||
has_ascii_compat_fixed = enc;
|
||||
else if (has_ascii_compat_fixed != enc)
|
||||
rb_raise(rb_eArgError, "regexp encodings differ");
|
||||
rb_raise(rb_eArgError, "incompatible encodings: %s and %s",
|
||||
rb_enc_name(has_ascii_compat_fixed), rb_enc_name(enc));
|
||||
}
|
||||
else {
|
||||
has_asciionly = 1;
|
||||
|
@ -2652,7 +2654,8 @@ rb_reg_s_union(VALUE self, VALUE args0)
|
|||
if (!has_ascii_incompat)
|
||||
has_ascii_incompat = enc;
|
||||
else if (has_ascii_incompat != enc)
|
||||
rb_raise(rb_eArgError, "regexp encodings differ");
|
||||
rb_raise(rb_eArgError, "incompatible encodings: %s and %s",
|
||||
rb_enc_name(has_ascii_incompat), rb_enc_name(enc));
|
||||
}
|
||||
else if (rb_enc_str_asciionly_p(e)) {
|
||||
has_asciionly = 1;
|
||||
|
@ -2661,12 +2664,20 @@ rb_reg_s_union(VALUE self, VALUE args0)
|
|||
if (!has_ascii_compat_fixed)
|
||||
has_ascii_compat_fixed = enc;
|
||||
else if (has_ascii_compat_fixed != enc)
|
||||
rb_raise(rb_eArgError, "regexp encodings differ");
|
||||
rb_raise(rb_eArgError, "incompatible encodings: %s and %s",
|
||||
rb_enc_name(has_ascii_compat_fixed), rb_enc_name(enc));
|
||||
}
|
||||
v = rb_reg_s_quote(Qnil, e);
|
||||
}
|
||||
if (has_ascii_incompat && (has_asciionly || has_ascii_compat_fixed)) {
|
||||
rb_raise(rb_eArgError, "regexp encodings differ");
|
||||
if (has_ascii_incompat) {
|
||||
if (has_asciionly) {
|
||||
rb_raise(rb_eArgError, "ASCII incompatible encoding: %s",
|
||||
rb_enc_name(has_ascii_incompat));
|
||||
}
|
||||
if (has_ascii_compat_fixed) {
|
||||
rb_raise(rb_eArgError, "incompatible encodings: %s and %s",
|
||||
rb_enc_name(has_ascii_incompat), rb_enc_name(has_ascii_compat_fixed));
|
||||
}
|
||||
}
|
||||
|
||||
rb_str_append(source, v);
|
||||
|
|
Loading…
Reference in a new issue