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

787 Коммитов

Автор SHA1 Сообщение Дата
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
nobu 5a647a3f5f * include/ruby/ruby.h (CONST_ID): constant ID cache for non-gcc.
* *.c: no cache in init functions.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17053 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 09:25:32 +00:00
akr 507f89d33f * io.c (fptr_finalize): close IO object if fd is already closed.
(rb_p): call rb_io_write just once.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 08:48:41 +00:00
ko1 72ba13aa8e * array.c, bignum.c, cont.c, dir.c, dln.c, encoding.c, enumerator.c,
enumerator.c (enumerator_allocate), eval_jump.c, file.c, hash.c,
  io.c, load.c, pack.c, proc.c, random.c, re.c, ruby.c, st.c,
  string.c, thread.c, thread_pthread.c, time.c, util.c, variable.c,
  vm.c, gc.c:
  allocated memory objects by xmalloc (ruby_xmalloc) should be
  freed by xfree (ruby_xfree).
* ext/curses/curses.c, ext/dbm/dbm.c, ext/digest/digest.c,
  ext/gdbm/gdbm.c, ext/json/ext/parser/parser.c,
  ext/json/ext/parser/unicode.c, ext/openssl/ossl_cipher.c,
  ext/openssl/ossl_hmac.c, ext/openssl/ossl_pkey_ec.c,
  ext/sdbm/init.c, ext/strscan/strscan.c, ext/zlib/zlib.c:
  ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-08 10:01:40 +00:00
nobu 0455e8ea9a * io.c (rb_f_open), re.c (rb_reg_search), transcode.c (str_transcode):
suppress warnings.

* util.c (quorem, rv_alloc, nrv_alloc): only used in dtoa().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-07 12:38:03 +00:00
usa c7144179bb * io.c (rb_open_file, rb_io_s_sysopen): fmode should be unsigned int.
fixed [ruby-dev:34979]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-06 16:26:05 +00:00
mame 7eb625425c * re.c: fix SEGV by Regexp.allocate.names, Match.allocate.names, etc.
* test/ruby/test_regexp.rb: add tests for above.

* io.c: fix SEGV by IO.allocate.print, etc.

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


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16757 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-02 12:45:42 +00:00
nobu 075530a685 * suppress warnings with -Wwrite-string.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16716 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-31 09:28:20 +00:00
mame 47cc870a5a remove a compile error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-29 13:44:29 +00:00
mame 8fefe64adc * io.c (argf_readchar): raise EOFError, synchronizing IO#readchar.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16681 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-29 13:42:20 +00:00
mame 17248a467e * io.c (argf_external_encoding, argf_internal_encoding): fix SEGV by
ARGF.external_encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-29 13:30:09 +00:00
nobu 1dc20d9d15 * io.c (rb_getc): same as rb_read_check.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-28 06:32:10 +00:00
knu e33e3ed2c6 * io.c (Init_IO): Define ARGF.{lines,bytes,chars}.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-27 04:13:58 +00:00
akr 20f4f5f82c * io.c (rb_f_gets.): re-enable rdoc.
(rb_f_readline): ditto.
  (rb_f_readlines): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 23:27:17 +00:00
usa 9416fedc28 * process.c, include/ruby/intern.h (rb_run_exec_options): externed.
* process.c (save_redirect_fd, save_env_i, save_env, run_exec_dup2,
	  run_exec_open, run_exec_pgroup, run_exec_rlimit, rb_run_exec_options):
	  save parent's process environments.
	  !!!remark!!! these are not thread-safe.

	* process.c (rb_spawn_internal): remove calling run_exec_options()
	  because cannot restore after spawn. we'll fix this later.

	* io.c (pipe_open): ditto.

	* test/ruby/test_process.rb (test_execopts_env): upcase environment
	  variable name for case insensitive platforms.

	* win32/win32.c (init_env): set USER environment variable only when
	  USERNAME is available.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16395 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-12 14:15:32 +00:00
akr 14a97fd48a * thread.c (thread_cleanup_func_before_exec): extracted from
thread_cleanup_func not to touch pthread data.
  pthread_cond_destroy in forked process may cause deadlock on
  Debian GNU/Linux Etch on x86, x86-64 and IA64.
  this doesn't cause resource leak because the process will exec soon.
  (terminate_atfork_before_exec_i): defined.
  (rb_thread_atfork_before_exec): defined.

* include/ruby/intern.h (rb_thread_atfork_before_exec): declared.

* process.c (rb_exec_atfork): call rb_thread_atfork_before_exec
  instead of rb_thread_atfork.

* io.c (popen_exec): call rb_thread_atfork_before_exec instead of
  rb_thread_atfork.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-11 04:15:29 +00:00
nobu 9757c5450c * io.c (io_puts_ary): check recursion first. [ruby-dev:34580]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16311 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-07 08:43:24 +00:00
matz d7f6b873da * io.c (io_fflush): IO#flush problem within threads. a patch from
<s.wanabe at gmail.com> in [ruby-dev:34595].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16297 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-05 11:12:17 +00:00
nobu 96b0b1cf82 * io.c (internal_read_func, internal_write_func): split from
internal_io_func.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-05-02 14:59:28 +00:00
akr 36cb003300 * process.c (check_exec_redirect_fd): prohibit duplex IO.
(check_exec_fds): record maxhint even if close_others is not
  specified.
  (rb_exec_arg_fixup): renamed from rb_exec_arg_fix.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-30 05:40:19 +00:00
akr 59ba2bf0b6 * include/ruby/intern.h (rb_exec_arg_init): declared.
(rb_exec_arg_addopt): delared.
  (rb_exec_arg_fix): declared.
  (rb_exec_initarg): removed.
  (rb_exec_getargs): removed.
  (rb_exec_initarg2): removed.

* io.c (struct popen_arg): make execarg as a pointer.
  (popen_exec): follow popen_arg change.
  (pipe_open): add eargp argument.  extract argc and argv from eargp.
  use rb_exec_arg_addopt to add redirect options.
  (pipe_open_v): set up struct rb_exec_arg.
  (pipe_open_s): set up struct rb_exec_arg.

* process.c (rb_exec_arg_addopt): new function extracted from
  check_exec_options_i.
  (check_exec_options_i): use rb_exec_arg_addopt.
  (rb_check_exec_options): opthash is always a hash now.
  (rb_exec_getargs): make it static.
  (rb_exec_fillarg): renamed from rb_exec_initarg2.  don't set up
  redirect_fds.
  (rb_exec_arg_init): new function.
  (rb_exec_arg_fix): new function.
  (rb_f_exec): use rb_exec_arg_init and rb_exec_arg_fix.  use
  rb_exec_arg_addopt to set close_others option.
  (run_exec_options): make close_others by default.
  (rb_spawn_internal): use rb_exec_arg_init and rb_exec_arg_fix.  use
  rb_exec_arg_addopt to set close_others option.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-28 00:11:46 +00:00
nobu 87e4ad0a23 * io.c, signal.c, thread.c, thread_win32.c, include/ruby/intern.h:
suppress warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-26 09:36:35 +00:00
akr 278b63a3e4 * include/ruby/intern.h (rb_env_clear): declared.
(rb_io_mode_modenum): declared.
  (rb_close_before_exec): declared.
  (struct rb_exec_arg): add options and redirect_fds field.
  (rb_check_argv): removed.
  (rb_exec_initarg): declared.
  (rb_exec_getargs): declared.
  (rb_exec_initarg2): declared.
  (rb_fork): add third argument: fds.

* io.c (max_file_descriptor): new static variable to record maximum
  file descriptor ruby used.
  (UPDATE_MAXFD): new macro.
  (UPDATE_MAXFD_PIPE): new macro.
  (rb_io_mode_modenum): externed.
  (rb_sysopen): update max_file_descriptor.
  (rb_close_before_exec): new function.
  (popen_exec): redirection removed because it is done by extended
  spawn mechanism.
  (pipe_open): generate a hash for spawn options to specify
  redirections.
  (pipe_open_v): use rb_exec_getargs.
  (pipe_open_s): use rb_exec_getargs.
  (rb_io_initialize): update max_file_descriptor..

* process.c (hide_obj): new function.
  (check_exec_redirect_fd): new function.
  (check_exec_redirect): new function.
  (check_exec_options_i): new function.
  (check_exec_fds): new function.
  (rb_check_exec_options): new function.
  (check_exec_env_i): new function.
  (rb_check_exec_env): new function.
  (rb_exec_getargs): new function.
  (rb_exec_initarg2): new function.
  (rb_exec_initarg): new function.
  (rb_f_exec): use rb_exec_initarg.
  (intcmp): new function.
  (run_exec_dup2): new function.
  (run_exec_close): new function.
  (run_exec_open): new function.
  (run_exec_pgroup): new function.
  (run_exec_rlimit): new function.
  (run_exec_options): new function.
  (rb_exec): call run_exec_options.
  (move_fds_to_avoid_crash): new function.
  (pipe_nocrash): new function.
  (rb_fork): use pipe_nocrash to avoid file descriptor conflicts.
  (rb_spawn): use rb_exec_initarg.
  (rlimit_resource_name2int): extracted from rlimit_resource_type.
  (rlimit_type_by_hname): new function.
  (rlimit_type_by_lname): new function.
  (rlimit_resource_type): use rlimit_type_by_hname.
  (proc_daemon): add fds argument for rb_fork.

* hash.c (rb_env_clear): renamed from env_clear and externed.

[ruby-dev:34086]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-24 14:46:39 +00:00
akr b1166a0469 * io.c (copy_stream_body): call rb_io_check_readable and
rb_io_check_writable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16128 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-21 10:09:33 +00:00
nobu d92efa3c0b * io.c (copy_stream_func): suppress warnings.
* thread_pthread.c (add_signal_thread_list): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-20 06:14:49 +00:00
akr ae2921ae67 * io.c (copy_stream_rbuf_to_dst): removed.
(copy_stream_fallback_body): don't bypass write method.
  (copy_stream_body): simplified.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-20 06:13:17 +00:00
akr 01c433b58c * io.c (copy_stream_fallback): write directly (bypassing write method)
if possible.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-20 04:59:04 +00:00
akr f0fbfeda51 avoid warnings in copy_stream_body.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-20 04:12:32 +00:00
akr a16e0c29db * io.c (copy_stream_fallback): read directly (bypassing readpartial)
if possible.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-20 03:51:57 +00:00
akr 9579647fe1 * io.c (copy_stream_body): use readpartial and write method for
non-IOs such as StringIO and ARGF.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16087 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-19 19:47:16 +00:00
mame 0a2053713b * enc/trans/utf_16_32.c (fun_so_to_utf_16be, fun_so_to_utf_16le): add
parentheses to remove warnings of gcc.

* io.c (rb_io_getc): remove unused variables.

* compile.c (NODE_NEXT, NODE_REDO): remove unused labels.

* ext/nkf/nkf.c (rb_nkf_convert): remove unused variables.

* ext/syck/rubyext.c (syck_resolver_initialize,
  syck_resolver_detect_implicit, syck_emitter_emit): remove unused
  variables.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-17 13:22:40 +00:00
matz 5a4c8a1ad7 * io.c: #undef rb_argv moved before #define.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16040 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-15 10:21:01 +00:00
usa b2acbb2c67 * {bcc,win}32/Makefile.sub (config.h): define ssize_t.
* io.c (copy_stream_body): some platform don't have O_NOCTTY.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15865 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-31 09:58:41 +00:00
naruse 839dc7f9ab * io.c (io_getc): set coderange while getting characters.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15863 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-30 19:16:29 +00:00
yugui 70153a6a73 * io.c (rb_io_lines, rb_io_bytes, rb_io_chars) Fixed their rdocs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-30 15:39:00 +00:00
matz ef260b085e revert git backfire in r15860; sorry
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15861 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-30 15:00:12 +00:00
matz 3730710d79 * proc.c (proc_dup): should copy is_lambda attribute as well.
[ruby-talk:296244]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-30 14:50:55 +00:00
akr c8ac4a209b forgot to return a value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-30 07:35:09 +00:00
akr 0ef84dcefc * io.c: IO.copy_stream implemented. [ruby-dev:33843]
* thread.c (rb_fd_select): new function.

* configure.in (sys/sendfile.h): check the header file.
  (sendfile): check the function.
  (pread): check the function.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-30 06:38:05 +00:00
yugui 4aa9be0f5c * io.c (rb_io_each_char, rb_io_chars, argf_each_char, io_getc): Added character-wise
iterators; IO#each_char, IO#chars, ARGF#each_char. [ruby-dev:34052]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15845 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-28 10:58:31 +00:00
nobu 068ce36454 * io.c (rb_f_gets, rb_f_readline, rb_f_readlines): delegates to ARGF
as well as puts and putc.  [ruby-dev:34100]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-21 12:32:33 +00:00
nobu 2029a832e5 * io.c (argf_getline): use receiver.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-20 12:46:35 +00:00
nobu 890b0352dd * io.c: removed trailing blanks.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-19 15:29:09 +00:00
nobu a130e92582 * io.c (argf_initialize_copy): get rid of segfault.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-19 15:21:15 +00:00
nobu 42522ee2a6 * io.c (argf_tell, argf_seek_m, argf_set_pos, argf_rewind,
argf_fileno, argf_to_io, argf_eofl, argf_getc, argf_getbyte,
  argf_readchar, argf_readbyte, argf_each_line): use receiver.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-19 15:14:01 +00:00
nobu bdfe0b8f18 * io.c (rb_io_putc, rb_io_puts): ouput directly if the reciever is
rb_stdout to get rid of infinite recursion.  [ruby-dev:34059]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-19 14:52:43 +00:00
akr 861219ce4a fix doc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15734 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-09 01:04:46 +00:00
matz 39787ea14d * numeric.c (fix_to_s): avoid rb_scan_args() when no argument
given. 
* bignum.c (rb_big_to_s): ditto.
* enum.c (enum_first): ditto.
* eval_jump.c (rb_f_catch): ditto.
* io.c (rb_obj_display): ditto.
* class.c (rb_obj_singleton_methods): ditto.
* object.c (rb_class_initialize): ditto.
* random.c (rb_f_srand): ditto.
* range.c (range_step): ditto.
* re.c (rb_reg_s_last_match): ditto.
* string.c (rb_str_to_i): ditto.
* string.c (rb_str_each_line): ditto.
* string.c (rb_str_chomp_bang): ditto.
* string.c (rb_str_sum): ditto.

* string.c (str_modifiable): declare inline.
* string.c (str_independent): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-05 05:22:17 +00:00
naruse 70b55c5dcf * io.c (open_key_args): use rb_io_open_with_args instead of rb_f_open.
[ruby-core:15763]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-04 05:36:08 +00:00
naruse 8ac9b7c2ed * io.c (open_key_args): use rb_io_open instead of rb_f_open.
[ruby-core:15746]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15682 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-03 20:34:58 +00:00
nobu 3b5d60c0b1 * io.c (rb_io_ungetc): reduce redundant call.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-02 14:04:02 +00:00
nobu b8a733d0b8 * io.c (struct argf): packed ARGF stuffs.
* ruby.c (proc_options): use ruby_set_inplace_mode().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-01 08:59:04 +00:00
naruse 4c7d380a81 * io.c (read_all, rb_io_getline_fast): encoding is rb_input_encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15652 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-01 01:33:17 +00:00
naruse 198e1d074c * io.c (rb_io_getline_fast): scan coderange.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-28 06:30:38 +00:00
nobu 586f727b8c * io.c (rb_io_getline_1): get rid of segfault. [ruby-dev:33938]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-28 02:25:14 +00:00
naruse 343a1504e3 * io.c (read_all): fix if.
* io.c (rb_io_getline_1): move needless set encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-27 20:56:03 +00:00
naruse 4dd9fd71b3 * string.c (rb_str_coderange_scan_restartable): coderange scaning
for partial read.

* io.c (read_all): set coderange when not convert encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-27 15:19:22 +00:00
matz ca22f3e168 * io.c (rb_f_putc): invoke stdout method so that redefining putc
may take effect.   [ruby-talk:291844]

* io.c (rb_f_puts): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-21 07:47:12 +00:00
nobu ce0264b6f5 * io.c (argf_set_encoding): uses current_file after check if next
input is available.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-21 05:49:42 +00:00
nobu 7f2ca5ba7a * io.c (argf_set_encoding): uses current_file after check for next
input.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15561 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-21 05:47:12 +00:00
usa f761aacdd8 * io.c (open_key_args): set arg->io even if no options passed.
[ruby-dev:33072]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-20 01:09:21 +00:00
matz 878bbd1199 * io.c (open_key_args): allow specifying both :mode and :encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15485 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-15 07:35:11 +00:00
akr 433fbebfbc * io.c (io_reopen): check STDIN, STDOUT and STDERR mode according to
stdio streams.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-14 12:01:50 +00:00
akr 82b088aa0c * io.c (io_reopen): don't change access mode for stdin, stdout and
stderr.  [ruby-core:15360]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15396 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-02-07 07:40:25 +00:00
nobu 6f4d6b1650 * io.c (rb_io_close_read): replaces fptr with the tied writer if
duplex.

* io.c (rb_io_close_write): unties the tied IO for writing if duplex.
  [ruby-dev:33532]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-30 21:24:24 +00:00
