changeset 26706:71e6e67b2898 v8.2.3882

patch 8.2.3882: more duplicated code in f_getreginfo() Commit: https://github.com/vim/vim/commit/d3f00f54bf955bd01767db3a0af25866bc112ec7 Author: zeertzjq <zeertzjq@outlook.com> Date: Fri Dec 24 12:02:43 2021 +0000 patch 8.2.3882: more duplicated code in f_getreginfo() Problem: More duplicated code in f_getreginfo(). Solution: Also use getreg_get_regname(). (closes https://github.com/vim/vim/issues/9398)
author Bram Moolenaar <Bram@vim.org>
date Fri, 24 Dec 2021 13:15:03 +0100
parents 8cf97ce864e8
children d1af15dbf206
files src/evalfunc.c src/version.c
diffstat 2 files changed, 9 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/evalfunc.c
+++ b/src/evalfunc.c
@@ -4675,8 +4675,8 @@ f_getpos(typval_T *argvars, typval_T *re
 }
 
 /*
- * 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
@@ -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;
@@ -7831,22 +7830,11 @@ f_getreginfo(typval_T *argvars, typval_T
     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 = (strregname == NULL ? '"' : *strregname);
-    if (regname == 0 || regname == '@')
+    regname = getreg_get_regname(argvars);
+    if (regname == 0)
+	return;
+
+    if (regname == '@')
 	regname = '"';
 
     if (rettv_dict_alloc(rettv) == FAIL)
--- a/src/version.c
+++ b/src/version.c
@@ -750,6 +750,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3882,
+/**/
     3881,
 /**/
     3880,