From: Bram Moolenaar Date: Thu, 5 Apr 2018 20:44:39 +0000 (+0200) Subject: patch 8.0.1666: % argument in ch_log() causes trouble X-Git-Tag: v8.0.1666 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d5359b24ceefefed4b3a37efd9bf54176935f3a5;p=vim patch 8.0.1666: % argument in ch_log() causes trouble Problem: % argument in ch_log() causes trouble. Solution: Use string as third argument in internal ch_log(). (Dominique Pelle, closes #2784) --- diff --git a/src/evalfunc.c b/src/evalfunc.c index dc2c14c3d..1ffbb21fa 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -1993,7 +1993,7 @@ f_ch_log(typval_T *argvars, typval_T *rettv UNUSED) if (argvars[1].v_type != VAR_UNKNOWN) channel = get_channel_arg(&argvars[1], FALSE, FALSE, 0); - ch_log(channel, (char *)msg); + ch_log(channel, "%s", msg); } /* @@ -12927,7 +12927,7 @@ get_callback(typval_T *arg, partial_T **pp) } /* - * Unref/free "callback" and "partial" retured by get_callback(). + * Unref/free "callback" and "partial" returned by get_callback(). */ void free_callback(char_u *callback, partial_T *partial) diff --git a/src/testdir/test_channel.vim b/src/testdir/test_channel.vim index 9de3ca01f..59283d272 100644 --- a/src/testdir/test_channel.vim +++ b/src/testdir/test_channel.vim @@ -1823,3 +1823,15 @@ func Test_list_args() call s:test_list_args('print("hello\"world\"")', 'hello"world"', 1) call s:test_list_args('print("hello\tworld")', "hello\tworld", 1) endfunc + +" Do this last, it stops any channel log. +func Test_zz_ch_log() + call ch_logfile('Xlog', 'w') + call ch_log('hello there') + call ch_log('%s%s') + call ch_logfile('') + let text = readfile('Xlog') + call assert_match("hello there", text[1]) + call assert_match("%s%s", text[2]) + call delete('Xlog') +endfunc diff --git a/src/version.c b/src/version.c index b29d64c82..44fb030fc 100644 --- a/src/version.c +++ b/src/version.c @@ -762,6 +762,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1666, /**/ 1665, /**/