Mercurial > vim
comparison src/evalfunc.c @ 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 | c9a83dc9081b |
children | 9c9b8d95b05f |
comparison
equal
deleted
inserted
replaced
26705:8cf97ce864e8 | 26706:71e6e67b2898 |
---|---|
4673 | 4673 |
4674 getpos_both(argvars, rettv, FALSE, FALSE); | 4674 getpos_both(argvars, rettv, FALSE, FALSE); |
4675 } | 4675 } |
4676 | 4676 |
4677 /* | 4677 /* |
4678 * Common between getreg() and getregtype(): get the register name from the | 4678 * Common between getreg(), getreginfo() and getregtype(): get the register |
4679 * first argument. | 4679 * name from the first argument. |
4680 * Returns zero on error. | 4680 * Returns zero on error. |
4681 */ | 4681 */ |
4682 static int | 4682 static int |
4683 getreg_get_regname(typval_T *argvars) | 4683 getreg_get_regname(typval_T *argvars) |
4684 { | 4684 { |
7819 * "getreginfo()" function | 7819 * "getreginfo()" function |
7820 */ | 7820 */ |
7821 static void | 7821 static void |
7822 f_getreginfo(typval_T *argvars, typval_T *rettv) | 7822 f_getreginfo(typval_T *argvars, typval_T *rettv) |
7823 { | 7823 { |
7824 char_u *strregname; | |
7825 int regname; | 7824 int regname; |
7826 char_u buf[NUMBUFLEN + 2]; | 7825 char_u buf[NUMBUFLEN + 2]; |
7827 long reglen = 0; | 7826 long reglen = 0; |
7828 dict_T *dict; | 7827 dict_T *dict; |
7829 list_T *list; | 7828 list_T *list; |
7830 | 7829 |
7831 if (in_vim9script() && check_for_opt_string_arg(argvars, 0) == FAIL) | 7830 if (in_vim9script() && check_for_opt_string_arg(argvars, 0) == FAIL) |
7832 return; | 7831 return; |
7833 | 7832 |
7834 if (argvars[0].v_type != VAR_UNKNOWN) | 7833 regname = getreg_get_regname(argvars); |
7835 { | 7834 if (regname == 0) |
7836 strregname = tv_get_string_chk(&argvars[0]); | 7835 return; |
7837 if (strregname == NULL) | 7836 |
7838 return; | 7837 if (regname == '@') |
7839 if (in_vim9script() && STRLEN(strregname) > 1) | |
7840 { | |
7841 semsg(_(e_register_name_must_be_one_char_str), strregname); | |
7842 return; | |
7843 } | |
7844 } | |
7845 else | |
7846 strregname = get_vim_var_str(VV_REG); | |
7847 | |
7848 regname = (strregname == NULL ? '"' : *strregname); | |
7849 if (regname == 0 || regname == '@') | |
7850 regname = '"'; | 7838 regname = '"'; |
7851 | 7839 |
7852 if (rettv_dict_alloc(rettv) == FAIL) | 7840 if (rettv_dict_alloc(rettv) == FAIL) |
7853 return; | 7841 return; |
7854 dict = rettv->vval.v_dict; | 7842 dict = rettv->vval.v_dict; |