diff options
| author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-17 07:47:29 +0000 |
|---|---|---|
| committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-01-17 07:47:29 +0000 |
| commit | 6c4e9b2b9c9c3217cd40e549a407b2fa1939f420 (patch) | |
| tree | 98e8759ac61214e1c4d8027bb52b592116b0d3bc | |
| parent | 2ca46bfc9d7ee33e940e5fa885ec59a6e0b22298 (diff) | |
merge revision(s) 49201,49203: [Backport #10727]
* eval_error.c (error_print): pos and len parameters of rb_str_substr()
are counted by characters, not bytes. use rb_str_subseq() instead.
[Bug #10727] [ruby-core:67473]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
| -rw-r--r-- | ChangeLog | 6 | ||||
| -rw-r--r-- | eval_error.c | 2 | ||||
| -rw-r--r-- | test/ruby/test_exception.rb | 12 | ||||
| -rw-r--r-- | version.h | 2 |
4 files changed, 20 insertions, 2 deletions
@@ -1,3 +1,9 @@ +Sat Jan 17 16:47:20 2015 NAKAMURA Usaku <usa@ruby-lang.org> + + * eval_error.c (error_print): pos and len parameters of rb_str_substr() + are counted by characters, not bytes. use rb_str_subseq() instead. + [Bug #10727] [ruby-core:67473] + Sat Jan 17 16:35:59 2015 Seiei Higa <hanachin@gmail.com> * vm_method.c (rb_export_method): bail out if the original method diff --git a/eval_error.c b/eval_error.c index 12cfe36571..405d738236 100644 --- a/eval_error.c +++ b/eval_error.c @@ -169,7 +169,7 @@ error_print(void) warn_print(")\n"); } if (tail) { - warn_print_str(rb_str_substr(e, tail - einfo, elen - len - 1)); + warn_print_str(rb_str_subseq(e, tail - einfo, elen - len - 1)); } if (tail ? einfo[elen-1] != '\n' : !epath) warn_print2("\n", 1); } diff --git a/test/ruby/test_exception.rb b/test/ruby/test_exception.rb index 6876d6dc9c..c68d226333 100644 --- a/test/ruby/test_exception.rb +++ b/test/ruby/test_exception.rb @@ -686,4 +686,16 @@ $stderr = $stdout; raise "\x82\xa0"') do |outs, errs, status| assert_match /\u3042/, err end end + + def test_multibyte_and_newline + bug10727 = '[ruby-core:67473] [Bug #10727]' + assert_in_out_err([], <<-'end;', [], /\u{306b 307b 3093 3054} \(E\)\n\u{6539 884c}/, bug10727, encoding: "UTF-8") + class E < StandardError + def initialize + super("\u{306b 307b 3093 3054}\n\u{6539 884c}") + end + end + raise E + end; + end end @@ -1,6 +1,6 @@ #define RUBY_VERSION "2.2.0" #define RUBY_RELEASE_DATE "2015-01-17" -#define RUBY_PATCHLEVEL 20 +#define RUBY_PATCHLEVEL 21 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 1 |
