ruby-changes:3241
From: ko1@a...
Date: 27 Dec 2007 16:38:52 +0900
Subject: [ruby-changes:3241] akr - Ruby:r14734 (trunk): * re.c (rb_reg_s_union): show encodings in error message.
akr 2007-12-27 16:38:23 +0900 (Thu, 27 Dec 2007)
New Revision: 14734
Modified files:
trunk/ChangeLog
trunk/re.c
Log:
* re.c (rb_reg_s_union): show encodings in error message.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14734&r2=14733
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/re.c?r1=14734&r2=14733
Index: re.c
===================================================================
--- re.c (revision 14733)
+++ re.c (revision 14734)
@@ -2631,13 +2631,15 @@
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 @@
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 @@
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);
Index: ChangeLog
===================================================================
--- ChangeLog (revision 14733)
+++ ChangeLog (revision 14734)
@@ -1,3 +1,7 @@
+Thu Dec 27 16:37:06 2007 Tanaka Akira <akr@f...>
+
+ * re.c (rb_reg_s_union): show encodings in error message.
+
Thu Dec 27 15:25:16 2007 Tanaka Akira <akr@f...>
* encoding.c (rb_enc_codelen): show codepoint in error message.
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml