naruse
634cfdc6e6
Set encoding and strip bom when modeenc string is "r:foo-bom" [ruby-dev:37236]
...
* include/ruby/io.h (FMODE_STRIP_BOM): new constant.
* io.c (io_encname_bom_p): judge whether the encoding name
is *-bom or not.
(parse_mode_enc): drop "-bom".
(rb_io_modestr_fmode): set FMODE_STRIP_BOM if needed.
(rb_io_extract_modeenc): ditto.
(io_strip_bom): strip bom if exists.
(io_set_encoding_by_bom): set encoding if there is bom.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24001 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-07-09 14:47:48 +00:00
nobu
877dca1e27
* include/ruby/io.h (typedef struct rb_io_t):
...
* io.c (flush_before_seek):
* io.c (io_fillbuf):
* io.c (io_fread):
* io.c (io_getpartial):
* ruby.c (load_file_internal):
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@21709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-01-21 04:56:06 +00:00
nobu
551dfe9d8b
* include/ruby/io.h (rb_io_t): added write_lock to serialize.
...
[ruby-core:19668]
* gc.c (gc_mark_children): mark write_lock.
* gc.c (rb_gc_call_finalizer_at_exit): Mutex also needs to be
deferred.
* io.c (io_fflush, io_binwrite, fptr_finalize): serializes writing.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20144 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-11-07 20:47:02 +00:00
mame
ca9589aeb0
* io.c (rb_getc, rb_io_fread, rb_io_fwrite, rb_read_pending):
...
remove deprecated functions which do not work. [ruby-dev:36697]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19805 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-10-16 15:18:17 +00:00
akr
2fb01bc0d1
comment changed.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-24 12:23:52 +00:00
akr
baac56be36
* include/ruby/io.h (rb_io_t): rename field: writeconv_stateless to
...
writeconv_asciicompat.
* io.c: follow the renaming.
* gc.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19274 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-09 15:02:42 +00:00
akr
01acf18704
* include/ruby/io.h (rb_io_modestr_fmode): renamed from
...
rb_io_mode_flags.
(rb_io_modestr_oflags): renamed from rb_io_mode_modenum.
(rb_io_oflags_fmode): renamed from rb_io_modenum_flags.
(rb_io_mode_flags): defined as a macro.
(rb_io_modenum_flags): ditto.
* io.c: follow the renaming with consistency.
* process.c (check_exec_redirect): call rb_io_modestr_oflags.
* ext/pty/depend: pty.o depends on io.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19153 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 11:30:35 +00:00
akr
12a55a6c7d
* include/ruby/io.h (rb_io_mode_modenum): moved from
...
include/ruby/intern.h.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 11:08:10 +00:00
akr
49e9f42703
* include/ruby/io.h (rb_io_enc_t): rename flags to ecflags.
...
(rb_io_t): rename writeconv_pre_flags to writeconv_pre_ecflags.
(MakeOpenFile): follow the renaming.
* io.c: follow the renaming.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19124 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-04 10:22:11 +00:00
akr
58964e3249
* include/ruby/io.h (rb_io_t): new fields: encs.ecopts and
...
writeconv_pre_ecopts.
(MakeOpenFile): initialize them.
* include/ruby/encoding.h (rb_str_transcode): take ecopts argument.
(rb_econv_flags): removed.
(rb_econv_prepare_opts): declared.
(rb_econv_open_opts): declared.
* io.c (make_writeconv): use rb_econv_open_opts.
(make_readconv): ditto.
(io_fwrite): follow rb_str_transcode change.
(rb_io_extract_modeenc): use rb_econv_prepare_opts.
(rb_file_open_generic): initialize encs.ecopts.
(rb_file_open_internal): ditto.
(rb_io_reopen): ditto.
(argf_ecopts): defined.
(argf_next_argv): set encs.ecopts.
(io_encoding_set): use rb_econv_prepare_opts.
(argf_set_encoding): set argf_ecopts.
* gc.c (gc_mark_children): mark encs.ecopts and writeconv_pre_ecopts
in T_FILE.
* transcode.c (transcode_loop): take ecopts argument. use
rb_econv_open_opts.
(rb_econv_flags): removed.
(rb_econv_prepare_opts): defined.
(rb_econv_open_opts): defined.
(str_transcode0): take ecopts.
(str_transcode): use rb_econv_prepare_opts.
(rb_str_transcode): take ecopts.
(econv_init): accept hash argument.
(econv_insert_output): follow rb_str_transcode change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19109 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 18:18:10 +00:00
akr
56343375b8
* include/ruby/encoding.h (rb_econv_option_t): removed. Since
...
rb_econv_option_t has only one field, int flags, rb_econv_option_t is
replaced by int.
* include/ruby/io.h: follow the above change.
* io.c: ditto.
* transcode.c: ditto.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19103 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 15:11:46 +00:00
akr
a08b97c2f6
* include/ruby/io.h (rb_io_t): refcnt field removed.
...
(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
2008-08-27 17:19:19 +00:00
akr
99a26ac164
* include/ruby/io.h (rb_io_t): rename crbuf to cbuf.
...
* io.c: follow the renaming.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18874 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-26 15:06:28 +00:00
akr
75b2d7cbe8
* include/ruby/io.h (rb_io_t): new field: writeconv_pre_opts.
...
* 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
2008-08-25 17:45:30 +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
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
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
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
f78380f0f1
* include/ruby/io.h (FMODE_TRUNC): value changed because 0x100 is used
...
as FMODE_NOREVLOOKUP in socket.c
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18717 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 21:10:28 +00:00
akr
b929da2a1e
* include/ruby/io.h (FMODE_TRUNC): new constant.
...
* io.c (rb_io_mode_flags): set FMODE_TRUNC for "w".
(rb_io_modenum_flags): set FMODE_TRUNC for O_TRUNC.
(rb_io_flags_modenum): new function.
(rb_io_mode_modenum): just use rb_io_mode_flags and
rb_io_flags_modenum.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 18:38:32 +00:00
akr
21ba5836e6
* include/ruby/io.h (rb_fopen): declaration removed.
...
* io.c (rb_fopen): unused function removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18709 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 12:51:52 +00:00
akr
074ad688b1
* include/ruby/io.h (FMODE_READWRITE): define as
...
FMODE_READABLE|FMODE_WRITABLE.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18708 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 12:14:55 +00:00
akr
b7643cfdcd
* include/ruby/io.h (FMODE_*): sorted and describe the values in
...
hexadecimal.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18703 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 09:06:38 +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
f7bdac01c2
update comment.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 08:00:55 +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
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
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
matz
266d186bcf
* include/ruby/io.h (MakeOpenFile): fptr->enc should be
...
intialized to zero. [ruby-dev:32569]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14207 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-12-13 04:10:24 +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
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
nobu
2b592580bf
* include/ruby: moved public headers.
...
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-06-10 03:06:15 +00:00