diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-11-01 13:57:44 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-11-01 13:57:44 +0100 |
commit | 55e29611d20bca14fa5efc61385bc8a6b7acd9e2 (patch) | |
tree | ab93029caf0fe68c139d7b7d02c67fe11abf02b7 /src/list.c | |
parent | 963734e316bd17dd7290abcac28b875435d06381 (diff) | |
download | vim-git-55e29611d20bca14fa5efc61385bc8a6b7acd9e2.tar.gz |
patch 8.2.1933: cannot sort using locale orderingv8.2.1933
Problem: Cannot sort using locale ordering.
Solution: Add a flag for :sort and sort() to use the locale. (Dominique
Pellé, closes #7237)
Diffstat (limited to 'src/list.c')
-rw-r--r-- | src/list.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/list.c b/src/list.c index 62c571c71..1da4f3d0c 100644 --- a/src/list.c +++ b/src/list.c @@ -1516,6 +1516,7 @@ typedef struct typedef struct { int item_compare_ic; + int item_compare_lc; int item_compare_numeric; int item_compare_numbers; #ifdef FEAT_FLOAT @@ -1594,10 +1595,10 @@ item_compare(const void *s1, const void *s2) p2 = (char_u *)""; if (!sortinfo->item_compare_numeric) { - if (sortinfo->item_compare_ic) - res = STRICMP(p1, p2); + if (sortinfo->item_compare_lc) + res = strcoll((char *)p1, (char *)p2); else - res = STRCMP(p1, p2); + res = sortinfo->item_compare_ic ? STRICMP(p1, p2): STRCMP(p1, p2); } else { @@ -1706,6 +1707,7 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) goto theend; // short list sorts pretty quickly info.item_compare_ic = FALSE; + info.item_compare_lc = FALSE; info.item_compare_numeric = FALSE; info.item_compare_numbers = FALSE; #ifdef FEAT_FLOAT @@ -1773,6 +1775,11 @@ do_sort_uniq(typval_T *argvars, typval_T *rettv, int sort) info.item_compare_func = NULL; info.item_compare_ic = TRUE; } + else if (STRCMP(info.item_compare_func, "l") == 0) + { + info.item_compare_func = NULL; + info.item_compare_lc = TRUE; + } } } |