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

310 Коммитов

Автор SHA1 Сообщение Дата
akr ca3148059b * transcode.c (econv_description): show ECONV_HTML_TEXT_ENCODER and
ECONV_HTML_ATTR_ENCODER.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19188 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 11:11:21 +00:00
akr e4b70ffe43 * transcode.c (rb_econv_binmode): check actual transcoders.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19187 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 11:07:01 +00:00
akr f88c9f03f7 * transcode.c (rb_econv_open): fix last_tc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19186 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 10:54:59 +00:00
akr f10af82d25 * transcode.c (str_transcode0): check ECONV_HTML_TEXT_ENCODER and
ECONV_HTML_ATTR_ENCODER.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 09:48:32 +00:00
akr 987ec6b787 * transcode.c (allocate_converted_string): fix overflow condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 09:39:12 +00:00
akr e490d92548 * transcode.c (sym_html): new variable.
(sym_text): ditto.
  (sym_attr): ditto.
  (econv_opts): check :html=>:text and :html=>:attr.
  (Init_transcode): initialize the above variables.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19180 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 06:07:34 +00:00
akr 34be4c1ce5 * include/ruby/encoding.h (ECONV_HTML_TEXT_ENCODER): new constant.
(ECONV_HTML_ATTR_ENCODER): ditto.

* transcode.c (rb_econv_open): check ECONV_HTML_TEXT_ENCODER and
  ECONV_HTML_ATTR_ENCODER.
  (Init_transcode): Encoding::Converter::HTML_TEXT_ENCODER and
  Encoding::Converter::HTML_ATTR_ENCODER defined.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19179 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 05:47:30 +00:00
akr 5117020d9e * transcode.c (struct trans_open_t): defined to pass num_additional.
(trans_open_i): use struct trans_open_t.
  (rb_econv_open): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19178 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 05:16:40 +00:00
akr 27e9c48ccc * transcode.c (rb_econv_open): needless branch removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19176 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 03:44:31 +00:00
akr 073bced367 * transcode.c (rb_econv_open): test condition simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19175 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 03:38:59 +00:00
akr 393f57670f * transcode.c (stateless_encoding_i): ignore supplemental conversions.
Encoding::Converter.stateless_encoding("html-attr-escaped") should be
  nil.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19174 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-06 03:26:35 +00:00
akr 0be34e2a49 * transcode.c (rb_econv_open): fail for ASCII incompatible with
newline conversion.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 22:27:46 +00:00
akr dc98e2528a * transcode.c (output_hex_charref): upcase hexadecimal digits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19163 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 20:37:36 +00:00
akr c500c37fbc * include/ruby/encoding.h (ECONV_UNDEF_HEX_CHARREF): defined.
* transcode.c (output_hex_charref): new function.
  (rb_econv_convert): call output_hex_charref if
  ECONV_UNDEF_HEX_CHARREF.
  (Init_transcode): Encoding::Converter::UNDEF_HEX_CHARREF added.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19162 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 20:24:18 +00:00
akr 7d3598ee60 * transcode.c (rb_econv_convert): use ECONV_INVALID_MASK and
ECONV_UNDEF_MASK.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19161 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 19:03:21 +00:00
akr 80abde2c89 * transcode.c (allocate_converted_string): add arguments for a buffer
allocated by caller.
  (rb_econv_insert_output): provide caller allocated buffer to
  allocate_converted_string.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19159 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 18:20:20 +00:00
akr f0d9f949e8 * transcode.c (str_transcode_enc_args): local variables renamed.
(str_transcode0): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19158 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 17:59:32 +00:00
akr e93289c03f update rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19157 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 17:25:56 +00:00
akr 134ca08dd1 * transcode.c (econv_s_stateless_encoding): new method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19156 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 17:23:49 +00:00
akr f2fd6d3b15 * transcode.c (enc_arg): extracted from str_transcode_enc_args.
(str_transcode_enc_args): use enc_arg.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-05 17:02:33 +00:00
akr f549f1ae32 * transcode_data.h (rb_transcoder): rename fields:
from_encoding -> src_encoding, to_encoding -> dst_encoding.

* transcode.c: follow the renaming.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19142 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-04 15:46:18 +00:00
akr a50b307900 * transcode.c: variables renamed for consistency.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-04 15:35:30 +00:00
akr 0406b0f154 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-04 13:17:40 +00:00
akr 5da4e660ad * transcode.c (econv_init): accept an integer as 3rd argument as well.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19132 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-04 12:55:02 +00:00
akr 2494e67f16 * transcode.c (sym_partial_input): new variable.
(econv_primitive_convert): accept a hash as 5th argument as well.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19131 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-04 12:48:21 +00:00
akr f7607eff9a * transcode.c (sym_universal_newline_decoder): new variable.
(sym_crlf_newline_encoder): ditto.
  (sym_cr_newline_encoder): ditto.
  (econv_opts): check newline converter options.
  (econv_init): make 3rd argument hash/nil only.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-04 12:08:54 +00:00
