Project

General

Profile

Bug #6167

String#count: wrong result for multiple complements of multi-byte characters

Added by john_firebaugh (John Firebaugh) about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0]
Backport:
[ruby-core:43371]

Description

"\u0100\u0101".count("\u0100", "\u0101")
=> 2

Since multiple arguments are intersected, the expected result is 0. Compare:

"\u0080\u0081".count("\u0080", "\u0081")
=> 0

This takes a different path through tr_setup_table and returns the correct result.

Analogous bugs exists in String#squeeze and String#delete, which also use tr_setup_table.

Associated revisions

Revision 73a184cc
Added by naruse (Yui NARUSE) about 7 years ago

  • string.c (tr_setup_table): fix multiple non latin argument for non latin (over 256 characters) tr-like methods. [ruby-core:43371] [Bug #6167]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 35127
Added by naruse (Yui NARUSE) about 7 years ago

  • string.c (tr_setup_table): fix multiple non latin argument for non latin (over 256 characters) tr-like methods. [ruby-core:43371] [Bug #6167]

Revision 35127
Added by naruse (Yui NARUSE) about 7 years ago

  • string.c (tr_setup_table): fix multiple non latin argument for non latin (over 256 characters) tr-like methods. [ruby-core:43371] [Bug #6167]

Revision 35127
Added by naruse (Yui NARUSE) about 7 years ago

  • string.c (tr_setup_table): fix multiple non latin argument for non latin (over 256 characters) tr-like methods. [ruby-core:43371] [Bug #6167]

Revision 35127
Added by naruse (Yui NARUSE) about 7 years ago

  • string.c (tr_setup_table): fix multiple non latin argument for non latin (over 256 characters) tr-like methods. [ruby-core:43371] [Bug #6167]

Revision 35127
Added by naruse (Yui NARUSE) about 7 years ago

  • string.c (tr_setup_table): fix multiple non latin argument for non latin (over 256 characters) tr-like methods. [ruby-core:43371] [Bug #6167]

Revision 35127
Added by naruse (Yui NARUSE) about 7 years ago

  • string.c (tr_setup_table): fix multiple non latin argument for non latin (over 256 characters) tr-like methods. [ruby-core:43371] [Bug #6167]

History

Updated by john_firebaugh (John Firebaugh) about 7 years ago

Other incorrect results:

"\u0100\u0101".count("a", "\u0100")
=> 1
"\u0100\u0101".count("\u0100", "a")
=> 1

Both should be 0.

#2

Updated by naruse (Yui NARUSE) about 7 years ago

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

This issue was solved with changeset r35127.
John, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • string.c (tr_setup_table): fix multiple non latin argument for non latin (over 256 characters) tr-like methods. [ruby-core:43371] [Bug #6167]

Also available in: Atom PDF