mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
2494e67f16
commit
5da4e660ad
2 changed files with 19 additions and 4 deletions
|
@ -1,3 +1,7 @@
|
|||
Thu Sep 4 21:53:58 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* transcode.c (econv_init): accept an integer as 3rd argument as well.
|
||||
|
||||
Thu Sep 4 21:46:21 2008 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* transcode.c (sym_partial_input): new variable.
|
||||
|
|
19
transcode.c
19
transcode.c
|
@ -2361,21 +2361,25 @@ make_dummy_encoding(const char *name)
|
|||
static VALUE
|
||||
econv_init(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE source_encoding, destination_encoding, opthash, ecopts;
|
||||
VALUE source_encoding, destination_encoding, opt, opthash, flags_v, ecopts;
|
||||
int sidx, didx;
|
||||
const char *sname, *dname;
|
||||
rb_encoding *senc, *denc;
|
||||
rb_econv_t *ec;
|
||||
int ecflags;
|
||||
|
||||
rb_scan_args(argc, argv, "21", &source_encoding, &destination_encoding, &opthash);
|
||||
rb_scan_args(argc, argv, "21", &source_encoding, &destination_encoding, &opt);
|
||||
|
||||
if (opthash == Qnil) {
|
||||
if (NIL_P(opt)) {
|
||||
ecflags = 0;
|
||||
ecopts = Qnil;
|
||||
}
|
||||
else if (!NIL_P(flags_v = rb_check_to_integer(opt, "to_int"))) {
|
||||
ecflags = NUM2INT(flags_v);
|
||||
ecopts = Qnil;
|
||||
}
|
||||
else {
|
||||
opthash = rb_convert_type(opthash, T_HASH, "Hash", "to_hash");
|
||||
opthash = rb_convert_type(opt, T_HASH, "Hash", "to_hash");
|
||||
ecflags = rb_econv_prepare_opts(opthash, &ecopts);
|
||||
}
|
||||
|
||||
|
@ -3339,8 +3343,15 @@ Init_transcode(void)
|
|||
rb_define_method(rb_cEncodingConverter, "last_error", econv_last_error, 0);
|
||||
rb_define_method(rb_cEncodingConverter, "replacement", econv_get_replacement, 0);
|
||||
rb_define_method(rb_cEncodingConverter, "replacement=", econv_set_replacement, 1);
|
||||
rb_define_const(rb_cEncodingConverter, "INVALID_MASK", INT2FIX(ECONV_INVALID_MASK));
|
||||
rb_define_const(rb_cEncodingConverter, "INVALID_REPLACE", INT2FIX(ECONV_INVALID_REPLACE));
|
||||
rb_define_const(rb_cEncodingConverter, "UNDEF_MASK", INT2FIX(ECONV_UNDEF_MASK));
|
||||
rb_define_const(rb_cEncodingConverter, "UNDEF_REPLACE", INT2FIX(ECONV_UNDEF_REPLACE));
|
||||
rb_define_const(rb_cEncodingConverter, "PARTIAL_INPUT", INT2FIX(ECONV_PARTIAL_INPUT));
|
||||
rb_define_const(rb_cEncodingConverter, "OUTPUT_FOLLOWED_BY_INPUT", INT2FIX(ECONV_OUTPUT_FOLLOWED_BY_INPUT));
|
||||
rb_define_const(rb_cEncodingConverter, "UNIVERSAL_NEWLINE_DECODER", INT2FIX(ECONV_UNIVERSAL_NEWLINE_DECODER));
|
||||
rb_define_const(rb_cEncodingConverter, "CRLF_NEWLINE_ENCODER", INT2FIX(ECONV_CRLF_NEWLINE_ENCODER));
|
||||
rb_define_const(rb_cEncodingConverter, "CR_NEWLINE_ENCODER", INT2FIX(ECONV_CR_NEWLINE_ENCODER));
|
||||
|
||||
rb_define_method(rb_eConversionUndefined, "source_encoding_name", ecerr_source_encoding_name, 0);
|
||||
rb_define_method(rb_eConversionUndefined, "destination_encoding_name", ecerr_destination_encoding_name, 0);
|
||||
|
|
Loading…
Reference in a new issue