akr 0031967d20 * transcode_data.h (PType): defined unconditionaly.
* transcode.c (PType): don't define here.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19127 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-04 11:31:37 +00:00
akr 45c3707303 * include/ruby/encoding.h (ECONV_INVALID_IGNORE): removed because
it tend to cause security problem.  If the behaviour is really
  required, ECONV_INVALID_REPLACE with empty string can be used.
  For example, CVE-2006-2313, CVE-2008-1036, [ruby-core:15645]
  (ECONV_UNDEF_IGNORE): ditto.

* transcode.c (rb_econv_convert): follow the above change.
  (econv_opts): ditto.
  (Init_transcode): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19123 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-04 10:15:34 +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 0ebcad6a7b * include/ruby/encoding.h (rb_econv_set_replacemenet): declared.
* transcode.c (rb_econv_t): new fields: replacement_str,
  replacement_len, replacement_enc and replacement_allocated.
  (get_replacement_character): make len as size_t.
  (rb_econv_open_by_transcoder_entries): initialize the new fields.
  (rb_econv_close): deallocate replacement_str if it allocated.
  (make_replacement): new function.
  (output_replacement_character): use make_replacement.
  (rb_econv_set_replacemenet): defined.
  (econv_get_replacement): new method.
  (econv_set_replacement): new method.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19108 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 16:34:11 +00:00
usa 9b6608c78d * transcode.c (transcode_restartable0): avoid VC++6's bug.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 16:02: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 1afc1b7bc8 * transcode.c (rb_transcoding): moved from transcode_data.h.
(TRANSCODING_READBUF): ditto.
  (TRANSCODING_WRITEBUF): ditto.
  (TRANSCODING_STATE_EMBED_MAX): ditto.
  (TRANSCODING_STATE): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19097 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 14:34:09 +00:00
akr f6441bf61c * transcode_data.h (rb_transcoding): remove stateful field.
add state field.
  (TRANSCODING_STATE): defined.
  (rb_transcoder): add fields: state_size, state_init_func,
  state_fini_func.
  change rb_transcoding* argument to void*.

* transcode.c (transcode_restartable0): use TRANSCODING_STATE for
  first arguments of transcoder functions.
  (rb_transcoding_open_by_transcoder): initialize state field.
  (rb_transcoding_close): finalize state field.

* tool/transcode-tblgen.rb: provide state size/init/fini.

* enc/trans/newline.trans (universal_newline_init): defined.
  (fun_so_universal_newline): take void* as a state pointer.
  (rb_universal_newline): provide state size/init/fini.
  (rb_crlf_newline): ditto.
  (rb_cr_newline): ditto.

* enc/trans/iso2022.trans (iso2022jp_init): defined.
  (fun_si_iso2022jp_to_eucjp): take void* as a state pointer.
  (fun_so_iso2022jp_to_eucjp): ditto.
  (fun_so_eucjp_to_iso2022jp): ditto.
  (iso2022jp_reset_sequence_size): ditto.
  (finish_eucjp_to_iso2022jp): ditto.
  (rb_ISO_2022_JP_to_EUC_JP): provide state size/init/fini.
  (rb_EUC_JP_to_ISO_2022_JP): ditto.

* enc/trans/utf_16_32.trans (fun_so_from_utf_16be): take void* as a
  state pointer.
  (fun_so_to_utf_16be): ditto.
  (fun_so_from_utf_16le): ditto.
  (fun_so_to_utf_16le): ditto.
  (fun_so_from_utf_32be): ditto.
  (fun_so_to_utf_32be): ditto.
  (fun_so_from_utf_32le): ditto.
  (fun_so_to_utf_32le): ditto.
  (rb_from_UTF_16BE): provide state size/init/fini.
  (rb_to_UTF_16BE): ditto.
  (rb_from_UTF_16LE): ditto.
  (rb_to_UTF_16LE): ditto.
  (rb_from_UTF_32BE): ditto.
  (rb_to_UTF_32BE): ditto.
  (rb_from_UTF_32LE): ditto.
  (rb_to_UTF_32LE): ditto.

* enc/trans/japanese.trans (fun_so_eucjp2sjis): take void* as a state
  pointer.
  (fun_so_sjis2eucjp): ditto.
  (rb_eucjp2sjis): provide state size/init/fini.
  (rb_sjis2eucjp): provide state size/init/fini.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 14:12:06 +00:00
akr 6378201f8b * transcode_data.h (WORDINDEX_SHIFT_BITS): defined.
(WORDINDEX2INFO): defined.
  (INFO2WORDINDEX): defined.

* tool/transcode-tblgen.rb: use WORDINDEX2INFO.

