From 903ec5bd85df6acfde67c113ebd6a0ed58debcec Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Fri, 24 Dec 2021 21:20:34 +0800 Subject: [PATCH] vim-patch:8.2.3882: more duplicated code in f_getreginfo() Problem: More duplicated code in f_getreginfo(). Solution: Also use getreg_get_regname(). (closes vim/vim#9398) https://github.com/vim/vim/commit/d3f00f54bf955bd01767db3a0af25866bc112ec7 --- src/nvim/eval/funcs.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c index 1f12e2d4af..32026282cf 100644 --- a/src/nvim/eval/funcs.c +++ b/src/nvim/eval/funcs.c @@ -3918,8 +3918,8 @@ static void f_getqflist(typval_T *argvars, typval_T *rettv, FunPtr fptr) get_qf_loc_list(true, NULL, &argvars[0], rettv); } -/// Common between getreg() and getregtype(): get the register name from the -/// first argument. +/// Common between getreg(), getreginfo() and getregtype(): get the register +/// name from the first argument. /// Returns zero on error. static int getreg_get_regname(typval_T *argvars) { @@ -7331,18 +7331,12 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) /// "getreginfo()" function static void f_getreginfo(typval_T *argvars, typval_T *rettv, FunPtr fptr) { - const char *strregname; - if (argvars[0].v_type != VAR_UNKNOWN) { - strregname = tv_get_string_chk(&argvars[0]); - if (strregname == NULL) { - return; - } - } else { - strregname = (const char *)get_vim_var_str(VV_REG); + int regname = getreg_get_regname(argvars); + if (regname == 0) { + return; } - int regname = (strregname == NULL ? '"' : *strregname); - if (regname == 0 || regname == '@') { + if (regname == '@') { regname = '"'; }