aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
Commit message (Collapse)AuthorAgeFilesLines
* * include/ruby/io.h (rb_io_t): refcnt field removed.akr2008-08-271-6/+3
| | | | | | | | | | | (MakeOpenFile): refcnt initialization removed. * io.c (rb_io_fptr_finalize): don't check refcnt. (rb_io_close_read): don't use refcnt. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18885 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_initialize): don't accept IO object. [ruby-dev:35895]akr2008-08-271-42/+15
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18883 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/encoding.h (rb_econv_result_t): enumeration constant:akr2008-08-261-5/+7
| | | | | | | | | | | | | | | | | | | | | | econv_incomplete_input. * io.c (finish_writeconv): check econv_incomplete_input. * transcode.c (transcode_restartable0): return econv_incomplete_input for unexpected end of source buffer. (trans_sweep): check econv_incomplete_input. (rb_trans_conv): ditto. (rb_econv_convert0): ditto. (rb_econv_convert): ditto. (transcode_loop): ditto. (make_econv_exception): change message for econv_incomplete_input. (econv_result_to_symbol): return :incomplete_input for econv_incomplete_input. (ecerr_incomplete_input): new method. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/io.h (rb_io_t): rename crbuf to cbuf.akr2008-08-261-61/+61
| | | | | | | | * io.c: follow the renaming. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (make_writeconv): copy invalid/undef flags.akr2008-08-251-9/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/io.h (rb_io_t): new field: writeconv_pre_opts.akr2008-08-251-12/+9
| | | | | | | | | * io.c (make_writeconv): initialize writeconv_pre_opts. (io_fwrite): use writeconv_pre_opts. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: test _WIN32 for CRLF platform. (cygwin defines O_BINARY.)akr2008-08-251-2/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18855 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: force CRLF handling if RUBY_TEST_CRLF_ENVIRONMENT is defined.akr2008-08-251-1/+1
| | | | | | | This is only for testing. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_fwrite): add TEXTMODE_NEWLINE_ENCODER to option forakr2008-08-251-1/+6
| | | | | | | rb_str_transcode. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18851 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/intern.h (rb_io_ungetbyte): added prototype.nobu2008-08-251-5/+1
| | | | | | | | | * 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
* * io.c (rb_io_init_copy): copy encs.akr2008-08-241-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rdoc updated.akr2008-08-241-25/+34
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_open): add an argument: vperm.akr2008-08-241-6/+15
| | | | | | | | (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
* * io.c (sym_invalid): removed.akr2008-08-241-5/+0
| | | | | | | | | | (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
* * io.c (rb_io_reopen): initialize fptr->encs.opts.akr2008-08-241-0/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18818 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_s_pipe): accept optional hash.akr2008-08-241-11/+15
| | | | | | | | | | | | | | | | (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
* * include/ruby/io.h (rb_io_enc_t): add opts field.akr2008-08-241-24/+17
| | | | | | | | | | | | | | | | | | | | | | | | | (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
* * io.c (struct argf): use struct rb_io_enc_t.akr2008-08-241-3/+3
| | | | | | | | (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
* * include/ruby/encoding.h (rb_str_transcode): make 3rd argumentakr2008-08-241-4/+5
| | | | | | | | | | | | | | | | 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
* * include/ruby/io.h (rb_io_t): make enc and enc2 as structakr2008-08-241-48/+42
| | | | | | | | | | 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
* * include/ruby/encoding.h (rb_econv_opts): declared.akr2008-08-241-28/+8
| | | | | | | | | | * 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
* * include/ruby/encoding.h (rb_econv_option_t): defined.akr2008-08-241-15/+16
| | | | | | | | | | | | | | | | (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
* * include/ruby/encoding.h (rb_str_transcode): add ecflags argument.akr2008-08-241-7/+26
| | | | | | | | | | | | | | | | | | | | * 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
* * include/ruby/encoding.h (rb_econv_substr_append): renamed fromakr2008-08-241-1/+1
| | | | | | | | | | | | | | | | | | | 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
* * include/ruby/encoding.h (rb_econv_open_exc): declared.akr2008-08-241-2/+4
| | | | | | | | | | | | | * 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
* * io.c (rb_scan_open_args): use pop_last_hash.akr2008-08-231-6/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * include/ruby/io.h (FMODE_INVALID_MASK): defined.akr2008-08-231-0/+35
| | | | | | | | | | | | | | | | | | | | | (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
* * io.c (rb_io_extract_modeenc): check :textmode and :binmode in optionakr2008-08-231-0/+18
| | | | | | | hash. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (check_pipe_command): extracted from rb_f_open and rb_io_open.akr2008-08-231-7/+21
| | | | | | | | (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
* * io.c (read_all): fptr->enc2 is 0 if no conversion.akr2008-08-231-9/+5
| | | | | | | | (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
* * include/ruby/io.h (rb_io_t): remove path field and add pathv field.akr2008-08-231-63/+56
| | | | | | | | | | | | | | | | (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
* * include/ruby/io.h (FMODE_TEXTMODE): defined.akr2008-08-221-55/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* * io.c (rb_io_pid): use PIDT2NUM.akr2008-08-221-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_file_open_generic): take filename as a VALUE.akr2008-08-211-10/+11
| | | | | | | | | | | (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
* * io.c (rb_io_s_sysopen): mode can be a Bignum.akr2008-08-211-5/+8
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_extract_modeenc): notify coerced to caller.akr2008-08-211-6/+12
| | | | | | | (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
* * io.c (rb_io_extract_modeenc): use rb_check_to_integer to testakr2008-08-211-3/+4
| | | | | | | integer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18759 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_io_initialize): accept hash argument.akr2008-08-211-13/+15
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18756 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_extract_encoding_option): if internal encoding is notakr2008-08-211-1/+4
| | | | | | | specified, enc is external encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_extract_encoding_option): enc2 is external encoding ifakr2008-08-201-31/+46
| | | | | | | | | | | | | | | | 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
* * io.c (prep_io): local variable renamed.akr2008-08-201-7/+7
| | | | | | | | (rb_io_fdopen): ditto. (prep_stdio): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (open_key_args): simplified.akr2008-08-201-6/+3
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (open_key_args): IO.foreach(path, rs, limit) didn't work.akr2008-08-201-3/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18737 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_file_sysopen_internal): unused function removed.akr2008-08-201-13/+1
| | | | | | | (rb_file_sysopen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c: use mode_t for the 3rd argument, permission, of open(2).akr2008-08-201-30/+30
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (io_set_encoding): removed.akr2008-08-201-22/+11
| | | | | | | | | (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
* * io.c (rb_file_open_internal): use rb_io_flags_modenum.akr2008-08-201-7/+8
| | | | | | | | (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
* * io.c (rb_io_open_with_args): use rb_open_file instead of rb_io_open.akr2008-08-201-12/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18726 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (rb_scan_open_args): extracted from rb_open_file.akr2008-08-201-4/+20
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18725 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * io.c (convconfig_t): new type.akr2008-08-201-42/+96
| | | | | | | | | | | | | (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