diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | test/ruby/test_econv.rb | 11 | ||||
-rw-r--r-- | transcode.c | 7 |
3 files changed, 21 insertions, 2 deletions
@@ -1,3 +1,8 @@ +Sun Aug 31 14:17:34 2008 Tanaka Akira <akr@fsij.org> + + * transcode.c (econv_primitive_convert): make two arguments, + destination_byteoffset and destination_bytesize, optional. + Sun Aug 31 14:12:06 2008 Tanaka Akira <akr@fsij.org> * transcode.c (make_econv_exception): error message simplified. diff --git a/test/ruby/test_econv.rb b/test/ruby/test_econv.rb index 52e8b97b4f..b1052dfc21 100644 --- a/test/ruby/test_econv.rb +++ b/test/ruby/test_econv.rb @@ -93,7 +93,16 @@ class TestEncodingConverter < Test::Unit::TestCase assert_equal("\xEF\xBD\xA1".force_encoding("UTF-8") * n, dst) end - def test_nil_destination_bytesize_with_nonnli_byteoffset + def test_nil_destination_bytesize2 + ec = Encoding::Converter.new("Shift_JIS", "UTF-8") + n = 10000 + src = "\xa1".force_encoding("Shift_JIS") * n + ret = ec.primitive_convert(src, dst="") + assert_equal(:finished, ret) + assert_equal("\xEF\xBD\xA1".force_encoding("UTF-8") * n, dst) + end + + def test_nil_destination_bytesize_with_nonnil_byteoffset ec = Encoding::Converter.new("Shift_JIS", "UTF-8") n = 2000 src = "\xa1".force_encoding("Shift_JIS") * n diff --git a/transcode.c b/transcode.c index 420f5752ff..d692b13d79 100644 --- a/transcode.c +++ b/transcode.c @@ -2321,6 +2321,8 @@ econv_result_to_symbol(rb_econv_result_t res) /* * call-seq: + * primitive_convert(source_buffer, destination_buffer) -> symbol + * primitive_convert(source_buffer, destination_buffer, destination_byteoffset) -> symbol * primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize) -> symbol * primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, flags) -> symbol * @@ -2345,9 +2347,12 @@ econv_result_to_symbol(rb_econv_result_t res) * destination_buffer should be a string. * * destination_byteoffset should be an integer or nil. + * nil means the end of destination_buffer. + * If it is omitted, nil is assumed. * * destination_bytesize and flags should be an integer or nil. * nil means that unlimited. + * If it is omitted, nil is assumed. * * primitive_convert convert the content of source_buffer from beginning * and store the result into destination_buffer. @@ -2409,7 +2414,7 @@ econv_primitive_convert(int argc, VALUE *argv, VALUE self) unsigned long output_byteend; int flags; - rb_scan_args(argc, argv, "41", &input, &output, &output_byteoffset_v, &output_bytesize_v, &flags_v); + rb_scan_args(argc, argv, "23", &input, &output, &output_byteoffset_v, &output_bytesize_v, &flags_v); if (NIL_P(output_byteoffset_v)) output_byteoffset = 0; /* dummy */ |