Here is a preliminary patch that passes make test-all (except for some RubyGems/SSL tests) on a glibc-based Linux (but I think some less common code might not work anymore on Windows and other platforms that don't implement x but validate the mode string). Also rb_io_oflags_modestr() didn't differentiate between w+ and r+ before - was that intended?
Here is a preliminary patch that passes make test-all (except for
some RubyGems/SSL tests) on a glibc-based Linux (but I think some less
common code might not work anymore on Windows and other platforms that
don't implement x but validate the mode string).
Haven't tested, but I like this feature for consistency with glibc
and Python.
Also rb_io_oflags_modestr() didn't differentiate between w+ and r+
before - was that intended?
I hope not, but it may also be too late to change without breaking
existing code and causing major data loss...
Yes, MODE_BINARY confused me (it uses it arguments in reverse order). I think MODE_BINARY_EXCL is a bad idea anyway. In V2 an ArgumentError is raised by rb_io_oflags_modestr() when O_EXCL is set. This also affects the related flags: File::EXCL feature. $stdout.reopen('stdout', 'w', flags: File::EXCL) does now raise as it should since freopen() might not support x which could cause the truncation of an existing file! That might not be the best solution though.