From 84cf6bd81bec93b49166cd48fccc7087fdbaa6fc Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Tue, 16 Jun 2020 20:03:43 +0200 Subject: patch 8.2.0988: getting directory contents is always case sorted Problem: Getting directory contents is always case sorted. Solution: Add sort options and v:collate. (Christian Brabandt, closes #6229) --- src/ex_cmds2.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) (limited to 'src/ex_cmds2.c') diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c index d83facf0d1..f0b5bfd451 100644 --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1185,6 +1185,14 @@ set_lang_var(void) loc = get_locale_val(LC_TIME); # endif set_vim_var_string(VV_LC_TIME, loc, -1); + +# ifdef HAVE_GET_LOCALE_VAL + loc = get_locale_val(LC_COLLATE); +# else + // setlocale() not supported: use the default value + loc = (char_u *)"C"; +# endif + set_vim_var_string(VV_COLLATE, loc, -1); } #endif @@ -1232,6 +1240,12 @@ ex_language(exarg_T *eap) name = skipwhite(p); whatstr = "time "; } + else if (STRNICMP(eap->arg, "collate", p - eap->arg) == 0) + { + what = LC_COLLATE; + name = skipwhite(p); + whatstr = "collate "; + } } if (*name == NUL) @@ -1274,7 +1288,7 @@ ex_language(exarg_T *eap) // Reset $LC_ALL, otherwise it would overrule everything. vim_setenv((char_u *)"LC_ALL", (char_u *)""); - if (what != LC_TIME) + if (what != LC_TIME && what != LC_COLLATE) { // Tell gettext() what to translate to. It apparently doesn't // use the currently effective locale. Also do this when @@ -1309,7 +1323,7 @@ ex_language(exarg_T *eap) } # ifdef FEAT_EVAL - // Set v:lang, v:lc_time and v:ctype to the final result. + // Set v:lang, v:lc_time, v:collate and v:ctype to the final result. set_lang_var(); # endif # ifdef FEAT_TITLE @@ -1462,11 +1476,13 @@ get_lang_arg(expand_T *xp UNUSED, int idx) return (char_u *)"ctype"; if (idx == 2) return (char_u *)"time"; + if (idx == 3) + return (char_u *)"collate"; init_locales(); if (locales == NULL) return NULL; - return locales[idx - 3]; + return locales[idx - 4]; } /* -- cgit v1.2.3