Skip to content

Commit d5359b2

Browse files
committed
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)
1 parent 9a993e3 commit d5359b2

3 files changed

Lines changed: 16 additions & 2 deletions

File tree

‎src/evalfunc.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1993,7 +1993,7 @@ f_ch_log(typval_T *argvars, typval_T *rettv UNUSED)
19931993
if (argvars[1].v_type != VAR_UNKNOWN)
19941994
channel = get_channel_arg(&argvars[1], FALSE, FALSE, 0);
19951995

1996-
ch_log(channel, (char *)msg);
1996+
ch_log(channel, "%s", msg);
19971997
}
19981998

19991999
/*
@@ -12927,7 +12927,7 @@ get_callback(typval_T *arg, partial_T **pp)
1292712927
}
1292812928

1292912929
/*
12930-
* Unref/free "callback" and "partial" retured by get_callback().
12930+
* Unref/free "callback" and "partial" returned by get_callback().
1293112931
*/
1293212932
void
1293312933
free_callback(char_u *callback, partial_T *partial)

‎src/testdir/test_channel.vim‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,3 +1823,15 @@ func Test_list_args()
18231823
call s:test_list_args('print("hello\"world\"")', 'hello"world"', 1)
18241824
call s:test_list_args('print("hello\tworld")', "hello\tworld", 1)
18251825
endfunc
1826+
1827+
" Do this last, it stops any channel log.
1828+
func Test_zz_ch_log()
1829+
call ch_logfile('Xlog', 'w')
1830+
call ch_log('hello there')
1831+
call ch_log('%s%s')
1832+
call ch_logfile('')
1833+
let text = readfile('Xlog')
1834+
call assert_match("hello there", text[1])
1835+
call assert_match("%s%s", text[2])
1836+
call delete('Xlog')
1837+
endfunc

‎src/version.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,8 @@ static char *(features[]) =
762762

763763
static int included_patches[] =
764764
{ /* Add new patch number below this line */
765+
/**/
766+
1666,
765767
/**/
766768
1665,
767769
/**/

0 commit comments

Comments
 (0)