aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
Commit message (Collapse)AuthorAgeFilesLines
...
* process.c: add :exception option to Kernel.#systemk0kubun2018-01-241-3/+3
| | | | | | | | to raise error when it fails. [Feature 14386] [GH-1795] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* use predefined IDskazu2018-01-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* internal.h: remove dependecy on ruby/encoding.hnobu2018-01-091-1/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: rb_stderr_to_original_pnobu2018-01-071-3/+9
| | | | | | | * io.c (rb_stderr_to_original_p): hoist out the condition to write messages to the stderr FD directly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: clear Strings we create for IO.copy_streamnormal2018-01-051-2/+5
| | | | | | | | | | | | | While we can't recycle strings after giving them rb_funcall*, we can reduce their malloc overhead by resizing them to zero. This only affects cases where either `src' or `dst' is a non-IO object and either `copy_length' is passed or there is pre-existing data in the read buffer. * io.c (copy_stream_fallback_body): clear when done with `copy_length' (copy_stream_body): clear when done with pre-existing read buffer git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] Improve example of IO#pread [ci skip]kazu2017-12-241-4/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] Use File.open with block instead of File.new without close [ci skip]kazu2017-12-241-3/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: ignore EPERMglass2017-12-221-0/+2
| | | | | | | | | * io.c (nogvl_copy_file_range): ignore EPERM and fallback to sendfile(2) or read/write. copy_file_range(2) may not exist even if __NR_copy_file_range is defined in the build environment. [Bug #14207] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61412 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: IO#pwrite uses tmp buffer to avoid parallel modificationnormal2017-12-211-4/+6
| | | | | | | | | | | Since we release GVL, we must freeze and duplicate the string buffer to prevent other threads from modifying our buffer while we are waiting on pwrite(2). * io.c (rb_io_pwrite): use_rb_str_tmp_frozen_{acquire/release} [Bug #14195] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: opening external commandnobu2017-12-181-11/+5
| | | | | | | | | | * io.c (rb_io_open_generic): try to open the named file as usual, if klass is not IO nor File, so that Errno::ENOENT will be raised probably. calling on File will be same in the future. From: Nobuyoshi Nakada <nobu@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: open generic in binreadnobu2017-12-181-1/+1
| | | | | | | | * io.c (rb_io_s_binread): fix r61317, unintentional change. From: Nobuyoshi Nakada <nobu@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61319 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: opening external commandnobu2017-12-181-15/+26
| | | | | | | | | | * io.c (rb_io_open_generic): when external command will be invoked as other than IO singleton method, probably unintentionally, warn if it is File or raise ArgumentError. From: Nobuyoshi Nakada <nobu@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: open_key_args by rb_io_opennobu2017-12-181-29/+9
| | | | | | | | | * io.c (open_key_args): open by rb_io_open always also when open_args: option is given. From: Nobuyoshi Nakada <nobu@ruby-lang.org> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61314 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] `IO.new` accepts `external_encoding`kazu2017-12-151-0/+3
| | | | | | | Revert part of r61278 [Bug #13655] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* IO.new doesn't recive "-" as external_encoding [Bug #13655]naruse2017-12-151-4/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix a documentation error of IO#putc.shugo2017-12-031-4/+4
| | | | | | | IO#putc is multi-byte character safe when a String is given as its argument. [ruby-core:82019] [Bug #13741] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* bold/underscore support in traceback before Windows10usa2017-12-011-0/+5
| | | | | | | | * io.c (rb_write_error2): call `rb_w32_write_console()` when the device is tty, like `rb_write_error_str()`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60957 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: read BOM only for readingnobu2017-11-231-0/+3
| | | | | | | * io.c (io_strip_bom): just abandon detecting UTF encoding by BOM unless opened for reading. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: improve docs for the chomp optionstomar2017-11-021-6/+12
| | | | | | | * io.c: [DOC] improve the description for the chomp option and add examples to IO.readlines and IO#readlines; other small fixes. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: improve docsstomar2017-10-291-7/+7
| | | | | | * io.c: [DOC] fix rdoc for some cross references; fix grammar. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: docs for IO#writestomar2017-10-291-2/+2
| | | | | | * io.c: [DOC] fix example and language in IO#write docs. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: honor buffered modenobu2017-10-291-5/+9
| | | | | | | | * io.c (io_writev): honor buffered mode to get rid of broken pipe error when stdout is redirected to a pipeline. [ruby-core:83578] [Feature #14042] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: convert to string at writevnobu2017-10-291-1/+1
| | | | | | | | * io.c (io_fwritev): needs conversion to string before accessing the content, as well as single argument case, not to segfault. [Feature #9323] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60534 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add note to close_{read,write} tookazu2017-10-281-0/+4
| | | | | | | when call on closed stream [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix IO.copy_stream on O_APPEND destination on Linuxnormal2017-10-271-0/+10
| | | | | | | | | | | | | Linux copy_file_range(2) fails with EBADF if the destination FD has O_APPEND set. Preserve existing (Ruby <= 2.4) behavior by falling back to alternative copy mechanisms if this is the case (instead of raising Errno::EBADF). * io.c (nogvl_copy_file_range): do not raise on O_APPEND dst * test/ruby/test_io.rb (test_copy_stream_append): new test [Feature #13867] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60490 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* common conversion functionsnobu2017-10-261-1/+1
| | | | | | | | | | | | | * array.c (rb_to_array_type): make public to share common code internally. * hash.c (rb_to_hash_type): make public to share common code internally. * symbol.c (rb_to_symbol_type): make public to share common code internally. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: let rb_p use writevnobu2017-10-251-5/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: warn old writenobu2017-10-251-0/+7
| | | | | | | * io.c (rb_io_puts): warn if write method accepts just one argument. [ruby-core:83529] [Feature #14042] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60423 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: write a newline togethernobu2017-10-251-4/+16
| | | | | | | | * io.c (rb_io_puts): write a newline together at once for each argument. based on the patch by rohitpaulk (Rohit Kuruvilla) at [ruby-core:83508]. [Feature #14042] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Update call-seq of ARGF.read_nonblockkazu2017-10-241-2/+2
| | | | | | | | ARGF.read_nonblock supports `exception: false' like IO#read_nonblock since 2.3.0. [Feature #11358] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Drop to support NaCl platform.hsbt2017-10-231-15/+0
| | | | | | | | | | | Because NaCl and PNaCl are already sunset status. see https://bugs.chromium.org/p/chromium/issues/detail?id=239656#c160 configure.ac: Patch for this file was provided by @nobu. [Feature #14041][ruby-core:83497][fix GH-1726] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60374 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix infinite retrynobu2017-10-231-13/+13
| | | | | | | * io.c (io_binwritev): fix infinite retry when flushing buffered data. [Feature #9323] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix buffered outputnobu2017-10-231-2/+2
| | | | | | | * io.c (io_binwritev): append to buffered data, not overwriting. [Feature #9323] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60372 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix totalnobu2017-10-231-1/+1
| | | | | | * io.c (io_writev): total may be a bignum. [Feature #9323] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: no restrictionnobu2017-10-231-46/+9
| | | | | | | * io.c (io_write_m): remove argc restriction upto IOV_MAX-1. [Feature #9323] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix indent and comment [ci skip]kazu2017-10-221-3/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix local variablesnobu2017-10-221-1/+2
| | | | | | | * io.c (io_writev): fix local variable declarations, when writev(2) is not available. [Feature #9323] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Make IO#write accept multiple argumentsglass2017-10-221-8/+225
| | | | | | | io.c: make IO#write accept multiple arguments. it uses writev(2) if possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60343 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add documentation for `chomp` option.hsbt2017-10-211-30/+47
| | | | | | | | https://github.com/ruby/ruby/pull/1717 Patch by @ksss [fix GH-1717] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60308 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Clarify the behavior of IO.write without offset in write mode.hsbt2017-10-211-2/+2
| | | | | | | | | https://github.com/ruby/ruby/pull/1571 Patch by @takanabe [fix GH-1571] [Bug #11638][ruby-core:71277] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60294 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: introduce copy offload to IO.copy_streamglass2017-10-211-0/+113
| | | | | | | io.c (rb_io_s_copy_stream): add copy offload feature (by using copy_file_range(2) if available) to IO.copy_stream git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60284 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] describe methods used for src and dst argument.akr2017-10-211-1/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Get rid of shadowing local variablesnobu2017-10-181-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: encoding of ARGF.inplace_modenobu2017-10-101-30/+19
| | | | | | | * io.c (argf_next_argv): encode inplace mode suffix to the path encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: path name conversion at ARGFnobu2017-10-101-2/+4
| | | | | | | * io.c (argf_next_argv): the standard conversion to path name should take place. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: [DOC] about buffering [ci skip]nobu2017-10-051-0/+5
| | | | | | | | * io.c (rb_file_initialize): [DOC] stated that non-tty file is buffered by the default, and added links to related methods. [ruby-core:83081] [Bug #13965] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: check null charnobu2017-10-021-2/+2
| | | | | | | | * io.c (ruby_set_inplace_mode): check if null is contained. based on the patch by tommy (Masahiro Tomita) in [ruby-dev:50272]. [Bug #13960] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: fix segfault with closing socket on Windowsshirosaki2017-09-281-4/+11
| | | | | | | | | | | | * io.c (fptr_finalize_flush): add an argument to keep GVL. * io.c (fptr_finalize): adjust for above change. * io.c (io_close_fptr): closing without GVL causes another exception while raising exception in another thread. This causes segfault on Windows. Keep GVL while closing when another thread raises. [Bug #13856] [ruby-core:82602] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* File#path: Raise IOError when a file is O_TMPFILEsorah2017-08-311-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | File#path for a file opened with O_TMPFILE has no meaning. A filepath returned by this method isn't guarranteed about its accuracy, but files opened with O_TMPFILE are known its recorded path has no meaning. So let them not to return any pathname. After a discussion in ruby-core, just returning Qnil makes guessing the root cause difficult. Instead, this patch makes the method to raise an error. Other consideration is calling fnctl(2) on rb_file_path, but it adds a overhead, and it's difficult to determine O_TMPFILE status after fd has been closed. [Feature #13568] * io.c(rb_file_open_generic): Set Qnil to fptr->pathv when opening a file using O_TMPFILE * file.c(rb_file_path): Raise IOError when fptr->pathv is Qnil * file.c(rb_file_path): [DOC] Update for the new behavior git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* io.c: shrink read buffernobu2017-08-311-19/+39
| | | | | | | | | * io.c (io_setstrbuf): return true if the buffer is newly created. * io.c (io_set_read_length): shrink the read buffer if it is a new object and is too large. [ruby-core:81370] [Bug #13597] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e