From: Jason Ish Date: Mon, 16 Jun 2025 22:34:36 +0000 (-0600) Subject: windows: use _tzname instead of tzname X-Git-Tag: suricata-8.0.0~65 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F13467%2Fhead;p=thirdparty%2Fsuricata.git windows: use _tzname instead of tzname 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. --- diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index 657830316d..9100806b3e 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -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 diff --git a/src/util-strptime.c b/src/util-strptime.c index e0475ec611..ac858980c9 100644 --- a/src/util-strptime.c +++ b/src/util-strptime.c @@ -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