To: vim_dev@googlegroups.com Subject: Patch 8.1.0977 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0977 Problem: Blob not tested with Ruby. Solution: Add more test coverage. fixes a crash. (Dominique Pelle, closes #4036) Files: src/if_ruby.c, src/testdir/test_ruby.vim *** ../vim-8.1.0976/src/if_ruby.c 2019-02-18 20:42:46.834041670 +0100 --- src/if_ruby.c 2019-02-23 14:17:11.461680173 +0100 *************** *** 1267,1273 **** int i; for (i = 0; i < RSTRING_LEN(str); i++) { ! sprintf(buf, "%02X", RSTRING_PTR(str)[i]); rb_str_concat(result, rb_str_new2(buf)); } return result; --- 1267,1273 ---- int i; for (i = 0; i < RSTRING_LEN(str); i++) { ! sprintf(buf, "%02X", (unsigned char)(RSTRING_PTR(str)[i])); rb_str_concat(result, rb_str_new2(buf)); } return result; *** ../vim-8.1.0976/src/testdir/test_ruby.vim 2018-08-11 14:24:06.945748177 +0200 --- src/testdir/test_ruby.vim 2019-02-23 14:22:47.707724036 +0100 *************** *** 306,311 **** --- 306,314 ---- call assert_equal('foo', RubyEval('Vim::evaluate("\"foo\"")')) call assert_equal('String', RubyEval('Vim::evaluate("\"foo\"").class')) + call assert_equal('["\x01\xAB"]', RubyEval('Vim::evaluate("0z01ab").unpack("M")')) + call assert_equal('String', RubyEval('Vim::evaluate("0z01ab").class')) + call assert_equal('[1, 2]', RubyEval('Vim::evaluate("[1, 2]")')) call assert_equal('Array', RubyEval('Vim::evaluate("[1, 2]").class')) *************** *** 324,329 **** --- 327,339 ---- call assert_equal('FalseClass',RubyEval('Vim::evaluate("v:false").class')) endfunc + func Test_Vim_blob() + call assert_equal('0z', RubyEval('Vim::blob("")')) + call assert_equal('0z31326162', RubyEval('Vim::blob("12ab")')) + call assert_equal('0z00010203', RubyEval('Vim::blob("\x00\x01\x02\x03")')) + call assert_equal('0z8081FEFF', RubyEval('Vim::blob("\x80\x81\xfe\xff")')) + endfunc + func Test_Vim_evaluate_list() call setline(line('$'), ['2 line 2']) ruby Vim.command("normal /^2\n") *** ../vim-8.1.0976/src/version.c 2019-02-22 19:40:57.693250456 +0100 --- src/version.c 2019-02-23 14:18:10.413345154 +0100 *************** *** 781,782 **** --- 781,784 ---- { /* Add new patch number below this line */ + /**/ + 977, /**/ -- hundred-and-one symptoms of being an internet addict: 22. You've already visited all the links at Yahoo and you're halfway through Lycos. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///