* transcode.c: use INFO2WORDINDEX.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19093 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 12:35:29 +00:00
akr 6fe24d1f13 refactor last change.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 12:09:59 +00:00
akr 069f85f812 * transcode.c (BL_MIN_BYTE): defined.
(BL_MAX_BYTE): defined.
  (BL_OFFSET): defined.
  (BL_ACTION): defined.
  (transcode_restartable0): use BL_MIN_BYTE, BL_MAX_BYTE and
  BL_ACTION.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 12:08:27 +00:00
akr ac5631e6f0 * transcode.c (BYTE_ADDR): defined.
(WORD_ADDR): ditto.
  (BL_BASE): use BYTE_ADDR and WORD_ADDR.
  (BL_INFO): use WORD_ADDR.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19089 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-03 11:59:50 +00:00
akr 41e1933fd8 * transcode_data.h (base_element): removed.
(BYTE_LOOKUP): removed.
  (BYTE_LOOKUP_BASE): don't cast.
  (BYTE_LOOKUP_INFO): ditto.
  (PType): unsigned int, instead of uintptr_t.
  (rb_transcoding): change type of next_field, conv_tree_start and
  word_array.

* tool/transcode-tblgen.rb: generate word_array as array of unsigned
  int.

* transcode.c (transcode_restartable0): follow the above type change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19070 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-02 13:26:02 +00:00
akr 6058eeaf03 * tool/transcode-tblgen.rb: record infos and BYTE_LOOKUPs as index of
word_array to avoid relocation.

* transcode.c (transcode_restartable0): add word_array to get infos
  and BYTE_LOOKUPs.

* transcode_data.h (BYTE_LOOKUP_INFO): change return type to
  uintptr_t.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-01 18:06:28 +00:00
akr 7908180df1 * tool/transcode-tblgen.rb: record offsets array as index of
byte_array to avoid relocation.

* transcode.c (transcode_restartable0): add byte_array to get offsets
  array.

* transcode_data.h (BYTE_LOOKUP_BASE): change return type to
  uintptr_t.
  (rb_transcoder): add fields: byte_array, word_array and word_size.

* enc/trans/newline.trans: follow rb_transcoder change.

* enc/trans/iso2022.trans: ditto.

* enc/trans/utf_16_32.trans: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19043 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-01 17:40:32 +00:00
akr 752e053a1d * transcode_data.h (BYTE_LOOKUP): change to uintptr_t array.
(BYTE_LOOKUP_BASE): follow the type change.
  (BYTE_LOOKUP_INFO): ditto.
  (PType): ditto.
  (rb_transcoding): ditto.

* tool/transcode-tblgen.rb: follow the type change.

* transcode.c: ditto.

* enc/trans/newline.trans: ditto.

* enc/trans/iso2022.trans: ditto.

* enc/trans/utf_16_32.trans: ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19038 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-01 16:22:49 +00:00
akr 2ae7b0328e * transcode_data.h (BYTE_LOOKUP_BASE): abstract accessor for
BYTE_LOOKUP.
  (BYTE_LOOKUP_INFO): ditto.

* transcode.c (transcode_restartable0): use BYTE_LOOKUP_BASE and
  BYTE_LOOKUP_INFO.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19037 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-09-01 14:33:56 +00:00
akr e7ee4fabd4 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 15:31:14 +00:00
akr a017cecf42 fix typos.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18999 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 14:24:51 +00:00
akr c3434e35ac rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18996 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 09:38:12 +00:00
akr 69610b07c3 * transcode.c (transcode.c): set source_encoding and
destination_encoding as encoding object.
  (ecerr_source_encoding): new method.
  (ecerr_destination_encoding): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18993 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 09:08:31 +00:00
akr 72ee10b19c * transcode.c (make_econv_exception): rename instance variable names
for storing encoding names.
  (ecerr_source_encoding_name): method renamed.
  (ecerr_destination_encoding_name): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 08:17:48 +00:00
