1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2008-08-31 05:18:29 +00:00
parent f3c43ae0c2
commit 9d2accff2b
3 changed files with 21 additions and 2 deletions

View file

@ -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> Sun Aug 31 14:12:06 2008 Tanaka Akira <akr@fsij.org>
* transcode.c (make_econv_exception): error message simplified. * transcode.c (make_econv_exception): error message simplified.

View file

@ -93,7 +93,16 @@ class TestEncodingConverter < Test::Unit::TestCase
assert_equal("\xEF\xBD\xA1".force_encoding("UTF-8") * n, dst) assert_equal("\xEF\xBD\xA1".force_encoding("UTF-8") * n, dst)
end 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") ec = Encoding::Converter.new("Shift_JIS", "UTF-8")
n = 2000 n = 2000
src = "\xa1".force_encoding("Shift_JIS") * n src = "\xa1".force_encoding("Shift_JIS") * n

View file

@ -2321,6 +2321,8 @@ econv_result_to_symbol(rb_econv_result_t res)
/* /*
* call-seq: * 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) -> symbol
* primitive_convert(source_buffer, destination_buffer, destination_byteoffset, destination_bytesize, flags) -> 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_buffer should be a string.
* *
* destination_byteoffset should be an integer or nil. * 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. * destination_bytesize and flags should be an integer or nil.
* nil means that unlimited. * nil means that unlimited.
* If it is omitted, nil is assumed.
* *
* primitive_convert convert the content of source_buffer from beginning * primitive_convert convert the content of source_buffer from beginning
* and store the result into destination_buffer. * and store the result into destination_buffer.
@ -2409,7 +2414,7 @@ econv_primitive_convert(int argc, VALUE *argv, VALUE self)
unsigned long output_byteend; unsigned long output_byteend;
int flags; 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)) if (NIL_P(output_byteoffset_v))
output_byteoffset = 0; /* dummy */ output_byteoffset = 0; /* dummy */