Commit graph

800 commits

Author SHA1 Message Date
yugui
6ac1783d4b merges r22146 from trunk into ruby_1_9_1.
* io.c (io_encoding_set): ignore second argument when external and
  internal are same. [ruby-dev:37939]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22523 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 09:48:57 +00:00
yugui
b08d687d0a merges r22121 from trunk into ruby_1_9_1.
* io.c (rb_io_s_binread): ensures file path.  [ruby-dev:37940]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 09:48:27 +00:00
yugui
930729e695 merges r22099 from trunk into ruby_1_9_1.
* io.c (io_fread): use rb_io_wait_readable for retry
  avoid Errno::EINTR on ruby -e 'trap(:CHLD) {}; spawn("sleep 1"); STDIN.read'

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22518 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 09:48:19 +00:00
yugui
0cc6f32d32 merges r22037 from trunk into ruby_1_9_1.
rdoc update.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@22511 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-02-22 09:47:29 +00:00
yugui
6c04b9531c merges r21715 and r21718 from trunk into ruby_1_9_1.
* io.c (rb_io_ungetbyte, rb_io_ungetc): clears EOF flag.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-28 09:20:46 +00:00
yugui
62b07ab133 merges r21709, r21710 from trunk into ruby_1_9_1.
* include/ruby/io.h (FMODE_EOF): EOF flag on TTY.
* io.c (io_set_eof): sets EOF flag for TTY.
* io.c (io_seek): clears EOF flag.
* io.c (io_fillbuf): returns EOF if already met EOF.  [ruby-dev:37798]
* io.c (io_fillbuf, io_fread, io_getpartial): sets EOF.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-28 09:20:37 +00:00
yugui
fea523c18b merges r21504 from trunk into ruby_1_9_1.
* io.c (rb_io_wait_readable, rb_io_wait_writable): need rb_fd_ptr.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-15 15:38:31 +00:00
yugui
a0eb50c4d9 merges r21503 from trunk into ruby_1_9_!.
* io.c (appendline): reformed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-15 15:38:17 +00:00
yugui
12e5996d83 merges r21492 and r21495 from trunk into ruby_1_9_1.
* io.c (rb_io_close_read): call rb_io_fptr_cleanup() instead of
	  fptr_finalize() because the fptr has special finalizser if it is a
	  pipe.  [ruby-dev:37757] (3)

	* io.c (io_reopen, rb_io_init_copy): should register fptr to
	  pipe_list when copying pipe fptr.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-15 15:37:51 +00:00
yugui
298efbfad6 merges r21491 from trunk into ruby_1_9_1.
* io.c (rb_io_initialize): workaround for Windows. [ruby-dev:37686]
          (also see [ruby-dev:37721])

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-15 15:37:42 +00:00
yugui
a78c02923b merges r21288 from trunk into ruby_1_9_1.
* io.c (maygvl_copy_stream_wait_read): renamed to add prefix to
  express GVL state.
  (nogvl_copy_stream_wait_write): ditto.
  (nogvl_copy_stream_sendfile): ditto.
  (maygvl_copy_stream_read): ditto.
  (nogvl_copy_stream_write): ditto.
  (nogvl_copy_stream_read_write): ditto.
  (nogvl_copy_stream_func): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-04 14:05:19 +00:00
yugui
8ed6868de0 merges r21211 and r21213 from trunk into ruby_1_9_1.
update rdoc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-01 06:42:39 +00:00
yugui
89c2ab70a4 merges r21209 from trunk into ruby_1_9_1.
* io.c (copy_stream_body): don't check to_io because
  Zlib::GzipWriter#to_io returns the underlying IO.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21229 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-01 06:42:23 +00:00
yugui
90326df926 merges r21068 from trunk into ruby_1_9_1.
* io.c (fptr_finalize): don't allocate objects if noraise.
  (finish_writeconv): add noalloc argument to be able to avoid
  object allocation.
  (finish_writeconv_arg): introduced again.
  (finish_writeconv_sync): follow the above change.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-26 11:16:43 +00:00
yugui
d2165fe2bb merges r21059 from trunk into ruby_1_9_1.
* io.c (fptr_finalize): close the IO object even if finish_writeconv or
  flush is failed.
  (finish_writeconv): don't raise.  return errno or exception.
  (finish_writeconv_arg): removed.
  (finish_writeconv_sync): follow finish_writeconv change.

* transcode.c (rb_econv_make_exception): new function.

* include/ruby/encoding.h (rb_econv_make_exception): declared.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21069 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-26 11:16:07 +00:00
yugui
096d5338bd merges r20990 from trunk into ruby_1_9_1.
* io.c (rb_io_initialize): check fd validity.  [ruby-dev:36646]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21041 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-25 09:58:18 +00:00
yugui
f1f90757c4 merges r20989 from trunk into ruby_1_9_1.
* io.c (flush_before_seek): check io_fflush result.
  (rb_io_check_readable): ditto.
  (rb_io_flush): ditto.
  (rb_io_fsync): ditto.
  (remain_size): ditto.
  (rb_io_write_nonblock): ditto.
  (finish_writeconv): ditto.
  (fptr_finalize): ditto.
  (io_reopen): ditto.
  (rb_io_reopen): ditto.
  (copy_stream_body): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-25 09:58:07 +00:00
