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

690 Коммитов

Автор SHA1 Сообщение Дата
akr 08911df311 * io.c: test _WIN32 for CRLF platform. (cygwin defines O_BINARY.)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 16:49:31 +00:00
akr 5c6d113a4b * io.c: force CRLF handling if RUBY_TEST_CRLF_ENVIRONMENT is defined.
This is only for testing.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 16:30:43 +00:00
akr 6c1190d10f * io.c (io_fwrite): add TEXTMODE_NEWLINE_ENCODER to option for
rb_str_transcode.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 15:37:04 +00:00
nobu ce60bbc851 * include/ruby/intern.h (rb_io_ungetbyte): added prototype.
* io.c (rb_io_gets): use rb_io_getline_1 for unget buffer.

* ruby.c (load_file): use rb_io_ungetbyte.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18832 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 08:36:46 +00:00
akr 329729da55 * io.c (rb_io_init_copy): copy encs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 10:40:37 +00:00
akr 98e34b223b rdoc updated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 10:32:59 +00:00
akr 7918141932 * io.c (rb_io_open): add an argument: vperm.
(open_key_args): call rb_io_open with perm.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18820 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 10:18:32 +00:00
akr 6f8c2ea9c4 * io.c (sym_invalid): removed.
(sym_undef): removed.
  (sym_ignore): removed.
  (sym_replace): removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 10:11:52 +00:00
akr c22f52c06f * io.c (rb_io_reopen): initialize fptr->encs.opts.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 10:07:46 +00:00
akr 071319fde1 * io.c (rb_io_s_pipe): accept optional hash.
(rb_io_set_encoding): ditto.
  (rb_io_extract_modeenc): use rb_econv_opts to initialize
  ecopts.
  (rb_file_open_generic): ditto.
  (rb_file_open_internal): ditto.
  (io_encoding_set): new argument: opt.
  (argf_set_encoding): copy fptr->encs.opts to argf_ecopts.

* transcode.c (rb_econv_opts): accept Qnil for initialization.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18817 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 09:40:31 +00:00
akr 571b114708 * include/ruby/io.h (rb_io_enc_t): add opts field.
(FMODE_INVALID_MASK): removed.
  (FMODE_INVALID_IGNORE): ditto.
  (FMODE_INVALID_REPLACE): ditto.
  (FMODE_UNDEF_MASK): ditto.
  (FMODE_UNDEF_IGNORE): ditto.
  (FMODE_UNDEF_REPLACE): ditto.
  (MakeOpenFile): initialize the opts field.

* io.c (make_writeconv): use the opts field.
  (io_fwrite): ditto.
  (make_readconv): ditto.
  (argf_ecopts): new macro.
  (rb_io_extract_modeenc): fill the opts field.
  (argf_next_argv): ditto.
  (rb_file_open_generic): initialize the opts field.
  (rb_file_open_internal): ditto.
  (io_encoding_set): ditto.
  (argf_set_encoding): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18816 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 09:13:55 +00:00
akr 6d019ccbd0 * io.c (struct argf): use struct rb_io_enc_t.
(argf_enc): follow the struct argf change.
  (argf_enc2): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18815 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 09:03:04 +00:00
akr 09c7eba7b1 * include/ruby/encoding.h (rb_str_transcode): make 3rd argument
rb_econv_option_t*.

* transcode.c (transcode_loop): take rb_econv_option_t* as a argument.
  (str_transcode0): ditto.
  (str_transcode): make rb_econv_option_t and call str_transcode0 with
  it.
  (rb_str_transcode): take rb_econv_option_t*.

* io.c (io_fwrite): follow the rb_str_transcode change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18814 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 08:39:09 +00:00
akr d7bf454666 * include/ruby/io.h (rb_io_t): make enc and enc2 as struct
rb_io_enc_t;

* io.c: follow the structure change.
  (convconfig_t): defined by rb_io_enc_t.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 07:49:13 +00:00
akr f27b74142e * include/ruby/encoding.h (rb_econv_opts): declared.
* transcode.c (rb_econv_opts): defined.

* io.c (rb_io_extract_modeenc): use rb_econv_opts.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18811 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 07:20:21 +00:00
akr 9b8adfed22 * include/ruby/encoding.h (rb_econv_option_t): defined.
(rb_econv_open): 3rd arg changed.
  (rb_econv_open_exc): ditto.

* io.c (make_writeconv): use rb_econv_option_t.
  (make_readconv): ditto.
  (rb_econv_open): take rb_econv_option_t for options.
  (rb_econv_open_exc): ditto.
  (transcode_loop): use rb_econv_option_t.
  (econv_init): use rb_econv_option_t.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 07:12:44 +00:00
