Bug #9849

gsub(String, String) doesn't work properly

Added by Shugo Maeda over 1 year ago. Updated over 1 year ago.

[ruby-core:62669]
Status:Closed
Priority:Normal
Assignee:Nobuyoshi Nakada
ruby -v:ruby 2.2.0dev (2014-05-19 trunk 46010) [i686-linux] Backport:2.0.0: DONTNEED, 2.1: DONTNEED

Description

gsub(String, String) doesn't work properly as follows:

$ ruby -ve 'puts "あああ\"foo\"\n\"bar\"".gsub("\"", "\"\"")' 
ruby 2.2.0dev (2014-05-19 trunk 46010) [i686-linux]
あああ""foo"
"bar""

The expected behavior is:

$ ~/.rbenv/versions/2.1.1/bin/ruby -ve 'puts "あああ\"foo\"\n\"bar\"".gsub("\"", "\"\"")' 
ruby 2.1.1p76 (2014-02-24 revision 45161) [i686-linux]
あああ""foo""
""bar""

It seems that the bug was introduced by r45451, so I assign this issue to nobu.

Associated revisions

Revision 46013
Added by Nobuyoshi Nakada over 1 year ago

string.c: byte offset

  • string.c (rb_pat_search): advance by byte offset but not by char offset. [Bug #9849]

Revision 46013
Added by Nobuyoshi Nakada over 1 year ago

string.c: byte offset

  • string.c (rb_pat_search): advance by byte offset but not by char offset. [Bug #9849]

History

#1 Updated by Nobuyoshi Nakada over 1 year ago

  • Backport changed from 2.0.0: UNKNOWN, 2.1: UNKNOWN to 2.0.0: DONTNEED, 2.1: DONTNEED

#2 Updated by Nobuyoshi Nakada over 1 year ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Applied in changeset r46013.


string.c: byte offset

  • string.c (rb_pat_search): advance by byte offset but not by char offset. [Bug #9849]

Also available in: Atom PDF