Move time_t test later so 32-bit check of 64-bit functions can work

https://github.com/Hamlib/Hamlib/issues/1478
pull/1513/head
Mike Black W9MDB 2024-02-15 09:25:39 -06:00
rodzic 4cadea95f8
commit 1ea597b6e1
1 zmienionych plików z 16 dodań i 7 usunięć

Wyświetl plik

@ -2826,6 +2826,7 @@ char *date_strget(char *buf, int buflen, int localtime)
struct tm result = { 0, 0, 0, 0, 0, 0, 0, 0, 0};
int mytimezone;
// 2038 failure here for 32-bit time_t
t = time(NULL);
if (localtime)
@ -3068,12 +3069,6 @@ int rig_test_2038(RIG *rig)
__MSVCRT_VERSION__);
#endif
if (sizeof(time_t) == 4)
{
rig_debug(RIG_DEBUG_TRACE, "%s: ctime is null, 2038 test failed\n", __func__);
return 1;
}
int failed = 0;
#if defined(__MSVCRT_VERSION__)
x = (__time64_t)((1UL << 31) - 1);
@ -3082,12 +3077,26 @@ int rig_test_2038(RIG *rig)
if (strlen(s) == 0) { failed = 1; }
rig_debug(RIG_DEBUG_VERBOSE, "%s: MSVCRT 2038 test = 0x%08lx:%s\n", __func__, x,
s);
#else
x = (time_t)((1U << 31) - 1);
if (sizeof(time_t) == 4)
{
rig_debug(RIG_DEBUG_TRACE, "%s: time_t is 4 bytes, 2038 test failed\n",
__func__);
return 1;
}
x = (time_t)((1U << 63) - 1);
char *s = ctime(&x);
if (s == NULL) { failed = 1; }
rig_debug(RIG_DEBUG_VERBOSE, "%s: time_t 2038 test = 0x%08lx:%s", __func__, x,
s);
#endif
if (failed)