comparison src/eval.c @ 8344:2aa24f702b8d v7.4.1464

commit https://github.com/vim/vim/commit/5131c144feb046c5e2b72e6c172159d80ce06b3c Author: Bram Moolenaar <Bram@vim.org> Date: Mon Feb 29 22:05:26 2016 +0100 patch 7.4.1464 Problem: When the argument of sort() is zero or empty it fails. Solution: Make zero work as documented. (suggested by Yasuhiro Matsumoto)
author Christian Brabandt <cb@256bit.org>
date Mon, 29 Feb 2016 22:15:05 +0100
parents 3e54b31d50c7
children e70fa2e110ec
comparison
equal deleted inserted replaced
8343:78e751a59cc8 8344:2aa24f702b8d
19193 i = get_tv_number_chk(&argvars[1], &error); 19193 i = get_tv_number_chk(&argvars[1], &error);
19194 if (error) 19194 if (error)
19195 goto theend; /* type error; errmsg already given */ 19195 goto theend; /* type error; errmsg already given */
19196 if (i == 1) 19196 if (i == 1)
19197 info.item_compare_ic = TRUE; 19197 info.item_compare_ic = TRUE;
19198 else 19198 else if (argvars[1].v_type != VAR_NUMBER)
19199 info.item_compare_func = get_tv_string(&argvars[1]); 19199 info.item_compare_func = get_tv_string(&argvars[1]);
19200 else if (i != 0)
19201 {
19202 EMSG(_(e_invarg));
19203 goto theend;
19204 }
19200 if (info.item_compare_func != NULL) 19205 if (info.item_compare_func != NULL)
19201 { 19206 {
19202 if (STRCMP(info.item_compare_func, "n") == 0) 19207 if (*info.item_compare_func == NUL)
19208 {
19209 /* empty string means default sort */
19210 info.item_compare_func = NULL;
19211 }
19212 else if (STRCMP(info.item_compare_func, "n") == 0)
19203 { 19213 {
19204 info.item_compare_func = NULL; 19214 info.item_compare_func = NULL;
19205 info.item_compare_numeric = TRUE; 19215 info.item_compare_numeric = TRUE;
19206 } 19216 }
19207 else if (STRCMP(info.item_compare_func, "N") == 0) 19217 else if (STRCMP(info.item_compare_func, "N") == 0)