[1.9] String#lines with default $/ divides strings incorrectly
--------------------------------------------------------------

                 Key: JRUBY-4562
                 URL: http://jira.codehaus.org/browse/JRUBY-4562
             Project: JRuby
          Issue Type: Bug
          Components: Core Classes/Modules
    Affects Versions: JRuby 1.5
         Environment: Linux 2.6.31-19
            Reporter: Tomo Kazahaya


In 1.9 compatible mode, if the default object of {{$/}} is used, 
{{String#lines}} divides string objects incorrectly -- successive LFs are 
concatenated to the top of next chunk. This problem does not happen when in 1.8 
compatible mode.

{noformat}
--
# sample.rb
p <<EOS.lines.to_a
multi-line string with
two or more LFs


in a row
EOS
--

$ ruby1.8 -v sample.rb
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
["multi-line string with\n", "two or more LFs\n", "\n", "\n", "in a row\n"]
$ ruby -v sample.rb
ruby 1.9.2dev (2010-02-12 trunk 26649) [i686-linux]
["multi-line string with\n", "two or more LFs\n", "\n", "\n", "in a row\n"]
$ jruby -v sample.rb
jruby 1.5.0.dev (ruby 1.8.7 patchlevel 174) (2010-02-15 2770c7f) (Java 
HotSpot(TM) Client VM 1.6.0_15) [i386-java]
["multi-line string with\n", "two or more LFs\n", "\n", "\n", "in a row\n"]
$ jruby --1.9 -v sample.rb
jruby 1.5.0.dev (ruby 1.9.2dev trunk 24787) (2010-02-15 2770c7f) (Java 
HotSpot(TM) Client VM 1.6.0_15) [i386-java]
["multi-line string with\n", "two or more LFs\n", "\n\nin a row\n"]
{noformat}

However, if {{"\n"}} is reassigned to {{$/}}, this problem will not occur.

{noformat}
--
# sample.rb
$/ = "\n" # reassign to $/
p <<EOS.lines.to_a
  :
  :
--

$ jruby --1.9 -v sample.rb
jruby 1.5.0.dev (ruby 1.9.2dev trunk 24787) (2010-02-15 2770c7f) (Java 
HotSpot(TM) Client VM 1.6.0_15) [i386-java]
["multi-line string with\n", "two or more LFs\n", "\n", "\n", "in a row\n"]
{noformat}


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