ruby-changes:7460
From: akr <ko1@a...>
Date: Sun, 31 Aug 2008 14:18:49 +0900 (JST)
Subject: [ruby-changes:7460] Ruby:r18979 (trunk): * transcode.c (econv_primitive_convert): make two arguments,
akr 2008-08-31 14:18:29 +0900 (Sun, 31 Aug 2008) New Revision: 18979 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=18979 Log: * transcode.c (econv_primitive_convert): make two arguments, destination_byteoffset and destination_bytesize, optional. Modified files: trunk/ChangeLog trunk/test/ruby/test_econv.rb trunk/transcode.c Index: ChangeLog =================================================================== --- ChangeLog (revision 18978) +++ ChangeLog (revision 18979) @@ -1,3 +1,8 @@ +Sun Aug 31 14:17:34 2008 Tanaka Akira <akr@f...> + + * transcode.c (econv_primitive_convert): make two arguments, + destination_byteoffset and destination_bytesize, optional. + Sun Aug 31 14:12:06 2008 Tanaka Akira <akr@f...> * transcode.c (make_econv_exception): error message simplified. Index: test/ruby/test_econv.rb =================================================================== --- test/ruby/test_econv.rb (revision 18978) +++ test/ruby/test_econv.rb (revision 18979) @@ -93,8 +93,17 @@ 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 dst = "abcd" * 2000 Index: transcode.c =================================================================== --- transcode.c (revision 18978) +++ transcode.c (revision 18979) @@ -2321,6 +2321,8 @@ /* * 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 @@ * 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 @@ 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 */ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/