diff options
| author | Paul Eggert | 1995-09-20 03:26:43 +0000 |
|---|---|---|
| committer | Paul Eggert | 1995-09-20 03:26:43 +0000 |
| commit | 70b13a6cc936d0053aafcdbb1ad691afb54164f1 (patch) | |
| tree | 651d1e4fafda18bb6124b9f1ea26e3461f68e4de /src | |
| parent | afd9831b8da5745a247670158486003b9c7eac6d (diff) | |
| download | emacs-70b13a6cc936d0053aafcdbb1ad691afb54164f1.tar.gz emacs-70b13a6cc936d0053aafcdbb1ad691afb54164f1.zip | |
(gettimeofday, init_gettimeofday, daylight, gmtoffset): Undo previous change.
(init_environment): No need to call tzset and init_gettimeofday,
since `main' now does that for us.
(gettimeofday): Ignore tzp; it's obsolescent.
(init_gettimeofday): Invoke tzset first.
Diffstat (limited to 'src')
| -rw-r--r-- | src/msdos.c | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/src/msdos.c b/src/msdos.c index dc48834c0e3..a72e59a315a 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -1415,7 +1415,10 @@ internal_terminal_init () | |||
| 1415 | 1415 | ||
| 1416 | /* When time zones are set from Ms-Dos too may C-libraries are playing | 1416 | /* When time zones are set from Ms-Dos too may C-libraries are playing |
| 1417 | tricks with time values. We solve this by defining our own version | 1417 | tricks with time values. We solve this by defining our own version |
| 1418 | of `gettimeofday' bypassing GO32. */ | 1418 | of `gettimeofday' bypassing GO32. Our version needs to be initialized |
| 1419 | once and after each call to `tzset' with TZ changed. */ | ||
| 1420 | |||
| 1421 | static int daylight, gmtoffset; | ||
| 1419 | 1422 | ||
| 1420 | int | 1423 | int |
| 1421 | gettimeofday (struct timeval *tp, struct timezone *tzp) | 1424 | gettimeofday (struct timeval *tp, struct timezone *tzp) |
| @@ -1423,16 +1426,44 @@ gettimeofday (struct timeval *tp, struct timezone *tzp) | |||
| 1423 | if (tp) | 1426 | if (tp) |
| 1424 | { | 1427 | { |
| 1425 | struct time t; | 1428 | struct time t; |
| 1429 | struct date d; | ||
| 1430 | struct tm tmrec; | ||
| 1426 | 1431 | ||
| 1427 | gettime (&t); | 1432 | gettime (&t); |
| 1428 | tp->tv_sec = time (NULL); | 1433 | /* If midnight occurs here, the results can be incorrect. */ |
| 1429 | /* If tp->tv_sec%60 != t.ti_sec, the seconds counter turned over | 1434 | getdate (&d); |
| 1430 | between the call to `gettime' and the call to `time'. */ | 1435 | tmrec.tm_year = d.da_year - 1900; |
| 1431 | tp->tv_usec = tp->tv_sec%60 != t.ti_sec ? 0 : t.ti_hund * (1000000/100); | 1436 | tmrec.tm_mon = d.da_mon - 1; |
| 1437 | tmrec.tm_mday = d.da_day; | ||
| 1438 | tmrec.tm_hour = t.ti_hour; | ||
| 1439 | tmrec.tm_min = t.ti_min; | ||
| 1440 | tmrec.tm_sec = t.ti_sec; | ||
| 1441 | tmrec.tm_gmtoff = gmtoffset; | ||
| 1442 | tmrec.tm_isdst = daylight; | ||
| 1443 | tp->tv_sec = mktime (&tmrec); | ||
| 1444 | tp->tv_usec = t.ti_hund * (1000000 / 100); | ||
| 1432 | } | 1445 | } |
| 1433 | /* Ignore tzp; it's obsolescent. */ | 1446 | /* Ignore tzp; it's obsolescent. */ |
| 1434 | return 0; | 1447 | return 0; |
| 1435 | } | 1448 | } |
| 1449 | |||
| 1450 | void | ||
| 1451 | init_gettimeofday () | ||
| 1452 | { | ||
| 1453 | time_t ltm, gtm; | ||
| 1454 | struct tm *lstm; | ||
| 1455 | #undef tzset | ||
| 1456 | extern void tzset (void); | ||
| 1457 | |||
| 1458 | tzset (); | ||
| 1459 | daylight = 0; | ||
| 1460 | gmtoffset = 0; | ||
| 1461 | ltm = gtm = time (NULL); | ||
| 1462 | ltm = mktime (lstm = localtime (<m)); | ||
| 1463 | gtm = mktime (gmtime (>m)); | ||
| 1464 | daylight = lstm->tm_isdst; | ||
| 1465 | gmtoffset = (int)(gtm - ltm) / 60; | ||
| 1466 | } | ||
| 1436 | 1467 | ||
| 1437 | /* These must be global. */ | 1468 | /* These must be global. */ |
| 1438 | static _go32_dpmi_seginfo ctrl_break_vector; | 1469 | static _go32_dpmi_seginfo ctrl_break_vector; |