mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* string.c (trnext): fix bug with string ending with '\\'.
[ruby-dev:45374][Bug #6160] * test/ruby/test_string.rb (TestString#test_delete): test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2cab78a9ff
commit
ea6511c63a
3 changed files with 13 additions and 2 deletions
|
@ -1,3 +1,11 @@
|
|||
Sat Mar 17 01:46:05 2012 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* string.c (trnext): fix bug with string ending with '\\'.
|
||||
[ruby-dev:45374][Bug #6160]
|
||||
|
||||
* test/ruby/test_string.rb (TestString#test_delete): test for
|
||||
above.
|
||||
|
||||
Fri Mar 16 20:06:24 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* string.c (trnext): should advance char-wise.
|
||||
|
|
4
string.c
4
string.c
|
@ -4956,12 +4956,12 @@ trnext(struct tr *t, rb_encoding *enc)
|
|||
for (;;) {
|
||||
if (!t->gen) {
|
||||
if (t->p == t->pend) return -1;
|
||||
if (rb_enc_ascget(t->p, t->pend, &n, enc) == '\\') {
|
||||
if (rb_enc_ascget(t->p, t->pend, &n, enc) == '\\' && t->p + n < t->pend) {
|
||||
t->p += n;
|
||||
}
|
||||
t->now = rb_enc_codepoint_len(t->p, t->pend, &n, enc);
|
||||
t->p += n;
|
||||
if (rb_enc_ascget(t->p, t->pend, &n, enc) == '-') {
|
||||
if (rb_enc_ascget(t->p, t->pend, &n, enc) == '-' && t->p + n < t->pend) {
|
||||
t->p += n;
|
||||
if (t->p < t->pend) {
|
||||
unsigned int c = rb_enc_codepoint_len(t->p, t->pend, &n, enc);
|
||||
|
|
|
@ -508,6 +508,9 @@ class TestString < Test::Unit::TestCase
|
|||
assert_equal("a", "abc\u{3042 3044 3046}".delete("^a"))
|
||||
assert_equal("bc\u{3042 3044 3046}", "abc\u{3042 3044 3046}".delete("a"))
|
||||
assert_equal("\u3042", "abc\u{3042 3044 3046}".delete("^\u3042"))
|
||||
|
||||
bug6160 = '[ruby-dev:45374]'
|
||||
assert_equal("", '\\'.delete('\\'), bug6160)
|
||||
end
|
||||
|
||||
def test_delete!
|
||||
|
|
Loading…
Add table
Reference in a new issue