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

646 Коммитов

Автор SHA1 Сообщение Дата
akr f58382aaf3 * io.c (Init_IO): new constants: File::DSYNC, File::RSYNC and
File::NOFOLLOW.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18723 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 10:16:20 +00:00
akr 76a3923c99 * io.c (rb_open_file): don't lookup :mode and :perm in opt. it is
useless because vmode and perm is overwritten by rb_scan_args
  anyway.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18722 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 09:43:24 +00:00
akr a5c0ee40b1 * io.c (open_key_args): meaningless MEMCPY removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18721 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 09:38:43 +00:00
akr 2901137a81 * io.c (prep_io) [cygwin]: use FMODE_BINMODE instead of O_BINARY.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 09:33:55 +00:00
akr a0e0e30864 * io.c (parse_mode_enc): extracted from mode_enc.
(io_extract_encoding_option): extracted from io_set_encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18715 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 20:20:31 +00:00
akr 608230bfa8 * io.c (rb_io_flags_modenum): make it static.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 19:17:46 +00:00
akr b929da2a1e * include/ruby/io.h (FMODE_TRUNC): new constant.
* io.c (rb_io_mode_flags): set FMODE_TRUNC for "w".
  (rb_io_modenum_flags): set FMODE_TRUNC for O_TRUNC.
  (rb_io_flags_modenum): new function.
  (rb_io_mode_modenum): just use rb_io_mode_flags and
  rb_io_flags_modenum.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 18:38:32 +00:00
akr 77ba9a5f56 * io.c (fopen): macro for vms removed. fopen is not used now.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 17:37:05 +00:00
akr 21ba5836e6 * include/ruby/io.h (rb_fopen): declaration removed.
* io.c (rb_fopen): unused function removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 12:51:52 +00:00
akr 4bba634ae7 * io.c (rb_io_flags_mode): use hexadecimal in error message.
(rb_io_modenum_mode): ditto.
  (rb_io_initialize): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18707 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 12:14:02 +00:00
akr fb7be908bb * io.c (rb_io_flags_mode): add a prefix 0 to octal in error message.
(rb_io_modenum_mode): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18704 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 09:24:34 +00:00
akr 02f43f1bd9 * io.c (rb_open_file): encoding in mode string was ignored if perm is
specified.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 16:33:46 +00:00
akr 20d2ecafa3 fix preivous change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18699 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 16:05:57 +00:00
akr d889297933 * io.c (rb_open_file): don't access argv[-1] by
File.allocate.instance_eval { initialize }.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 16:04:09 +00:00
akr febc4b9923 * io.c (rb_io_check_readable): side effect for STDIN removed.
(rb_io_external_encoding): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 15:35:21 +00:00
akr 1b821cb4a3 * io.c (io_ungetbyte): renamed from io_ungetc.
(rb_io_ungetbyte): new method.
  (rb_io_ungetc): push back into character buffer if enc2 is set.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18694 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 14:28:45 +00:00
akr e32e9a06e4 * io.c (id_encode): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 13:42:09 +00:00
akr edc9581f16 * io.c (make_writeconv): if enc and enc2 is set, convert
string.encoding to enc2.

* include/ruby/io.h: comment changed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 13:35:55 +00:00
akr 035d4816c3 * include/ruby/io.h (rb_io_t): new fields: writeconv,
writeconv_stateless and writeconv_initialized.
  (MakeOpenFile): initialize them.

* include/ruby/encoding.h (rb_econv_stateless_encoding): declared.
  (rb_econv_string): declared.

* io.c (make_writeconv): new function.
  (io_fwrite): use econv.
  (make_readconv): fix error message.
  (finish_writeconv): new function.
  (fptr_finalize): call finish_writeconv.
  (clear_writeconv): new function.
  (clear_codeconv): new function to call both clear_readconv and
  clear_writeconv.
  (rb_io_fptr_finalize): call clear_codeconv instead of
  clear_readconv.
  (mode_enc): ditto.
  (io_set_encoding): ditto.
  (argf_next_argv): ditto.
  (io_encoding_set): ditto.