matz d7f5b291be * io.c (open_key_args): allow encoding key to take two encoding
names.  a patch from <rubikitch AT ruby-lang.org>.  [ruby-dev:33540]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15350 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-30 17:23:27 +00:00
akr dc36ca0ba5 * io.c (select_internal): fix SEGV by `select [STDIN],nil,[STDIN]'.
fixed by Petr Chromec.
  http://rubyforge.org/tracker/index.php?func=detail&aid=17275&group_id=426&atid=1698


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15346 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-30 15:21:40 +00:00
matz 06cd63ce93 * io.c (rb_open_file): should check NUL in path.
<http://www.rubyist.net/~matz/20080125.html#c01>.

* io.c (rb_io_s_popen): ditto.

* io.c (rb_io_reopen): ditto.

* io.c (next_argv): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15286 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-28 03:32:27 +00:00
akr fc208c1bd5 * include/ruby/oniguruma.h: precise mbclen API redesigned to avoid
inline functions.
  (onigenc_mbclen_charfound): removed.
  (onigenc_mbclen_needmore): removed.
  (onigenc_mbclen_recover): removed.
  (ONIGENC_MBCLEN_CHARFOUND): removed.
  (ONIGENC_MBCLEN_CHARFOUND_P): defined.
  (ONIGENC_MBCLEN_CHARFOUND_LEN): defined.
  (ONIGENC_MBCLEN_INVALID): removed.
  (ONIGENC_MBCLEN_INVALID_P): defined.
  (ONIGENC_MBCLEN_NEEDMORE): removed.
  (ONIGENC_MBCLEN_NEEDMORE_P): defined.
  (ONIGENC_MBCLEN_NEEDMORE_LEN): defined.
  (ONIGENC_MBC_ENC_LEN): use onigenc_mbclen_approximate.

* regenc.c (onigenc_mbclen_approximate): defined.

* include/ruby/encoding.h (MBCLEN_CHARFOUND): removed.
  (MBCLEN_INVALID): removed.
  (MBCLEN_NEEDMORE): removed.
  (MBCLEN_CHARFOUND_P): defined.
  (MBCLEN_INVALID_P): defined.
  (MBCLEN_NEEDMORE_P): defined.
  (MBCLEN_CHARFOUND_LEN): defined.
  (MBCLEN_NEEDMORE_LEN): defined.

* encoding.c: use new API.

* re.c: ditto.

* string.c: ditto.

* parse.y: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-27 14:27:07 +00:00
akr f4d73e05d4 * io.c (rb_io_getline_fast): don't care ASCII incompatible encoding.
(prepare_getline_args): generate a newline according to IO encoding
  when necessary.
  (rb_io_getline_1): call rb_io_getline_fast only for ASCII
  compatible encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15241 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-25 15:57:32 +00:00
matz 4bcfd50ee7 * io.c (rb_io_getline_fast): the end point of left_char_head()
must be the last character.  [ruby-cvs:22445]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15210 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-24 07:34:07 +00:00
matz 9580a9ca91 * string.c (rb_str_each_line): use memchr(3) for faster newline
search.

* io.c (appendline): remove unused arguments

* io.c (rb_io_getline_fast): make much simpler (and faster).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-23 18:43:51 +00:00
matz f7929ed206 * io.c (Init_IO): stdin/stdout may not be duplex.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15098 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-17 22:21:40 +00:00
matz d765a38bf5 * io.c (io_fwrite): always flush IO on tty, even without newlines.
[ruby-core:15107]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-17 22:20:20 +00:00
nobu 64239e2291 * io.c (rb_io_check_readable): flush tied write IO too.
* io.c (Init_IO): tie stdin with stdout.  [ruby-core:15107]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-17 15:49:33 +00:00
nobu e477c919db * io.c (pipe_open, rb_io_s_popen): clear temporary object to release
and prevent from GC.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15079 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-16 09:03:12 +00:00
nobu db26a9b105 * load.c (rb_feature_p): get rid of unlimited alloca.
* object.c (rb_cstr_to_dbl): ditto.

* io.c (mode_enc): fixed uninitialized variable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15074 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-16 06:26:33 +00:00
nobu 2402ecabb0 * file.c (sys_fail2): get rid of unlimited alloca.
* io.c (mode_enc, pipe_open, rb_io_s_popen): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15073 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-16 05:55:22 +00:00
matz fa246559d2 * io.c (appendline): specifying limit should not generate broken
byte sequence.  strings should be rounded.  [ruby-dev:33088]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-14 15:07:49 +00:00
matz f309847177 io.c (io_encoding_set): typo fixed
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14976 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-10 06:44:30 +00:00
matz a4c82312c3 * io.c (io_encoding_set): handle nil for v1.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14975 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-10 06:42:49 +00:00
matz 76b247202a * io.c (io_encoding_set): IO.pipe("euc-jp", nil) should work as
IO.pipe("euc-jp", nil).  [ruby-dev:33000]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14974 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-10 01:54:43 +00:00
matz 81064a7688 * io.c (rb_io_binmode): should not alter encoding. [ruby-dev:32918]
* io.c (io_read_encoding): need not to return ASCII-8BIT for
  binary IO.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14972 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-09 17:44:13 +00:00
akr 6cdef2dc7e * $Date$ keyword removed to avoid inclusion of locale dependent
string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-06 15:49:38 +00:00
akr 8702c4d0d7 update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14890 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-05 03:35:13 +00:00
akr 1aaf8b1713 * io.c (io_ungetc): move data in buffer if it is required to store the
argument.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14873 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-03 15:40:45 +00:00
nobu 2000bde8e7 * io.c (fptr_finalize): clear errno first. [ruby-talk:284492]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-03 02:29:04 +00:00
nobu 46933426b0 * io.c (rb_io_mode_enc): encoding spec is not allowed in binary mode.
[ruby-dev:32913]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-01-01 08:50:49 +00:00
akr 32fe1ecdbc comment modified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-29 14:52:32 +00:00
akr fffd379d44 * io.c (io_fflush): don't retry when wbuf modified by other threads.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-29 14:49:11 +00:00
usa b3c2e224d3 * io.c (io_unread): fix typo.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14776 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-28 18:10:31 +00:00
usa 57bb055c93 * io.c (io_unread): adhoc workaround for non-binary mode of some DOSish
platforms. this is not perfect and safety, but works with most cases.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14775 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-28 17:20:24 +00:00
akr fc9cc7440a * io.c (io_fflush): checks wbuf modification by other threads.
not perfect.  it need locks.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-27 05:36:02 +00:00
akr b3e3c8a578 * io.c (io_fflush): check closed fptr after rb_write_internal to avoid
SEGV on MacOS X.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14719 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-26 08:33:38 +00:00
matz 3878b30881 * io.c (appendline): move RS comparison to rb_io_getline_1().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14691 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 09:52:52 +00:00
matz 72bf77fb30 * io.c (rb_io_external_encoding): should return nil for
pass-through write IO.  [ruby-dev:32740]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14672 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 06:44:58 +00:00
akr 9f98c9a9c2 * io.c (appendline): initialize rslen to 1 if rsptr is 0.
rslen should be the length of the delimiter.
  if only delim is given, it should be 1.
  [ruby-dev:32746]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 06:38:00 +00:00
nobu 33a071016b * io.c (io_encoding_set): missing return type.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14661 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-25 05:11:59 +00:00
matz 29595e23d7 * io.c (rb_io_s_pipe): now takes up to two arguments. allow its
external/internal encoding by Encoding objects.

* io.c (rb_io_set_encoding): new method to set encoding of the IO.

* io.c (argf_set_encoding): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-24 18:17:35 +00:00
matz a04a812ed0 * include/ruby/encoding.h (rb_enc_left_char_head): new utility macro.
* include/ruby/encoding.h (rb_enc_right_char_head): ditto.

* io.c (appendline): does multibyte RS search in the function.

* io.c (prepare_getline_args): RS may be nil.

* io.c (rb_io_getc): should process character based on external
  encoding, when transcoding required.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-24 16:36:14 +00:00
matz c749064f9f * io.c (appendline): should do multibyte aware RS search.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14554 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 19:55:18 +00:00
matz b4f2e2ba07 * io.c (io_enc_str): should preserve default_external encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14553 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 19:29:01 +00:00
matz 459ca7f3f0 * io.c (prepare_getline_args): convert RS to external encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 18:12:44 +00:00
matz 7ea8ec5483 * io.c (rb_io_check_readable): should not fill fptr->enc always.
read-write IO (e.g. socket) does not work.  [ruby-dev:32685]

* io.c (io_read_encoding): retrieve reading encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14543 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 18:01:16 +00:00
matz 5f9748deb7 * io.c (rb_io_external_encoding): should return the encoding of
the file reading.

* io.c (rb_io_internal_encoding): should return the encoding of
  read string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 17:38:32 +00:00
matz 648cd42f77 * io.c (rb_f_open): documentation update.
* io.c (rb_io_s_pipe): ditto.

* io.c (io_fwrite): wrong encoding destination.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 17:13:07 +00:00
matz 93444eea15 * io.c (rb_io_s_pipe): allow specifying read-side encoding.
* io.c (io_enc_str): wrong encoding destination.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14537 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 16:48:28 +00:00
matz 61ea3fd50d * io.c (open_key_args): IO direct methods (foreach, readlines,
read) now takes keyword argument: encoding, mode, open_args.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 16:02:46 +00:00
matz 2e791ace7f * io.c (rb_io_s_read): encoding argument reverted.
* io.c (mode_enc): independent function to share code.

* io.c (rb_io_internal_encoding): new method.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 15:56:41 +00:00
nobu a3c87a7859 * io.c (rb_io_binmode_m): removed C99ism.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14509 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-23 02:01:34 +00:00
akr 5b809a28f8 * include/ruby/encoding.h, encoding.c, re.c, io.c, parse.y, numeric.c,
ruby.c, transcode.c: rename rb_ascii_encoding. to
  rb_ascii8bit_encoding.  rb_ascii_encoding is ambiguous with 
  ASCII-8BIT and US-ASCII.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-22 23:47:18 +00:00
matz e8a71bc853 * io.c (rb_io_mode_enc): do not set encoding unless explicitly
specified.

* io.c (rb_io_check_readable): fill fptr->enc by default_external
  if it's empty.

* io.c (io_enc_str): fptr->enc is always set for reading IO (by
  rb_io_check_readable(fptr)).

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-22 17:28:20 +00:00
davidflanagan b83cbb0c7c * io.c, io.h: temporary patch to partially implement transcode-on-read and transcode-on-write
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14497 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-22 16:21:09 +00:00
davidflanagan ac42f7adf9 io.c: fix typo in rdoc comment
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14445 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 21:10:55 +00:00
matz d7cc14d436 * encoding.c (rb_ascii_encoding): renamed from previous
rb_default_encoding().

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14443 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 18:55:30 +00:00
matz 2bed2cdc7f * io.c (io_ungetc): avoid buffer relocation, which might cause
serious problem under concurrent situation.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14439 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 16:54:25 +00:00
ko1 91c6c2c170 * io.c: write() should be in blocking region.
* bootstraptest/test_io.rb, test_knownbug.rb: move a fixed test.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14428 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 09:43:49 +00:00
matz e48ea0a5f3 * io.c (rb_io_s_read): allow specifying encoding explicitly.
* io.c (rb_io_binmode): specifies encoding to ASCII-8BIT (binary).

* io.c (rb_io_s_read): IO should be in binary mode when offset is
  specified.

* encoding.c (rb_to_encoding): returns default encoding if no
  corresponding encoding found.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 07:02:55 +00:00
akr 0d49e43be2 * io.c (Init_IO): define IO::BINARY even if O_BINARY is not exist.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14403 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 05:47:15 +00:00
matz ad47716266 * io.c (rb_io_external_encoding): should fill delayed
initialization for STDIN.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14398 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 04:32:53 +00:00
matz 1b27cfcd6c * io.c (rb_io_external_encoding): new method.
* encoding.c (rb_enc_from_encoding): returns Qnil for NULL
  encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14397 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 04:26:38 +00:00
matz 74a0c0cc7e * io.c (rb_io_mode_enc): set default external encoding if no
encoding specified explicitly.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14389 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 03:29:54 +00:00
akr 4cf437519f * regerror.c, string.c, io.c, lib/getoptlong.rb, lib/net/imap.rb,
compile.c, sprintf.c, parse.y, ext/win32ole/win32ole.c,
  ext/tk/sample/demos-en/entry3.rb, ext/tk/lib/tcltk.rb,
  ext/openssl/ossl_bn.c, numeric.c, vm.c,
  benchmark/bm_so_meteor_contest.rb, bignum.c, ruby.c: don't "illegal"
  for non law violation context.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14377 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-21 02:31:11 +00:00
gotoyuzo d86caf3188 * io.c (select_internal): should return original value.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14370 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-20 16:12:38 +00:00
matz 11f3462fb7 * io.c (rb_f_p): RDoc update. a patch from murphy <murphy AT rubychan.de>.
[ruby-core:14010]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14228 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-14 08:38:18 +00:00
matz c3b5279d49 * io.c (rb_io_synchronized): should check if initialized.
[ruby-dev:32585]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14219 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 17:06:41 +00:00
matz b754d62f72 * io.c (rb_io_getc): use default external encoding if fptr->enc is
not set.  [ruby-dev:32565]

* lib/rubygems/package.rb (Gem::TarReader::Entry::rewind): typo fixed.
  [ruby-dev:32565]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14204 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-12 23:58:58 +00:00
matz 0ca7036682 * io.c (read_all): should associate default external encoding.
* io.c (io_read): should NOT associate default external encoding.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14203 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-12 23:46:58 +00:00
matz 098ca00175 * io.c (rb_io_mode_enc): allow specifying external encoding in
open mode, e.g. open(path, "r:utf-8").

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-12 13:23:07 +00:00
matz 6fd91d288c * io.c (rb_io_check_readable): set default external encoding to
STDIN.

* io.c (io_enc_str): associate encoding to output string.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14199 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-12 07:39:43 +00:00
nobu 54f236542d * file.c (rb_get_path): use the original object if to_path method is
not defined.  [ruby-dev:32473]

* io.c (rb_f_open): call to_open on non-string objects, instead of
  to_str.  [ruby-dev:32473]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-09 03:18:21 +00:00
akr 69406aad50 * encoding.c (rb_enc_precise_mbclen): new function for mbclen with
validation.

* include/ruby/encoding.h (rb_enc_precise_mbclen): declared.
  (MBCLEN_CHARFOUND): new macro.
  (MBCLEN_INVALID): new macro.
  (MBCLEN_NEEDMORE): new macro.

* include/ruby/oniguruma.h (OnigEncodingTypeST): replace mbc_enc_len
  by precise_mbc_enc_len.
  (ONIGENC_PRECISE_MBC_ENC_LEN): new macro.
  (ONIGENC_CONSTRUCT_MBCLEN_CHARFOUND): new macro.
  (ONIGENC_CONSTRUCT_MBCLEN_INVALID): new macro.
  (ONIGENC_CONSTRUCT_MBCLEN_NEEDMORE): new macro.
  (ONIGENC_MBCLEN_CHARFOUND): new macro.
  (ONIGENC_MBCLEN_INVALID): new macro.
  (ONIGENC_MBCLEN_NEEDMORE): new macro.
  (ONIGENC_MBC_ENC_LEN): use ONIGENC_PRECISE_MBC_ENC_LEN.

* enc/euc_jp.c: validation implemented.

* enc/sjis.c: ditto.

* enc/utf8.c: ditto.

* string.c (rb_str_inspect): use rb_enc_precise_mbclen for invalid
  encoding.
  (rb_str_valid_encoding_p): new method String#valid_encoding?.

* io.c (rb_io_getc): use rb_enc_precise_mbclen.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-06 09:28:26 +00:00
matz 70e28cf1eb * io.c (rb_f_open): use to_open for every non-string object. path
object may use method_missing.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14064 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-01 05:22:15 +00:00
nobu cf74bde83c * io.c (rb_read_internal, rb_sysopen_internal): remove C99 dependency.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14017 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-26 01:44:23 +00:00
ko1 c4c151bed8 * io.c: add rb_read_internal() as blocking function.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14007 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-23 08:35:29 +00:00
ko1 3453b2bd0e * gc.h, vm_core.h: decl of rb_gc_save_machine_context()
should be at vm_core.h.
* include/ruby/ruby.h, intern.h: remove type rb_thread_t.
* include/ruby/intern.h: change rb_unblock_function_t,
  rb_unblock_function_t.
* file.c, process.c: apply above changes.
* thread.c, thread_pthread.ci, thread_win32.ci: ditto.
* io.c: support blocking open (2). [ruby-core:13614]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-20 10:47:53 +00:00
akr d481323b92 * io.c (rb_io_close_on_exec_p): new method IO#close_on_exec?.
(rb_io_set_close_on_exec): new method IO#close_on_exec=.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-20 08:12:34 +00:00
usa cae4fb76dc * include/ruby/win32.h win32/win32.c (rb_w32_pipe_exec): use dual fd
instead of socketpair when mode is RDWR.

	* io.c (pipe_open): pass &write_fd to rb_w32_pipe_exec().

	* io.c (popen_redirect): define only when HAVE_FORK.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-20 04:04:51 +00:00
akr 0d8ac93f58 * include/ruby/io.h (rb_io_t): add tied_io_for_writing member.
* io.c: use tied_io_for_writing for duplex popen.

* gc.c: mark tied_io_for_writing.

* common.mk: gc.o depends io.h.

  [ruby-dev:32205]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13977 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-20 03:16:53 +00:00
matz 1c4e2b11a1 * io.c (rb_io_each_byte): should update rbuf_off and rbuf_len for
each iteration.  [ruby-dev:31659][ruby-dev:32192]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-11-09 07:54:39 +00:00
nobu bb053cd824 * io.c (rb_io_tell, rb_io_seek): check errno too. [ruby-dev:32093]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-25 05:19:33 +00:00
matz 150a8b4fe0 * io.c (Init_IO): remove obsolete variables: $defout, $deferr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-10-04 07:53:32 +00:00
nobu 29621688c7 * io.c (rb_io_fdopen): create IO object from fd.
* parse.y (yycompile): use encoding of the source as default.

* ruby.c (proc_options, load_file): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-28 20:29:32 +00:00
nobu 041fbcbf50 * io.c (rb_io_getline_fast, rb_io_getline_1): set encoding to the
result string, as well as getc.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13542 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-28 04:20:12 +00:00
matz 2f6f2bfb02 * io.c (io_ungetc): reallocate internal buffer if pushing data
excess capacity.  [ruby-dev:31650]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13512 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-25 12:45:03 +00:00
nobu bf6575ef62 * io.c (popen_exec), process.c (rb_spawn): stop other threads before
exec.  [ruby-core:08262]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13471 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-20 08:28:03 +00:00
nobu 9391daf954 * io.c (rb_io_s_sysopen): should not use alloca for unknowen size
input.  [ruby-dev:31775]

* parse.y (rb_id2str): ditto.

* marshal.c (w_float): use snprintf instead of sprintf.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-12 06:19:06 +00:00
matz ae11bc70f1 * io.c (rb_io_getc): forgot to commit rb_enc_mbclen() fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-09-06 15:30:49 +00:00
matz 1a0b7d0fb6 * io.c (rb_io_each_byte): caused infinite loop. [ruby-dev:31652]
* io.c (rb_io_getc): should return nil at EOF, not EOFError.

* lib/delegate.rb (SimpleDelegator::__setobj__): use raise
  argument to specify backtrace.

* test/ruby/test_fnmatch.rb (TestFnmatch::bracket_test):
  String#include? no longer works for Fixnum.  use #chr.
  [ruby-dev:31652]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-26 17:22:26 +00:00
nobu 8bbac3ba77 * io.c (swallow): removed condition using an unset variable.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 06:20:48 +00:00
matz a25fbe3b3e * encoding.c: provide basic features for M17N.
* parse.y: encoding aware parsing.

* parse.y (pragma_encoding): encoding specification pragma.

* parse.y (rb_intern3): encoding specified symbols.

* string.c (rb_str_length): length based on characters.  
  for older behavior, bytesize method added.

* string.c (rb_str_index_m): index based on characters.  rindex as
  well.

* string.c (succ_char): encoding aware succeeding string.

* string.c (rb_str_reverse): reverse based on characters.

* string.c (rb_str_inspect): encoding aware string description.

* string.c (rb_str_upcase_bang): encoding aware case conversion.
  downcase, capitalize, swapcase as well.

* string.c (rb_str_tr_bang): tr based on characters.  delete,
  squeeze, tr_s, count as well.

* string.c (rb_str_split_m): split based on characters.

* string.c (rb_str_each_line): encoding aware each_line.

* string.c (rb_str_each_char): added.  iteration based on
  characters.

* string.c (rb_str_strip_bang): encoding aware whitespace
  stripping.  lstrip, rstrip as well.

* string.c (rb_str_justify): encoding aware justifying (ljust,
  rjust, center).

* string.c (str_encoding): get encoding attribute from a string. 

* re.c (rb_reg_initialize): encoding aware regular expression

* sprintf.c (rb_str_format): formatting (i.e. length count) based
  on characters.

* io.c (rb_io_getc): getc to return one-character string.
  for older behavior, getbyte method added.

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

* io.c (rb_io_ungetc): allow pushing arbitrary string at the
  current reading point.

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

* ext/strscan/strscan.c: encoding support.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13261 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-25 03:29:39 +00:00
matz 5e1c401ff5 * array.c (rb_ary_s_try_convert): a new class method to convert
object or nil if it's not target-type.  this mechanism is used
  to convert types in the C implemented methods.

* hash.c (rb_hash_s_try_convert): ditto.

* io.c (rb_io_s_try_convert): ditto.

* re.c (rb_reg_s_try_convert): ditto.

* string.c (rb_str_s_try_convert): ditto.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13251 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-24 17:47:09 +00:00
matz 009debfd02 * io.c (rb_io_s_foreach): argument count check before making
Enumerator.  [ruby-dev:31525]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13119 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-20 14:46:03 +00:00
nobu e7e1b3a2d6 * io.c (argf_readpartial): argf_forward needs argc and argv.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13021 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-15 21:29:10 +00:00
matz 758c51cafe * io.c (ARGF_FORWARD): wrongly compares with current_file with
rb_stdout.  should be rb_stdin.  [ruby-cvs:20177]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-15 07:47:03 +00:00
nobu ad1e42421c * io.c (rb_io_initialize, argf_each_line, argf_each_byte): suppress
warnings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-15 05:59:24 +00:00
matz 7e8d337aa4 * io.c (argf_close): always close via method.
* io.c (Init_IO): remove obsolete Kernel#getc.

* io.c (argf_each_line): should use #each_line, not #each.

* io.c (argf_each_line): simplified.

* io.c (argf_getline): should handle non T_FILE object in ARGV.

* io.c (argf_each_byte): each_byte should yield bytes not
  one-character strings.  [ruby-dev:31374]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12931 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-14 11:03:29 +00:00
nobu 819619495a * io.c (pipe_open): fix for win32 platforms.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12894 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-07 03:31:54 +00:00
nobu 43009063c7 * io.c (pipe_open_v, pipe_open_s): separate array and string
cases.  [ruby-dev:31344]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-08-04 19:56:27 +00:00
nobu fead3c93e7 * io.c (rb_f_p): return nil if no argument. [ruby-dev:31285]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-07-24 01:37:07 +00:00