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

1364 Коммитов

Автор SHA1 Сообщение Дата
nobu 3b8b470c8e io.c: update ARGF examples
* io.c (argf_each_line, argf_inplace_mode_set): [DOC] Update ARGF
  documentation examples.  `ARGF.lines` has been deprecated in
  favor of `ARGF.each_line`.  [Fixes GH-615]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45991 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-18 03:15:57 +00:00
nobu 831202f85c io.c: buffer must be modifiable
* io.c (io_setstrbuf): always check if the buffer is modifiable.
  [ruby-core:62643] [Bug #9847]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-17 23:22:28 +00:00
tadf d85c226f73 * io.c (io_{read,write}_nonblock): use rb_get_kwargs instead of
rb_hash_aref.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-05-06 09:37:24 +00:00
nobu d64ba37ad0 process.c: constify
* process.c (rb_execarg_new, rb_execarg_init): constify argv.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17 08:21:47 +00:00
ko1 57e557908a * enumerator.c (enumerator_block_call): use PARRAY_CONST_PTR()
instead of RARRAY_PTR().
* io.c (rb_io_s_popen): ditto.
* numeric.c (num_step_size): ditto.
* vm_eval.c (rb_apply): ditto.
* vm_eval.c (rb_eval_cmd): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-17 04:20:16 +00:00
usa 8b48053beb * io.c (rb_io_fsync): need to fsync even if on Windows. fixed mistake of
r45254 and r45256.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45258 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02 19:41:01 +00:00
usa e1c40b1967 * io.c (rb_io_fsync): revert a part of r45254. explicit fsync should update
the metadata.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02 18:08:04 +00:00
usa ab3002afa3 * io.c (rb_io_flush_raw, rb_io_fsync): [EXPERIMENTAL] remove force
syncing for Win32 to speed up IO.  this may break some tests, and
  they'll be fixed later.
  [ruby-core:58570] [Bug #9153]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45254 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-03-02 17:56:32 +00:00
nobu cc216f9aae adjust indent and style
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-27 07:10:14 +00:00
normal 10a8e87ce5 io.c (rb_f_backquote): trade volatile for manual recycle
* io.c (rb_f_backquote): trade volatile for manual recycle
  rb_gc_force_recycle ensures object is visible until recycle

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44995 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-16 04:19:29 +00:00
akr 6f8b0e9bb0 * include/ruby/intern.h,
include/ruby/io.h,
  include/ruby/ruby.h,
  include/ruby/win32.h,
  include/ruby/backward/rubysig.h,
  bignum.c,
  gc.c,
  io.c,
  process.c,
  safe.c,
  struct.c,
  thread.c,
  ext/socket/rubysocket.h,
  ext/-test-/old_thread_select: Remove deprecated definitions
  [ruby-core:60581] [Feature #9502]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44955 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-14 15:16:31 +00:00
akr 61f50ae03e * io.c (SMALLBUF): Unused macro removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-08 06:11:47 +00:00
normal 5061285407 io.c (rb_io_syswrite): add RB_GC_GUARD
* io.c (rb_io_syswrite): add RB_GC_GUARD
  [Bug #9472][ruby-core:60407]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44790 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-01 20:50:56 +00:00
nobu 3d3a02c97f io.c: check socket on other than linux
* io.c (nogvl_copy_stream_sendfile): check socket on other than
  linux, as sendfile(2) on non-socket fd works only on linux.
  [Feature #9427]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44750 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-29 11:08:16 +00:00
normal c5f2c66270 io.c: remove socket check
* io.c (nogvl_copy_stream_sendfile): remove socket check
  [ruby-core:59856][Feature #9427]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-29 09:13:08 +00:00
akr e457f6312f * io.c (rb_update_max_fd): Return immediately if the given fd is small
enough.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-18 13:42:39 +00:00
akr f962eba5f4 * io.c: Test O_CLOEXEC only once.
Patch by Eric Wong.  [ruby-core:59419] [Feature #9328]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44640 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-18 13:28:35 +00:00
glass bddde8eee3 * io.c (io_binwrite): use writev(2) to avoid double write if available.
* configure.in: check writev(2)

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-15 11:37:23 +00:00
glass 72385b042d * io.c (io_fwrite): freeze converted str.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-01-02 07:29:13 +00:00
glass 4e4e65a148 * io.c (io_fwrite): allocate frozen str only when str is not converted.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-12-31 12:25:16 +00:00
nobu 7566c49068 ruby/ruby.h: RB_BLOCK_CALL_FUNC_ARGLIST
* include/ruby/ruby.h (RB_BLOCK_CALL_FUNC_ARGLIST): for declaration
  argument list of rb_block_call_func.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 07:59:14 +00:00
nobu 9f45081627 ruby/ruby.h: add blockarg to rb_block_call_func
* include/ruby/ruby.h (rb_block_call_func): add blockarg.  block
  function can take block argument, e.g., proc {|&blockarg| ...}.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-29 02:26:48 +00:00
nobu 21f81885ab win32.c: rb_w32_dup2
* win32/win32.c (rb_w32_dup2): extract from rb_cloexec_dup2() and
  redirect_dup2().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-28 07:15:56 +00:00
zzak c3b3e99953 * io.c: [DOC] ARGF.gets may return nil [Bug #9029] patch by znz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-09 06:01:04 +00:00
glass 05a4d176d6 * io.c (rb_io_open_with_args): use RARRAY_CONST_PTR().
* io.c (rb_scan_open_args): use const qualifier for above.

* io.c (rb_open_file): ditto.

* io.c (rb_io_open_with_args): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-08 04:30:40 +00:00
ko1 c5e08b764e * add RUBY_TYPED_FREE_IMMEDIATELY to data types which only use
safe functions during garbage collection such as xfree().
  On default, T_DATA objects are freed at same points as fianlizers.
  This approach protects issues such as reported by [ruby-dev:35578].
  However, freeing T_DATA objects immediately helps heap usage.
  Most of T_DATA (in other words, most of dfree functions) are safe.
  However, we turned off RUBY_TYPED_FREE_IMMEDIATELY by default
  for safety.
* cont.c: ditto.
* dir.c: ditto.
* encoding.c: ditto.
* enumerator.c: ditto.
* error.c: ditto.
* file.c: ditto.
* gc.c: ditto.
* io.c: ditto.
* iseq.c: ditto.
* marshal.c: ditto.
* parse.y: ditto.
* proc.c: ditto.
* process.c: ditto.
* random.c: ditto.
* thread.c: ditto.
* time.c: ditto.
* transcode.c: ditto.
* variable.c: ditto.
* vm.c: ditto.
* vm_backtrace.c: ditto.
* vm_trace.c: ditto.
* ext/bigdecimal/bigdecimal.c: ditto.
* ext/objspace/objspace.c: ditto.
* ext/stringio/stringio.c: ditto.
* ext/strscan/strscan.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-29 11:16:54 +00:00
nobu de004e3a5c io.c: make IO#reopen("pathname") atomic
* io.c (rb_io_reopen): create a new, temporary FD via rb_sysopen and
  call rb_cloexec_dup2 on it to atomically replace the file fptr->fd
  points to.  This leaves no possible window where fptr->fd is invalid
  to userspace (even for any threads running w/o GVL).  based on the
  patch by Eric Wong <normalperson@yhbt.net> at [ruby-core:57943].
  [Bug #9036]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-20 06:41:24 +00:00
nobu a2b448106f io.c: use rb_funcallv
* io.c (rb_io_write): use rb_funcallv() instead of rb_funcall() to get
  rid of unnecessary alloca.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43202 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-08 15:34:40 +00:00
nobu cd006f08e2 io.c: use local variables instead of struct members
* io.c (copy_stream_body): move src_io and dst_io back to top level
  and use instead of stp->src and stp->dst.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-06 18:43:50 +00:00
nobu 99526d0f4e io.c: suppress false uninitialized-variable warning
* io.c (io_ascii8bit_binmode): split from rb_io_ascii8bit_binmode() to
  call with rb_io_t* directly.

* io.c (copy_stream_body): move src_io and dst_io into each blocks
  where those are only used.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-06 13:52:44 +00:00
nobu bda5eac115 io.c: wait child process after close_read
* io.c (rb_io_close_read): duplex IO should wait its child process
  even after close_read.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43117 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-02 07:26:54 +00:00
nobu f0d8be4e2b io.c: get rid of race condition
* io.c (rb_io_close_write): detach tied IO for writing before closing
  to get rid of race condition.  [ruby-list:49598]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43114 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-02 05:20:02 +00:00
nobu a9eca1b20d io.c: keep fptr read-closed
* io.c (rb_io_close_read): keep fptr in write_io to be discarded, to
  fix freed pointer access when it is in use by other threads, and get
  rid of potential memory/fd leak.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43112 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-10-02 05:19:00 +00:00
akr e6fe59e96e [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-23 12:52:49 +00:00
akr 6876f79b34 [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43009 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-22 03:43:14 +00:00
akr 42cc596402 [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-21 07:52:02 +00:00
nobu 7fff518d53 io.c: [DOC]
* io.c (rb_io_advise): [DOC] adjust indent and fix lists.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43005 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-21 04:42:21 +00:00
nobu 28e50d05d3 io.c: [DOC]
* io.c (rb_f_select): [DOC] adjust indent.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-21 04:42:19 +00:00
akr fa24a0c5ad [DOC]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43003 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-21 03:50:54 +00:00
kazu dc4b0b4161 * io.c (rb_f_printf): [DOC] add missing parenthesis in rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-09-10 03:06:14 +00:00
nobu 8ef0192103 io.c: copy in binary mode
* io.c (copy_stream_body): should write in binary mode.  based on a
  patch by godfat (Lin Jen-Shin) at [ruby-core:56556].
  [ruby-core:56518] [Bug #8767]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27 08:03:00 +00:00
nobu 1e238c5aa2 io.c: common oflags
* io.c (copy_stream_body): move common open flags.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-27 08:02:34 +00:00
tenderlove 988ca60565 * io.c (io_read_nonblock): support non-blocking reads without raising
exceptions. As in: `io.read_nonblock(size, exception: false)`
  [ruby-core:38666] [Feature #5138]
* ext/openssl/ossl_ssl.c (ossl_ssl_read_internal): ditto
* ext/stringio/stringio.c (strio_sysread): ditto
* io.c (rb_io_write_nonblock): support non-blocking writes without
  raising an exception.
* ext/openssl/ossl_ssl.c (ossl_ssl_write_internal): ditto
* test/openssl/test_pair.rb (class OpenSSL): tests
* test/ruby/test_io.rb (class TestIO): ditto
* test/socket/test_nonblock.rb (class TestSocketNonblock): ditto
* test/stringio/test_stringio.rb (class TestStringIO): ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-26 22:41:44 +00:00
usa d6af2a2b21 * io.c, internal.h (rb_io_flush_raw): new function to select calling
fsync() (on Windows).

* io.c (rb_io_flush_raw): use above function.

* file.c (rb_file_truncate): use above function.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 11:53:41 +00:00
usa bc08992a2e * io.c (rb_io_rewind): remove fsync() for Windows to improve the
performance.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42560 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-08-15 08:01:28 +00:00
glass e4b0852ae4 * io.c (io_getpartial): use rb_str_locktmp_ensure().
[ruby-core:56121] [Bug #8669]

* io.c (rb_io_sysread): ditto.

* test/ruby/test_io.rb: add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42214 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 11:31:58 +00:00
glass dd8f7a6cfd * string.c: add internal API rb_str_locktmp_ensure().
* io.c (io_fread): use rb_str_locktmp_ensure().
  [ruby-core:56121] [Bug #8669]

* test/ruby/test_io.rb: add a test for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42212 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 08:49:25 +00:00
glass 0a7785431c * io.c (interpret_seek_whence): support SEEK_DATA and SEEK_HOLE.
These are whences for lseek(2) supported by Linux since version 3.1.
  [ruby-core:56123] [Feature #8671]

* test/ruby/test_io.rb: Add tests for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-28 04:06:14 +00:00
glass 3495f2b87a * io.c (appendline): cosmetic change
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-16 02:25:54 +00:00
glass 8ce3f4beea * io.c (appendline): use READ_CHAR_PENDING_XXX macros and
RSTRING_END().

* io.c (rb_io_getline_1): rewrite nested if statement into one
  statement.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-09 03:49:49 +00:00