yugui
107347961b merges r20988 from trunk into ruby_1_9_1.
* io.c (io_fflush): flush write buffer without write lock in
  finalizers.  [ruby-dev:37572]

* io.c (rb_io_fptr_finalize): clear write lock before finalizing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21039 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-25 09:57:52 +00:00
yugui
5b7d89de75 merges r20987 from trunk into ruby_1_9_1.
* io.c (fptr_finalize): close the IO object even if close(2) is failed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-25 09:57:40 +00:00
yugui
b9bab42804 merges r20982 and r20983 from trunk into ruby_1_9_1.
* io.c (rb_io_flush): fsync() after buffer is flushed on win32.
	  [ruby-core:20043]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21035 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-25 09:57:13 +00:00
yugui
c2f1f60fc2 merges r20954 from trunk into ruby_1_9_1.
* io.c (rb_io_init_copy): call io_seek only if io_tell succeeds.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21018 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-25 09:54:32 +00:00
yugui
9c171e3d6b merges r20946 from trunk into ruby_1_9_1.
* io.c: rdoc for File::open and 1.9 feature in file modes.

* transcode.c: rdoc for String#encode

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-25 09:54:17 +00:00
yugui
9f00ed1310 merges r20934 from trunk into ruby_1_9_1.
* io.c (pipe_open): need to initialize args.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@21010 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-25 09:53:11 +00:00
yugui
1bfa299015 merges r20892 from trunk into ruby_1_9_1.
* dln.c (dln_find_1): supplements an extension for executable
  files on DOSish platforms.

* io.c (pipe_open): use rb_w32_aspawn() for array form.

* win32/win32.c (rb_w32_pipe_exec): no longer used.

* win32/win32.c (rb_w32_spawn, rb_w32_aspawn): deals with batch
  files and commands with extensions.  [ruby-core:20695]

* win32/win32.c (has_redirection): supports environment variables
  references.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-21 05:27:20 +00:00
yugui
82d84b4971 merges r20528 from trunk into ruby_1_9_1.
* win32/win32.c (rb_w32_read): ERROR_BROKEN_PIPE is not a real error
	  at this point.

	* io.c (pipe_open): use rb_w32_spawn() instead of rb_w32_pipe_exec()
	  to use our own redirection scheme.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-21 05:27:06 +00:00
yugui
600a52cac1 merges r20870 from trunk into ruby_1_9_1.
* io.c (rb_io_extract_encoding_option): "internal_encoding: nil"
  to specify no-transcoding.  and other corner case fixed.
  [ruby-dev:37496]

* hash.c (rb_hash_lookup2): new function to look-up hash with
  default value.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20886 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-19 12:12:03 +00:00
akr
8613423945 rdoc fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20649 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-11 16:17:56 +00:00
yugui
72c96b806c merges r20532 from trunk into ruby_1_9_1.
* io.c (io_binwrite): arg.offset should be updated after retry.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20552 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-05 13:34:16 +00:00
yugui
a78d9cd85a merges r20472 from trunk into ruby_1_9_1.
update rdoc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-04 08:55:02 +00:00
yugui
65616e8940 merges r20458 and r20459 from trunk into ruby_1_9_1.
* io.c (rb_io_getc, rb_io_readchar): documentation correction from
  Emiel van de Laar.  [ruby-core:20212]

* ext/stringio/stringio.c (strio_ungetbyte): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-12-04 08:54:37 +00:00
yugui
7d0e1c3a77 merges r20144 from trunk into ruby_1_9_1.
* include/ruby/io.h (rb_io_t): added write_lock to serialize.
  [ruby-core:19668]

* gc.c (gc_mark_children): mark write_lock.

* gc.c (rb_gc_call_finalizer_at_exit): Mutex also needs to be
  deferred.

* io.c (io_fflush, io_binwrite, fptr_finalize): serializes writing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20192 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-11 11:00:29 +00:00
yugui
58b6ac5f67 merges r20045 from trunk into ruby_1_9_1.
* io.c (rb_io_rewind): should reset fptr->readconv if it's
  available.

* io.c (more_char): clear readconv at EOF.

* test/ruby/test_file.rb: should not read after EOF.  use rewind
  instead.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@20058 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-30 12:09:24 +00:00