akr c6d291b003 * include/ruby/encoding.h (rb_str_transcode): add ecflags argument.
* transcode.c (econv_opts): extracted from str_transcode.
  (str_transcode_enc_args): extracted from str_transcode.
  (str_transcode0): extracted from str_transcode.
  (str_transcode): use econv_opts, str_transcode_enc_args,
  str_transcode0.
  (rb_str_transcode): call str_transcode0.
  (econv_primitive_insert_output): give the additional argument for
  rb_str_transcode.

* io.c (make_writeconv): use invalid/undef flags.
  (io_fwrite): ditto.
  (rb_scan_open_args): give the additional argument for
  rb_str_transcode.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 06:25:24 +00:00
akr bc0efbc9cd * include/ruby/encoding.h (rb_econv_substr_append): renamed from
rb_econv_string.
  (rb_econv_str_convert): declared.
  (rb_econv_substr_convert): declared.
  (rb_econv_str_append): declared.

* io.c (io_fwrite): use rb_econv_str_convert instead of
  rb_econv_string.

* transcode.c (rb_econv_substr_append): renamed from rb_econv_string.
  (rb_econv_str_append): new function.
  (rb_econv_substr_convert): ditto.
  (rb_econv_str_convert): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18806 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 03:22:43 +00:00
akr 8f9ed3c464 * include/ruby/encoding.h (rb_econv_open_exc): declared.
* transcode.c (rb_eNoConverter): new exception.
  (rb_econv_open_exc): new function.
  (transcode_loop): use rb_econv_open_exc.

* io.c (make_writeconv): use rb_econv_open_exc.
  (make_readconv): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 02:42:37 +00:00
akr cefcbd24f6 * io.c (rb_scan_open_args): use pop_last_hash.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-23 09:30:06 +00:00
akr 2b78afebc7 * include/ruby/io.h (FMODE_INVALID_MASK): defined.
(FMODE_INVALID_IGNORE): defined.
  (FMODE_INVALID_REPLACE): defined.
  (FMODE_UNDEF_MASK): defined.
  (FMODE_UNDEF_IGNORE): defined.
  (FMODE_UNDEF_REPLACE): defined.

* io.c (sym_invalid): defined.
  (sym_undef): defined.
  (sym_ignore): defined.
  (sym_replace): defined.
  (make_readconv): specify ECONV_INVALID_* and ECONV_UNDEF_* if
  FMODE_INVALID_* and FMODE_UNDEF_* is set.
  (rb_io_extract_modeenc): check {:invalid, :undef} => {:replace,
  :ignore} for FMODE_INVALID_* and FMODE_UNDEF_*.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-23 08:41:02 +00:00
akr 860c233103 * io.c (rb_io_extract_modeenc): check :textmode and :binmode in option
hash.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-23 02:23:42 +00:00
akr d2cb86c532 * io.c (check_pipe_command): extracted from rb_f_open and rb_io_open.
(rb_f_open): use check_pipe_command.
  (rb_io_open): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-23 01:45:49 +00:00
akr 341abd3f88 * io.c (read_all): fptr->enc2 is 0 if no conversion.
(rb_io_getline_fast): ditto.
  (io_getc): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18783 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-23 01:14:33 +00:00
akr 895fd7ec5e * include/ruby/io.h (rb_io_t): remove path field and add pathv field.
(MakeOpenFile): initialize pathv as Qnil.

* gc.c: mark pathv field in T_FILE.

* io.c: follow the rb_io_t field change.

* file.c: ditto.

* ext/socket/socket.c: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18782 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-23 00:47:54 +00:00
akr c0d3881e0e * include/ruby/io.h (FMODE_TEXTMODE): defined.
* include/ruby/encoding.h (rb_econv_t): new field: flags.
  (rb_econv_binmode): declared.

* io.c (io_unread): text mode hack removed.
  (NEED_NEWLINE_DECODER): defined.
  (NEED_NEWLINE_ENCODER): defined.
  (NEED_READCONV): defined.
  (NEED_WRITECONV): defined.
  (TEXTMODE_NEWLINE_ENCODER): defined for windows.
  (make_writeconv): setup converter with TEXTMODE_NEWLINE_ENCODER for
  text mode.
  (io_fwrite): use NEED_WRITECONV.  character code conversion is
  disabled if fptr->writeconv_stateless is nil.
  (make_readconv): setup converter with
  ECONV_UNIVERSAL_NEWLINE_DECODER for text mode.
  (read_all): use NEED_READCONV.
  (appendline): use NEED_READCONV.
  (rb_io_getline_1): use NEED_READCONV.
  (io_getc): use NEED_READCONV.
  (rb_io_ungetc): use NEED_READCONV.
  (rb_io_binmode): OS-level text mode test removed.  call
  rb_econv_binmode.
  (rb_io_binmode_m): call rb_io_binmode_m with write_io as well.
  (rb_io_flags_mode): return mode string including "t".
  (rb_io_mode_flags): detect "t" for text mode.
  (rb_sysopen): always specify O_BINARY.

* transcode.c (rb_econv_open_by_transcoder_entries): initialize flags.
  (rb_econv_open): if source and destination encoding is
  both empty string, open newline converter.  last_tc will be NULL in
  this case.
  (rb_econv_encoding_to_insert_output): last_tc may be NULL now.
  (rb_econv_string): ditto.
  (output_replacement_character): ditto.
  (transcode_loop): ditto.
  (econv_init): ditto.
  (econv_inspect): ditto.
  (rb_econv_binmode): new function.




git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-22 16:44:00 +00:00
akr 1dce3b071e * io.c (rb_io_pid): use PIDT2NUM.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-22 03:42:09 +00:00
akr f61354c405 * io.c (rb_file_open_generic): take filename as a VALUE.
(rb_file_open_internal): ditto.
  (rb_io_open): ditto.
  (rb_file_open): pass filename as a VALUE to rb_file_open_internal.
  (rb_open_file): pass filename as a VALUE to rb_file_open_generic.
  (open_key_args): pass filename as a VALUE to rb_io_open.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18765 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-21 20:12:29 +00:00
akr fbc6ea6c95 * io.c (rb_io_s_sysopen): mode can be a Bignum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-21 18:03:52 +00:00
akr ddda4e5508 * io.c (rb_io_extract_modeenc): notify coerced to caller.
(rb_io_initialize): mode may be a Bignum.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18760 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-21 17:58:50 +00:00
akr 9910ee4f5c * io.c (rb_io_extract_modeenc): use rb_check_to_integer to test
integer.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-21 17:44:38 +00:00
akr dd7cf02eab * io.c (rb_io_initialize): accept hash argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-21 17:09:56 +00:00
akr d34079b17a * io.c (io_extract_encoding_option): if internal encoding is not
specified, enc is external encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-21 10:07:21 +00:00
akr caf34a9305 * io.c (io_extract_encoding_option): enc2 is external encoding if
external encoding and internal encoding is given.
  (pipe_open): add flags and convconfig argument to initialize
  fptr->{mode,enc,enc2}.
  (pipe_open_v): pass flags and convconfig from caller to pipe_open.
  (pipe_open_s): ditto.
  (pop_last_hash): new function.
  (rb_io_s_popen): use last hash as option to specify code conversion.
  (rb_io_open): specify flags and convconfig arguments for
  pipe_open_s.
  (rb_f_backquote): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 18:14:07 +00:00
akr e6c300e08a * io.c (prep_io): local variable renamed.
(rb_io_fdopen): ditto.
  (prep_stdio): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 17:31:53 +00:00
akr 19569c8f25 * io.c (open_key_args): simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 17:03:27 +00:00
akr 4a2cd03fbd * io.c (open_key_args): IO.foreach(path, rs, limit) didn't work.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 16:57:46 +00:00
akr 1bfaed8f8d * io.c (rb_file_sysopen_internal): unused function removed.
(rb_file_sysopen): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 16:32:12 +00:00
akr 10e5d07681 * io.c: use mode_t for the 3rd argument, permission, of open(2).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 16:10:36 +00:00
akr 578fc84000 * io.c (io_set_encoding): removed.
(rb_io_open): set up encoding using new argument opt.
  (open_key_args): call rb_io_open with opt.  don't call
  io_set_encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18730 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 14:56:23 +00:00
akr 4046ecde2f * io.c (rb_file_open_internal): use rb_io_flags_modenum.
(rb_io_reopen): use rb_io_flags_modenum and rb_io_modenum_mode.
  (rb_io_stdio_file): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18729 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 13:32:08 +00:00
akr 65370097cd * io.c (rb_io_open_with_args): use rb_open_file instead of rb_io_open.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 11:33:36 +00:00
akr 9074da1b44 * io.c (rb_scan_open_args): extracted from rb_open_file.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 11:16:59 +00:00
akr f684d04a66 * io.c (convconfig_t): new type.
(rb_io_extract_modeenc): new function.
  (rb_file_open_generic): new function.
  (rb_file_open_internal): use rb_file_open_generic.
  (rb_file_sysopen_internal): use rb_file_open_generic.
  (rb_open_file): use rb_io_extract_modeenc and rb_file_open_generic.
  (rb_io_open): call rb_file_open_internal instead of rb_file_open.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-20 10:24:37 +00:00
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