Skip to content

Commit

Permalink
patch 8.2.3882: more duplicated code in f_getreginfo()
Browse files Browse the repository at this point in the history
Problem:    More duplicated code in f_getreginfo().
Solution:   Also use getreg_get_regname(). (closes #9398)
  • Loading branch information
zeertzjq authored and brammool committed Dec 24, 2021
1 parent 6073f13 commit d3f00f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/evalfunc.c
Expand Up @@ -4675,8 +4675,8 @@ f_getpos(typval_T *argvars, typval_T *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
Expand Down Expand Up @@ -7821,7 +7821,6 @@ range_list_materialize(list_T *list)
static void
f_getreginfo(typval_T *argvars, typval_T *rettv)
{
char_u *strregname;
int regname;
char_u buf[NUMBUFLEN + 2];
long reglen = 0;
Expand All @@ -7831,22 +7830,11 @@ f_getreginfo(typval_T *argvars, typval_T *rettv)
if (in_vim9script() && check_for_opt_string_arg(argvars, 0) == FAIL)
return;

if (argvars[0].v_type != VAR_UNKNOWN)
{
strregname = tv_get_string_chk(&argvars[0]);
if (strregname == NULL)
return;
if (in_vim9script() && STRLEN(strregname) > 1)
{
semsg(_(e_register_name_must_be_one_char_str), strregname);
return;
}
}
else
strregname = get_vim_var_str(VV_REG);
regname = getreg_get_regname(argvars);
if (regname == 0)
return;

regname = (strregname == NULL ? '"' : *strregname);
if (regname == 0 || regname == '@')
if (regname == '@')
regname = '"';

if (rettv_dict_alloc(rettv) == FAIL)
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -749,6 +749,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3882,
/**/
3881,
/**/
Expand Down

0 comments on commit d3f00f5

Please sign in to comment.