String#unpack with Z* pattern is incorrect
------------------------------------------

                 Key: JRUBY-1748
                 URL: http://jira.codehaus.org/browse/JRUBY-1748
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.x
         Environment: Latest JRuby 1.1b1 from trunk
            Reporter: Vladimir Sizikov
         Attachments: string-unpack-with-z-pattern.patch

Consider the following examples (and the first example is right from ruby-doc 
for unpack method!):

{noformat}
puts "abc \0abc \0".unpack('Z*Z*').inspect
puts "abc \0abc \0".unpack('Z10').inspect
puts "abc \0abc \0".unpack('Z7Z*').inspect
puts "abc \0abc \0".unpack('Z50Z*').inspect
puts "abc \0\0\0abc \0".unpack('Z*Z*').inspect
puts "\0\0abc".unpack('Z*').inspect
puts "\0\0abc\0\0".unpack('Z*').inspect
{noformat}

MRI 1.8.6 and MRI 1.9 print:
{noformat}
["abc ", "abc "]
["abc "]
["abc ", "c "]
["abc ", ""]
["abc ", ""]
[""]
[""]
{noformat}

JRuby prints
{noformat}
["abc \000abc ", ""]
["abc \000abc "]
["abc \000ab", "c "]
["abc \000abc ", ""]
["abc \000\000\000abc ", ""]
["\000\000abc"]
["\000\000abc"]
{noformat}

This also leads to one of the Rubinius spec failures.

The proposed patch (and unit tests) fixes the problem and all mentioned 
failures.


-- 
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

Reply via email to