aboutsummaryrefslogtreecommitdiffstats
path: root/transcode.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-13 06:08:56 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-08-13 06:08:56 +0000
commit4aa251999d88642e0b58a9e1d2060b8f219fd299 (patch)
tree45346dbaf12cc2ab5a8cf73d6f1e26c0ce1ff9c7 /transcode.c
parenteb8e0dc10e6eb69a9472f8c8816158d2f58077fd (diff)
downloadruby-4aa251999d88642e0b58a9e1d2060b8f219fd299.tar.gz
* 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
Diffstat (limited to 'transcode.c')
-rw-r--r--transcode.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/transcode.c b/transcode.c
index 62e11c7551..4d709f04b1 100644
--- a/transcode.c
+++ b/transcode.c
@@ -1290,15 +1290,21 @@ econv_s_allocate(VALUE klass)
}
static VALUE
-econv_init(VALUE self, VALUE from_encoding, VALUE to_encoding, VALUE flags_v)
+econv_init(int argc, VALUE *argv, VALUE self)
{
+ VALUE from_encoding, to_encoding, flags_v;
const char *from_e, *to_e;
rb_trans_t *ts;
int flags;
+ rb_scan_args(argc, argv, "21", &from_encoding, &to_encoding, &flags_v);
+
StringValue(from_encoding);
StringValue(to_encoding);
- flags = NUM2INT(flags_v);
+ if (flags_v == Qnil)
+ flags = 0;
+ else
+ flags = NUM2INT(flags_v);
from_e = RSTRING_PTR(from_encoding);
to_e = RSTRING_PTR(to_encoding);
@@ -1331,8 +1337,9 @@ check_econv(VALUE self)
}
static VALUE
-econv_primitive_convert(VALUE self, VALUE input, VALUE output, VALUE output_size_v, VALUE flags_v)
+econv_primitive_convert(int argc, VALUE *argv, VALUE self)
{
+ VALUE input, output, output_size_v, flags_v;
rb_trans_t *ts = check_econv(self);
rb_trans_result_t res;
const unsigned char *ip, *is;
@@ -1340,8 +1347,13 @@ econv_primitive_convert(VALUE self, VALUE input, VALUE output, VALUE output_size
long output_size;
int flags;
+ rb_scan_args(argc, argv, "31", &input, &output, &output_size_v, &flags_v);
+
output_size = NUM2LONG(output_size_v);
- flags = NUM2INT(flags_v);
+ if (flags_v == Qnil)
+ flags = 0;
+ else
+ flags = NUM2INT(flags_v);
StringValue(output);
StringValue(input);
rb_str_modify(output);
@@ -1397,8 +1409,8 @@ Init_transcode(void)
rb_cEncodingConverter = rb_define_class_under(rb_cEncoding, "Converter", rb_cData);
rb_define_alloc_func(rb_cEncodingConverter, econv_s_allocate);
- rb_define_method(rb_cEncodingConverter, "initialize", econv_init, 3);
- rb_define_method(rb_cEncodingConverter, "primitive_convert", econv_primitive_convert, 4);
+ rb_define_method(rb_cEncodingConverter, "initialize", econv_init, -1);
+ rb_define_method(rb_cEncodingConverter, "primitive_convert", econv_primitive_convert, -1);
rb_define_method(rb_cEncodingConverter, "max_output", econv_max_output, 0);
rb_define_const(rb_cEncodingConverter, "PARTIAL_INPUT", INT2FIX(PARTIAL_INPUT));
rb_define_const(rb_cEncodingConverter, "UNIVERSAL_NEWLINE", INT2FIX(UNIVERSAL_NEWLINE));