JRuby defaults to "\r\n" newlines on Windows, where MRI 1.8 and 1.9 use just 
"\n"
---------------------------------------------------------------------------------

                 Key: JRUBY-4253
                 URL: http://jira.codehaus.org/browse/JRUBY-4253
             Project: JRuby
          Issue Type: Bug
          Components: Parser
    Affects Versions: JRuby 1.4
         Environment: Windows XP Pro SP3
            Reporter: Steve Shreeve
            Assignee: Thomas E Enebo
            Priority: Minor


On Windows, Ruby scripts are normally saved with the default "\r\n" line 
endings. When using DATA.gets to read text below the "__END__" tag, however, 
MRI 1.8 and 1.9 silently remove the "\r" character (leaving just "\n"). This 
means that the same script performs differently on Windows using MRI 1.8/1.9 
versus JRuby 1.4. I can force the file to save with UNIX-style line endings, 
but it would be convenient if JRuby performed identically to MRI 1.8/1.9.

Here's an example:

=8<===8<===8<===8<===8<===8<===8<===8<===8<==

p "group 1", DATA.gets("\n\n")
p "group 2", DATA.gets("\n\n")
p "group 3", DATA.gets("\n\n")

__END__

This is group number 1
It contains some text here
And a little more text

This is group number 2
It also has some text

Again, we've got group number three
With even a little more text than the others
It sort of rambles on a bit and then, with a poof...
It's done!

=8<===8<===8<===8<===8<===8<===8<===8<===8<==

When I run this in MRI 1.8/1.9, I get the following:

"group 1"
"\nThis is group number 1\nIt contains some text here\nAnd a little more 
text\n\n"
"group 2"
"This is group number 2\nIt also has some text\n\n"
"group 3"
"Again, we've got group number three\nWith even a little more text than the 
others\nIt sort of rambles on a bit and then, with a poof...\nIt's done!\n"

When I run this in JRuby 1.4, I get the following:

"group 1"
"\r\nThis is group number 1\r\nIt contains some text here\r\nAnd a little more 
text\r\n\r\nThis is group number 2\r\nIt also has some text\r\n\r\nAgain, we've 
got group number three\r\nWith even a little more text than the others\r\nIt 
sort of rambles on a bit and then, with a poof...\r\nIt's done!\r\n"
"group 2"
nil
"group 3"
nil

This is not a huge deal, but it would be helpful to fix.

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