String#count incorrectly works with high-order bytes
----------------------------------------------------
Key: JRUBY-1720
URL: http://jira.codehaus.org/browse/JRUBY-1720
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Environment: Latest JRuby 1.1b1 from trunk, Ubuntu Linux 7.10
Reporter: Vladimir Sizikov
Attachments: string_count.diff
Consider the following example:
s = "hel-[()]-lo012^"
puts s.count("\x00-\xFF")
MRI returns 15.
JRuby returns 0.
This leads to at least 3 Rubinius spec failures for String.
For example:
String#count counts all chars in a sequence FAILED
Expected 0 to equal 15
/opt/work/rubinius/spec/mini_rspec.rb:221:in `=='
/opt/work/rubinius/./spec/core/string/count_spec.rb:46:in `=='
/opt/work/rubinius/./spec/core/string/count_spec.rb:43:in `it'
/opt/work/rubinius/spec/mini_rspec.rb:414:in `it'
/opt/work/rubinius/./spec/core/string/count_spec.rb:43:in `it'
/opt/work/rubinius/./spec/core/string/count_spec.rb:43:in `describe'
/opt/work/rubinius/spec/mini_rspec.rb:410:in `describe'
/opt/work/rubinius/./spec/core/string/count_spec.rb:4:in `describe'
/opt/work/rubinius/./spec/core/string/count_spec.rb:4:in `load'
tmp/last_mspec.rb:13:in `load'
tmp/last_mspec.rb:1:in `each'
tmp/last_mspec.rb:7:in `each'
The proposed patch fixes the problem and all 3 related spec failures.
The problem was due to incorrect handling of high-order bytes in ranges.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email