Skip to content

Commit 17ed6f7

Browse files
jasonishvictorjulien
authored andcommitted
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.
1 parent 106e09e commit 17ed6f7

2 files changed

Lines changed: 78 additions & 73 deletions

File tree

.github/workflows/builds.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,6 +2985,7 @@ jobs:
29852985
make
29862986
mingw-w64-ucrt-x86_64-cbindgen
29872987
mingw-w64-ucrt-x86_64-jansson
2988+
mingw-w64-ucrt-x86_64-jq
29882989
mingw-w64-ucrt-x86_64-libpcap
29892990
mingw-w64-ucrt-x86_64-libtool
29902991
mingw-w64-ucrt-x86_64-libyaml

src/util-strptime.c

Lines changed: 77 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -383,54 +383,58 @@ again: switch (c = *fmt++) {
383383
#endif
384384
bp += 3;
385385
} else {
386-
ep = find_string(bp, &i,
387-
(const char * const *)tzname,
388-
NULL, 2);
389-
if (ep != NULL) {
390-
tm->tm_isdst = i;
386+
ep = find_string(bp, &i,
387+
#ifdef _WIN32
388+
(const char *const *)_tzname,
389+
#else
390+
(const char *const *)tzname,
391+
#endif
392+
NULL, 2);
393+
if (ep != NULL) {
394+
tm->tm_isdst = i;
391395
#ifdef TM_GMTOFF
392396
tm->TM_GMTOFF = -(timezone);
393397
#endif
394398
#ifdef TM_ZONE
395399
tm->TM_ZONE = tzname[i];
396400
#endif
397-
}
398-
bp = ep;
399-
}
400-
continue;
401-
402-
case 'z':
403-
/*
404-
* We recognize all ISO 8601 formats:
405-
* Z = Zulu time/UTC
406-
* [+-]hhmm
407-
* [+-]hh:mm
408-
* [+-]hh
409-
* We recognize all RFC-822/RFC-2822 formats:
410-
* UT|GMT
411-
* North American : UTC offsets
412-
* E[DS]T = Eastern : -4 | -5
413-
* C[DS]T = Central : -5 | -6
414-
* M[DS]T = Mountain: -6 | -7
415-
* P[DS]T = Pacific : -7 | -8
416-
* Military
417-
* [A-IL-M] = -1 ... -9 (J not used)
418-
* [N-Y] = +1 ... +12
419-
*/
420-
while (isspace(*bp))
421-
bp++;
422-
423-
switch (*bp++) {
424-
case 'G':
425-
if (*bp++ != 'M')
426-
return NULL;
427-
/*FALLTHROUGH*/
428-
case 'U':
429-
if (*bp++ != 'T')
430-
return NULL;
431-
/*FALLTHROUGH*/
432-
case 'Z':
433-
tm->tm_isdst = 0;
401+
}
402+
bp = ep;
403+
}
404+
continue;
405+
406+
case 'z':
407+
/*
408+
* We recognize all ISO 8601 formats:
409+
* Z = Zulu time/UTC
410+
* [+-]hhmm
411+
* [+-]hh:mm
412+
* [+-]hh
413+
* We recognize all RFC-822/RFC-2822 formats:
414+
* UT|GMT
415+
* North American : UTC offsets
416+
* E[DS]T = Eastern : -4 | -5
417+
* C[DS]T = Central : -5 | -6
418+
* M[DS]T = Mountain: -6 | -7
419+
* P[DS]T = Pacific : -7 | -8
420+
* Military
421+
* [A-IL-M] = -1 ... -9 (J not used)
422+
* [N-Y] = +1 ... +12
423+
*/
424+
while (isspace(*bp))
425+
bp++;
426+
427+
switch (*bp++) {
428+
case 'G':
429+
if (*bp++ != 'M')
430+
return NULL;
431+
/*FALLTHROUGH*/
432+
case 'U':
433+
if (*bp++ != 'T')
434+
return NULL;
435+
/*FALLTHROUGH*/
436+
case 'Z':
437+
tm->tm_isdst = 0;
434438
#ifdef TM_GMTOFF
435439
tm->TM_GMTOFF = 0;
436440
#endif
@@ -489,37 +493,37 @@ again: switch (c = *fmt++) {
489493
continue;
490494
}
491495
return NULL;
492-
}
493-
offs = 0;
494-
for (i = 0; i < 4; ) {
495-
if (isdigit(*bp)) {
496-
offs = offs * 10 + (*bp++ - '0');
497-
i++;
498-
continue;
499-
}
500-
if (i == 2 && *bp == ':') {
501-
bp++;
502-
continue;
503-
}
504-
break;
505-
}
506-
switch (i) {
507-
case 2:
508-
offs *= 100;
509-
break;
510-
case 4:
511-
i = offs % 100;
512-
if (i >= 60)
513-
return NULL;
514-
/* Convert minutes into decimal */
515-
offs = (offs / 100) * 100 + (i * 50) / 30;
516-
break;
517-
default:
518-
return NULL;
519-
}
520-
if (neg)
521-
offs = -offs;
522-
tm->tm_isdst = 0; /* XXX */
496+
}
497+
offs = 0;
498+
for (i = 0; i < 4;) {
499+
if (isdigit(*bp)) {
500+
offs = offs * 10 + (*bp++ - '0');
501+
i++;
502+
continue;
503+
}
504+
if (i == 2 && *bp == ':') {
505+
bp++;
506+
continue;
507+
}
508+
break;
509+
}
510+
switch (i) {
511+
case 2:
512+
offs *= 100;
513+
break;
514+
case 4:
515+
i = offs % 100;
516+
if (i >= 60)
517+
return NULL;
518+
/* Convert minutes into decimal */
519+
offs = (offs / 100) * 100 + (i * 50) / 30;
520+
break;
521+
default:
522+
return NULL;
523+
}
524+
if (neg)
525+
offs = -offs;
526+
tm->tm_isdst = 0; /* XXX */
523527
#ifdef TM_GMTOFF
524528
tm->TM_GMTOFF = offs;
525529
#endif

0 commit comments

Comments
 (0)