akr 2d71485ec1 * transcode.c (econv_putback): associate encoding to the result.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 07:59:03 +00:00
akr d427cf3af8 * transcode.c (econv_insert_output): raise ArgumentError on failure.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 07:43:19 +00:00
akr c3f55e6d48 * transcode.c (econv_last_error): new method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18980 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 05:27:52 +00:00
akr 9d2accff2b * transcode.c (econv_primitive_convert): make two arguments,
destination_byteoffset and destination_bytesize, optional.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18979 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 05:18:29 +00:00
akr f3c43ae0c2 * transcode.c (make_econv_exception): error message simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-31 05:12:32 +00:00
akr d9c5f88abc * transcode.c (econv_putback): make max argument optional.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18967 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-30 19:39:16 +00:00
akr 97a5808a14 * transcode.c (rb_econv_putback): putback from last byte.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-30 19:36:38 +00:00
akr 998a4ec5af * transcode.c (econv_putback): renamed from econv_primitive_putback.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18965 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-30 19:27:35 +00:00
akr 5bbc51ed43 * transcode.c (econv_insert_output): renamed from
econv_primitive_insert_output.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18964 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-30 19:23:23 +00:00
akr 5e222d6945 * transcode.c (econv_primitive_errinfo): 5th element (partial_input)
removed from result.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-30 18:45:48 +00:00
akr c2ba5cf9c5 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18929 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-29 16:25:27 +00:00
akr d4afbe49f3 rdoc update.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18914 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-28 18:28:52 +00:00
akr 2c80188627 * transcode.c (econv_finish): new method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18913 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-28 18:00:02 +00:00
akr 23d10cbb00 * transcode.c (econv_convert): new method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18912 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-28 17:46:18 +00:00
akr ad8cfb1b94 * transcode.c (econv_primitive_convert): accept nil as
destination_bytesize for unlimited destination size.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18911 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-28 17:39:02 +00:00
akr 3811bb53bd * transcode.c (econv_primitive_convert): accept nil as input for empty
input.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-28 17:13:49 +00:00
akr c23ec90e81 * transcode.c (sym_invalid_byte_sequence): new variable.
(sym_undefined_conversion): ditto.
  (sym_destination_buffer_full): ditto.
  (sym_source_buffer_empty): ditto.
  (sym_finished): ditto.
  (sym_output_followed_by_input): ditto.
  (sym_incomplete_input): ditto.
  (econv_result_to_symbol): use above variables.
  (Init_transcode): initialize above variables.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-28 16:59:17 +00:00
akr 1366802a1f * transcode.c (transcode_loop): simplified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-26 16:14:49 +00:00
akr db6ec3105e * include/ruby/encoding.h (rb_econv_result_t): enumeration constant:
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
2008-08-26 16:09:29 +00:00
akr a68e409eaa * include/ruby/encoding.h (rb_econv_elem_t): move to transcode.c
(rb_econv_t): defined as an incomplete type.

* transcode.c (rb_econv_elem_t): moved from encoding.h.
  (rb_econv_t): complete type defined.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-26 15:01:11 +00:00
akr 19ab08653e * transcode.c (rb_econv_open): disable newline conversion for ASCII
incompatible encodings.
  (str_transcode0): don't need disable newline conversion here.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-26 12:55:14 +00:00
akr 18b097b73b * transcode.c (rb_econv_binmode): binmode is effective only once.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-26 12:45:20 +00:00
akr 873987f2e0 * transcode.c (str_transcode0): disable newline conversion for ASCII
incompatible encoding.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 16:27:23 +00:00
akr 1a805010ed * transcode.c (str_transcode0): don't short cut for newline conversion.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18852 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 15:58:35 +00:00
akr 86154f63b3 * transcode.c (make_econv_exception): show readagain part for invalid
byte sequence exception.  store the part as an instance variable.
  (ecerr_readagain_bytes): new method to access the readagain part.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18850 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 15:26:54 +00:00
akr 0486026389 * transcode.c (rb_econv_open): make last_tc NULL if there are only
additional transcoders.
  (econv_description): extracted from rb_econv_open_exc.
  (rb_econv_open_exc): use econv_description.
  (econv_inspect): use econv_description.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18843 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 15:01:36 +00:00
akr aeffc67dbb * transcode.c (rb_econv_open_by_transcoder_entries): initialize
last_error.  num_trans may be zero.
  (rb_econv_convert0): num_trans may be zero.
  (rb_econv_putbackable): ditto.
  (rb_econv_putback): ditto.
  (rb_econv_convert): input_ptr and output_ptr may be NULL.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18835 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 13:04:16 +00:00
nobu 10906176b4 * transcode.c (rb_econv_substr_append): fix for buffer overrun.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18831 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 08:35:42 +00:00
nobu 8c6040edca * transcode.c (rb_econv_open_exc): constified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18828 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-25 01:42:36 +00:00
akr 2c78899641 * configure.in (BUILTIN_TRANSSRCS): defined.
(BUILTIN_TRANSOBJS): defined.

* enc/Makefile.in (BUILTIN_TRANSES): defined.

* enc/make_encmake.rb (BUILTIN_TRANSES): defined.

* enc/depend: don't generate rules for builtin transcoders.

* common.mk (COMMONOBJS): add BUILTIN_TRANSOBJS.
  (enc.mk): pass BUILTIN_TRANSOBJS.
  (newline.c): new rule.
  (newline.$(OBJEXT)): new ru.e
  (srcs): newline.c added.

* Makefile.in (BUILTIN_TRANSSRCS): defined.
  (BUILTIN_TRANSOBJS): defined.

* transcode.c (Init_transcode): call Init_newline.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 15:58:43 +00:00
akr bf5e559ce0 * transcode.c (declare_transcoder): arguments order changed.
(rb_declare_transcoder): call declare_transcoder just once.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 15:13:37 +00:00
akr ae1b02a8da * include/ruby/encoding.h (rb_econv_t): use rb_econv_option_t.
* transcode.c: follow the rb_econv_t change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 10:49:36 +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 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 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 b47c46106a * transcode.c (rb_econv_substr_append): associate dst with destination
encoding when dst is created.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 06:44:21 +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 51ad3df2ce * transcode.c (str_transcode): check last hash only if 0 < argc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18807 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 04:28:12 +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 7c2c7ea315 * transcode.c (rb_econv_open): return NULL on error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18804 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-24 03:03:18 +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 d4fabf0e36 * include/ruby/encoding.h (ECONV_INVALID_MASK): defined.
(ECONV_INVALID_IGNORE): defined.
  (ECONV_INVALID_REPLACE): defined.
  (ECONV_UNDEF_MASK): defined.
  (ECONV_UNDEF_IGNORE): defined.
  (ECONV_UNDEF_REPLACE): defined.

* transcode.c (INVALID_IGNORE): removed.
  (INVALID_REPLACE): removed.
  (UNDEF_IGNORE): removed.
  (UNDEF_REPLACE): removed.
  (rb_econv_convert0): renamed from rb_econv_convert.
  (rb_econv_convert): defined to call rb_econv_convert0 with
  replace/ignore behavior moved from transcode_loop.
  (transcode_loop): replace/ignore behavior removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18787 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-23 06:02:58 +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 8f3e88c432 * transcode.c (rb_econv_open): fix memory leak.
(rb_econv_close): ditto.
  fixed by shinichiro.h.  [ruby-dev:35880]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18710 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-19 17:32:31 +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 8372c16764 * transcode.c (transcode_search_path): prevent infinite loop by
searching a path for self conversion.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18687 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-18 04:22:31 +00:00
akr 128abaede6 * transcode.c (econv_primitive_putback): new method.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18671 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-17 04:40:59 +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 04bbc1df12 * transcode.c (make_econv_exception): add several instance variables
to exception object.
  (ecerr_source_encoding): new method:
  Encoding::ConversionUndefined#source_encoding and 
  Encoding::InvalidByteSequence#source_encoding.
  (ecerr_destination_encoding): new method:
  Encoding::ConversionUndefined#destination_encoding and 
  Encoding::InvalidByteSequence#destination_encoding.
  (econverr_error_char): new method:
  Encoding::ConversionUndefined#error_char.
  (econverr_error_bytes): new method:
  Encoding::ConversionUndefined#error_bytes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18669 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-17 03:05:40 +00:00
akr 6acb0e79c8 * include/ruby/encoding.h (rb_econv_check_error): declared.
* transcode.c (make_econv_exception): new function.
  (transcode_loop): use make_econv_exception.
  (rb_econv_check_error): defined.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18662 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 15:04:39 +00:00
akr 4dff8b2428 * include/ruby/encoding.h (rb_econv_elem_t): fields removed: from and
to.
  (rb_econv_t): new fields: source_encoding_name and
  destination_encoding_name.

* transcode.c (rb_econv_open_by_transcoder_entries): initialize the
  new fields.
  (rb_econv_open): set up the new fields.
  (econv_inspect): use the new fields.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 06:25:38 +00:00
akr 7a0bea4fd3 * include/ruby/encoding.h (rb_econv_t): add fields: in_buf_start,
in_data_start, in_data_end, in_buf_end and last_trans_index.
  (rb_econv_output): removed.
  (rb_econv_insert_output): declared.
  (rb_econv_encoding_to_insert_output): declared.

* enc/trans/newline.trans (rb_universal_newline): stateful_type
  changed.

* transcode.c (transcode_restartable0): initialize inchar_start,
  tc->recognized_len and next_table at beginning of the loop.
  (rb_econv_open_by_transcoder_entries): initialize new fields.
  (rb_econv_open): setup last_trans_index.
  (trans_sweep): last out_buf_start can be non-NULL now.
  (rb_econv_convert): check last out_buf_start and in_buf_start at
  first.
  (rb_econv_output_with_destination_encoding): removed.
  (econv_just_convert): removed.
  (rb_econv_output): removed.
  (econv_primitive_output): method removed.
  (rb_econv_encoding_to_insert_output): new function.
  (allocate_converted_string): new function.
  (rb_econv_insert_output): new function.
  (econv_primitive_insert_output): new method.
  (output_replacement_character): use rb_econv_insert_output.  unused
  arguments removed.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-16 05:32:42 +00:00
akr 3a427c6199 * transcode.c (econv_just_convert): extracted from rb_econv_output.
(rb_econv_output): use econv_just_convert.
  (econv_primitive_output): new method.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18647 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-15 14:17:11 +00:00
akr fe091e89b7 * include/ruby/encoding.h (rb_econv_output): add str_encoding
argument.

* transcode.c (get_replacement_character): add repl_enc_ptr argument.
  (rb_econv_output_with_destination_encoding): renamed from
  rb_econv_output and make it static.
  (rb_econv_output): convert str and call
  rb_econv_output_with_destination_encoding.
  (output_replacement_character): follow above interface change.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-15 11:02:07 +00:00
akr 7f0c5beb6f * include/ruby/encoding.h (rb_econv_t): add error_tc in last_error.
* transcode.c (rb_econv_convert): fill error_tc.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18644 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-15 09:33:59 +00:00
akr 131e194cec * include/ruby/encoding.h (rb_econv_t): new field: last_error.
* transcode.c (rb_trans_conv): new argument: result_position_ptr.
  (rb_econv_convert): fill last_error.
  (econv_result_to_symbol): extracted from econv_primitive_convert.
  (econv_primitive_errinfo): new method.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18643 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-15 09:12:56 +00:00
akr 96ae1f008f * transcode.c (conv_init): check empty name.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-15 00:34:16 +00:00
akr 520cd6d186 * transcode.c (econv_init): don't create dummy encoding if
rb_econv_open is failed.
  (make_dummy_encoding): new function extracted from make_encoding.
  (make_encoding): removed.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18634 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-15 00:05:06 +00:00
akr 95af70c5e7 udpate rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18632 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 16:10:57 +00:00
akr 8eda80ff2c * transcode.c (econv_primitive_convert): set destination_buffer
encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 16:06:33 +00:00
akr 74a36d5d1f * include/ruby/encoding.h (rb_econv_output): declared.
* transcode_data.h (rb_transcoder): add resetsize_func field.

* enc/trans/iso2022.trans (iso2022jp_reset_sequence_size): defined.
  (rb_EUC_JP_to_ISO_2022_JP): provede resetsize_func.

* tool/transcode-tblgen.rb: set NULL for resetsize_func.

* transcode.c (rb_econv_output): new function for inserting output.
  (output_replacement_character): use rb_econv_output.
  (transcode_loop): check return value of
  output_replacement_character.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 15:56:39 +00:00
akr e0e39e0db8 * include/ruby/encoding.h (ECONV_UNIVERSAL_NEWLINE_DECODER): defined.
(ECONV_CRLF_NEWLINE_ENCODER): ditto.
  (ECONV_CR_NEWLINE_ENCODER): ditto.
  (ECONV_PARTIAL_INPUT): ditto.
  (ECONV_OUTPUT_FOLLOWED_BY_INPUT): ditto.

* transcode.c: use ECONV_* defined as above.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18627 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 14:48:41 +00:00
akr ed7d1a25cb * transcode.c: local variable renamed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18626 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 14:35:55 +00:00
akr c82aee31b4 * include/ruby/encoding.h (rb_econv_result_t): moved from
transcode_data.h.
  (rb_econv_elem_t): ditto.
  (rb_econv_t): ditto.  source_encoding and destination_encoding field
  is added.
  (rb_econv_open): declared.
  (rb_econv_convert): ditto.
  (rb_econv_close): ditto.

* transcode.c (rb_econv_open_by_transcoder_entries): initialize
  source_encoding and destination_encoding field as NULL.
  (rb_econv_open): make it external linkage.
  (rb_econv_close): ditto.
  (rb_econv_convert): ditto.  renamed from rb_econv_conv.
  (make_encoding): new function.
  (econv_init): use make_encoding and store rb_encoding* in
  rb_econv_t.
  (econv_source_encoding): new method
  Encoding::Converter#source_encoding.
  (econv_destination_encoding): new method
  Encoding::Converter#destination_encoding.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18625 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 14:28:10 +00:00
akr 87779b507e * transcode_data.h (rb_econv_result_t): change enumeration
constant's prefix: transcode_ to econv_.

* transcode.c: follow the constant prefix change.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18624 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 13:45:54 +00:00
akr a6daaf16b0 * transcode.c (econv_init): accept Encoding object as source_encoding
and destination_encoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18623 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 12:35:19 +00:00
akr db30661aa9 * transcode.c (rb_econv_open_by_transcoder_entries): renamed from
rb_trans_open_by_transcoder_entries.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 11:59:47 +00:00
akr 5a4844ed6c * transcode.c (econv_max_output): removed.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18620 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 11:56:55 +00:00
akr bd9bd52954 * transcode_data.h (transcode_invalid_byte_sequence): renamed from
transcode_invalid_input.
  (transcode_destination_buffer_full): renamed from transcode_obuf_full.
  (transcode_source_buffer_empty): renamed from transcode_ibuf_empty.
  (rb_econv_result_t): renamed from rb_trans_result_t.
  (rb_econv_elem_t): renamed from rb_trans_elem_t.
  (rb_econv_t): renamed from rb_trans_t.

* transcode.c (UNIVERSAL_NEWLINE_DECODER): renamed from
  UNIVERSAL_NEWLINE.
  (CRLF_NEWLINE_ENCODER): renamed from CRLF_NEWLINE.
  (CR_NEWLINE_ENCODER): renamed from CR_NEWLINE.
  (rb_econv_open): renamed from rb_trans_open.
  (rb_econv_close): renamed from rb_trans_close.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18618 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 11:31:27 +00:00
akr dd92751104 * transcode.c (load_transcoder): unused function removed.
(rb_transcoding_open): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 10:42:28 +00:00
akr a99e6c15b8 * transcode.c (rb_econv_conv): new function. it don't consume input
too much, even for multilevel conversion.
  (transcode_loop): use rb_econv_conv.
  (econv_primitive_convert): ditto.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18610 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 06:35:33 +00:00
akr bcae240f19 * transcode_data.h (rb_trans_result_t): new enumeration constant:
transcode_output_followed_by_input.

* transcode.c (OUTPUT_FOLLOWED_BY_INPUT): new flag.
  (transcode_restartable0): suspend when output followed by input if
  OUTPUT_FOLLOWED_BY_INPUT is specified.
  (trans_sweep): check OUTPUT_FOLLOWED_BY_INPUT.
  (rb_trans_conv): support OUTPUT_FOLLOWED_BY_INPUT.
  (econv_primitive_convert): return :output_followed_by_input for
  transcode_output_followed_by_input.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18608 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 06:12:27 +00:00
nobu 914969a040 * thread.c (rb_thread_priority_set): get rid of C99 feature.
* transcode.c (transcode_search_path): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 05:56:51 +00:00
nobu 473dbc4e3f * transcode.c (load_transcoder): suppress warning.
* missing/vsnprintf.c (BSD_vfprintf): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-14 03:20:38 +00:00
akr ae8522ff7e rdoc updated.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 23:45:31 +00:00
akr fde26b7d7a * transcode.c (econv_primitive_convert): add output_byteoffset
argument.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 17:24:42 +00:00
nobu e6eb8f0399 * transcode.c (rb_trans_open): constified.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18590 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 15:49:30 +00:00
akr 9adfb3066d * transcode.c (econv_inspect): new method.
+


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 08:47:57 +00:00
akr 3e7d8bf9f8 * transcode.c (transcode_restartable0): several local variables
removed.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 08:36:47 +00:00
akr 04f7390ca8 * transcode_data.h (rb_transcoding): add fields: writebuf_off,
writebuf_len and writebuf.
  (TRANSCODING_WRITEBUF): new macro.

* transcode.c (transcode_restartable0): output until output buffer is
  really full.
  (rb_transcoding_open_by_transcoder): initialize writebuf_len,
  writebuf_off and writebuf.
  (rb_transcoding_close): finalize writebuf.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 08:28:39 +00:00
akr 81719aff65 add rdoc.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 07:32:34 +00:00
akr 4aa251999d * transcode.c (econv_init): make flags argument optional.
(econv_primitive_convert): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18562 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 06:08:56 +00:00
akr a14d5eb09b * enc/trans/newline.trans (rb_crlf_newline): new transcoder.
(rb_cr_newline): new transcoder.

* transcode.c (trans_open_i): one more exra room for input newline
  converter.
  (rb_trans_open): crlf newline and cr newline implemented.
  (Init_transcode): Encoding::Converter::CRLF_NEWLINE and
  Encoding::Converter::LF_NEWLINE defined.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18557 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 05:48:57 +00:00
akr 74a2a7bdbf * enc/trans/newline.trans: new file.
* transcode_data.h (rb_trans_t): add last_tc field.

* transcode.c (UNIVERSAL_NEWLINE): defined.
  (CRLF_NEWLINE): defined.
  (CR_NEWLINE): defined.
  (rb_trans_open_by_transcoder_entries): initialize last_tc.
  (trans_open_i): allocate one more room for newline converter.
  (rb_trans_open): universal newline implemented.
  (more_output_buffer): take max_output argument instead ts.
  (output_replacement_character): take tc argument instead of ts.
  (transcode_loop): use last_tc field.
  (econv_init): add flags argument for rb_trans_open.
  (Init_transcode): Encoding::Converter::UNIVERSAL_NEWLINE defined.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18556 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 05:30:42 +00:00
akr e9ebe1a161 * transcode.c (transcode_search_path): return the length of converter
path.
  (load_transcoder_entry): renamed from load_transcoder.
  (load_transcoder): new function for loding transcoder by encoding
  names.
  (rb_transcoding_open_by_transcoder): extracted from
  rb_transcoding_open.
  (rb_transcoding_open): use load_transcoder and
  rb_transcoding_open_by_transcoder.
  (rb_trans_open_by_transcoder_entries): new function.
  (trans_open_i): construct entries array.
  (rb_trans_open): use rb_trans_open_by_transcoder_entries.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18551 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 02:40:24 +00:00
akr 5501d84ceb * transcode.c (econv_primitive_convert): add output_size argument.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18548 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 23:03:46 +00:00
akr 9d4bb3b969 * transcode.c (rb_trans_conv): report last transcode_obuf_full.
(econv_max_output): new method Encoding::Converter#max_output.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18547 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 22:43:17 +00:00
naruse fc6484cbf4 * transcode.c (str_transcode): fix error message.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18545 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 17:37:47 +00:00
akr edcd02cb5a * transcode.c (rb_cEncodingConverter): new class Encoding::Converter.
(econv_free): new function.
  (econv_s_allocate): ditto.
  (econv_init): ditto.
  (check_econv): ditto.
  (econv_primitive_convert): new method.
  (Init_transcode): define Encoding::Converter.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18544 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 14:46:18 +00:00
akr 608cb2ed32 * transcode.c (rb_trans_open): free ts before raise.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18535 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 09:51:42 +00:00
akr 6d87cec02c * transcode_data.h (rb_trans_elem_t): new field: from and to.
* transcode.c (trans_open_i): just record from and to.
  (rb_trans_open): load transcodings.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18531 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 09:42:49 +00:00
akr abef7fa890 * transcode.c (trans_open_i): check the result of rb_transcoding_open.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18526 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 08:17:27 +00:00
akr 5ade93542f * transcode_data.h (TRANSCODE_ERROR): removed.
* tool/transcode-tblgen.rb: 8bit byte of ASCII-8BIT is a valid
  (but unique to ASCII-8BIT) character.

* transcode.c (rb_eConversionUndefined): new error.
  (rb_eInvalidByteSequence): ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18524 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-12 07:20:10 +00:00
akr 94ca2d94de * transcode_data.h (rb_transcoder): add resetstate_func field for
resetting a state of stateful encoding.

* enc/trans/iso2022.trans (rb_EUC_JP_to_ISO_2022_JP): specify
  finish_eucjp_to_iso2022jp for resetstate_func.

* tool/transcode-tblgen.rb: specify NULL for resetstate_func.

* transcode.c (output_replacement_character): call resetstate_func
  before appending the replacement character.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18503 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-11 22:44:23 +00:00
akr 5f9b877ebe * transcode.c (get_replacement_character): extracted from
output_replacement_character.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18502 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-11 22:21:15 +00:00
akr 425098de96 * transcode.c (rb_trans_conv): find second last error.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18500 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-11 21:49:38 +00:00
akr a2901a7c75 * transcode_data.h (rb_trans_result_t): new type.
(rb_trans_elem_t): new type.
  (rb_trans_t): new type.

* transcode.c (transcode_dispatch_cb): removed.
  (transcode_dispatch): removed.
  (rb_transcoding_result_t): moved to rb_trans_result_t in
  transcode_data.h.
  (transcode_restartable0): goto follow_info when FUNsi.
  (rb_transcoding_open): use get_transcoder_entry.
  (rb_trans_open): new function.
  (rb_trans_conv): ditto.
  (rb_trans_close): ditto.
  (trans_open_i): ditto.
  (trans_sweep): ditto.
  (more_output_buffer): take rb_trans_t instead of rb_transcoding as
  an argument.
  (transcode_loop): take from_encoding and to_encoding instead of tr
  as arguments.  use rb_trans_open/rb_trans_conv/rb_trans_close.
  (str_transcode): don't use transcode_dispatch.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-11 15:50:42 +00:00
akr bd5bf3726c * transcode_data.h (rb_transcoding): rename fields.
readlen -> recognized_len.
  feedlen -> readagain_len.

* transcode.c: follow the field renaming.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18481 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-11 01:06:21 +00:00
akr badd9f1efc * transcode.c (transcode_restartable0): invalid handling simplified.
(transcode_restartable): use PARTIAL_INPUT for converting buffered
  input.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18476 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-10 13:37:44 +00:00
akr 436a136b4e * transcode_data.h (rb_transcoding): new field: flags.
* transcode.c (load_transcoder): extracted from transcode_dispatch_cb.
  (rb_transcoding_result_t): renamed from transcode_result_t.
  (rb_transcoding_open): new function.
  (rb_transcoding_convert): ditto.
  (rb_transcoding_close): ditto.
  (transcode_loop): use rb_transcoding_open, rb_transcoding_convert
  and rb_transcoding_close.
  (str_transcode): don't need rb_transcoding.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-10 12:26:01 +00:00
akr 2ce7aeca6e * transcode.c: rename my_transcoding to tc and my_transcoder to tr.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-10 02:33:05 +00:00