usa
605102f3cb merge from trunk (r19984, r19985, r19991-r19998)
* io.c (extract_binmode): new function to extract binmode/textmode
	  options from hash.

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

	* io.c (rb_io_s_pipe): recognize binmode/textmode options.

	* io.c (make_readconv): now can specify the size of cbuf.

	* io.c (read_all, appendline, io_getc, rb_io_ungetc): follow above
	  change.

	* win32/win32.c (rb_w32_pipe_exec): internal fds should be always
	  binmode.

	* test/ruby/test_file.rb (test_each_char_extended_file,
	  test_getbyte_extended_file): add tests.

	* test/ruby/test_file.rb (test_*_extended_file): test in default/text/
	  binary mode.

	* test/ruby/test_file.rb (test_para_gets_extended_file): output file
	  should be binmode.

	* test/ruby/test_io.rb (test_copy_stream, test_copy_stream_socket): skip
	  some tests if there isn't IO#nonblock=.

	* test/ruby/test_io.rb (test_close_on_exec): skip if there isn't
	  IO#close_on_exec=.

	* test/ruby/test_io.rb (test_bytes, test_readbyte): depend on binmode.

	* test/ruby/test_io.rb (test_sysopen): should specify the mode of
	  IO::for_fd if F_GETFL is not available.

	* test/ruby/test_io_m17n.rb (test_getc_invalid3): should set binmode if 
	  enc is not compatible with ASCII.

	* test/ruby/test_require.rb (test_require_too_long_filename): too long
	  commandline may be rejected by OS.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@19999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-28 12:17:54 +00:00
nobu
782f3bd3f9 * io.c (argf_init): initial value of $. should be 0.
see [ruby-dev:36937].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-27 06:55:06 +00:00
usa
db8e3024e7 * io.c (read_all): the 3rd argument maybe Qnil.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-27 01:03:22 +00:00
nobu
0db5641dae * io.c (read_all): use the given buffer to read when needs readconv.
based on the patch by wanabe <s.wanabe AT gmail.com> at
  [ruby-dev:36931].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19943 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-26 04:30:45 +00:00
matz
a9a23756b5 * io.c (pipe_open): remove unnecessary flush before fork.
a patch from Kazuhiro NISHIYAMA <zn at mbf.nifty.com>
  in [ruby-dev:36840].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19888 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-22 08:27:48 +00:00
matz
c5377c2bcc * io.c (open_key_args): should adjust argc, argv in struct
foreach_arg.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 13:57:16 +00:00
matz
b6ef272d02 * ext/zlib/zlib.c: remove obsolete prototype macros.
* ext/zlib/zlib.c (struct gzfile): add encoding field to gzfile
  structure.

* ext/zlib/zlib.c (rb_gzreader_getc): now works on characters.

* ext/zlib/zlib.c (rb_gzreader_getbyte): new method to retrieve
  single byte.

* ext/zlib/zlib.c (rb_gzreader_readbyte): ditto.

* ext/zlib/zlib.c (rb_gzreader_each_byte): renamed from each_char

* ext/zlib/zlib.c (rb_gzreader_ungetc): allow unget strings.

* ext/zlib/zlib.c (rb_gzreader_ungetbyte): renamed from ungetc.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 09:18:34 +00:00
shugo
d423b884b8 * io.c, include/ruby/intern.h (rb_io_ascii8bit_binmode): externed.
* ext/socket/socket.c (init_sock): use rb_io_ascii8bit_binmode()
  instead of rb_io_binmode().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19868 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 04:31:15 +00:00
nobu
4442095d4c * io.c (rb_file_open_internal): should initialize fmode before using.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-21 01:40:41 +00:00
matz
e50a5bcef0 * io.c (rb_io_extract_modeenc): plain rb/wb should set ASCII-8BIT
to the external_encoding.

* io.c (rb_file_open_internal): ditto.

* io.c (NEED_WRITECONV): no conversion when the external_encoding
  is ASCII-8BIT.

* io.c (do_writeconv): skip ASCII-8BIT.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-20 16:57:19 +00:00
akr
7d48eab260 * io.c (rb_io_ascii8bit_binmode): renamed from rb_io_binmode.
(rb_io_binmode): don't change encoding conversion.
  (rb_io_binmode_m): call rb_io_ascii8bit_binmode.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-20 15:53:14 +00:00
akr
de55ffd024 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19829 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-18 05:07:38 +00:00
akr
0cda4bb3bf * io.c (rb_io_binmode): reset encoding conversion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-16 15:25:25 +00:00
mame
ca9589aeb0 * io.c (rb_getc, rb_io_fread, rb_io_fwrite, rb_read_pending):
remove deprecated functions which do not work.  [ruby-dev:36697]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-16 15:18:17 +00:00
akr
5c9dd204f5 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-15 09:15:46 +00:00
nobu
1288965f4e * io.c (Init_IO): $FILENAME and $* must be read-only. [ruby-dev:36698]
* variable.c (*_getter, *_setter, *_marker): made public.

* include/ruby/ruby.h (rb_gvar_*_{getter,setter,marker}): declared.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19781 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-14 11:45:32 +00:00
akr
43f910a9aa rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-11 13:44:31 +00:00
akr
470a309c4a rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-08 10:06:16 +00:00