* gc.c (gc_mark_children): mark writeconv_stateless in T_FILE.

* transcode.c (stateless_encoding_i): new function.
  (rb_econv_stateless_encoding): ditto.
  (rb_econv_string): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 12:06:42 +00:00
akr 89b4f06a59 * io.c (clear_readconv): extracted from rb_io_fptr_finalize.
(mode_enc): call clear_readconv.
  (io_set_encoding): ditto.
  (argf_next_argv): ditto.
  (io_encoding_set): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18690 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 08:24:49 +00:00
akr 43a3aa5ebf * io.c (mode_enc): modify enc and enc2 consistently.
(io_set_encoding): ditto.
  (io_encoding_set): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18688 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 07:55:04 +00:00
akr 08dcd12235 * io.c (io_enc_str): code conversion removed.
(io_enc_str_converted): removed because it is identical to
  io_enc_str now.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 03:47:15 +00:00
akr 6f1fe004f7 * io.c (io_shift_crbuf): add strp argument to append into existing
string.
  (read_all): use econv if enc2 is set.
  (io_getc): follow the io_shift_crbuf change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 03:13:53 +00:00
akr 815fd8536b * io.c (io_enc_str_converted): new function.
(make_readconv): extracted from io_getc.
  (more_char): ditto.
  (appendline): use econv via make_readconv and more_char for code
  conversion.
  (prepare_getline_args): don't convert record separator.
  (rb_io_getline_1): don't use rb_io_getline_fast if enc2 is set.
  (io_getc): use make_readconv and more_char.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18684 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 01:40:01 +00:00
akr f3a42261fb * io.c (appendline): appendline cannot check character boundary.
(rb_io_getline_1): relax limit until character boundary.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-17 19:41:39 +00:00
akr 0ff4061ef7 * io.c (prepare_getline_args): io.gets(10,nil) should cause TypeError.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18675 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-17 12:54:26 +00:00
akr 0051d4a077 * include/ruby/encoding.h (rb_econv_putbackable): declared.
(rb_econv_putback): ditto.

* transcode.c (rb_econv_putbackable): implemented.
  (rb_econv_putback): ditto.

* io.c (io_getc): put back bytes if possible.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18670 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-17 04:25:56 +00:00
akr 63daa7c07d * include/ruby/io.h (rb_io_t): new fields: readconv, crbuf, crbuf_off,
crbuf_len, crbuf_capa.
  (MakeOpenFile): initialize them.

* io.c (io_shift_crbuf): new function.
  (io_getc): use econv.
  (rb_io_fptr_finalize): finalize readconv and crbuf.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 17:06:35 +00:00
nobu 5f9c188d97 * include/ruby/ruby.h (rb_intern_const): tiny optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 00:20:31 +00:00
shugo f433d710d0 * object.c (rb_obj_untrusted): new method Object#untrusted?.
(rb_obj_untrust): new method Object#untrust.
  (rb_obj_trust): new method Object#trust.
* array.c, debug.c, time.c, include/ruby/ruby.h, re.c, variable.c,
  string.c, io.c, dir.c, vm_method.c, struct.c, class.c, hash.c,
  ruby.c, marshal.c: fixes for Object#untrusted?.
* test/ruby/test_module.rb, test/ruby/test_array.rb,
  test/ruby/test_object.rb, test/ruby/test_string.rb,
  test/ruby/test_marshal.rb, test/ruby/test_hash.rb: added tests for
  Object#untrusted?.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 07:25:05 +00:00
nobu 90ca8317d3 * io.c (shutdown): not define if defined already.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-08 14:27:25 +00:00
nobu 1c22ef1705 * configure.in (shutdown, sched_yield, pthread_attr_setinheritsched):
check for Haiku.

* eval_intern.h, io.c, thread_pthread.c: use autoconfisticated results.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-08 08:03:19 +00:00
naruse 48e21d2051 * eval_intern.h: Add support to Haiku. see [ruby-core:18110]
* include/ruby/defines.h: ditto.

* configure.in: ditto.

* thread_pthread.c: ditto.

