To: vim_dev@googlegroups.com Subject: Patch 7.4.1547 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1547 Problem: Getting a cterm highlight attribute that is not set results in the string "-1". Solution: Return an empty string. (Taro Muraoka) Files: src/syntax.c, src/testdir/test_alot.vim, src/testdir/test_syn_attr.vim *** ../vim-7.4.1546/src/syntax.c 2016-03-02 21:51:52.151805147 +0100 --- src/syntax.c 2016-03-11 20:15:03.786035727 +0100 *************** *** 8999,9004 **** --- 8999,9006 ---- n = HL_TABLE()[id - 1].sg_cterm_fg - 1; else n = HL_TABLE()[id - 1].sg_cterm_bg - 1; + if (n < 0) + return NULL; sprintf((char *)name, "%d", n); return name; } *** ../vim-7.4.1546/src/testdir/test_alot.vim 2016-03-12 19:03:28.213328900 +0100 --- src/testdir/test_alot.vim 2016-03-12 19:12:43.551549420 +0100 *************** *** 16,20 **** --- 16,21 ---- source test_searchpos.vim source test_set.vim source test_sort.vim + source test_syn_attr.vim source test_undolevels.vim source test_unlet.vim *** ../vim-7.4.1546/src/testdir/test_syn_attr.vim 2016-03-12 19:22:28.237455612 +0100 --- src/testdir/test_syn_attr.vim 2016-03-12 19:20:51.942461332 +0100 *************** *** 0 **** --- 1,31 ---- + " Test syntax highlighting functions. + + func Test_missing_attr() + hi Mine term=bold cterm=italic + call assert_equal('Mine', synIDattr(hlID("Mine"), "name")) + call assert_equal('', synIDattr(hlID("Mine"), "bg", 'term')) + call assert_equal('1', synIDattr(hlID("Mine"), "bold", 'term')) + call assert_equal('1', synIDattr(hlID("Mine"), "italic", 'cterm')) + hi Mine term=reverse cterm=inverse + call assert_equal('1', synIDattr(hlID("Mine"), "reverse", 'term')) + call assert_equal('1', synIDattr(hlID("Mine"), "inverse", 'cterm')) + hi Mine term=underline cterm=standout gui=undercurl + call assert_equal('1', synIDattr(hlID("Mine"), "underline", 'term')) + call assert_equal('1', synIDattr(hlID("Mine"), "standout", 'cterm')) + call assert_equal('1', synIDattr(hlID("Mine"), "undercurl", 'gui')) + hi Mine term=NONE cterm=NONE gui=NONE + call assert_equal('', synIDattr(hlID("Mine"), "bold", 'term')) + call assert_equal('', synIDattr(hlID("Mine"), "italic", 'cterm')) + call assert_equal('', synIDattr(hlID("Mine"), "reverse", 'term')) + call assert_equal('', synIDattr(hlID("Mine"), "inverse", 'cterm')) + call assert_equal('', synIDattr(hlID("Mine"), "underline", 'term')) + call assert_equal('', synIDattr(hlID("Mine"), "standout", 'cterm')) + call assert_equal('', synIDattr(hlID("Mine"), "undercurl", 'gui')) + + if has('gui') + hi Mine guifg=blue guibg=red font=something + call assert_equal('blue', synIDattr(hlID("Mine"), "fg", 'gui')) + call assert_equal('red', synIDattr(hlID("Mine"), "bg", 'gui')) + call assert_equal('something', synIDattr(hlID("Mine"), "font", 'gui')) + endif + endfunc *** ../vim-7.4.1546/src/version.c 2016-03-12 19:03:28.217328858 +0100 --- src/version.c 2016-03-12 19:07:10.043019897 +0100 *************** *** 745,746 **** --- 745,748 ---- { /* Add new patch number below this line */ + /**/ + 1547, /**/ -- Apparently, 1 in 5 people in the world are Chinese. And there are 5 people in my family, so it must be one of them. It's either my mum or my dad. Or my older brother Colin. Or my younger brother Ho-Cha-Chu. But I think it's Colin. /// 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 ///