mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (trnext): should advance char-wise.
[ruby-core:43335][Bug #6156] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7af3e9f08b
commit
ba20fe6289
3 changed files with 13 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
|||
Fri Mar 16 20:06:24 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (trnext): should advance char-wise.
|
||||
[ruby-core:43335][Bug #6156]
|
||||
|
||||
Fri Mar 16 17:42:05 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (block_append_gen): fix unreachable warning line number.
|
||||
|
|
8
string.c
8
string.c
|
@ -4956,13 +4956,13 @@ trnext(struct tr *t, rb_encoding *enc)
|
|||
for (;;) {
|
||||
if (!t->gen) {
|
||||
if (t->p == t->pend) return -1;
|
||||
if (t->p < t->pend - 1 && *t->p == '\\') {
|
||||
t->p++;
|
||||
if (rb_enc_ascget(t->p, t->pend, &n, enc) == '\\') {
|
||||
t->p += n;
|
||||
}
|
||||
t->now = rb_enc_codepoint_len(t->p, t->pend, &n, enc);
|
||||
t->p += n;
|
||||
if (t->p < t->pend - 1 && *t->p == '-') {
|
||||
t->p++;
|
||||
if (rb_enc_ascget(t->p, t->pend, &n, enc) == '-') {
|
||||
t->p += n;
|
||||
if (t->p < t->pend) {
|
||||
unsigned int c = rb_enc_codepoint_len(t->p, t->pend, &n, enc);
|
||||
t->p += n;
|
||||
|
|
|
@ -1500,6 +1500,10 @@ class TestString < Test::Unit::TestCase
|
|||
assert_equal(true, "\u0101".tr("\u0101", "a").ascii_only?)
|
||||
assert_equal(true, "\u3041".tr("\u3041", "a").ascii_only?)
|
||||
assert_equal(false, "\u3041\u3042".tr("\u3041", "a").ascii_only?)
|
||||
|
||||
bug6156 = '[ruby-core:43335]'
|
||||
str, range, star = %w[b a-z *].map{|s|s.encode("utf-16le")}
|
||||
assert_equal(star, str.tr(range, star), bug6156)
|
||||
end
|
||||
|
||||
def test_tr!
|
||||
|
|
Loading…
Reference in a new issue