Project

General

Profile

Actions

Bug #6167

closed

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

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

Status:
Closed
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.

Updated by john_firebaugh (John Firebaugh) about 12 years ago

Other incorrect results:

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

Both should be 0.

Actions #2

Updated by naruse (Yui NARUSE) about 12 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]
Actions

Also available in: Atom PDF

Like0
Like0Like0