patch 9.2.0399: MS-Windows: compile warning in strptime.c

Commit: 
https://github.com/vim/vim/commit/a622dda91597f379bcbddb2e4370ef1ea61fbc47
Author: Yasuhiro Matsumoto <[email protected]>
Date:   Mon Apr 27 17:10:25 2026 +0000

    patch 9.2.0399: MS-Windows: compile warning in strptime.c
    
    Problem:  MS-Windows: compile warning in strptime.c
              (John Marriott, after v9.2.0398)
    Solution: Fix the compile warning (Yasuhiro Matsumoto).
    
    Use _get_tzname() instead of the deprecated tzname[] global on UCRT and
    MSVC builds; older MinGW (msvcrt.dll) keeps using tzname[] as a
    fallback.
    
    related: #20054
    closes:  #20079
    
    Signed-off-by: Yasuhiro Matsumoto <[email protected]>
    Signed-off-by: Christian Brabandt <[email protected]>

diff --git a/src/strptime.c b/src/strptime.c
index ca6fcd8a9..0d1663cf0 100644
--- a/src/strptime.c
+++ b/src/strptime.c
@@ -70,9 +70,13 @@
 #define isleap_sum(a, b) \
                        isleap(((unsigned)(a) + (unsigned)(b)) % 400)
 
-#ifdef _MSC_VER
-# define timezone   _timezone
-# define tzname            _tzname
+/*
+ * _get_tzname() is provided by the UCRT and by the MSVC CRT.  Older MinGW
+ * builds linking against msvcrt.dll fall back to the deprecated tzname[]
+ * global (mingw-w64 already exposes the POSIX-named tzname[]).
+ */
+#if defined(_UCRT) || defined(_MSC_VER)
+# define USE_GET_TZNAME
 #endif
 
 /* Locale tables (English / "C" locale). */
@@ -571,10 +575,27 @@ namedzone:
                    continue;
                }
                /*
-                * Our current timezone
+                * Our current timezone.  Prefer _get_tzname() over the
+                * tzname[] global, which UCRT marks deprecated because it
+                * may be inaccurate after locale changes.
                 */
+#ifdef USE_GET_TZNAME
+               {
+                   char tzbuf[2][32];
+                   const char *tznames[2] = { tzbuf[0], tzbuf[1] };
+                   size_t tzlen;
+
+                   _tzset();
+                   if (_get_tzname(&tzlen, tzbuf[0], sizeof(tzbuf[0]), 0) != 0)
+                       tzbuf[0][0] = NUL;
+                   if (_get_tzname(&tzlen, tzbuf[1], sizeof(tzbuf[1]), 1) != 0)
+                       tzbuf[1][0] = NUL;
+                   ep = find_string(bp, &i, tznames, NULL, 2);
+               }
+#else
                ep = find_string(bp, &i,
                        (const char *const *)tzname, NULL, 2);
+#endif
                if (ep != NULL)
                {
                    tm->tm_isdst = i;
diff --git a/src/version.c b/src/version.c
index fc2cb3b8d..454153955 100644
--- a/src/version.c
+++ b/src/version.c
@@ -729,6 +729,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    399,
 /**/
     398,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1wHPmX-004IMG-7i%40256bit.org.

Raspunde prin e-mail lui