summaryrefslogtreecommitdiffstats
path: root/re.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-27 07:38:23 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-12-27 07:38:23 +0000
commit46d4991a331e68d6b3c1292b12ed9e4896c07c65 (patch)
treecbb9ada083fba81a8e10338d47db0010e7b4ae0c /re.c
parenta9f1a3c3b84d05a1b0184c42f3191559202974a4 (diff)
downloadruby-46d4991a331e68d6b3c1292b12ed9e4896c07c65.tar.gz
ruby-46d4991a331e68d6b3c1292b12ed9e4896c07c65.tar.xz
ruby-46d4991a331e68d6b3c1292b12ed9e4896c07c65.zip
* re.c (rb_reg_s_union): show encodings in error message.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@14734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 're.c')
-rw-r--r--re.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/re.c b/re.c
index dcbc23460..eae1ebd05 100644
--- a/re.c
+++ b/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);
OSZAR »