Mercurial > vim
diff src/list.c @ 22303:4ce3906e5997 v8.2.1701
patch 8.2.1701: Vim9: sort("i") does not work
Commit: https://github.com/vim/vim/commit/08e51f446bd4bf1a0342c471163b1ed083e9eedb
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Sep 16 23:23:36 2020 +0200
patch 8.2.1701: Vim9: sort("i") does not work
Problem: Vim9: sort("i") does not work.
Solution: Don't try getting a number for a string argument. (closes https://github.com/vim/vim/issues/6958)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 16 Sep 2020 23:30:04 +0200 |
parents | 07e48ee8c3bb |
children | 47596deedfb5 |
line wrap: on
line diff
--- a/src/list.c +++ b/src/list.c @@ -1717,18 +1717,25 @@ do_sort_uniq(typval_T *argvars, typval_T else { int error = FALSE; + int nr = 0; - i = (long)tv_get_number_chk(&argvars[1], &error); - if (error) - goto theend; // type error; errmsg already given - if (i == 1) - info.item_compare_ic = TRUE; - else if (argvars[1].v_type != VAR_NUMBER) - info.item_compare_func = tv_get_string(&argvars[1]); - else if (i != 0) + if (argvars[1].v_type == VAR_NUMBER) { - emsg(_(e_invarg)); - goto theend; + nr = tv_get_number_chk(&argvars[1], &error); + if (error) + goto theend; // type error; errmsg already given + if (nr == 1) + info.item_compare_ic = TRUE; + } + if (nr != 1) + { + if (argvars[1].v_type != VAR_NUMBER) + info.item_compare_func = tv_get_string(&argvars[1]); + else if (nr != 0) + { + emsg(_(e_invarg)); + goto theend; + } } if (info.item_compare_func != NULL) {