Commit graph

1101 commits

Author SHA1 Message Date
naruse
64b6f2b2a1 merge revision(s) 35594: [Backport #6422]
* io.c (io_unread): fix IO#pos with mode 'r' bug on Windows.
	  If the end of reading buffer is CR, io_unread() needs to unread one
	  more byte.
	  [ruby-core:44874] [Bug #6401]

	* test/ruby/test_io_m17n.rb (TestIO_M17N#test_pos_with_buffer_end_cr):
	  add a test for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35613 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-10 16:05:13 +00:00
naruse
7201291187 merge revision(s) 35296: [Backport #6295]
* io.c (rb_io_eof): use eof() instead of io_fillbuf(). It's because
	  io_unread() doesn't work properly when reading CRLF with read(length)
	  and mode 'r'.
	  [ruby-core:44189][Bug #6271]

	* test/ruby/test_io_m17n.rb (TestIO_M17N#test_read_crlf_and_eof):
	  test for above.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35331 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-14 19:36:06 +00:00
naruse
0e84de2b98 merge revision(s) 34785,35095,35098,35111,35152: [Backport #6294]
* io.c (set_binary_mode_with_seek_cur): reorder function qualifiers.
	* test/ruby/test_io.rb (TestIO#test_pos_with_getc): added.
	  see [Bug #6179][ruby-core:43518]

	* test/ruby/test_io.rb (TestIO#test_pos_with_getc): updated.
	  see [ruby-core:43550]

	* io.c (static int io_fflush): add the definition.
	  Use it in set_binary_mode_with_seek_cur().

	* io.c (set_binary_mode_with_seek_cur): refactoring to split the
	  content into io_unread(). Fix the possibility of buffer overflow.

	* io.c (io_unread): add new implementation for Windows. Previous one
	  caused invalid cursor position using IO#pos with OS text mode. New
	  one fixes the bug.

	* test/ruby/test_io_m17n.rb
	  (TestIO_M17N#test_pos_dont_move_cursor_position): add a test for
	  above bug.
	  [ruby-core:43497] [Bug #6179]

	* io.c (io_unread): fixed memory leak.  report by nagachika via IRC.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35328 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-14 18:02:01 +00:00
naruse
0e19adc87f merge revision(s) 35255:
* io.c (io_unread): cast as long the value for extra_max.
	  [ruby-core:44137] [Bug #6257]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@35256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-07 21:54:11 +00:00
nobu
9ca160c168 merge revision(s) 33172,33968:
* ext/io/console/console.c (console_set_winsize): remove
  unused variable.
	* io.c (Init_IO):  Mention io/console methods.  [Ruby 1.9 - Bug #5602]

	* ext/io/console/console.c:  Mention that io/console must be required
	  similar to lib/time.rb


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-06 03:31:12 +00:00
naruse
0f377c1c10 merge revision(s) 34786,34787,34788,34789:
* dir.c, file.c, io.c: use rb_sys_fail_path.

	* error.c: new functions to deal exceptions with string instances.

	* dir.c, file.c, io.c (rb_sys_fail_path): use rb_sys_fail_str.

	* test/ruby/test_literal.rb (TestRubyLiteral#test_special_const):
	  test for https://bugs.php.net/bug.php?id=61095


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-25 12:32:19 +00:00
naruse
f7f7f93a03 merge revision(s) 34795:
* dir.c (dir_inspect), io.c (rb_io_inspect): keep encoding of path.
	  [Bug #6072]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-25 08:10:23 +00:00
nobu
35bf8099d4 merge revision(s) 34735,34736:
* io.c (rb_io_s_foreach): return enumerator including kerword
	  arguments.  [ruby-dev:45267][Bug #6054]

	* io.c (rb_io_s_foreach): argument check before making Enumerator.
	  [ruby-dev:31525]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34749 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-22 13:04:38 +00:00
nobu
8f8764fd31 merge revision(s) 34576:
* io.c (Init_IO): use directive hack to make ARGF documentable
	  in other tools.  [ruby-core:42515][Bug #6007]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-13 03:06:52 +00:00
naruse
a208a75072 merge revision(s) 34043,34045,34132: [Backport #5791]
* win32/win32.c, include/ruby/win32.h (rb_w32_fd_is_text): new function.

	* win32/win32.c (init_stdhandle): set default mode of stdin as binmode.

	* io.c (set_binary_mode_with_seek_cur): new function to replace
	  SET_BINARY_MODE_WITH_SEEK_CUR macro.  now returns previous mode of the
	  fd and take care of LF in rbuf.

	* io.c (do_writeconv): set text mode when needed.

	* io.c (io_read): need to change the mode of the IO to binmode
	  temporally when the length for IO#read, because IO#read with length
	  must behave so.

	* test/ruby/test_io_m17n.rb (TestIO_M17N#est_{read_with_length,
	  read_with_length_binmode,get[cs]_and_read_with_binmode,
	  read_with_binmode_and_get[cs],read_write_with_binmode}): tests for
	  above changes.
	all patches are written by Hiroshi Shirosaki. [ruby-core:41496]
	[Feature #5714]

	* test/ruby/test_io_m17n.rb
	  (TestIO_M17N#test_{read_with_binmode_and_get[cs]}): only for Windows.

	* test/ruby/test_io_m17n.rb (TestIO_M17N#test_{read_with_length,

	* io.c (rb_sys_fail_path): move the definition.
	  Move above for using it in set_binary_mode_with_seek_cur().

	* io.c (set_binary_mode_with_seek_cur): fix improper seek cursor.
	  Seeking file cursor with setting binary mode has possibility to
	  cause infinite loop. Fixed the bug and refined error handling.
	  Introduced at r34043.
	  And cleanups as below.
	  Remove unnecessary parentheses of `fptr`.
	  Use return value of setmode().

	* test/ruby/test_io_m17n.rb
	  (TestIO_M17N#test_seek_with_setting_binmode): add a test for abobe.
	  [ruby-core:41671] [Bug #5714]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34546 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-10 18:39:05 +00:00
naruse
773b80bf36 merge revision(s) 33937: [Backport #5704]
* ext/zlib/zlib.c (rb_gzreader_initialize): use binary mode by default
	  under Windows. Patch by Hiroshi Shirosaki. [ruby-core:40706]
	  [Feature #5562]

	* include/ruby/encoding.h (void rb_econv_binmode): define NEWLINE
	  decorator.

	* io.c (rb_cloexec_fcntl_dupfd): Introduce NEED_READCONV and
	  NEED_WRITECONV to replace universal newline decorator by CRLF only
	  when required to improve file reading and writing under Windows.
	  Patch by Hiroshi Shirosaki. [ruby-core:40706] [Feature #5562]

	* io.c (do_writeconv): adjust binary mode if required.

	* io.c (read_all, appendline, swallow, rb_io_getline_1): ditto.

	* io.c (io_getc, rb_io_each_codepoint, rb_io_ungetc): ditto.

	* io.c (rb_io_binmode, rb_io_ascii8bit_binmode): ditto.

	* io.c (rb_io_extract_modeenc, rb_sysopen): ditto.

	* io.c (pipe_open, prep_stdio, io_encoding_set): ditto.

	* io.c (rb_io_s_pipe, copy_stream_body): ditto.

	* test/ruby/test_io_m17n.rb (EOT): add test for pipe and stdin in
	  binary mode.

	* win32/win32.c (init_stdhandle): remove O_BINARY from stdhandle
	  initialization.

	* win32/win32.c (rb_w32_write): use FTEXT mode accordingly.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-10 18:24:25 +00:00
naruse
093ade0eb8 merge revision(s) 33662,33666,33770: [Backport #5793]
------------------------------------------------------------------------
r33662 | usa | 2011-11-08 02:48:11 +0900 (Tue, 08 Nov 2011) | 18 lines

* include/ruby/encoding.h (ECONV_NEWLINE_DECORATOR_READ_MASK,
  ECONV_NEWLINE_DECORATOR_WRITE_MASK): new macro.

* io.c (rb_io_extract_modeenc, pipe_open, prep_stdio, argf_next_argv):
  set TEXTMODE_NEWLINE_DECORATOR_ON_WRITE for textmode on creating IO
  if the flag is available.

* io.c (make_writeconv): drop decorators for reading.

* io.c (make_readconv): drop decorators for writing.

* io.c (do_writeconv): existing writeconv is not the condition to raise
  ArgumentError.  should check textmode or not.

* test/ruby/test_io_m17n.rb
  (TestIO_M17N#test_{cr,lf,crlf}_decorator_on_stdout): test above
  changes.

------------------------------------------------------------------------

	* include/ruby/encoding.h (ECONV_NEWLINE_DECORATOR_READ_MASK,
	  ECONV_NEWLINE_DECORATOR_WRITE_MASK): new macro.

	* io.c (rb_io_extract_modeenc, pipe_open, prep_stdio, argf_next_argv):
	  set TEXTMODE_NEWLINE_DECORATOR_ON_WRITE for textmode on creating IO
	  if the flag is available.

	* io.c (make_writeconv): drop decorators for reading.

	* io.c (make_readconv): drop decorators for writing.

	* io.c (do_writeconv): existing writeconv is not the condition to raise
	  ArgumentError.  should check textmode or not.

	* test/ruby/test_io_m17n.rb
	  (TestIO_M17N#test_{cr,lf,crlf}_decorator_on_stdout): test above
	  changes.

	* io.c (argf_next_argv): wrong timing of setting ecflags.
	  fixed the failure of TestArgf#test_textmode introduced at r33662.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-10 18:21:01 +00:00
naruse
36b3d5577c merge revision(s) 34409,34412,34417:
* io.c (argf_close): skip stdin, which should be readable again.
	  [ruby-dev:45160] [Bug #5952]

	* io.c (argf_readlines): reinitialize after all read to be
	  readable again.

	* io.c (argf_next_argv): reset ARGF.next_p on ARGV.replace.
	  r34409 breaks replacing ARGV.
	  [ruby-dev:45160] [Bug #5952]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34528 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-09 20:12:02 +00:00
nobu
c65134a327 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-09 03:25:07 +00:00
kosaki
ea0ef6af83 merge revision(s) r33826:
* io.c (rb_io_fsync,rb_io_fdatasync): release GVL during fsync().
	  fsync() and fdatasync() may take a long time on slow disks and/or
	  if there is much dirty data.
	  Patch by Eric Wong. [Feature #5665] [ruby-core:41247]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34451 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-06 20:19:29 +00:00
naruse
234753aed4 merge revision(s) 33691,33692:
* io.c (rb_update_max_fd): fstat(2) can fail with other than
	  EBADF.  [ruby-dev:44837] [Backport #4339].  Cf.
	  http://pubs.opengroup.org/onlinepubs/9699919799/functions/fstat.html
	  EBADF.  [ruby-dev:44837] [Bug #5593].  Cf.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-06 12:26:47 +00:00
usa
a3fcbc9712 merge revision(s) 33667:
* io.c (io_fwrite): call rb_w32_write_console() only if FMODE_TTY is
  set.  this is the one of the reason of IO writing slowness of Windows
  in 1.9.3 or later.

[Backport #5592]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34436 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-06 07:32:09 +00:00
marcandre
a3192373a5 * io.c: Improve rdoc for {File|IO}.write
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@34079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-20 06:52:04 +00:00
tarui
dc08e762fc * io.c (make_writeconv): unversal_newline converter is for reading.
so, if the io is text mode and has ECONV_UNIVERSAL_NEWLINE_DECORATOR
  flag, use crlf_newline converter for writing.
  this change fixes the problem about the luck of CR up Kernel.p and
  Kernel.puts to stdout/stderr on Windows.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 16:33:51 +00:00
arton
547584dd21 * io.c (io_fflush): remove fsync().
* io.c (rb_io_flush, rb_io_rewind): fsync() here.
These pathces are backports of trunk r33651 for [Bug #5585]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 14:45:27 +00:00
kosaki
69cc900f52 merge revision(s) 33171:
* io.c (argf_next_argv): open in default text mode.
	  [ruby-core:39234] [Bug #5268]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-07 14:43:10 +00:00
nobu
8403b23f36 * io.c (validate_enc_binmode, prep_stdio): default to text mode on
dosish platforms.  [ruby-core:38822] [Bug #5164]
* transcode.c (rb_econv_prepare_options): keep default ecflags
  unchanged if no options.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-02 12:11:17 +00:00
nobu
77ed5993fe * io.c (rb_io_each_byte): rbuf can be refreshed during yield.
[Bug #5119]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30 14:14:46 +00:00
akr
5314b52068 * io.c (rb_update_max_fd): validate fd.
* ext/socket/rubysocket.h (rsock_discard_cmsg_resource): add
  msg_peek_p argument for the declaration.

* ext/socket/ancdata.c (discard_cmsg): add msg_peek_p argument.
  assume FreeBSD, NetBSD and MacOS X doesn't generate passed fd
  when MSG_PEEK. 
  (rsock_discard_cmsg_resource): add msg_peek_p argument.
  (bsock_recvmsg_internal): call rsock_discard_cmsg_resource with
  msg_peek_p argument.

* ext/socket/unixsocket.c (unix_recv_io): call
  rsock_discard_cmsg_resource with msg_peek_p argument.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-23 08:13:37 +00:00
akr
fdcac09849 * backport r32579, r32581, r32587 by akr and r32588 by kazu.
r32579:

* io.c (rb_update_max_fd): new function.

* internal.h (rb_update_max_fd): declare rb_update_max_fd.

* thread_pthread.c (rb_thread_create_timer_thread): update max fd when
  timer thread pipe is created.

r32581:

* io.c (UPDATE_MAXFD): removed.

r32587:

* include/ruby/intern.h (rb_update_max_fd): declaration moved from
  internal.h.

* file.c: ditto.

* io.c: call rb_update_max_fd for each new fds.

* process.c: ditto.

* random.c: ditto.

* ruby.c: ditto.

* ext/io/console/console.c: ditto.

* ext/openssl/ossl_bio.c: ditto.

* ext/pty/pty.c: ditto.

* ext/socket/init.c: ditto.

* ext/socket/socket.c: ditto.

* ext/socket/ancdata.c: ditto.

* ext/socket/unixsocket.c: ditto.

r32588:

* io.c (rb_update_max_fd): remove parentheses. they are not in
  macro.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@32591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-20 22:11:56 +00:00
drbrain
0c3833ec5a * io.c: Note that methods other than IO#gets may increase IO#lineno.
[Ruby 1.9 - Bug #4902]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32465 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-09 00:21:44 +00:00
nobu
dc3697f62f * io.c (rb_io_close): close(2) on a fd which is being read by
another thread causes deadlock on Mac OS X 10.5

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32462 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-08 23:37:08 +00:00
ko1
eb35bb0b35 * include/ruby/intern.h, thread_pthread.c (rb_reserved_fd_p,
RB_RESERVED_FD_P): added.  This C API is to limit to access
  fds which are used by RubyVM internal.  In this version of
  CRuby, return 1 if fd is communication pipe.
  If your application needs to close all file descriptors to
  preent resource leak, skip internal fds using this C API.
  We also define a macro RB_RESERVED_FD_P(fd).  So you can write
  #ifndef RB_RESERVED_FD_P
  #define RB_RESERVED_FD_P(fd) 0
  #endif
  for Ruby 1.9.2 or previous version to write compatible extensions.
  See [ruby-core:37727]
* thread_win32.c (rb_reserved_fd_p): added (return 0 for any fds).
* io.c (rb_io_initialize): raise ArgumentError if given fd is reserved by Ruby.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-03 21:56:59 +00:00
drbrain
926301969f * math.c: Attach documentation for Math.
* object.c:  Document NIL, TRUE, FALSE.
	* io.c:  Improve grammar in ARGF comment.  Document STDIN/OUT/ERR.
	  Document ARGF global constant.
	* lib/rake:  Hide deprecated toplevel constants from RDoc (import from
	  rake trunk).
	* lib/thwait.rb:  Document ThWait.
	* lib/mathn.rb:  Hide Math redefinition from RDoc
	* lib/sync.rb:  Add a basic comment for Sync_m, Synchronizer_m, Sync,
	  Synchronizer.
	* parse.y:  Document SCRIPT_LINES__.
	* hash.c:  Document ENV class and global constant.
	* vm.c:  Document TOPLEVEL_BINDING.
	* version.c:  Document RUBY_* constants.
	* ruby.c:  Document DATA and ARGV.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32281 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-29 03:09:34 +00:00
nobu
6effaa9a13 * io.c (fill_cbuf): finish reading at EOF, and the readconv has
been cleared by another thread while io_fillbuf() is waiting at
  select().  a patch in [ruby-core:37197] by Hiroshi Shirosaki
  <h.shirosaki AT gmail.com>.  fixed #3840

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 15:00:00 +00:00
akr
8192693ccf * io.c: supress warnings.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-18 02:10:09 +00:00
akr
e7996eb3cc * internal.h: declare internal functions here.
* node.h: declare NODE dependent internal functions here.

* iseq.h: declare rb_iseq_t dependent internal functions here.

* vm_core.h: declare rb_thread_t dependent internal functions here.

* bignum.c, class.c, compile.c, complex.c, cont.c, dir.c, encoding.c,
  enumerator.c, error.c, eval.c, file.c, gc.c, hash.c, inits.c, io.c,
  iseq.c, load.c, marshal.c, math.c, numeric.c, object.c, parse.y,
  proc.c, process.c, range.c, rational.c, re.c, ruby.c, string.c,
  thread.c, time.c, transcode.c, variable.c, vm.c,
  tool/compile_prelude.rb: don't declare internal functions declared
  in above headers.  include above headers if required.

  Note that rb_thread_mark() was declared as
  void rb_thread_mark(rb_thread_t *th) in cont.c but defined as
  void rb_thread_mark(void *ptr) in vm.c.  Now it is declared as
  the later in internal.h.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-17 22:43:38 +00:00
drbrain
2adddf4c2b * io.c: Improve documentation of IO and File open and new.
Patch by Roger Pack.  [Ruby 1.9 - Bug #4790]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-16 23:50:30 +00:00
akr
60e078c860 * io.c: use select() appropriately for sendfile().
Fixed by Eric Wong.  [ruby-core:36150]
  (maygvl_copy_stream_wait_readwrite): removed.
  (nogvl_copy_stream_sendfile): use nogvl_copy_stream_wait_write and
  maygvl_copy_stream_wait_read instead of
  maygvl_copy_stream_wait_readwrite.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32019 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-12 02:18:51 +00:00
nobu
34b19050b3 * io.c (io_getc): should be 7bit if ascii. fixes #4557
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32000 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-11 09:02:11 +00:00
akr
87f025da25 * io.c: fix IO.copy_stream interrupt handling.
based on the patch by Eric Wong.  [ruby-core:36156]

* vm_core.h (rb_thread_call_with_gvl): don't declare here.

* thread.c: include internal.h.
  (rb_thread_execute_interrupts): new function.

* internal.h (rb_thread_execute_interrupts): declared.
  (rb_thread_call_with_gvl): declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31971 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-09 15:02:46 +00:00
usa
19c78f9b9b * io.c (io_fflush): windows -- call fsync() only when the FD is tied to
file, because if the FD is pipe, it blocks.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-03 10:59:37 +00:00
usa
fd8010fc0a * io.c (rb_io_s_write, rb_io_s_binwrite): return!!!
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-02 11:06:40 +00:00
sorah
7b3948f055 * io.c: Add File.write, File.binwrite. [Feature #1081] [ruby-core:21701]
* test/ruby/test_io.rb: Test for File.write, File.binwrite.

* NEWS: News for above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31902 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-02 07:30:11 +00:00
usa
2b0363df5d * io.c (io_flush, rb_io_flush): need to fsync() when ruby calls internal
flush. [ruby-core:36670] [Bug #4813]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31901 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-02 03:35:40 +00:00
ryan
38de163f1e doco: p outputs newline regardless of record separator
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-06-01 00:48:09 +00:00
nobu
fcc86b0f4c * io.c (io_encoding_set): should honor already set ecflags since it
might be set by mode option.  fixed #4804

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 16:15:15 +00:00
nobu
a010ea9a45 no space inside parens
* io.c: remove spaces before closing parens.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31866 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 15:05:09 +00:00
usa
da1db8b454 * io.c (rb_io_s_pipe): potential bug. the mode of read IO is set as
DEFAULT_TEXTMODE in call of io_set_encoding(), and of write IO is
  also set as it in call of io_new_instance() via rb_protect().
  so, if DEFAULT_TEXTMODE is not 0, we should check the result of
  extract_binmode() and avoid crush of default IO mode and the result.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-31 05:21:36 +00:00
naruse
9efb5a9d6a * io.c (fill_cbuf): return MORE_CHAR_SUSPENDED when cbuf is not empty.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 18:06:42 +00:00
kosaki
78271e8c72 * io.c (fill_cbuf): Fix test-all crash.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 17:09:27 +00:00
nobu
b5bc09d234 * io.c (validate_enc_binmode): do not clear textmode flag if
default.  fixed #4732

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31748 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 13:45:12 +00:00
nobu
9909c67583 * io.c (fill_cbuf): finish reading at EOF.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-27 13:38:56 +00:00
kosaki
67cf354b46 * io.c (rb_io_extract_modeenc): accept combination hash and
File::Constants. (eg. File.open('yo', :mode => File::WRONLY))
  [Feature #4742][ruby-core:36338]
* test/ruby/test_io.rb (TestIO#test_open_mode): new test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-21 13:20:43 +00:00
kosaki
898374126e revert O_CLOEXEC patch series completely.
because boron chkbuild test result says, An old linux kernel ignore O_CLOEXEC
silently instead of return an error. It may lead to bring new security risk.
So, we have to be pending it until finish to implement proper fallback logic.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-19 12:18:41 +00:00