[Win32utils-devel] IO.read questions

Heesob Park phasis at gmail.com
Thu May 3 05:01:17 UTC 2012


Hi,

2012/5/3 Daniel Berger <djberg96 at gmail.com>

> On Wed, May 2, 2012 at 7:02 PM, Luis Lavena <luislavena at gmail.com> wrote:
> > On Wed, May 2, 2012 at 9:48 PM, Daniel Berger <djberg96 at gmail.com>
> wrote:
> >> Hi,
> >>
> >> ruby 1.9.3p125 (both mingw and mswin)
> >>
> >> Is this a bug? I've got a file, test.txt, that contains nothing but
> this:
> >>
> >> This is line 1
> >> This is line 2
> >> This is line 3
> >>
> >> I ran these snippets of code:
> >>
> >> IO.read('test.txt')          # => "This is line 1\nThis is line
> >> 2\nThis is line 3\n"
> >> IO.read('test.txt', nil)     # => "This is line 1\nThis is line
> >> 2\nThis is line 3\n"
> >> IO.read('test.txt', nil, 0) # => "This is line 1\r\nThis is line
> >> 2\r\nThis is line 3\r\n"
> >>
> >> Why are the native line endings retained if I specify an offset? Ruby
> >> 1.8.x doesn't do that, btw.
> >>
> >
> > A regression fixed in patch level 194
> >
> > Root issue is caused by newline universal:
> >
> > https://bugs.ruby-lang.org/issues/6271
> >
> > Along other like File#pos
>
> Thanks, I upgraded and it's working now.
>
> I noticed another problem I think, though. According to the docs I
> should be able to pass open_args and those should be passed along to
> open(). However, this doesn't work:
>
> IO.read('test.txt', open_args: ['rS']) # Try to force a sequential scan
>
> But that blows up with an invalid access mode error, even though 'S'
> is a legal mode on Windows. It looks to me like io.c is explicitly
> checking mode values instead of just letting them pass through to the
> open function and letting it fail on its own if they're invalid.
>
> Or am I doing it wrong?
>
>
I think that is a nice feature.

Why don't you make a feature request on http://bugs.ruby-lang.org/ ?

Even if it is rejected, you can make your own IO with the WinRuby :)

Regards,

Park Heesob
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/win32utils-devel/attachments/20120503/b668e341/attachment.html>


More information about the win32utils-devel mailing list