mirror of
https://github.com/ruby/ruby.git
synced 2025-08-25 05:55:46 +02:00
![]() When opening a file with `File.open`, and then setting the encoding with `IO#set_encoding`, it still correctly performs CRLF -> LF conversion on Windows when reading files with a CRLF line ending in them (in text mode). However, the file is opened instead with either the `rb_io_fdopen` or `rb_file_open` APIs from C, the CRLF conversion is _NOT_ set up correctly; it works if the encoding is not specified, but if `IO#set_encoding` is called, the conversion stops happening. This seems to be because the encflags never get ECONV_DEFAULT_NEWLINE_DECORATOR set in these codepaths. Concretely, this means that the conversion doesn't happen in the following circumstances: * When loading ruby files with require (that calls rb_io_fdopen) * When parsing ruuby files with RubyVM::AbstractSyntaxTree (that calls rb_file_open). This then causes the ErrorHighlight tests to fail on windows if git has checked them out with CRLF line endings - the error messages it's testing wind up with literal \r\n sequences in them because the iseq text from the parser contains un-newline-converted strings. This commit fixes the problem by copy-pasting the relevant snippet which sets this up in `rb_io_extract_modeenc` (for the File.open path) into the relevant codepaths for `rb_io_fdopen` and `rb_file_open`. [Bug #20101] |
||
---|---|---|
.. | ||
abi | ||
arith_seq | ||
array | ||
bignum | ||
bug-3571 | ||
bug-5832 | ||
bug-14834 | ||
bug_reporter | ||
class | ||
cxxanyargs | ||
debug | ||
dln/empty | ||
econv | ||
enumerator_kw | ||
eval | ||
exception | ||
fatal | ||
file | ||
float | ||
funcall | ||
gvl/call_without_gvl | ||
hash | ||
integer | ||
iseq_load | ||
iter | ||
load | ||
marshal | ||
memory_status | ||
memory_view | ||
method | ||
notimplement | ||
num2int | ||
path_to_class | ||
popen_deadlock | ||
postponed_job | ||
printf | ||
proc | ||
random | ||
rational | ||
rb_call_super_kw | ||
recursion | ||
regexp | ||
RUBY_ALIGNOF | ||
scan_args | ||
st | ||
string | ||
struct | ||
symbol | ||
thread/instrumentation | ||
thread_fd | ||
time | ||
tracepoint | ||
typeddata | ||
vm | ||
wait | ||
win32 | ||
auto_ext.rb |