diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/msdos.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/msdos.c b/src/msdos.c index eb95a800767..f1f1c388aec 100644 --- a/src/msdos.c +++ b/src/msdos.c | |||
| @@ -739,6 +739,7 @@ init_environment (argc, argv, skip_args) | |||
| 739 | break; | 739 | break; |
| 740 | } | 740 | } |
| 741 | tzset (); | 741 | tzset (); |
| 742 | init_gettimeofday (); | ||
| 742 | } | 743 | } |
| 743 | 744 | ||
| 744 | /* Flash the screen as a substitute for BEEPs. */ | 745 | /* Flash the screen as a substitute for BEEPs. */ |
| @@ -889,7 +890,59 @@ internal_terminal_init () | |||
| 889 | internal_terminal | 890 | internal_terminal |
| 890 | = (!noninteractive) && term && !strcmp (term, "internal"); | 891 | = (!noninteractive) && term && !strcmp (term, "internal"); |
| 891 | } | 892 | } |
| 893 | |||
| 894 | /* When time zones are set from Ms-Dos too may C-libraries are playing | ||
| 895 | tricks with time values. We solve this by defining our own version | ||
| 896 | of `gettimeofday' bypassing GO32. Our version needs to be initialized | ||
| 897 | once and after each call to `tzset' with TZ changed. */ | ||
| 898 | |||
| 899 | static int daylight, gmtoffset; | ||
| 892 | 900 | ||
| 901 | int | ||
| 902 | gettimeofday (struct timeval *tp, struct timezone *tzp) | ||
| 903 | { | ||
| 904 | if (tp) | ||
| 905 | { | ||
| 906 | struct time t; | ||
| 907 | struct date d; | ||
| 908 | struct tm tmrec; | ||
| 909 | |||
| 910 | gettime (&t); | ||
| 911 | getdate (&d); | ||
| 912 | tmrec.tm_year = d.da_year - 1900; | ||
| 913 | tmrec.tm_mon = d.da_mon - 1; | ||
| 914 | tmrec.tm_mday = d.da_day; | ||
| 915 | tmrec.tm_hour = t.ti_hour; | ||
| 916 | tmrec.tm_min = t.ti_min; | ||
| 917 | tmrec.tm_sec = t.ti_sec; | ||
| 918 | tmrec.tm_gmtoff = gmtoffset; | ||
| 919 | tmrec.tm_isdst = daylight; | ||
| 920 | tp->tv_sec = mktime (&tmrec); | ||
| 921 | tp->tv_usec = t.ti_hund * (1000000 / 100); | ||
| 922 | } | ||
| 923 | if (tzp) | ||
| 924 | { | ||
| 925 | tzp->tz_minuteswest = gmtoffset; | ||
| 926 | tzp->tz_dsttime = daylight; | ||
| 927 | } | ||
| 928 | return 0; | ||
| 929 | } | ||
| 930 | |||
| 931 | void | ||
| 932 | init_gettimeofday () | ||
| 933 | { | ||
| 934 | time_t ltm, gtm; | ||
| 935 | struct tm *lstm; | ||
| 936 | |||
| 937 | daylight = 0; | ||
| 938 | gmtoffset = 0; | ||
| 939 | ltm = gtm = time (NULL); | ||
| 940 | ltm = mktime (lstm = localtime (<m)); | ||
| 941 | gtm = mktime (gmtime (>m)); | ||
| 942 | daylight = lstm->tm_isdst; | ||
| 943 | gmtoffset = (int)(gtm - ltm) / 60; | ||
| 944 | } | ||
| 945 | |||
| 893 | /* These must be global. */ | 946 | /* These must be global. */ |
| 894 | static _go32_dpmi_seginfo ctrl_break_vector; | 947 | static _go32_dpmi_seginfo ctrl_break_vector; |
| 895 | static _go32_dpmi_registers ctrl_break_regs; | 948 | static _go32_dpmi_registers ctrl_break_regs; |