* io.c: ditto.

* lib/mkmf.rb: ditto.

* ext/socket/getaddrinfo.c: ditto.

* ext/socket/extconf.rb: ditto.

* ext/socket/socket.c: ditto.

* ext/socket/addrinfo.h: ditto.

* ext/socket/getnameinfo.c: ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18402 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-06 20:52:44 +00:00
nobu f1ff09fbf6 * array.c (rb_ary_sort_bang): reset to real class.
* file.c (rb_find_file_ext, rb_find_file): ditto.

* io.c (io_reopen): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-05 20:08:33 +00:00
nobu f2aa0e5b0c * io.c (retry_sendfile, retry_read): ENOSYS and EWOULDBLOCK are not
defined on every platforms.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18364 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-05 03:44:09 +00:00
mame be9994a03a * io.c (io_ungetc): raise NotImplementedError when ungetc is called
against dummy encoding IO.

* io.c (rb_io_getline_1): ditto when gets with delimiter is called.

* io.c (io_getc): ditto when getc is called.

* test/ruby/test_io_m17n.rb (test_terminator_stateful_conversion,
  test_getc_stateful_conversion, test_ungetc_stateful_conversion):
  these tests should raise NotImplementedError.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-29 14:38:44 +00:00
nobu c98b3a7e19 * io.c (prepare_getline_args): check if rs is a string when non-nil
lim is given.  [ruby-dev:35610]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18140 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-21 01:25:55 +00:00
mame 27bf963fa8 * io.c (appendline): remove invalid access.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-16 16:30:12 +00:00
nobu f3fcd2e4a0 * io.c (rb_io_wait_readable, rb_io_wait_writable): check if the file
descriptor is closed.

* thread.c (rb_thread_wait_fd_rw): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18027 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-11 11:51:39 +00:00
akr b279bf4270 rename rb_pipe_internal to rb_pipe.
use rb_pipe in pipe_nocrash.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17895 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-05 14:12:53 +00:00
akr 8b59b1cb98 * io.c (rb_pipe_internal): new function for handling EMFILE and ENFILE
error of pipe().
  (UPDATE_MAXFD_PIPE): removed.
  (pipe_open): use rb_pipe_internal.
  (rb_io_s_pipe): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-07-05 13:38:46 +00:00
mame c93f203e53 * io.c (argf_each_line): pass args to each_line. [ruby-dev:34958]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-30 13:22:10 +00:00
usa 404dda9716 * io.c (io_reopen): remove cygwin handling because it seems to be for
C's stdio.
	  fixed [ruby-dev:35183]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-24 07:54:05 +00:00
usa a9730c786e * io.c (rb_io_binmode_p, argf_binmode_p, Init_IO): new method
IO#binmode? and ARGF.binmode?  [ruby-dev:35148]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17507 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-21 15:08:57 +00:00
naruse 58d694fcdb * io.c (rb_open_file): fs_encoding and fname_encoding is
rb_encoding *.
  fixed [ruby-dev:35151]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-18 06:07:38 +00:00
naruse 235df50648 * io.c (rb_open_file): not rb_enc_get_index but rb_enc_get.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17401 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-18 05:31:35 +00:00
naruse e3aa138e53 * io.c (io_set_encoding): defined.
* io.c (rb_open_file): convert path on Windows and Mac OS X.

* io.c (open_key_args): use io_set_encoding and now accept
  internal_encoding and exernal_encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17373 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-16 21:31:56 +00:00
matz 53f0a8ade1 * io.c (read_all): should use io_read_encoding(), not
io_input_encoding().

* io.c (rb_io_getline_1): reduce calling of io_read_encoding().

* string.c (rb_str_scan): need not to restore $~ value, so avoid
  pinning match object.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-11 23:52:20 +00:00
nobu 1d09b69f62 * io.c (rb_io_reopen): clear read buffer.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17100 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-11 17:25:57 +00:00
matz a999490fe3 * io.c (io_fread): bypass buffered read if reading buffer is empty.
* io.c (remain_size): do not add extra one byte.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-11 14:54:23 +00:00