From 9be7c04e6cd5b0facedcb56b09a5bcfc339efe03 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 14:28:30 +0100 Subject: [PATCH 1/9] patch 8.0.0179: cannot have a local value for 'formatprg' Problem: 'formatprg' is a global option but the value may depend on the type of buffer. (Sung Pae) Solution: Make 'formatprg' global-local. (closes #1380) --- runtime/doc/options.txt | 2 +- src/normal.c | 10 ++++++---- src/option.c | 11 ++++++++++- src/option.h | 1 + src/structs.h | 1 + src/testdir/test_normal.vim | 32 ++++++++++++++++++++++---------- src/version.c | 2 ++ 7 files changed, 43 insertions(+), 16 deletions(-) diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 3d8e053f48..88dca60b77 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -3417,7 +3417,7 @@ A jump table for the options with a short description can be found at |Q_op|. *'formatprg'* *'fp'* 'formatprg' 'fp' string (default "") - global + global or local to buffer |global-local| {not in Vi} The name of an external program that will be used to format the lines selected with the |gq| operator. The program must take the input on diff --git a/src/normal.c b/src/normal.c index 5d0796f474..3456b73be4 100644 --- a/src/normal.c +++ b/src/normal.c @@ -1984,7 +1984,7 @@ do_pending_operator(cmdarg_T *cap, int old_col, int gui_yank) op_formatexpr(oap); /* use expression */ else #endif - if (*p_fp != NUL) + if (*p_fp != NUL || *curbuf->b_p_fp != NUL) op_colon(oap); /* use external command */ else op_format(oap, FALSE); /* use internal function */ @@ -2197,10 +2197,12 @@ op_colon(oparg_T *oap) } else if (oap->op_type == OP_FORMAT) { - if (*p_fp == NUL) - stuffReadbuff((char_u *)"fmt"); - else + if (*curbuf->b_p_fp != NUL) + stuffReadbuff(curbuf->b_p_fp); + else if (*p_fp != NUL) stuffReadbuff(p_fp); + else + stuffReadbuff((char_u *)"fmt"); stuffReadbuff((char_u *)"\n']"); } diff --git a/src/option.c b/src/option.c index 920f163a5f..6f9610dd0f 100644 --- a/src/option.c +++ b/src/option.c @@ -107,6 +107,7 @@ #if defined(FEAT_BEVAL) && defined(FEAT_EVAL) # define PV_BEXPR OPT_BOTH(OPT_BUF(BV_BEXPR)) #endif +#define PV_FP OPT_BOTH(OPT_BUF(BV_FP)) #ifdef FEAT_EVAL # define PV_FEX OPT_BUF(BV_FEX) #endif @@ -1258,7 +1259,7 @@ static struct vimoption options[] = {(char_u *)"^\\s*\\d\\+[\\]:.)}\\t ]\\s*", (char_u *)0L} SCRIPTID_INIT}, {"formatprg", "fp", P_STRING|P_EXPAND|P_VI_DEF|P_SECURE, - (char_u *)&p_fp, PV_NONE, + (char_u *)&p_fp, PV_FP, {(char_u *)"", (char_u *)0L} SCRIPTID_INIT}, {"fsync", "fs", P_BOOL|P_SECURE|P_VI_DEF, #ifdef HAVE_FSYNC @@ -5481,6 +5482,7 @@ check_buf_options(buf_T *buf) #if defined(FEAT_CRYPT) check_string_option(&buf->b_p_cm); #endif + check_string_option(&buf->b_p_fp); #if defined(FEAT_EVAL) check_string_option(&buf->b_p_fex); #endif @@ -10175,6 +10177,9 @@ unset_global_local_option(char_u *name, void *from) clear_string_option(&buf->b_p_tsr); break; #endif + case PV_FP: + clear_string_option(&buf->b_p_fp); + break; #ifdef FEAT_QUICKFIX case PV_EFM: clear_string_option(&buf->b_p_efm); @@ -10228,6 +10233,7 @@ get_varp_scope(struct vimoption *p, int opt_flags) { switch ((int)p->indir) { + case PV_FP: return (char_u *)&(curbuf->b_p_fp); #ifdef FEAT_QUICKFIX case PV_EFM: return (char_u *)&(curbuf->b_p_efm); case PV_GP: return (char_u *)&(curbuf->b_p_gp); @@ -10308,6 +10314,8 @@ get_varp(struct vimoption *p) case PV_TSR: return *curbuf->b_p_tsr != NUL ? (char_u *)&(curbuf->b_p_tsr) : p->var; #endif + case PV_FP: return *curbuf->b_p_fp != NUL + ? (char_u *)&(curbuf->b_p_fp) : p->var; #ifdef FEAT_QUICKFIX case PV_EFM: return *curbuf->b_p_efm != NUL ? (char_u *)&(curbuf->b_p_efm) : p->var; @@ -10873,6 +10881,7 @@ buf_copy_options(buf_T *buf, int flags) buf->b_p_inde = vim_strsave(p_inde); buf->b_p_indk = vim_strsave(p_indk); #endif + buf->b_p_fp = empty_option; #if defined(FEAT_EVAL) buf->b_p_fex = vim_strsave(p_fex); #endif diff --git a/src/option.h b/src/option.h index 13acabf7bd..0ad2fef64b 100644 --- a/src/option.h +++ b/src/option.h @@ -1029,6 +1029,7 @@ enum , BV_EP , BV_ET , BV_FENC + , BV_FP #ifdef FEAT_EVAL , BV_BEXPR , BV_FEX diff --git a/src/structs.h b/src/structs.h index 3fdfb5fcd2..9c0e0468b4 100644 --- a/src/structs.h +++ b/src/structs.h @@ -2097,6 +2097,7 @@ struct file_buffer long_u b_p_inde_flags; /* flags for 'indentexpr' */ char_u *b_p_indk; /* 'indentkeys' */ #endif + char_u *b_p_fp; /* 'formatprg' */ #if defined(FEAT_EVAL) char_u *b_p_fex; /* 'formatexpr' */ long_u b_p_fex_flags; /* flags for 'formatexpr' */ diff --git a/src/testdir/test_normal.vim b/src/testdir/test_normal.vim index 29bd783ebc..98177851ab 100644 --- a/src/testdir/test_normal.vim +++ b/src/testdir/test_normal.vim @@ -224,21 +224,33 @@ func! Test_normal06_formatprg() " only test on non windows platform if has('win32') return - else - " uses sed to number non-empty lines - call writefile(['#!/bin/sh', 'sed ''/./=''|sed ''/./{', 'N', 's/\n/ /', '}'''], 'Xsed_format.sh') - call system('chmod +x ./Xsed_format.sh') endif - call Setup_NewWindow() - %d - call setline(1, ['a', '', 'c', '', ' ', 'd', 'e']) + + " uses sed to number non-empty lines + call writefile(['#!/bin/sh', 'sed ''/./=''|sed ''/./{', 'N', 's/\n/ /', '}'''], 'Xsed_format.sh') + call system('chmod +x ./Xsed_format.sh') + let text = ['a', '', 'c', '', ' ', 'd', 'e'] + let expected = ['1 a', '', '3 c', '', '5 ', '6 d', '7 e'] + + 10new + call setline(1, text) set formatprg=./Xsed_format.sh norm! gggqG - call assert_equal(['1 a', '', '3 c', '', '5 ', '6 d', '7 e'], getline(1, '$')) + call assert_equal(expected, getline(1, '$')) + bw! + + 10new + call setline(1, text) + set formatprg=donothing + setlocal formatprg=./Xsed_format.sh + norm! gggqG + call assert_equal(expected, getline(1, '$')) + bw! + " clean up set formatprg= + setlocal formatprg= call delete('Xsed_format.sh') - bw! endfunc func! Test_normal07_internalfmt() @@ -251,7 +263,7 @@ func! Test_normal07_internalfmt() norm! gggqG call assert_equal(['1 2 3', '4 5 6', '7 8 9', '10 11 '], getline(1, '$')) " clean up - set formatprg= tw=0 + set tw=0 bw! endfunc diff --git a/src/version.c b/src/version.c index 1b64d5870f..dd5f700f86 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 179, /**/ 178, /**/ From 83381f7129aca00bc2dd24527f160bc6a60d70af Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 14:36:08 +0100 Subject: [PATCH 2/9] patch 8.0.0180: error E937 is used twice Problem: Error E937 is used both for duplicate key in JSON and for trying to delete a buffer that is in use. Solution: Rename the JSON error to E938. (Norio Takagi, closes #1376) --- src/json.c | 2 +- src/testdir/test_json.vim | 2 +- src/version.c | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/json.c b/src/json.c index faaeab35cc..a9333cf076 100644 --- a/src/json.c +++ b/src/json.c @@ -936,7 +936,7 @@ item_end: && dict_find(top_item->jd_tv.vval.v_dict, top_item->jd_key, -1) != NULL) { - EMSG2(_("E937: Duplicate key in JSON: \"%s\""), + EMSG2(_("E938: Duplicate key in JSON: \"%s\""), top_item->jd_key); clear_tv(&top_item->jd_key_tv); clear_tv(cur_item); diff --git a/src/testdir/test_json.vim b/src/testdir/test_json.vim index bd348fc42e..6616365134 100644 --- a/src/testdir/test_json.vim +++ b/src/testdir/test_json.vim @@ -152,7 +152,7 @@ func Test_json_decode() call assert_fails('call json_decode("blah")', "E474:") call assert_fails('call json_decode("true blah")', "E488:") call assert_fails('call json_decode("")', "E474:") - call assert_fails('call json_decode("{\"a\":1,\"a\":2}")', "E937:") + call assert_fails('call json_decode("{\"a\":1,\"a\":2}")', "E938:") call assert_fails('call json_decode("{")', "E474:") call assert_fails('call json_decode("{foobar}")', "E474:") diff --git a/src/version.c b/src/version.c index dd5f700f86..7b576afccf 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 180, /**/ 179, /**/ From 519d7785f4437762c07b2e04217f83a069a8c663 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 14:54:33 +0100 Subject: [PATCH 3/9] patch 8.0.0181: with cursorbind set cursor column highlighting is off Problem: When 'cursorbind' and 'cursorcolumn' are both on, the column highlignt in non-current windows is wrong. Solution: Add validate_cursor(). (Masanori Misono, closes #1372) --- src/move.c | 4 ++++ src/version.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/move.c b/src/move.c index 912e51ccd1..86b19aafc3 100644 --- a/src/move.c +++ b/src/move.c @@ -2841,6 +2841,10 @@ do_check_cursorbind(void) restart_edit_save = restart_edit; restart_edit = TRUE; check_cursor(); +# ifdef FEAT_SYN_HL + if (curwin->w_p_cuc) + validate_cursor(); +# endif restart_edit = restart_edit_save; # ifdef FEAT_MBYTE /* Correct cursor for multi-byte character. */ diff --git a/src/version.c b/src/version.c index 7b576afccf..9a30eaedf4 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 181, /**/ 180, /**/ From e47683a0913f102b6ae08c8848d5aa675d99b188 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 15:52:46 +0100 Subject: [PATCH 4/9] patch 8.0.0182: cursor ilne not update when 'cursorbind' is set Problem: When 'cursorbind' and 'cursorline' are set, but 'cursorcolumn' is not, then the cursor line highlighting is not updated. (Hirohito Higashi) Solution: Call redraw_later() with NOT_VALID. --- src/move.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/move.c b/src/move.c index 86b19aafc3..5968a8b088 100644 --- a/src/move.c +++ b/src/move.c @@ -2851,7 +2851,7 @@ do_check_cursorbind(void) if (has_mbyte) mb_adjust_cursor(); # endif - redraw_later(VALID); + redraw_later(curwin->w_p_cul ? NOT_VALID : VALID); /* Only scroll when 'scrollbind' hasn't done this. */ if (!curwin->w_p_scb) diff --git a/src/version.c b/src/version.c index 9a30eaedf4..806e86511a 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 182, /**/ 181, /**/ From 7173b47958a238bb07f80b8f26fb232b0ea69b4a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 17:04:38 +0100 Subject: [PATCH 5/9] patch 8.0.0183: ubsan warns for unaligned address Problem: Ubsan warns for using a pointer that is not aligned. Solution: First copy the address. (Yegappan Lakshmanan) --- src/channel.c | 9 ++++++++- src/version.c | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/channel.c b/src/channel.c index f522e80c4a..bd31bf3cba 100644 --- a/src/channel.c +++ b/src/channel.c @@ -710,7 +710,14 @@ channel_open( channel_free(channel); return NULL; } - memcpy((char *)&server.sin_addr, host->h_addr, host->h_length); + { + char *p; + + /* When using host->h_addr directly ubsan warns for it to not be + * aligned. First copy the pointer to aviod that. */ + memcpy(&p, &host->h_addr, sizeof(p)); + memcpy((char *)&server.sin_addr, p, host->h_length); + } /* On Mac and Solaris a zero timeout almost never works. At least wait * one millisecond. Let's do it for all systems, because we don't know why diff --git a/src/version.c b/src/version.c index 806e86511a..562757a722 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 183, /**/ 182, /**/ From 2b7bc567b9238aaac682236cb4f727d0376e1302 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 19:24:52 +0100 Subject: [PATCH 6/9] patch 8.0.0184: when an error is caught Vim still exits with non-zero result Problem: When in Ex mode and an error is caught by try-catch, Vim still exits with a non-zero exit code. Solution: Don't set ex_exitval when inside a try-catch. (partly by Christian Brabandt) --- src/message.c | 4 ++-- src/testdir/test_system.vim | 37 +++++++++++++++++++++++++++++++++++++ src/version.c | 2 ++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/message.c b/src/message.c index 7dda6fa893..2982a4051e 100644 --- a/src/message.c +++ b/src/message.c @@ -578,8 +578,6 @@ emsg(char_u *s) return TRUE; called_emsg = TRUE; - if (emsg_silent == 0) - ex_exitval = 1; /* * If "emsg_severe" is TRUE: When an error exception is to be thrown, @@ -642,6 +640,8 @@ emsg(char_u *s) return TRUE; } + ex_exitval = 1; + /* Reset msg_silent, an error causes messages to be switched back on. */ msg_silent = 0; cmd_silent = FALSE; diff --git a/src/testdir/test_system.vim b/src/testdir/test_system.vim index 0446bd9105..f82f751a91 100644 --- a/src/testdir/test_system.vim +++ b/src/testdir/test_system.vim @@ -46,3 +46,40 @@ function! Test_System() call assert_fails('call system("wc -l", 99999)', 'E86:') endfunction + +function! Test_system_exmode() + let cmd=" -es -u NONE -c 'source Xscript' +q; echo $?" + " Need to put this in a script, "catch" isn't found after an unknown + " function. + call writefile(['try', 'call doesnotexist()', 'catch', 'endtry'], 'Xscript') + let a = system(v:progpath . cmd) + call assert_equal('0', a[0]) + call assert_equal(0, v:shell_error) + + " Error before try does set error flag. + call writefile(['call nosuchfunction()', 'try', 'call doesnotexist()', 'catch', 'endtry'], 'Xscript') + let a = system(v:progpath . cmd) + call assert_notequal('0', a[0]) + + let cmd=" -es -u NONE -c 'source Xscript' +q" + let a = system(v:progpath . cmd) + call assert_notequal(0, v:shell_error) + + let cmd=" -es -u NONE -c 'call doesnotexist()' +q; echo $?" + let a = system(v:progpath. cmd) + call assert_notequal(0, a[0]) + + let cmd=" -es -u NONE -c 'call doesnotexist()' +q" + let a = system(v:progpath. cmd) + call assert_notequal(0, v:shell_error) + + let cmd=" -es -u NONE -c 'call doesnotexist()|let a=1' +q; echo $?" + let a = system(v:progpath. cmd) + call assert_notequal(0, a[0]) + + let cmd=" -es -u NONE -c 'call doesnotexist()|let a=1' +q" + let a = system(v:progpath. cmd) + call assert_notequal(0, v:shell_error) + + call delete('Xscript') +endfunc diff --git a/src/version.c b/src/version.c index 562757a722..be361f5c4a 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 184, /**/ 183, /**/ From fad609d067926d350b4e4ee6ecb55bdbf111a272 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 19:38:36 +0100 Subject: [PATCH 7/9] patch 8.0.0185: system() test fails on MS-Windows Problem: The system() test fails on MS-Windows. Solution: Skip the test on MS-Windows. --- src/testdir/test_system.vim | 4 ++++ src/version.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/testdir/test_system.vim b/src/testdir/test_system.vim index f82f751a91..a7de57aacc 100644 --- a/src/testdir/test_system.vim +++ b/src/testdir/test_system.vim @@ -48,6 +48,10 @@ function! Test_System() endfunction function! Test_system_exmode() + if !has('unix') + return + endif + let cmd=" -es -u NONE -c 'source Xscript' +q; echo $?" " Need to put this in a script, "catch" isn't found after an unknown " function. diff --git a/src/version.c b/src/version.c index be361f5c4a..d5fa5495ec 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 185, /**/ 184, /**/ From 5869cf060e60cc09e71b2b3bd85f0576ec78f9f5 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 20:06:14 +0100 Subject: [PATCH 8/9] patch 8.0.0186: confusing error message from assert_notequal() Problem: The error message from assert_notequal() is confusing. Solution: Only mention the expected value. --- src/eval.c | 23 +++++++++++++---------- src/testdir/test_assert.vim | 2 +- src/version.c | 2 ++ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/eval.c b/src/eval.c index 5bed90b3b5..f70d03b369 100644 --- a/src/eval.c +++ b/src/eval.c @@ -9256,6 +9256,8 @@ fill_assert_error( { if (atype == ASSERT_MATCH || atype == ASSERT_NOTMATCH) ga_concat(gap, (char_u *)"Pattern "); + else if (atype == ASSERT_NOTEQUAL) + ga_concat(gap, (char_u *)"Expected not equal to "); else ga_concat(gap, (char_u *)"Expected "); if (exp_str == NULL) @@ -9265,16 +9267,17 @@ fill_assert_error( } else ga_concat_esc(gap, exp_str); - if (atype == ASSERT_MATCH) - ga_concat(gap, (char_u *)" does not match "); - else if (atype == ASSERT_NOTMATCH) - ga_concat(gap, (char_u *)" does match "); - else if (atype == ASSERT_NOTEQUAL) - ga_concat(gap, (char_u *)" differs from "); - else - ga_concat(gap, (char_u *)" but got "); - ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0)); - vim_free(tofree); + if (atype != ASSERT_NOTEQUAL) + { + if (atype == ASSERT_MATCH) + ga_concat(gap, (char_u *)" does not match "); + else if (atype == ASSERT_NOTMATCH) + ga_concat(gap, (char_u *)" does match "); + else + ga_concat(gap, (char_u *)" but got "); + ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0)); + vim_free(tofree); + } } } diff --git a/src/testdir/test_assert.vim b/src/testdir/test_assert.vim index 25630f2dbc..8c54bddb8a 100644 --- a/src/testdir/test_assert.vim +++ b/src/testdir/test_assert.vim @@ -32,7 +32,7 @@ func Test_assert_notequal() call assert_notequal([1, 2, 3], s) call assert_notequal('foo', s) - call assert_match("Expected 'foo' differs from 'foo'", v:errors[0]) + call assert_match("Expected not equal to 'foo'", v:errors[0]) call remove(v:errors, 0) endfunc diff --git a/src/version.c b/src/version.c index d5fa5495ec..6511b36957 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 186, /**/ 185, /**/ From fe6ce331d94c24ad745d0bf329ec0a65a5c07cc9 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 14 Jan 2017 20:12:01 +0100 Subject: [PATCH 9/9] patch 8.0.0187: cant build with new Ruby version Problem: Building with a new Ruby version fails. Solution: Use ruby_sysinit() instead of NtInitialize(). (Tomas Volf, closes #1382) --- src/if_ruby.c | 4 ++++ src/version.c | 2 ++ 2 files changed, 6 insertions(+) diff --git a/src/if_ruby.c b/src/if_ruby.c index bc6edc7536..509d2f6cf1 100644 --- a/src/if_ruby.c +++ b/src/if_ruby.c @@ -862,7 +862,11 @@ static int ensure_ruby_initialized(void) int argc = 1; char *argv[] = {"gvim.exe"}; char **argvp = argv; +# ifdef RUBY19_OR_LATER + ruby_sysinit(&argc, &argvp); +# else NtInitialize(&argc, &argvp); +# endif #endif { #if defined(RUBY19_OR_LATER) || defined(RUBY_INIT_STACK) diff --git a/src/version.c b/src/version.c index 6511b36957..814934ded8 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 187, /**/ 186, /**/