Patch 8.2.2894

6 views
Skip to first unread message

Bram Moolenaar

unread,
May 28, 2021, 9:50:13 AM5/28/21
to vim...@googlegroups.com

Patch 8.2.2894
Problem: MS-Windows: using enc_locale() for strftime() might not work.
Solution: Use wcsftime(). (Ken Takata, closes #8271)
Files: src/time.c


*** ../vim-8.2.2893/src/time.c 2021-01-20 22:22:45.736246959 +0100
--- src/time.c 2021-05-28 15:45:49.347106427 +0200
***************
*** 252,258 ****
void
f_strftime(typval_T *argvars, typval_T *rettv)
{
- char_u result_buf[256];
struct tm tmval;
struct tm *curtime;
time_t seconds;
--- 252,257 ----
***************
*** 271,276 ****
--- 270,289 ----
rettv->vval.v_string = vim_strsave((char_u *)_("(Invalid)"));
else
{
+ # ifdef MSWIN
+ WCHAR result_buf[256];
+ WCHAR *wp;
+
+ wp = enc_to_utf16(p, NULL);
+ if (wp != NULL)
+ (void)wcsftime(result_buf, sizeof(result_buf) / sizeof(WCHAR),
+ wp, curtime);
+ else
+ result_buf[0] = NUL;
+ rettv->vval.v_string = utf16_to_enc(result_buf, NULL);
+ vim_free(wp);
+ # else
+ char_u result_buf[256];
vimconv_T conv;
char_u *enc;

***************
*** 296,301 ****
--- 309,315 ----
// Release conversion descriptors
convert_setup(&conv, NULL, NULL);
vim_free(enc);
+ # endif
}
}
# endif
*** ../vim-8.2.2893/src/version.c 2021-05-28 14:11:59.725797039 +0200
--- src/version.c 2021-05-28 15:48:37.858644557 +0200
***************
*** 752,753 ****
--- 752,755 ----
{ /* Add new patch number below this line */
+ /**/
+ 2894,
/**/

--
Yesterday is history.
Tomorrow is a mystery.
Today is a gift.
That's why it is called 'present'.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages