From ebabdff5cd24f2d30ab35051d1d65f7c29fa3dd3 Mon Sep 17 00:00:00 2001 From: ZyX Date: Sun, 13 Jul 2014 11:10:27 +0400 Subject: keymap: Make replace_termcodes and friends accept length and cpo_flags Reasons: - One does not have to do `s[len] = NUL` to work with these functions if they do not need to replace the whole string: thus `s` may be const. - One does not have to save/restore p_cpo to work with them. --- src/nvim/eval.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/nvim/eval.c') diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 0d6e3d3ca3..1c76847037 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -4719,13 +4719,14 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate) ++name; break; - /* Special key, e.g.: "\" */ - case '<': extra = trans_special(&p, name, TRUE); + // Special key, e.g.: "\" + case '<': + extra = trans_special((const char_u **) &p, STRLEN(p), name, true); if (extra != 0) { name += extra; break; } - /* FALLTHROUGH */ + // FALLTHROUGH default: MB_COPY_CHAR(p, name); break; @@ -12319,8 +12320,9 @@ static void get_maparg(typval_T *argvars, typval_T *rettv, int exact) mode = get_map_mode(&which, 0); - keys = replace_termcodes(keys, &keys_buf, TRUE, TRUE, FALSE); - rhs = check_map(keys, mode, exact, FALSE, abbr, &mp, &buffer_local); + keys = replace_termcodes(keys, STRLEN(keys), &keys_buf, true, true, false, + CPO_TO_CPO_FLAGS); + rhs = check_map(keys, mode, exact, false, abbr, &mp, &buffer_local); xfree(keys_buf); if (!get_dict) { -- cgit