Skip to content

Convert newlines in text mode on Windows through the transcoder - #11

Draft
aminmansuri wants to merge 9 commits into
jruby-10.0from
fix-windows-text-mode-newlines
Draft

aminmansuri wants to merge 9 commits into
jruby-10.0from
fix-windows-text-mode-newlines

Conversation

@aminmansuri

@aminmansuri aminmansuri commented Sep 17, 2026

Copy link
Copy Markdown
Owner

Changes (Windows only):

  1. Reading: text-mode IO's read converter gets the universal-newline decorator, so \r\n becomes \n.
  2. Writing: CRLF decorator no longer masked out of the write-conversion check, so \n becomes \r\n.
  3. Defaults: popen pipes get the default text mode, as in CRuby. Also, new ARGF instance starts in text mode instead of inheriting a previous binmode.

ruby/spec examples for CRLF on write and universal newline on read in text
mode, JUnit coverage of the decorator selection with the platform passed in,
and the Windows spec tags those examples replace. Red until the fix lands.
The JDK has no O_TEXT descriptors, so the default text mode MRI leaves to
the C runtime did nothing here: text-mode reads now get the universal
newline decorator, writes the CRLF one, and popen pipes the default text mode.
ARGF.binmode left the shared ARGF state in binmode for every later
ARGF.class.new, which MRI does not do; on Windows that hid text mode from
the ARGF specs. The File::BINARY flag check moves to the Windows tests.
The runner checks fixtures out with CRLF, so specs built on LF byte
offsets and lengths fail there for MRI as well; the ARGF byte readers
(each_byte, each_char, getc, readpartial) stay raw and are tagged too.
Its shared example is described as ARGF.getc, so the tag lives in the
readchar tags file; the reader stays byte-level like ARGF.getc.
MRI's rb_w32_write only lets the C runtime insert CRs on a file or on
stdout/stderr, so the default CRLF marker alone must not select the write
converter on a pipe.
MRI's _write does not count the CRs it inserts.
System.console() is non-null on JDK 22-24 when the standard streams are
redirected.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant