From a2e48b556b7537acd26353b6cc201410be7cf3dc Mon Sep 17 00:00:00 2001 From: erw7 Date: Sun, 25 Aug 2019 13:45:45 +0900 Subject: vim-patch:8.1.0362: cannot get the script line number when executing a function Problem: Cannot get the script line number when executing a function. Solution: Store the line number besides the script ID. (Ozaki Kiichi, closes vim/vim#3362) Also display the line number with ":verbose set". https://github.com/vim/vim/commit/f29c1c6aa3f365c025890fab5fb9efbe88eb1761 --- src/nvim/keymap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/nvim/keymap.c') diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c index eab65f2625..b8b9c945b9 100644 --- a/src/nvim/keymap.c +++ b/src/nvim/keymap.c @@ -824,7 +824,8 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, // Allocate space for the translation. Worst case a single character is // replaced by 6 bytes (shifted special key), plus a NUL at the end. - result = xmalloc(from_len * 6 + 1); + const size_t buf_len = from_len * 6 + 1; + result = xmalloc(buf_len); src = from; @@ -849,14 +850,15 @@ char_u *replace_termcodes(const char_u *from, const size_t from_len, // Replace by K_SNR _. // (room: 5 * 6 = 30 bytes; needed: 3 + + 1 <= 14) if (end - src >= 4 && STRNICMP(src, "", 5) == 0) { - if (current_SID <= 0) { + if (current_sctx.sc_sid <= 0) { EMSG(_(e_usingsid)); } else { src += 5; result[dlen++] = K_SPECIAL; result[dlen++] = (int)KS_EXTRA; result[dlen++] = (int)KE_SNR; - sprintf((char *)result + dlen, "%" PRId64, (int64_t)current_SID); + snprintf((char *)result + dlen, buf_len - dlen, "%" PRId64, + (int64_t)current_sctx.sc_sid); dlen += STRLEN(result + dlen); result[dlen++] = '_'; continue; -- cgit