]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
windows: use _tzname instead of tzname 13467/head
authorJason Ish <jason.ish@oisf.net>
Mon, 16 Jun 2025 22:34:36 +0000 (16:34 -0600)
committerVictor Julien <victor@inliniac.net>
Tue, 17 Jun 2025 13:37:45 +0000 (15:37 +0200)
tzname is a POSIX variable, WIN32 has prefixed many POSIX variables
with "_". While Mingw64 supports both, UCRT64 emits a compiler warning
on the usage of "tzname".

This triggered a rather large clang-format update.

.github/workflows/builds.yml
src/util-strptime.c

index 657830316d8af6ef9d8f04e43ac0c7e86a19f5f8..9100806b3e1df64a53ade27ae82235dd76af79ef 100644 (file)
@@ -2985,6 +2985,7 @@ jobs:
             make
             mingw-w64-ucrt-x86_64-cbindgen
             mingw-w64-ucrt-x86_64-jansson
+            mingw-w64-ucrt-x86_64-jq
             mingw-w64-ucrt-x86_64-libpcap
             mingw-w64-ucrt-x86_64-libtool
             mingw-w64-ucrt-x86_64-libyaml
index e0475ec611f0cb1f281b303faa2b3477b64d5d44..ac858980c981034baa499eb83dae99339ed68963 100644 (file)
@@ -383,54 +383,58 @@ recurse:
 #endif
                                bp += 3;
                        } else {
-                               ep = find_string(bp, &i,
-                                                (const char * const *)tzname,
-                                                 NULL, 2);
-                               if (ep != NULL) {
-                                       tm->tm_isdst = i;
+                            ep = find_string(bp, &i,
+#ifdef _WIN32
+                                    (const char *const *)_tzname,
+#else
+                                    (const char *const *)tzname,
+#endif
+                                    NULL, 2);
+                            if (ep != NULL) {
+                                tm->tm_isdst = i;
 #ifdef TM_GMTOFF
                                        tm->TM_GMTOFF = -(timezone);
 #endif
 #ifdef TM_ZONE
                                        tm->TM_ZONE = tzname[i];
 #endif
-                               }
-                               bp = ep;
-                       }
-                       continue;
-
-               case 'z':
-                       /*
-                        * We recognize all ISO 8601 formats:
-                        * Z    = Zulu time/UTC
-                        * [+-]hhmm
-                        * [+-]hh:mm
-                        * [+-]hh
-                        * We recognize all RFC-822/RFC-2822 formats:
-                        * UT|GMT
-                        *          North American : UTC offsets
-                        * E[DS]T = Eastern : -4 | -5
-                        * C[DS]T = Central : -5 | -6
-                        * M[DS]T = Mountain: -6 | -7
-                        * P[DS]T = Pacific : -7 | -8
-                        *          Military
-                        * [A-IL-M] = -1 ... -9 (J not used)
-                        * [N-Y]  = +1 ... +12
-                        */
-                       while (isspace(*bp))
-                               bp++;
-
-                       switch (*bp++) {
-                       case 'G':
-                               if (*bp++ != 'M')
-                                       return NULL;
-                               /*FALLTHROUGH*/
-                       case 'U':
-                               if (*bp++ != 'T')
-                                       return NULL;
-                               /*FALLTHROUGH*/
-                       case 'Z':
-                               tm->tm_isdst = 0;
+                            }
+                            bp = ep;
+                        }
+                        continue;
+
+                case 'z':
+                    /*
+                     * We recognize all ISO 8601 formats:
+                     * Z       = Zulu time/UTC
+                     * [+-]hhmm
+                     * [+-]hh:mm
+                     * [+-]hh
+                     * We recognize all RFC-822/RFC-2822 formats:
+                     * UT|GMT
+                     *          North American : UTC offsets
+                     * E[DS]T = Eastern : -4 | -5
+                     * C[DS]T = Central : -5 | -6
+                     * M[DS]T = Mountain: -6 | -7
+                     * P[DS]T = Pacific : -7 | -8
+                     *          Military
+                     * [A-IL-M] = -1 ... -9 (J not used)
+                     * [N-Y]  = +1 ... +12
+                     */
+                    while (isspace(*bp))
+                        bp++;
+
+                    switch (*bp++) {
+                        case 'G':
+                            if (*bp++ != 'M')
+                                return NULL;
+                            /*FALLTHROUGH*/
+                        case 'U':
+                            if (*bp++ != 'T')
+                                return NULL;
+                            /*FALLTHROUGH*/
+                        case 'Z':
+                            tm->tm_isdst = 0;
 #ifdef TM_GMTOFF
                                tm->TM_GMTOFF = 0;
 #endif
@@ -489,37 +493,37 @@ recurse:
                                        continue;
                                }
                                return NULL;
-                       }
-                       offs = 0;
-                       for (i = 0; i < 4; ) {
-                               if (isdigit(*bp)) {
-                                       offs = offs * 10 + (*bp++ - '0');
-                                       i++;
-                                       continue;
-                               }
-                               if (i == 2 && *bp == ':') {
-                                       bp++;
-                                       continue;
-                               }
-                               break;
-                       }
-                       switch (i) {
-                       case 2:
-                               offs *= 100;
-                               break;
-                       case 4:
-                               i = offs % 100;
-                               if (i >= 60)
-                                       return NULL;
-                               /* Convert minutes into decimal */
-                               offs = (offs / 100) * 100 + (i * 50) / 30;
-                               break;
-                       default:
-                               return NULL;
-                       }
-                       if (neg)
-                               offs = -offs;
-                       tm->tm_isdst = 0;       /* XXX */
+                    }
+                    offs = 0;
+                    for (i = 0; i < 4;) {
+                        if (isdigit(*bp)) {
+                            offs = offs * 10 + (*bp++ - '0');
+                            i++;
+                            continue;
+                        }
+                        if (i == 2 && *bp == ':') {
+                            bp++;
+                            continue;
+                        }
+                        break;
+                    }
+                    switch (i) {
+                        case 2:
+                            offs *= 100;
+                            break;
+                        case 4:
+                            i = offs % 100;
+                            if (i >= 60)
+                                return NULL;
+                            /* Convert minutes into decimal */
+                            offs = (offs / 100) * 100 + (i * 50) / 30;
+                            break;
+                        default:
+                            return NULL;
+                    }
+                    if (neg)
+                        offs = -offs;
+                    tm->tm_isdst = 0; /* XXX */
 #ifdef TM_GMTOFF
                        tm->TM_GMTOFF = offs;
 #endif