From 668bd7d992e3157e616ac7a0b0154d8accb17288 Mon Sep 17 00:00:00 2001 From: matz Date: Fri, 21 Dec 2007 05:03:14 +0000 Subject: [PATCH] * test/ruby/test_system.rb (TestSystem::valid_syntax): apply ASCII-8BIT encoding explicitly. * re.c (rb_reg_prepare_re): add encoding name in the message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ re.c | 2 +- test/ruby/test_system.rb | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 4a8a9f79c2..66eefad252 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Fri Dec 21 14:01:14 2007 Yukihiro Matsumoto + + * test/ruby/test_system.rb (TestSystem::valid_syntax): apply + ASCII-8BIT encoding explicitly. + + * re.c (rb_reg_prepare_re): add encoding name in the message. + Fri Dec 21 13:54:05 2007 Tanaka Akira * re.c: change "character encodings differ" error messages. diff --git a/re.c b/re.c index b6facf98ea..9306ae7bfd 100644 --- a/re.c +++ b/re.c @@ -943,7 +943,7 @@ rb_reg_prepare_re(VALUE re, VALUE str) if (rb_reg_fixed_encoding_p(re)) { if (ENCODING_GET(re) != rb_enc_get_index(str) && rb_enc_str_coderange(str) != ENC_CODERANGE_7BIT) { - rb_raise(rb_eArgError, "fixed character encoding regexp with incompatible string"); + rb_raise(rb_eArgError, "fixed character encoding regexp with incompatible string (encoding: %s)", rb_enc_name(rb_enc_get(str))); } } else if ((enc = rb_enc_get(str)) != 0 && diff --git a/test/ruby/test_system.rb b/test/ruby/test_system.rb index 7524b2e7af..403bacab2d 100644 --- a/test/ruby/test_system.rb +++ b/test/ruby/test_system.rb @@ -4,6 +4,7 @@ require 'tmpdir' class TestSystem < Test::Unit::TestCase def valid_syntax?(code, fname) + code.force_encoding("ascii-8bit") code = code.sub(/\A(?:\s*\#.*$)*(\n)?/n) { "#$&#{"\n" if $1 && !$2}BEGIN{return true}\n" }