Граф коммитов

1589 Коммитов

Автор SHA1 Сообщение Дата
nobu 472d910a26 Fix compile error when USE_COPY_FILE_RANGE is defined but not USE_SENDFILE
io.c: Variable and label definition are necessary in both cases.

From: Lars Kanis <lars@greiz-reinsdorf.de>

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-08 15:22:54 +00:00
nobu 49e801c1c7 io.c: unused assignments
* io.c (fptr_finalize_flush): removed unused assignments.  if
  noraise, err is never used after set.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-02 08:30:57 +00:00
nobu cc410b2a5c io.c: hoisted out io_fd_check_closed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-02 05:44:13 +00:00
nobu 00716bee78 io.c: fix comparison subject
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-31 17:35:27 +00:00
nobu 4139024e15 io.c: fix fptr_copy_finalizer
* io.c (fptr_copy_finalizer): fix inverted condition.  if
  finalizer does not change, pipe_list should not change too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-31 17:26:20 +00:00
nobu 4057ee5e8e io.c: fptr_copy_finalizer
* io.c (fptr_copy_finalizer): remove fptr from pipe_list when pipe
  became ordinary file, to fix access after free.  to be finalized
  by pipe_finalize and being in pipe_list must match.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-31 08:17:16 +00:00
nobu 1d5847d1af io.c: pipe_register_fptr
* io.c (pipe_register_fptr): get rid of double registration which
  causes access after free and segfault.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62121 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-31 04:24:57 +00:00
nobu 80d74ea732 io.c: simplified pipe_del_fptr
* io.c (pipe_del_fptr): merged code for the case fptr is first to
  the loop for the rest.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-31 04:02:18 +00:00
k0kubun fb29cffab0 process.c: add :exception option to Kernel.#system
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
2018-01-24 14:11:25 +00:00
kazu b8cc476ce9 use predefined IDs
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-22 13:09:37 +00:00
nobu e9cb552ec9 internal.h: remove dependecy on ruby/encoding.h
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-01-09 06:24:11 +00:00
nobu f39ea3d189 io.c: rb_stderr_to_original_p
* 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
2018-01-07 04:10:06 +00:00
normal 6776e0bc99 io.c: clear Strings we create for IO.copy_stream
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
2018-01-05 21:14:19 +00:00
kazu 9f68d0f591 [DOC] Improve example of IO#pread [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-24 02:41:00 +00:00
kazu 13247fa417 [DOC] Use File.open with block instead of File.new without close [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61433 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-24 01:26:46 +00:00
glass 072ed558d5 io.c: ignore EPERM
* 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
2017-12-22 08:47:39 +00:00
normal 3b174fb7d6 io.c: IO#pwrite uses tmp buffer to avoid parallel modification
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
2017-12-21 00:26:24 +00:00
nobu d2f685eed7 io.c: opening external command
* 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
2017-12-18 07:15:07 +00:00
nobu 6b718de1d6 io.c: open generic in binread
* 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
2017-12-18 07:10:15 +00:00
nobu 2ad35b31bb io.c: opening external command
* 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
2017-12-18 04:32:54 +00:00
nobu 7d24c27d21 io.c: open_key_args by rb_io_open
* 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
2017-12-18 03:38:20 +00:00
kazu a9419fbd4f [DOC] `IO.new` accepts `external_encoding`
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
2017-12-15 11:52:41 +00:00
naruse 9fa7722bbc IO.new doesn't recive "-" as external_encoding [Bug #13655]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61278 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-12-15 08:26:33 +00:00
shugo 3616b07c9a Fix a documentation error of IO#putc.
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
2017-12-03 08:10:42 +00:00
usa c88c7d911f bold/underscore support in traceback before Windows10
* 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
2017-12-01 05:32:29 +00:00
nobu 1046eae781 io.c: read BOM only for reading
* 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
2017-11-23 07:10:56 +00:00
stomar e36ccef549 io.c: improve docs for the chomp option
* 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
2017-11-02 20:38:04 +00:00
stomar b1e77e85b6 io.c: improve docs
* 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
2017-10-29 20:58:36 +00:00
stomar bf9ffeed31 io.c: docs for IO#write
* 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
2017-10-29 20:57:29 +00:00
nobu 8354b6d2cd io.c: honor buffered mode
* 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
2017-10-29 05:46:23 +00:00
nobu 85195203f4 io.c: convert to string at writev
* 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
2017-10-29 00:43:34 +00:00
kazu f0c3df3113 Add note to close_{read,write} too
when call on closed stream
[ci skip]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60530 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-28 16:34:30 +00:00
normal 524e660877 io.c: fix IO.copy_stream on O_APPEND destination on Linux
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
2017-10-27 18:37:23 +00:00
nobu 6b818dd961 common conversion functions
* 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
2017-10-26 07:23:23 +00:00
nobu 1b27af8d56 io.c: let rb_p use writev
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-25 12:33:42 +00:00
nobu 237901a41b io.c: warn old write
* 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
2017-10-25 12:04:53 +00:00
nobu 635d0822cd io.c: write a newline together
* 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
2017-10-25 05:44:38 +00:00
kazu 9885c1c79f Update call-seq of ARGF.read_nonblock
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
2017-10-24 12:10:32 +00:00
hsbt 0e2d2e6a79 Drop to support NaCl platform.
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
2017-10-23 05:56:25 +00:00
nobu 08524bc594 io.c: fix infinite retry
* 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
2017-10-23 05:28:12 +00:00
nobu 71a7ef31d7 io.c: fix buffered output
* 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
2017-10-23 05:09:35 +00:00
nobu 92023a8f60 io.c: fix total
* 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
2017-10-23 05:09:34 +00:00
nobu c0f40369b6 io.c: no restriction
* 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
2017-10-23 02:25:58 +00:00
kazu d9cfbb3cad Fix indent and comment [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60352 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-22 06:30:47 +00:00
nobu 6e3ff2ecd9 io.c: fix local variables
* 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
2017-10-22 06:22:50 +00:00
glass 3efa7126e5 Make IO#write accept multiple arguments
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
2017-10-22 02:11:07 +00:00
hsbt 2c27e52f8e Add documentation for `chomp` option.
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
2017-10-21 16:11:58 +00:00
hsbt 2476bf2bb1 Clarify the behavior of IO.write without offset in write mode.
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
2017-10-21 15:16:54 +00:00
glass 0686d5f4eb io.c: introduce copy offload to IO.copy_stream
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
2017-10-21 14:25:46 +00:00
akr ae2578f6bc [DOC] describe methods used for src and dst argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60233 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 06:45:41 +00:00