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

1461 Коммитов

Автор SHA1 Сообщение Дата
kosaki b8a1e36201 * thread.c (struct rb_mutex_struct): add allow_trap field.
* internal.h (rb_mutex_allow_trap): added.
* thread.c (rb_mutex_lock, rb_mutex_unlock): check mutex->allow_trap.
* thread.c (mutex_sleep): remove trap check because it uses
  rb_mutex_lock and rb_mutex_unlock internally.
* thread.c (rb_mutex_allow_trap): new helper function for the above.

* io.c (io_binwrite): mark fptr->write_lock as writable in trap.

* test/ruby/test_signal.rb (test_trap_puts): test for the above.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37930 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 08:30:51 +00:00
kosaki e6ef313a49 * io.c (FMODE_SYNCWRITE): removed unused macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-28 06:36:28 +00:00
naruse 3e0becb42d * io.c (argf_each_codepoint): add missing ARGF#codepoints [Bug #7438]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-26 07:37:25 +00:00
kosaki c8a3b2ba8b * io.c (Init_IO): removed all rb_file_const() into file.c.
* file.c (Init_File): replace with rb_file_const() with
  rb_define_const() because RDoc don't care rb_file_const.
  [Bug #5530]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37746 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-20 05:00:45 +00:00
zzak de794aefa6 * io.c (IO#new):
Fix indentation from r37444
  [ruby-core:48052] [Bug #7179]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-09 00:28:41 +00:00
zzak 4d42277823 * io.c (IO#new):
Documentation for IO#open modes and formatting
  [ruby-core#48052] [Bug #7179]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-03 04:27:56 +00:00
usa ee2718039c * process.c (redirect_dup2): set standard handles when new fd is stdio,
because if there is no allocated console at the moment Windows does
  not automatically associate it for child process's standard handle.
  this is adhoc workaround.
  reported by Martin Thiede at [ruby-core:48542] [Bug #7239].

* io.c (rb_cloexec_dup2): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-30 10:32:56 +00:00
nari c3a46d6aca * include/ruby/ruby.h: add C APIs.
VALUE rb_newobj_of(VALUE klass, VALUE flags)
  #define NEWOBJ_OF(obj,type,klass,flags)
  These allow to change a allocation strategy depending on klass
  or flags.

* gc.c: ditto

* array.c: use new C API.
* bignum.c: ditto
* class.c: ditto
* complex.c: ditto
* ext/socket/ancdata.c: ditto
* ext/socket/option.c: ditto
* hash.c: ditto
* io.c: ditto
* marshal.c: ditto
* numeric.c: ditto
* object.c: ditto
* random.c: ditto
* range.c: ditto
* rational.c: ditto
* re.c: ditto
* string.c: ditto
* struct.c: ditto
  [Feature #7177][Feature #7047]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37275 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-20 06:57:51 +00:00
nobu 5c677a83ba io.c: improved IO#reopen
* io.c (rb_io_reopen): improvement to accept optional arguments.
  a patch by Glass_saga (Masaki Matsushita) in [ruby-core:47806].
  [Feature #7103]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37071 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-10-03 02:43:19 +00:00
nobu 4a3c049cd1 io.c: IO#reopen int mode
* io.c (rb_io_reopen): accept File::Constants as well as mode string.
  based on the patch by Glass_saga (Masaki Matsushita) in
  [ruby-core:47694].  [Feature #7067]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-28 01:40:56 +00:00
nobu 59383b1f9c io.c: io_set_read_length
* io.c (io_set_read_length): if the read length equals to the buffer
  string size then nothing to do.  or ensure the string modifiable
  before setting the length only when the former is shorter.  based on
  the patch in [ruby-core:47541] by Hiroshi Shirosaki.
  [ruby-core:46586] [Bug #6764]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-16 02:39:18 +00:00
kosaki 84c77c1520 * ext/socket/basicsocket.c (rsock_bsock_send):
avoid unnecessary select() calls before doing I/O
  Patch by Eric Wong. [Feature #4538] [ruby-core:35586]
* ext/socket/init.c (rsock_s_recvfrom): ditto.
* ext/socket/init.c (rsock_s_accept): ditto.
* ext/socket/udpsocket.c (udp_send): ditto.
* io.c (io_fflush): ditto.
* io.c (io_binwrite): ditto.
* io.c (rb_io_syswrite): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-09 17:29:12 +00:00
kosaki 946f7fc788 * io.c (nogvl_close, maygvl_close, nogvl_fclose, maygvl_fclose):
suppress integer <-> pointer cast warnings.
  [Feature #4570] [ruby-core:35711]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-09 17:11:25 +00:00
kosaki 4c10b36467 * io.c (rb_io_close): notify fd close before releasing gvl.
* io.c (fptr_finalize): modify fptr->mode before releasing gvl.
  remove unnecessary rb_thread_fd_close().
  [Feature #4570] [ruby-core:35711]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36942 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-09 17:11:03 +00:00
kosaki 4b58f39ded * io.c (nogvl_close, maygvl_close, nogvl_fclose, maygvl_fclose):
new functions.
* io.c (fptr_finalize): release GVL if possible.
  Patched by Eric Wong. [Feature #4570] [ruby-core:35711]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36932 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-09 09:10:46 +00:00
kosaki 3df2fc2da8 * io.c (io_bufread): removed unnecessary rb_thread_wait_fd().
Patch by Eric Wong. [Bug #6629] [ruby-core:45789]
* io.c (rb_io_sysread): ditto.
* io.c (copy_stream_fallback_body): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-09 07:20:00 +00:00
eregon 1f65a21b6f * io.c: fix typo in io/console example.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-01 07:41:51 +00:00
akr 76d0abd334 * io.c (rb_io_close): call rb_last_status_clear.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-30 09:22:18 +00:00
akr e7ddd1fdc3 * internal.h (rb_last_status_clear): declared.
* process.c (rb_last_status_clear): exported.
  (rb_f_system): call rb_last_status_clear.

* io.c (rb_f_backquote): call rb_last_status_clear.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36849 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-29 14:44:08 +00:00
eregon fd7dc23d28 Kernel#inspect: improve consistency and do not call #to_s.
* object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s. A class
  can now benefit from the nice default #inspect even if it defines #to_s.
  Also, there is no more unexpected change in #inspect result.
* NEWS: Add note about the change.
* bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*):
  Adapt internal structures (by aliasing #inspect to #to_s) so they
  don't rely on the removed behavior (#inspect calling overridden #to_s).
* test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect.
* lib/pp.rb (class PP): do not call #to_s anymore, as #inspect
  no more does (mame).
* test/test_pp.rb (class PPInspectTest): remove related assertion (mame).
  [ruby-core:43238][Feature #6130]
* test/drb/drbtest.rb (DRbCore#teardown, DRbAry#teardown):
  adapt DRb tests with the new change (shirosaki).
  [ruby-core:47182][Bug #6866]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15 11:50:01 +00:00
naruse 780e7d0951 Revert r36699 and r36700. [Feature #6130]
Revert "Kernel#inspect: improve consistency and do not call #to_s."
Revert "update PP with recent Kernel#inspect change. Patch by Yusuke Endoh."

r36699 cause test-all failure on test/drb/test_drb.rb and
test/drb/test_drbssl.rb. Run test-all before commit.

Moreover its ChangeLog formst is wrong: see CommitterHowto
https://bugs.ruby-lang.org/projects/ruby/wiki/CommitterHowto#ChangeLog

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-15 01:09:10 +00:00
eregon 795c29dcda Kernel#inspect: improve consistency and do not call #to_s.
A class can now benefit from the nice default #inspect even if it
defines #to_s. Also, there is no more unexpected change in #inspect
result. Internal structures have been adapted so they don't rely
on the removed behavior (#inspect calling overridden #to_s).

* object.c (rb_obj_inspect): Kernel#inspect: do not call #to_s.
* test/ruby/test_object.rb (test_inspect): add tests for Kernel#inspect.
* bignum.c, io.c, numeric.c, object.c, proc.c, vm.c (Init_*):
  alias #inspect to #to_s where it was expected.
  [ruby-core:43238][Feature #6130]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-14 10:20:44 +00:00
nobu d97cd39f42 io.c: suppress unused variable warnings
* io.c (pipe_open): suppress warnings agains variable which are used
  when spawnv is available but fork is not.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-08-05 15:40:06 +00:00
nobu c05e6a8cda process.c: try conversion at redirection
* io.c (rb_io_check_io): make public.
* process.c (check_exec_redirect): try conversion to IO on redirect
  parameters.  [ruby-core:44181] [Bug #6269]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-27 09:25:54 +00:00
nobu 7bca2f031a get rid of warnings
* io.c (sysopen_func, rb_sysopen_internal): cast through VALUE to get
  rid of warnings.  fixup of r36355.
* process.c (rb_waitpid_blocking, rb_waitpid): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36361 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-11 03:17:35 +00:00
nobu c51a826764 rb_thread_call_without_gvl
* include/ruby/thread.h: new header file for thread stuff.
* thread.c (rb_thread_call_without_gvl): export.  [Feature#4328]
  returns void* instead of VALUE.  [Feature #5543]
* thread.c (rb_thread_blocking_region): deprecate.  [ruby-core:46295]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-10 13:57:11 +00:00
kosaki 3e1d8aab17 * dln.c: Simplify and make consistent an ifdef for Mac OS X.
* ext/socket/rubysocket.h: ditto.
* ext/tk/stubs.c: ditto.
* io.c: ditto.
* process.c: ditto.
* signal.c: ditto.
* vm_dump.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-07-09 15:52:49 +00:00
nobu f4d2374b45 adjust style.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 05:37:15 +00:00
nobu 2240eb37b8 popen: shell commands with envvars and execopts
* io.c (is_popen_fork): check if fork and raise NotImplementedError if
  unavailable.
* io.c (rb_io_s_popen): allow environment variables hash and exec
  options as flat parameters, not in an array arguments.
  [Feature#6651] [EXPERIMENTAL]
* process.c (rb_execarg_extract_options): extract exec options, but no
  exceptions on non-exec options and returns them as a Hash.
* process.c (rb_execarg_setenv): set environment variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-27 00:15:51 +00:00
nobu 876d4c4cc8 Revert r36213 "popen: shell commands with envvar"
* io.c (rb_io_s_popen): revert r36213 "popen: shell commands with
  envvar" because it disabled to let single command bypass shell.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36218 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-26 01:01:59 +00:00
nobu 0f0f0f4441 popen: shell commands with envvar
* io.c (is_popen_fork): check if fork and raise NotImplementedError if
  unavailable.
* io.c (rb_io_s_popen): allow shell commands with modified environment
  variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36213 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-25 06:42:05 +00:00
nobu cc1c97ae31 io.c: spawnv
* io.c (pipe_open): merge win32 code using spawnv().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36209 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-24 14:02:19 +00:00
akr 5c25fad66d * process.c: use the name "sargp" for struct rb_execarg variables
consistently for saving process attributes. 

* io.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36191 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-23 00:18:32 +00:00
akr 3eafc1660f * process.c: use the name "eargp" for struct rb_execarg variables
consistently except for saving process attributes. 

* io.c: ditto.

* ext/pty/pty.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36189 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-22 23:09:16 +00:00
akr c7a68e8d9d needless RB_GC_GUARD removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 13:46:14 +00:00
akr ed8040a62b * process.c (rb_execarg_addopt): take a VALUE argument instead of
struct rb_execarg.
  (rb_exec_arg_addopt): follow the rb_execarg_addopt change.
  (check_exec_options_i): ditto.

* io.c (pipe_open): follow the rb_execarg_addopt change.

* internal.h (rb_execarg_addopt): follow the definition change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 12:18:40 +00:00
akr 129cad739b remove unused variables.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-21 10:01:27 +00:00
akr d73d3a743b * process.c (rb_execarg_fixup): take a VALUE argument instead of
struct rb_execarg.

* internal.h (rb_execarg_fixup): follow the definition change.

* io.c (pipe_open): follow rb_execarg_fixup change.

* ext/pty/pty.c (establishShell): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20 21:25:20 +00:00
akr b60713de73 * internal.h (struct rb_execarg) moved and renamed from
struct rb_exec_arg in intern.h.

* include/ruby/intern.h (struct rb_exec_arg): refer Data object which
  contains struct rb_execarg.

* process.c: use struct rb_execarg instead of struct rb_exec_arg
  except functions declared in intern.h.
  (rb_exec_arg_addopt): extract a pointer to struct rb_execarg from
  struct rb_exec_arg.
  (rb_exec_arg_init): ditto.
  (rb_exec_arg_fixup): ditto.
  (rb_run_exec_options_err): ditto.
  (rb_run_exec_options): ditto.
  (rb_exec_err): ditto.
  (rb_exec): ditto.

* io.c: use struct rb_execarg instead of struct rb_exec_arg.

* ext/pty/pty.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20 11:46:50 +00:00
akr 826f98e688 * internal.h (rb_execarg_new): declared.
(rb_execarg_get): ditto.

* process.c (mark_exec_arg): new function.
  (free_exec_arg): ditto.
  (memsize_exec_arg): ditto.
  (exec_arg_data_type): defined.
  (rb_execarg_new): new function.
  (rb_execarg_get): ditto.
  (rb_f_exec): use rb_execarg_new.
  (rb_spawn_internal): ditto.
  (rb_f_spawn): ditto.

* io.c (pipe_open_v): use rb_execarg_new.
  (pipe_open_s): ditto.

* ext/pty/pty.c (establishShell): use rb_execarg_new.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-20 10:31:02 +00:00
akr 37a1355bf8 * include/ruby/intern.h (rb_exec_arg_init): deprecated.
(rb_exec_arg_addopt): ditto.
  (rb_exec_arg_fixup): ditto.
  (rb_run_exec_options): ditto.
  (rb_run_exec_options_err): ditto.

* internal.h (rb_execarg_init): declared.
  (rb_execarg_addopt): ditto.
  (rb_execarg_fixup): ditto.
  (rb_execarg_run_options): ditto.

* process.c: call rb_execarg_addopt, rb_execarg_fixup,
  rb_execarg_run_options, rb_execarg_init.
  (rb_execarg_addopt): renamed from rb_exec_arg_addopt.
  (rb_exec_arg_addopt): stub to call rb_execarg_addopt.
  (rb_execarg_init): renamed from rb_exec_arg_init.
  (rb_exec_arg_init): stub to call rb_execarg_init.
  (rb_execarg_fixup): renamed from rb_exec_arg_fixup.
  (rb_exec_arg_fixup): stub to call rb_execarg_fixup.
  (rb_execarg_run_options): renamed from rb_run_exec_options_err.
  (rb_run_exec_options_err): stub to call rb_execarg_run_options.
  (rb_run_exec_options): call rb_execarg_run_options.

* io.c: call rb_execarg_addopt, rb_execarg_fixup,
  rb_execarg_run_options, rb_execarg_init.

* ext/pty/pty.c (establishShell): call rb_execarg_init and
  rb_execarg_fixup.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-12 11:34:51 +00:00
akr 4b70fab915 * process.c (rb_fork_ruby): new function.
(rb_f_fork): use rb_fork_ruby instead of rb_fork.
  (rb_daemon): ditto.

* io.c (pipe_open): use rb_fork_ruby instead of rb_fork.

* internal.h (rb_fork_ruby): declared.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 11:21:07 +00:00
akr c27edd4a6e * io.c (popen_exec): don't call rb_thread_atfork_before_exec. use
rb_exec_async_signal_safe instead of rb_exec_err.
  (pipe_open): use rb_fork_async_signal_safe instead of rb_fork_err.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36008 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-10 03:16:32 +00:00
akr 795c5f9b40 * process.c: don't check the availability of FD_CLOEXEC. It should
be available if fork() is available.

* io.c: ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-08 14:46:23 +00:00
akr 3162e673a1 * internal.h (rb_exec_arg_init): change return type to void.
* process.c (rb_exec_arg_init): don't return a value.
  (rb_exec_arg_prepare): ditto.
  (rb_spawn_process): don't take the prog argument.  extract the 
  information from earg.
  (rb_spawn_internal): follow rb_spawn_process change.
  (rb_f_spawn): ditto.

* io.c (pipe_open): don't take the prog argument.  extract the
  information from eargp.
  (pipe_open_v): follow pipe_open change.
  (pipe_open_s): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35928 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 15:24:32 +00:00
akr 53b17a769b * internal.h (rb_exec_arg): use union to represent command invocation
with/without shell.

* process.c: follow the rb_exec_arg change.

* io.c (pipe_open): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35927 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 14:53:31 +00:00
nobu 2073258a7d obj_init_copy
* object.c (rb_obj_init_copy): should check if trusted too.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 11:13:18 +00:00
akr 5b13036fce * process.c: add comments about async-signal-safe.
* io.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35918 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 10:16:11 +00:00
drbrain e1b230d557 * io.c: Edited documentation for IO and File open and new and
Kernel#open for consistency and clarity.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-05 00:37:08 +00:00
akr 41819dc447 * internal.h (ARGVSTR2ARGC): defined.
(ARGVSTR2ARGV): defined.

* process.c (proc_exec_v): use ARGVSTR2ARGV.
  (rb_spawn_process): use ARGVSTR2ARGC and ARGVSTR2ARGV.

* io.c (pipe_open): use ARGVSTR2ARGV.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35909 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 10:19:32 +00:00
nobu a99d3a6271 unused variables
* io.c (pipe_open): argc and argv are not used on win32.

* process.c (rb_spawn_process): remove already useless variables.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 05:33:43 +00:00
usa 859869e522 * io.c (pipe_open): follow up changes in r35889.
* process.c (proc_spawn_n): now uses char ** instead of VALUE *.

* process.c (rb_spawn_process): prog is now VALUE of String, not char *.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-06-04 01:44:27 +00:00
nobu 3cc5ddcac1 Bug #6487
* io.c (io_strip_bom): check EOF.  [Bug #6487][ruby-core:45203]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-24 03:07:49 +00:00
nobu b0dd250dc9 use RB_TYPE_P() instead of comparison of TYPE()
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-23 07:13:21 +00:00
nobu 315a0cb926 * io.c: re-fix merge miss.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 04:08:09 +00:00
yugui 1d7dc02647 * io.c: Fix a mistake on merging the patch in the previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35673 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 03:20:02 +00:00
yugui 76bc2d1ed7 Imports Ruby's port to NativeClient (a.k.a NaCl).
Patch by Google Inc. [ruby-core:45073].

* configure.in (RUBY_NACL): New M4 func to configure variables for
  NaCl.
  (RUBY_NACL_CHECK_PEPPER_TYPES): New M4 func to check the old names
  of Pepper interface types.
  (BTESTRUBY): New variable to specify which ruby should be run on
  "make btest". NaCl can run the built binary by sel_ldr, but it need
  rbconfig.rb. So this variable is distinguished from $MINIRUBY.
  
* thread_pthread.c: Disabled some features on NaCl.

* io.c: ditto.

* process.c: ditto.

* signal.c: ditto.

* file.c: ditto.

* missing/flock.c: ditto.

* nacl/pepper_main.c: An example implementation of Pepper application
  that embeds Ruby.

* nacl/example.html: An example of web page that uses the Pepper
  application.

* nacl/nacl-config.rb: Detects variants of NaCl SDK.

* nacl/GNUmakefile.in: Makefile template for NaCl specific build
  process.

* nacl/package.rb: script for packaging a NaCl-Ruby embedding
  application. 

* nacl/reate_nmf.rb: Wrapper script of create_nmf.py

* dln.c (dln_load): Added a hack to call on NaCl.

* util.c (ruby_getcwd): Path to the current directort is not available
  on NaCl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-17 02:48:59 +00:00
usa 0923ae5ed1 * io.c: fixed a merge mistake of r33878, reported by nobu via IRC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-16 05:31:27 +00:00
shirosaki 7e134cf71e * 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/trunk@35594 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-08 12:01:05 +00:00
naruse 6a7666e562 * io.c (io_encoding_set): suppress warnings. [ruby-dev:45627]
this tmp1 is not required after r35538.

* addr2line.c: suppress warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-06 12:39:59 +00:00
naruse afd9ce9d9e * io.c (parse_mode_enc): remove warnings 'Ignoring internal encoding'.
[ruby-core:44455] [Bug #6324]

* io.c (io_encoding_set): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35538 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-05-04 16:14:51 +00:00
drbrain ab0eb272f9 * io.c (io_readpartial): Document the output buffer parameter is
overwritten with the read contents even when non-empty.
  Patch by yu nobuoka.  [ruby-trunk - Bug #6285]
* io.c (io_read_nonblock):  ditto.
* io.c (io_read):  ditto.
* io.c (rb_io_sysread):  ditto.
* io.c (argf_read):  ditto.
* io.c (argf_readpartial):  ditto.
* ext/stringio/stringio.c (strio_read):  ditto.
* test/ruby/test_argf.rb (class TestArgf):  Add test for existing
  behavior of read outbuf.
* test/ruby/test_io.rb (class TestIO):  ditto.
* test/stringio/test_stringio.rb (class TestStringIO):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-18 23:48:27 +00:00
nobu 57fb219905 * reduce UNREACHABLE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35333 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-15 00:06:13 +00:00
drbrain e95f7ea80d * variable.c (trace_ev): Removed "not reached" comment as this line is
reached.
* variable.c (rb_obj_remove_instance_variable):  Replaced "not reached"
  comment with the UNREACHABLE macro.
* variable.c (rb_mod_const_missing):  ditto.
* variable.c (rb_mod_remove_cvar):  ditto.
* enum.c (first_i):  ditto.
* string.c (rb_str_aref):  ditto.
* string.c (str_byte_aref):  ditto.
* string.c (rb_to_id):  ditto.
* io.c (rb_io_fmode_modestr):  ditto.
* io.c (rb_io_oflags_modestr):  ditto.
* pack.c (num2i32):  ditto.
* vm_eval.c (rb_method_missing):  ditto.
* vm_eval.c (rb_f_throw):  ditto.
* dir.c (dir_read):  ditto.
* win32/win32.c (child_result):  ditto.
* struct.c (rb_struct_getmember):  ditto.
* struct.c (rb_struct_set):  ditto.
* struct.c (rb_struct_aref_id):  ditto.
* eval.c (rb_f_raise):  ditto.
* process.c (rb_f_exit_bang):  ditto.
* process.c (rb_f_exit):  ditto.
* process.c (rb_f_abort):  ditto.
* ext/-test-/iter/break.c (iter_break_value):  ditto.
* ext/pty/pty.c (pty_check):  ditto.
* ext/openssl/ossl_pkey.c (ossl_pkey_new):  ditto.
* ext/readline/readline.c (rb_remove_history):  ditto.
* ext/stringio/stringio.c (strio_unimpl):  ditto.
* numeric.c (num_sadded):  ditto.
* numeric.c (num_init_copy):  ditto.
* numeric.c (rb_num2ll):  ditto.
* numeric.c (rb_num2ull):  ditto.
* vm_insnhelper.c (call_cfunc):  ditto.
* ruby.c (opt_W_getter):  ditto.
* bignum.c (rb_big_coerce):  ditto.
* file.c (rb_f_test):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35322 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-14 00:36:26 +00:00
drbrain da39d32f60 * encoding.c (rb_enc_codepoint_len): Use UNREACHABLE to avoid "control
reaches end of non-void function" warnings.  [ruby-trunk - Bug #6066]
* re.c (name_to_backref_number):  ditto.
* object.c (rb_Float):  ditto.
* io.c (io_readpartial):  ditto.
* io.c (io_read_nonblock):  ditto.
* pack.c (rb_uv_to_utf8):  ditto.
* proc.c (rb_method_entry_arity):  ditto.
* vm_method.c (rb_f_notimplement):  ditto.
* struct.c (rb_struct_aset_id):  ditto.
* class.c (rb_scan_args):  ditto.
* process.c (rlimit_resource_type):  ditto.
* process.c (rlimit_resource_value):  ditto.
* process.c (p_uid_switch):  ditto.
* process.c (p_gid_switch):  ditto.
* ext/digest/digest.c (rb_digest_instance_update):  ditto.
* ext/digest/digest.c (rb_digest_instance_finish):  ditto.
* ext/digest/digest.c (rb_digest_instance_reset):  ditto.
* ext/digest/digest.c (rb_digest_instance_block_length):  ditto.
* ext/bigdecimal/bigdecimal.c (BigDecimalCmp):  ditto.
* ext/dl/handle.c (rb_dlhandle_close):  ditto.
* ext/tk/tcltklib.c (pending_exception_check0):  ditto.
* ext/tk/tcltklib.c (pending_exception_check1):  ditto.
* ext/tk/tcltklib.c (ip_cancel_eval_core):  ditto.
* ext/tk/tcltklib.c (lib_get_reltype_name):  ditto.
* ext/tk/tcltklib.c (create_dummy_encoding_for_tk_core):  ditto.
* ext/tk/tkutil/tkutil.c (tk_hash_kv):  ditto.
* ext/openssl/ossl_ssl.c (ossl_ssl_session_reused):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_key_dsa_verify_asn1):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_at_infinit):  ditto.
* ext/openssl/ossl_pkey_ec.c (ossl_ec_point_is_on_curve):  ditto.
* ext/fiddle/conversions.c (generic_to_value):  ditto.
* ext/socket/raddrinfo.c (rsock_io_socket_addrinfo):  ditto.
* ext/socket/socket.c (sock_s_getnameinfo):  ditto.
* ext/ripper/eventids2.c (ripper_token2eventid):  ditto.
* cont.c (return_fiber):  ditto.
* dmydln.c (dln_load):  ditto.
* vm_insnhelper.c (vm_search_normal_superclass):  ditto.
* bignum.c (big_fdiv):  ditto.
* marshal.c (r_symlink):  ditto.
* marshal.c (r_symbol):  ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-13 23:45:37 +00:00
shirosaki 2f7290d4b3 * 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/trunk@35296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-11 12:05:19 +00:00
naruse 2f6ff54e31 * 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/trunk@35255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-04-07 21:53:05 +00:00
usa 9073db5cb1 * io.c (io_unread): fixed memory leak. report by nagachika via IRC.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-27 14:44:32 +00:00
shirosaki 7cbff3b9dd * 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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35111 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-22 14:05:31 +00:00
naruse db83618d2c * io.c (io_encoding_set): always warn if external encoding and internal
encoding are identical. [ruby-core:40727] [Bug #5568]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34997 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-13 04:03:06 +00:00
nobu 33ceea5cdb * encoding.c (rb_find_encoding): new function find encoding from
arbitrary object as a pointer to rb_encoding, and return NULL if
  not found.
* io.c (io_encoding_set): just warn unsupported encodings, but not
  exception.  [ruby-core:40726] [Bug #5567]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-12 10:23:17 +00:00
sorah 605f4baef7 * io.c: fix rdoc of `IO.binwrite` to show same as `IO.write` except
it opens file with mode "wb:ASCII-8BIT". [Bug #5782] [ruby-core:42592]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-11 06:49:49 +00:00
nobu 825430438d * io.c (pipe_open): cmd is no longer used if fork is available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-03-02 07:36:00 +00:00
nobu 97d6e56b0e * io.c (io_binwrite, rb_io_syswrite): use shared frozen source
strings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34847 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-28 09:47:47 +00:00
nobu 9b02a72d71 * io.c (io_fread, io_getpartial, rb_io_sysread): set buffer size
after check if readable, which can cause thread switch.
  [ruby-dev:45297][Bug #6099]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-28 09:33:35 +00:00
usa d74ccf8fc1 * io.c (rb_io_set_pos): add rdoc about textmode.
* test/ruby/test_io.rb (TestIO#test_setpos): use binmode.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34834 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-27 11:46:43 +00:00
nobu 80429eed63 * io.c, process.c, time.c, ext: use rb_sys_fail_str instead of
rb_sys_fail.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-27 01:50:27 +00:00
nobu eec0b2d88a * 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/trunk@34795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-24 22:53:51 +00:00
nobu adcb7e9e7b * dir.c, file.c, io.c (rb_sys_fail_path): use rb_sys_fail_str.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34788 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-24 07:48:34 +00:00
nobu 9acf2091e1 * dir.c, file.c, io.c: use rb_sys_fail_path.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-24 07:37:48 +00:00
nobu b8729f117c * io.c (set_binary_mode_with_seek_cur): reorder function qualifiers.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34785 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-24 07:13:24 +00:00
drbrain 0585853c69 * io.c (rb_io_f_sync): Fix double-negative typo. [ruby-trunk - #5837]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-23 02:00:39 +00:00
nobu 4341c58c39 * io.c (rb_io_extract_modeenc): fail only if conflicting
text/binary modes given explicitly.  [ruby-dev:45268][Bug #6055]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34753 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-22 17:33:10 +00:00
nobu 31d8a97657 * io.c (rb_io_s_foreach): argument check before making Enumerator.
[ruby-dev:31525]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-22 08:36:25 +00:00
nobu 873b56fd50 * io.c (rb_io_s_foreach): return enumerator including kerword
arguments.  [ruby-dev:45267][Bug #6054]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-22 08:07:38 +00:00
naruse 7eed0ca619 * io.c (io_strsetbuf): call rb_str_modify to make str independent
before calling rb_str_set_len for r34580.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-15 08:45:15 +00:00
nobu 52cb46337e * io.c (io_setstrbuf): cut down the buffer if longer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-14 07:00:33 +00:00
nobu df77202b37 * io.c (io_setstrbuf): defer resizing buffer string until data is
read actually.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34580 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-13 09:30:40 +00:00
nobu b7ef9fa2a4 * 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/trunk@34576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-13 01:24:45 +00:00
naruse 2a6ccf6c13 * 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/trunk@34417 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-02-02 08:52:55 +00:00
nobu 0470ce53c5 * 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.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-31 21:39:00 +00:00
naruse aa5b65b2ed * io.c (extract_binmode): raise an exception if binmode/textmode
is specified with both vmode and opthash.
  [ruby-core:42199] [Bug #5918]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-23 07:56:25 +00:00
naruse e7d83904cb * io.c (rb_io_extract_modeenc): set ASCII-8BIT if binmode is specified
with opthash. [ruby-core:42197] [Bug #5917]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34358 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-23 07:56:20 +00:00
drbrain 90943649fe * io.c (rb_io_s_read): Fix formatting of open_args comment. Reported
by Adam Prescott.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34296 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-01-13 21:59:36 +00:00
shirosaki 68fde4449a * 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/trunk@34132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-26 13:49:31 +00:00
marcandre 15e6d26049 * io.c: Improve rdoc for {File|IO}.write
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-20 07:07:46 +00:00
nobu 73768d54d3 * io.c (argf_type): make typed data.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34055 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-15 08:57:01 +00:00
usa 0c6103cf50 * 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]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-14 10:38:12 +00:00
drbrain 12e7e79727 * 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/trunk@33968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-07 01:49:40 +00:00
nobu b526738c3b * bignum.c (big_rshift), compile.c (validate_label,
iseq_build_from_ary_exception), cont.c (cont_capture), dir.c
  (dir_open_dir), gc.c (objspace_each_objects), io.c (pipe_open)
  (rb_io_advise), parse.y (parser_compile_string)
  (rb_parser_compile_file), proc.c (binding_free), process.c
  (rb_proc_exec_n, rb_seteuid_core, proc_setegid, rb_setegid_core)
  (p_uid_exchange, p_gid_exchange), regparse.c (strdup_with_null),
  signal.c (sig_dfl), vm.c (rb_iseq_eval, rb_iseq_eval_main),
  vm_insnhelper.c (vm_expandarray): suppress
  unused-but-set-variable warnings.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33951 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-05 09:57:00 +00:00
nobu 39a9b9ba7e * io.c: suppress unused-value warnings. fixup of r33937.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33944 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-04 23:56:59 +00:00
luislavena f9a6a1dd0c Introduce NEED_READCONV and NEED_WRITECONV to replace universal newline decorator
Use CRLF only when required to improve file reading and writing under Windows.
Patch by Hiroshi Shirosaki. [ruby-core:40706] [Feature #5562]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33937 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-04 01:10:06 +00:00
akr eecacaa024 * io.c (linux_get_maxfd): change local variable name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-12-01 13:31:58 +00:00
nobu 82d138f749 * io.c (rb_write_error2): suppress unused variable warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-29 00:58:28 +00:00
nobu fb8ff8de93 * io.c (rb_write_error2): fwrite() returns ssize_t.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-28 03:57:31 +00:00
usa 02f9b4d606 * io.c (rb_io_flush): release GVL during fsync() on Windows.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-28 02:47:51 +00:00
kosaki 8cee31214d * io.c (rb_write_error2): get rid of warning on linux. fwrite
of glibc is tagged __attribute__ ((__warn_unused_result__))
  if _FORTIFY_SOURCE != 0.
* vm_dump.c (rb_vm_bugreport): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33871 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-27 12:06:10 +00:00
akr 5f652716ca * io.c (copy_stream_body): use 0666 for permission argument for open.
[ruby-core:40865]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-26 15:18:05 +00:00
kosaki aa23f6b9fd * io.c (ioctl_narg_len, linux_iocparm_len): reinstantiate linux
specific narg length calculation.
* test/ruby/test_io.rb (test_ioctl_linux2): add new test for old and
  unstructured ioctl.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-25 02:45:50 +00:00
akr bee4e843ce * io.c (rb_io_reopen): re-initialize buffereing mode for stdout and
stderr.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-24 11:00:35 +00:00
kosaki d7166624bf Merge branch 'fsync-nogvl' into trunk
Conflicts:
	ChangeLog

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-24 02:57:57 +00:00
naruse fd8d9d9dce * io.c (ioctl_narg_len): don't use _IOC_SIZE macro on Linux.
On Linux some constants for ioctl(2) doesn't include the size of
  its return value and 16bit value; for example FIONREAD 0x541B.
  Moreover the manual, ioctl_list(2),  says "Note  that  the  size
  bits  are  very unreliable: in lots of cases they are wrong,
  either because of buggy macros using sizeof(sizeof(struct)),
  or because of legacy values."
  So we shouldn't use it.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-23 11:24:49 +00:00
akr 08f8dfc20b * io.c (linux_get_maxfd): get rid of a warning.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-21 15:26:12 +00:00
akr f49f6ff1d7 * io.c (linux_get_maxfd): new function to find maximum fd on Linux.
(rb_close_before_exec): use linux_get_maxfd.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-21 14:40:09 +00:00
usa 44cff77b95 * io.c (rb_cloexec_open): set O_NOINHERIT instead of O_CLOEXEC if it is
available (for Windows).

* win32/win32.c (fcntl): on F_DUPFD, determine the inheritance of the
  new handle by O_NOINHERIT flag of original fd.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-18 04:06:01 +00:00
usa bbe004c1e4 * 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/trunk@33770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-16 02:36:08 +00:00
akr 3d25acdccc * io.c, thread.c, ext/pty/pty.c, ext/fiddle/closure.c: use
__linux__ macro for consistency.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-15 11:09:47 +00:00
nobu 80c32b2330 * io.c (do_ioctl, ioctl_narg_len, setup_narg, rb_ioctl): use
ioctl_req_t.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33727 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 08:26:13 +00:00
nobu 9998578951 * ChangeLog, io.c: whitespace-cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 07:49:48 +00:00
kosaki 33817fbc29 * io.c (fcntl_narg_len): introduce narg calculation for fcntl instead
of hard coded 256.
* io.c (setup_narg): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:33:58 +00:00
kosaki 791f5449c1 * io.c (ioctl_narg_len): Linux doesn't have IOCPARM_LEN macro, but
has _IOC_SIZE. support it.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33718 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:29:37 +00:00
kosaki b3027d5929 * io.c (rb_ioctl): don't expose our sanity check value to ruby script.
It may change string value meaning if the value is string.
  (e.g. MacOS X has  F_GETPATH ioctl)
* io.c (rb_fcntl): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:27:51 +00:00
kosaki 7e2f0491ce * io.c (ioctl_req_t): Type of req argument of ioctl() depend on platform.
Moreover almost all linux ioctl can't be represented by 32bit integer
  (i.e. MSB is 1). We need wrap ioctl argument type.
[Bug #5429] [ruby-dev:44589]
* io.c (struct ioctl_arg): ditto.
* io.c (rb_ioctl): ditto.
* test/ruby/test_io.rb (test_ioctl_linux): add a testcase for ioctl



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:24:51 +00:00
kosaki fc7bb927a2 * io.c (struct io_cntl_arg): remove io_p member.
* io.c (nogvl_fcntl, do_fcntl, rb_fcntl): separated from ioctl functions.
* io.c (nogvl_io_cntl): remove fcntl depended logic.
* io.c (io_cntl): ditto.
* io.c (rb_io_ctl): ditto.
* io.c (rb_io_ioctl): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:17:41 +00:00
kosaki f13d10a0af * io.c (setup_narg): fix off by one bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:12:19 +00:00
kosaki eec252e2e5 * io.c (+setup_narg): factor out length calculation logic.
* io.c (rb_io_ctl): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:09:56 +00:00
kosaki 9d16ad639f * io.c (+ioctl_narg_len) new helper function.
* io.c (rb_io_ctl): don't use ioctl specific length check
  if caller is fcntl.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33711 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-12 02:06:23 +00:00
kosaki 0d746627af * io.c (pipe_open): Remove fflush(stdin). it's no effect.
Pointed out by Ikegami Daisuke <ikegami.da@gmail.com>.
  Thank you.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-11 03:41:13 +00:00
nobu 1393e55d09 * 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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-09 14:20:27 +00:00
nobu 42b4255d08 * io.c (rb_sysopen): max fd is updated in rb_sysopen_internal()
already.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-09 13:54:33 +00:00
usa 53881a8c6d * 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33667 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-08 05:52:32 +00:00
akr bd3b3c1b51 update doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33664 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 21:01:40 +00:00
usa add77a592b * 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 17:48:11 +00:00
usa 66595f3894 * io.c (io_fflush): remove fsync().
* io.c (rb_io_flush, rb_io_rewind): fsync() here.

these changes reduces fsync() calls to improve performance.
first reported at [ruby-list:48515] by ak7 at mail.goo.ne.jp .
[Bug #5585]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33651 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 11:08:39 +00:00
akr 987c03a387 * io.c (rb_close_before_exec): use F_MAXFD if available.
F_MAXFD is available on NetBSD since NetBSD 2.0.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33650 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-07 10:44:02 +00:00
akr 333c847f19 * io.c (rb_cloexec_fcntl_dupfd): don't clear try_dupfd_cloexec if
fcntl(F_DUPFD) failed as fcntl(F_DUPFD_CLOEXEC).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-05 10:13:00 +00:00
nobu 413f24d3b0 * whitespace cleanup.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-04 07:19:23 +00:00
usa a3ce319639 * io.c (make_writeconv): fixed typo of previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33629 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 19:06:43 +00:00
usa 102ec1171d * io.c (make_writeconv): fixed typo of previous commit.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 18:45:41 +00:00
usa 932d63efe0 * 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/trunk@33627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-03 16:59:53 +00:00
naruse f0bd639693 * io.c (rb_cloexec_pipe): remove workaround of r33587.
The bug of NetBSD is fixed on Mon Oct 31 21:31:29 UTC 2011.
  http://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=45545

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 12:43:47 +00:00
akr 809006f407 * io.c (rb_io_reopen): call rb_fd_fix_cloexec instead of
rb_maygvl_fd_fix_cloexec.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 10:49:40 +00:00
akr 89a1258110 * io.c (rb_io_reopen): call rb_maygvl_fd_fix_cloexec after freopen().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 10:01:01 +00:00
naruse f926980902 * io.c (nogvl_io_cntl): rb_cloexec_fcntl_dupfd's 2nd argument is int.
* process.c (move_fds_to_avoid_crash): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 05:56:51 +00:00
akr c16f98ab0a * io.c (rb_maygvl_fd_fix_cloexec): renamed from fd_set_cloexec.
* internal.h (rb_maygvl_fd_fix_cloexec): declared.

* ext/socket/init.c (cloexec_accept): use rb_maygvl_fd_fix_cloexec.
  (rsock_s_accept_nonblock): use rb_update_max_fd.
  (rsock_s_accept): use rb_update_max_fd.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-11-01 03:04:03 +00:00
akr 24176a8d5d add comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33595 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 23:24:25 +00:00
naruse 6a96646de2 Fix previous commit (r33586).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 13:50:32 +00:00
naruse ca6311b0b5 * io.c (rb_cloexec_pipe): NetBSD 6.0 will support pipe2(2),
but its return value is -1 or larger than 0.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 13:21:03 +00:00
akr 1a70dfe6f4 * include/ruby/intern.h (rb_fd_fix_cloexec): renamed from
rb_fd_set_cloexec.

* io.c: follow the above renaming.

* 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.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33585 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 12:49:16 +00:00
akr 687c41dc4d * io.c (fd_set_cloexec): clear CLOEXEC flag for standard file
descriptors.
  (rb_cloexec_dup): use rb_cloexec_fcntl_dupfd.
  (rb_cloexec_fcntl_dupfd): use F_DUPFD_CLOEXEC if available.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 11:17:15 +00:00
akr da5ae5544d * io.c (rb_cloexec_dup2): check oldfd == newfd at first.
pointed by KOSAKI Motohiro.  [ruby-dev:44713]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 03:07:26 +00:00
usa bdc85361e4 * io.c (rb_cloexec_fcntl_dupfd): this function needs F_DUPFD.
* io.c (nogvl_io_cntl): use rb_cloexec_fcntl_dupfd() only if the
  platform has F_DUPFD.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-31 01:52:21 +00:00
akr 5c19f07700 * include/ruby/intern.h (rb_cloexec_fcntl_dupfd): declared.
* io.c (rb_cloexec_fcntl_dupfd): new function.
  (nogvl_io_cntl): use rb_cloexec_fcntl_dupfd.

* process.c (move_fds_to_avoid_crash): use rb_cloexec_fcntl_dupfd.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 15:17:27 +00:00
akr e7f8c03818 * configure.in: check pipe2.
* io.c (rb_cloexec_pipe): use pipe2 if available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 13:48:35 +00:00
akr 0d2a92e0b3 * include/ruby/intern.h (rb_cloexec_pipe): declared.
* io.c (rb_cloexec_pipe): new function.
  (rb_pipe): use rb_cloexec_pipe.

* thread_pthread.c (rb_thread_create_timer_thread): use
  rb_cloexec_pipe.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 12:13:05 +00:00
akr 6e0ed044b6 * io.c (rb_cloexec_dup): refine control flow.
(rb_cloexec_dup2): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 11:07:09 +00:00
nobu 54816d10eb * io.c (rb_cloexec_dup, rb_cloexec_dup2): CLOEXEC has been set if
dup3 succeeded.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 01:47:23 +00:00
akr f0b021c0ce * io.c (rb_cloexec_dup): don't allocate standard file descriptors.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-30 01:02:46 +00:00
akr e745a03cfa * io.c (rb_cloexec_dup2): don't set CLOEXEC for standard file
descriptors.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33563 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 23:30:34 +00:00
akr cb9f3040d7 * configure.in: check dup3.
* io.c (rb_cloexec_dup2): use dup3 if available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 22:48:41 +00:00
akr 0a9cb21e62 * include/ruby/intern.h (rb_cloexec_dup2): declared.
* io.c (rb_cloexec_dup2): new function.
  (io_reopen): use rb_cloexec_dup2.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 13:11:01 +00:00
akr 54d7e82613 * io.c (rb_cloexec_dup): use F_DUPFD_CLOEXEC if available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 11:59:46 +00:00
akr a9648d1e58 add a comment.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 11:58:30 +00:00
akr 4ae2b92576 * include/ruby/intern.h (rb_cloexec_dup): declared.
* io.c (rb_cloexec_dup): new function.
  (ruby_dup): use rb_cloexec_dup.

* ext/pty/pty.c (pty_getpty): use rb_cloexec_dup.
  
* ext/openssl/ossl_bio.c (ossl_obj2bio): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 11:02:32 +00:00
akr baa2d74dae * io.c (rb_cloexec_open): use O_CLOEXEC if available.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 05:27:32 +00:00
akr 3ae3cd741d * include/ruby/intern.h (rb_cloexec_open): declared.
* io.c (fd_set_cloexec): extracted from rb_fd_set_cloexec.
  (rb_cloexec_open): new function.
  (sysopen_func): use rb_cloexec_open.
  (rb_sysopen_internal): use rb_update_max_fd instead of
  rb_fd_set_cloexec.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-29 02:33:28 +00:00
akr b317a4cd28 * io.c: use "__sun" instead of "sun" to detect SunOS.
* dln.c: ditto.

* cont.c: ditto.

* ext/sdbm/_sdbm.c: ditto.

[ruby-dev:44693]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33520 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-24 13:49:58 +00:00
akr a28fe36c89 * io.c (copy_stream_fallback_body): check nil for EOF of read method.
patch by Eric Wong.  [ruby-core:39134] [Bug #5237]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33515 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-23 23:19:14 +00:00
akr e7ff29581b * io.c (rb_fd_set_cloexec): set close-on-exec flag only if F_GETFD is
defined.  reported by Luis Lavena.  [ruby-core:40281] [Bug #5470]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-22 23:03:02 +00:00
akr b574a4d4a1 * include/ruby/intern.h (rb_fd_set_cloexec): declared.
* io.c (rb_fd_set_cloexec): new function.
  (ruby_dup): call rb_fd_set_cloexec to set close-on-exec flag.
  (rb_sysopen_internal): ditto.
  (rb_pipe): ditto.
  (io_reopen): ditto.
  (io_cntl): ditto.

* process.c (rb_f_exec): change the default :close_others option to
  true.
  (rb_f_system): ditto.
  (move_fds_to_avoid_crash): call rb_fd_set_cloexec to set
  close-on-exec flag.
  (ruby_setsid): ditto.
  (rb_daemon): ditto.

* thread_pthread.c (rb_thread_create_timer_thread): call
  rb_fd_set_cloexec to set close-on-exec flag.

* ruby.c (load_file_internal): ditto.

* file.c (rb_file_s_truncate): ditto.
  (file_load_ok): ditto.

* random.c (fill_random_seed): ditto.

* ext/pty/pty.c (chfunc): ditto.
  (get_device_once): ditto.

* ext/openssl/ossl_bio.c (ossl_obj2bio): ditto.

* ext/socket/init.c (rsock_socket): ditto.
  (rsock_s_accept_nonblock): ditto.
  (rsock_s_accept): ditto.

* ext/socket/socket.c (rsock_sock_s_socketpair): ditto.

* ext/socket/ancdata.c (discard_cmsg): ditto.
  (make_io_for_unix_rights): ditto.

* ext/socket/unixsocket.c (unix_recv_io): ditto.

* ext/io/console/console.c (console_dev): ditto.

[ruby-core:38140] [Feature #5041]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-22 09:58:15 +00:00
ktsj 02e4428ec5 * io.c: fix documentation of ARGF.lineno=.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-10-02 01:56:51 +00:00
nobu 8e6e8e6288 * use RB_TYPE_P which is optimized for constant types, instead of
comparison with TYPE.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33357 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-29 11:07:45 +00:00
matz 1796817e46 * io.c (Init_IO): update BINARY comment. it should not change the
encoding of the result to ASCII-8BIT.  [ruby-talk:387719]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33260 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-12 20:38:17 +00:00
nobu 74f724de1a * 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/trunk@33171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-03 14:52:18 +00:00
nobu 7dc7da3d86 * 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/trunk@33165 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-09-02 12:11:17 +00:00
usa f9e9eee677 * util.c, include/ruby/util.h (ruby_add_suffix): remove the function.
[Bug #5153] [ruby-core:38736]

* io.c (argf_next_argv): remove the call of above function.

* ext/-test-/add_suffix, test/-ext-/test_add_suffix.rb: remove the test
  extension module because this is only for testsing ruby_add_suffix().

* LEGAL: remove the mention about a part of util.c, because now we
  removed the part.

* io.c (argf_next_argv): now the new filename is not guranteed to
  use, so should check the return value of rename(2).

* test/ruby/test_argf.rb (TestArgf#test_inplace_rename_impossible):
  now we expect same result with other platforms on no_safe_rename
  platforms (=Windows).


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-08-03 07:10:56 +00:00
nobu f46cff647e * io.c (rb_pipe): pipe on cygwin can succeed half but fail
half.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-31 09:59:01 +00:00
naruse 4ac69a57b5 * io.c (rb_io_each_byte): remove unused variable e.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30 16:31:36 +00:00
nobu 321346cfa5 * io.c (rb_io_each_byte): rbuf can be refreshed during yield.
[Bug #5119]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32758 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-30 14:14:46 +00:00
akr 2bcd502a71 * 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/trunk@32638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-23 08:13:37 +00:00
kazu 55b0c9fb6c * io.c (rb_update_max_fd): remove parentheses. they are not in macro.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-20 15:00:00 +00:00
akr b41ccc4a9c * 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.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32587 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-20 13:26:10 +00:00
akr b1c03685bc * io.c (UPDATE_MAXFD): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32581 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-19 07:27:26 +00:00
akr 2c7576a021 * 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.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32579 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-19 07:10:19 +00:00
usa f15d0deaaf * win32/win32.c, include/ruby/win32.h (rb_w32_io_cancelable_p): renamed
from rb_w32_has_cancel_io().  now it takes a parameter as fd to check
  the fd is console or not, because we cannot cancel console input even
  if we have cancel_io function.

* io.c (WAIT_FD_IN_WIN32): call above function instead of the old one,
  so now we can kill the thread which calls STDIN.gets.
  the problem was reported by ko1 vir IRC.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-07-15 05:33:45 +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
nobu 3a47cf3395 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15 11:55:52 +00:00
kosaki 836a8cf214 * io.c (select_internal): remove unused variable (interrupt_flag).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31533 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-12 17:16:21 +00:00
kosaki be62297f92 * io.c (Init_IO): Added File::CLOEXEC constant. [ruby-core:22893] [Feature #1291]
* test/ruby/test_io.rb (TestIO#test_o_cloexec): test for File::CLOEXEC.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-04 11:29:24 +00:00
kosaki d7fa4d837e * io.c (rb_f_select): remove useless ifdef.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-04 02:54:34 +00:00
kosaki 9be37ca7d5 * thread.c (rb_wait_for_single_fd): new.
* thread.c (select_single): select(2) based backend for rb_wait_for_single_fd().

* io.c (make_writeconv): use rb_wait_for_single_fd() instaed of
  rb_thread_fd_select().
* io.c (rb_io_wait_readable): ditto.
* thread.c (rb_thread_wait_fd_rw): ditto.

* io.c (wait_readable): removed.
* thread.c (init_set_fd): new helper function.
* include/ruby/io.h (RB_WAITFD_IN, RB_WAITFD_PRI, RB_WAITFD_OUT):
  new constant for rb_single_wait_fd().

The patch was written by Eric Wong. [Ruby 1.9 - Feature #4531]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31419 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-04 00:59:57 +00:00
kosaki 2d2544c8e6 * include/ruby/intern.h (rb_thread_select): mark as deprecated.
* ext/io/wait/wait.c (wait_readable): use rb_thread_fd_select
  instead of rb_thread_select.
* ext/socket/init.c (wait_connectable0): ditto.
* ext/readline/readline.c (readline_event): ditto.
* io.c (rb_io_wait_readable, wait_readable, rb_io_wait_writable,
  wait_writable): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31394 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-30 11:15:15 +00:00
kosaki 98c7ca9b65 * io.c (copy_stream_body, rb_io_s_copy_stream): move rb_fd_init()
from copy_stream_body to rb_io_s_copy_stream. fds of passing
  rb_fd_term() have to be guaranteed initialized.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31391 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-30 07:30:45 +00:00
nobu 85c1d5d41d * io.c (make_writeconv): do not add textmode newline decorator if any
newline decorator is set already.  fixes #4618, fixes #4619

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-29 01:24:54 +00:00
nobu 9c48e59907 * io.c (rb_io_extract_modeenc, rb_f_backquote): set default text
mode.  fixes #4619
* io.c (pipe_open): set universal newline decorator if needed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31367 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-27 21:06:59 +00:00
nobu 8761467727 * io.c (validate_enc_binmode, rb_io_extract_modeenc): set newline
decorator according to open mode.
* transcode.c (rb_econv_prepare_options): new function, to prepare
  econv options with newline flags.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-26 15:55:21 +00:00
kazu fb7f3bf37c * io.c (rb_f_syscall): reduce warning: "HAVE___SYSCALL" is not defined.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31272 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-14 07:02:54 +00:00
kazu c5a284aa17 * io.c (rb_io_fdatasync): remove unused variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-13 11:22:34 +00:00
kosaki 0f771e33e2 * io.c: revert r31230.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-11 12:52:22 +00:00
kosaki 3ba502d5f0 * io.c (rb_io_syswrite): While local FS writes are usually
buffered, the buffers can be full or the file opened with
  O_SYNC. IO#syswrite can also be used on blocking IOs
  (pipe/socket) just like IO#write.
  The patch is written by Eric Wong. [ruby-core:35554]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31237 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-04 12:43:28 +00:00
kosaki f4755f214c * configure.in: disable fdatasync again on Mac OS X.
[ruby-core:35493][Bug #4500]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31232 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-03 12:35:29 +00:00
kosaki f35a7770cd * io.c (io_reopen): IO#close releases GVL if possible.
close() may block for certain file types (NFS, SO_LINGER
  sockets, inotify), so let other threads run. The patch was
  created by Eric Wong [ruby-core:35555][Bug #4527]

* io.c (fptr_finalize): ditto.

* io.c (maygvl_fclose): new.
* io.c (nogvl_fclose): ditto.
* io.c (maygvl_close): ditto.
* io.c (nogvl_close): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-04-03 12:23:59 +00:00
kosaki b2a8d109b6 * io.c (io_cntl): use rb_thread_io_blocking_region() instead
rb_thread_blocking_region().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31029 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-05 18:23:55 +00:00
kosaki c0359f8176 * io.c (io_cntl, nogvl_io_cntl): IO.fcntl() and IO.ioctl()
release GVL during calling kernel interface.
  Suggested by Eric Wong. [ruby-core:35417][Bug #4463]

* test/ruby/test_io.rb (TestIO#test_fcntl_lock): add new test for
  IO.fcntl().



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31025 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-04 16:38:34 +00:00
kosaki ff07709777 * io.c (io_cntl): change 'cmd' type to int. ioctl and fcntl need to
be passed int.
* io.c (rb_io_ctl): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-03-04 13:02:45 +00:00
nobu e7c0a6e1d7 * prevent temporary objects from GC, and should not use
RSTRING_PTR() for function calls since it evaluates the argument
  a couple of times.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30922 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-20 07:23:55 +00:00
nobu 58b325366d * thread.c (rb_thread_io_blocking_region): new function to run
blocking region with GIL released, for fd.
* thread.c (rb_thread_fd_close): implement.  [ruby-core:35203]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-12 05:44:23 +00:00
kosaki 0559227e87 * io.c (rb_io_s_sysopen): use NUM2MODET() instead NUM2UINT().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-08 07:04:45 +00:00
kosaki 3722e3a29a * io.c (rb_io_fdatasync): Use fsync(2) if if the underlying
operating system does not support fdatasync(2).



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30762 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-02-02 08:11:29 +00:00
kanemoto 2a5177e757 io.c (struct argf): char behaves like an unsigned char by default on AIX.
http://publib.boulder.ibm.com/infocenter/comphelp/v111v131/index.jsp?topic=/com.ibm.xlcpp111.aix.doc/language_ref/ch.html


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-30 01:02:46 +00:00
kosaki 4afa5fead8 * io.c (rb_io_open): Use NUM2MODET() instead NUM2UINT().
* io.c (rb_scan_open_args): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-28 02:23:58 +00:00
nobu 7909af18ed * io.c (argf_next_argv): go advance when the next file cannot be
read.  [ruby-core:34446]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30536 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-13 22:30:50 +00:00
kosaki b1f8bbf4f7 * io.c (rb_f_syscall): Add warning messages. [ruby-core:34062]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-12 14:22:39 +00:00
kosaki da235830b5 * io.c (rb_f_syscall): Some syscall return unsigned or pointer value.
Therefore we should only check the result is -1 or not. [ruby-core:34062]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-12 14:16:01 +00:00
kosaki caab5dcee7 * io.c (rb_f_syscall): Add 64bit Linux support. Some syscall takes
long type arguments.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30525 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-12 14:11:06 +00:00
yugui 45493bb28a * io.c (Kernel.#syscall): implemented on LP64/LLP64 environments too.
also uses __syscall if available for *BSD on 64bit architecture.
  [ruby-core:34062]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30499 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-09 07:39:22 +00:00
akr d3b337c58d fix spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30495 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-01-08 13:07:20 +00:00
nobu ae167e1e79 * io.c (maygvl_copy_stream_wait_readwrite): define if USE_SENDFILE
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-29 12:20:16 +00:00
kazu 1f4401ebe0 fix a typo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30410 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-27 22:27:13 +00:00
kosaki 085e40d45b * io.c (advice_arg_check): Change argument check.
Now, an unsupported advice makes NotImplementedError.
    [ruby-dev:42887] [Ruby 1.9-Feature#4204]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30375 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-25 17:25:02 +00:00
kosaki c9958d6ab4 * io.c (pipe_open): Added rb_thread_atfork(). We must reinitialize
GVL at new process creation.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-25 10:22:48 +00:00
nobu 522c538e93 * io.c (rb_io_extract_encoding_option): accept Encoding object as
encoding: optional argument.  [ruby-dev:42884]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30349 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-25 05:27:12 +00:00
tarui da4d3e8464 * io.c : add an extra byte to buffer for the specification of read
in Windows. see [ruby-core:33460] and r29980. and, we have to
	  discuss how to do this one byte.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-20 16:45:08 +00:00
kosaki a3ba982c75 * io.c (Init_IO): Added O_DIRECT. This feature was propsed by Run Paint Run Run.
[Feature #4015] [ruby-core:33018]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30247 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-19 16:18:16 +00:00
nobu 2d39e5265f * io.c: removed garbage line.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-16 22:08:50 +00:00
nobu 594ab9c8fd * io.c (rb_io_advise): removed unused variable, and fix indent.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30234 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-12-16 22:06:33 +00:00