comparison src/msdos.c @ 7523:8994727ff976

(gettimeofday): New function substituting the library function of the same name. (init_gettimeofday): New function. (init_environment): Call init_gettimeofday after possibly setting TZ environment variable.
author Richard M. Stallman <rms@gnu.org>
date Tue, 17 May 1994 07:24:12 +0000
parents b393834bab2a
children 13a977e6777a
comparison
equal deleted inserted replaced
7522:3049e726a161 7523:8994727ff976
737 case 972: /* Israel */ 737 case 972: /* Israel */
738 setenv ("TZ", "EET-02", 0); 738 setenv ("TZ", "EET-02", 0);
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. */
745 746
746 static unsigned char _xorattr; 747 static unsigned char _xorattr;
887 char *term = getenv ("TERM"); 888 char *term = getenv ("TERM");
888 889
889 internal_terminal 890 internal_terminal
890 = (!noninteractive) && term && !strcmp (term, "internal"); 891 = (!noninteractive) && term && !strcmp (term, "internal");
891 } 892 }
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;
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 (&ltm));
941 gtm = mktime (gmtime (&gtm));
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;
896 static int ctrlbreakinstalled = 0; 949 static int ctrlbreakinstalled = 0;
897 950