Mailing-List: contact cygwin-developers-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-developers-owner AT sourceware DOT cygnus DOT com Delivered-To: mailing list cygwin-developers AT sourceware DOT cygnus DOT com From: "Norbert Schulze" To: Subject: Some contributions Date: Tue, 31 Aug 1999 22:03:29 +0200 Message-ID: <000001bef3eb$ebb822d0$3a5ac5c1@guinan> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0001_01BEF3FC.AF40F2D0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2377.0 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 This is a multi-part message in MIME format. ------=_NextPart_000_0001_01BEF3FC.AF40F2D0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Some contributions: ChangeLog * times.cc (timezone): revert 'return TZ if set' patch. * times.cc (timezone): uses now tzset() and _timezone. * times.cc (gettimeofday): ditto. * localtime.c (tzsetwall): no negative minutes if offset is negativ. * localtime.c (tzsetwall): minutes place holder was missing if minutes == 0 and seconds !=0 (h:0:s). * localtime.c (tzsetwall): if timezone has no daylight saving (tz.StandardDate.wMonth==0) generate no daylight saving parameters. * smallprint.c (__small_vprintf): Handle 'l' after width argument. Regards Norbert ------=_NextPart_000_0001_01BEF3FC.AF40F2D0 Content-Type: application/octet-stream; name="localtime.c-patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="localtime.c-patch" --- localtime.c-orig Mon Aug 23 19:53:06 1999 +++ localtime.c Tue Aug 31 20:54:36 1999 @@ -10,8 +10,6 @@ #include extern DWORD strace_active; =20 -void cygwin_tzset(); - #define USG_COMPAT =20 /* END CYGNUS LOCAL */ @@ -1449,41 +1447,42 @@ tzsetwall P((void)) d =3D div(tz.Bias+tz.StandardBias, 60); sprintf(cp, "%d", d.quot); if (d.rem) - sprintf(cp=3Dstrchr(cp, 0), ":%d", d.rem); - cp =3D strchr(cp, 0); - wcstombs(cp, tz.DaylightName, sizeof(tz.DaylightName)); - for (src =3D cp; *src; ++src) { - if (is_upper(*src)) *cp++ =3D *src; + sprintf(cp=3Dstrchr(cp, 0), ":%d", abs(d.rem)); + if(tz.StandardDate.wMonth) { + cp =3D strchr(cp, 0); + wcstombs(cp, tz.DaylightName, sizeof(tz.DaylightName)); + for (src =3D cp; *src; ++src) { + if (is_upper(*src)) *cp++ =3D *src; + } + d =3D div(tz.Bias+tz.DaylightBias, 60); + sprintf(cp, "%d", d.quot); + if (d.rem) + sprintf(cp=3Dstrchr(cp, 0), ":%d", abs(d.rem)); + cp =3D strchr(cp, 0); + sprintf(cp=3Dstrchr(cp, 0), ",M%d.%d.%d/%d", + tz.DaylightDate.wMonth, + tz.DaylightDate.wDay, + tz.DaylightDate.wDayOfWeek, + tz.DaylightDate.wHour); + if (tz.DaylightDate.wMinute || tz.DaylightDate.wSecond) + sprintf(cp=3Dstrchr(cp, 0), ":%d", tz.DaylightDate.wMinute); + if (tz.DaylightDate.wSecond) + sprintf(cp=3Dstrchr(cp, 0), ":%d", tz.DaylightDate.wSecond); + cp =3D strchr(cp, 0); + sprintf(cp=3Dstrchr(cp, 0), ",M%d.%d.%d/%d", + tz.StandardDate.wMonth, + tz.StandardDate.wDay, + tz.StandardDate.wDayOfWeek, + tz.StandardDate.wHour); + if (tz.StandardDate.wMinute || tz.StandardDate.wSecond) + sprintf(cp=3Dstrchr(cp, 0), ":%d", tz.StandardDate.wMinute); + if (tz.StandardDate.wSecond) + sprintf(cp=3Dstrchr(cp, 0), ":%d", tz.StandardDate.wSecond); } - d =3D div(tz.Bias+tz.DaylightBias, 60); - sprintf(cp, "%d", d.quot); - if (d.rem) - sprintf(cp=3Dstrchr(cp, 0), ":%d", d.rem); - cp =3D strchr(cp, 0); - sprintf(cp=3Dstrchr(cp, 0), ",M%d.%d.%d/%d", - tz.DaylightDate.wMonth, - tz.DaylightDate.wDay, - tz.DaylightDate.wDayOfWeek, - tz.DaylightDate.wHour); - if (tz.DaylightDate.wMinute) - sprintf(cp=3Dstrchr(cp, 0), ":%d", tz.DaylightDate.wMinute); - if (tz.DaylightDate.wSecond) - sprintf(cp=3Dstrchr(cp, 0), ":%d", tz.DaylightDate.wSecond); - cp =3D strchr(cp, 0); - sprintf(cp=3Dstrchr(cp, 0), ",M%d.%d.%d/%d", - tz.StandardDate.wMonth, - tz.StandardDate.wDay, - tz.StandardDate.wDayOfWeek, - tz.StandardDate.wHour); - if (tz.StandardDate.wMinute) - sprintf(cp=3Dstrchr(cp, 0), ":%d", tz.StandardDate.wMinute); - if (tz.StandardDate.wSecond) - sprintf(cp=3Dstrchr(cp, 0), ":%d", tz.StandardDate.wSecond); /* printf("TZ deduced as `%s'\n", buf); */ if (tzparse(buf, lclptr, FALSE) =3D=3D 0) { settzname(); setenv("TZ", buf, 1); - cygwin_tzset(); return; } } @@ -1498,30 +1497,6 @@ tzset P((void)) { const char * name =3D getenv("TZ"); =20 -#if 0 /* we set it more accurately in tzsetwall() */ -#if defined(__CYGWIN32__) || defined(__CYGWIN__) - static char b[20]; - DWORD tzid; - TIME_ZONE_INFORMATION tz; - LONG bias; - - cygwin_tzset(); - - if (name =3D=3D NULL) - { -=09 - tzid =3D GetTimeZoneInformation (&tz); - - if (tzid =3D=3D TIME_ZONE_ID_DAYLIGHT) - bias =3D tz.Bias + tz.DaylightBias; - else - bias =3D tz.Bias + tz.StandardBias; - sprintf (b,"GMT%+d:%02d", (int) (-bias / 60), (int) (abs(bias) % = 60)); - name =3D b; - } -=09 -#endif -#endif if (name =3D=3D NULL) { tzsetwall(); return; ------=_NextPart_000_0001_01BEF3FC.AF40F2D0 Content-Type: application/octet-stream; name="smallprint.c-patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="smallprint.c-patch" --- smallprint.c-orig Thu Aug 26 05:58:40 1999 +++ smallprint.c Tue Aug 31 20:27:52 1999 @@ -81,7 +81,6 @@ __small_vsprintf (char *dst, const char { case '+': addsign = 1; - case 'l': fmt++; break; case '%': @@ -98,6 +97,8 @@ __small_vsprintf (char *dst, const char if (*fmt >= '1' && *fmt <= '9') len = *fmt++ - '0'; + if (*fmt == 'l') + fmt++; switch (*fmt++) { ------=_NextPart_000_0001_01BEF3FC.AF40F2D0 Content-Type: application/octet-stream; name="times.cc-patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="times.cc-patch" --- times.cc-orig Tue Aug 24 03:46:26 1999 +++ times.cc Tue Aug 31 20:39:18 1999 @@ -105,23 +105,9 @@ timezone () #else static NO_COPY char b[20] =3D {0}; #endif - DWORD tzid; - TIME_ZONE_INFORMATION tz; - LONG bias; - char *tzn; - - tzn =3D getenv("TZ"); - if (tzn) - return tzn; =20 - tzid =3D GetTimeZoneInformation (&tz); - - if (tzid =3D=3D TIME_ZONE_ID_DAYLIGHT) - bias =3D tz.Bias + tz.DaylightBias; - else - bias =3D tz.Bias + tz.StandardBias; - - __small_sprintf (b,"GMT%+d:%02d", (int) (-bias / 60), (int) = (abs(bias) % 60)); + tzset(); + __small_sprintf (b,"GMT%+d:%02d", (int) (-_timezone / 3600), (int) = (abs(_timezone / 60) % 60)); return b; } =20 @@ -144,18 +130,6 @@ int gettimeofday (struct timeval *p, struct timezone *z) { int res =3D 0; - DWORD tzid; - TIME_ZONE_INFORMATION tz; - LONG bias; - - tzid =3D GetTimeZoneInformation (&tz); - if (tzid =3D=3D TIME_ZONE_ID_INVALID) - res =3D -1; - - if (tzid =3D=3D TIME_ZONE_ID_DAYLIGHT) - bias =3D tz.Bias + tz.DaylightBias; - else - bias =3D tz.Bias + tz.StandardBias; =20 if (p !=3D NULL) { @@ -170,8 +144,9 @@ gettimeofday (struct timeval *p, struct=20 =20 if (z !=3D NULL) { - z->tz_minuteswest =3D bias; - z->tz_dsttime =3D (tzid =3D=3D TIME_ZONE_ID_DAYLIGHT); + tzset(); + z->tz_minuteswest =3D _timezone / 60; + z->tz_dsttime =3D _daylight; } =20 syscall_printf ("%d =3D gettimeofday (%x, %x)", res, p, z); @@ -407,19 +382,14 @@ localtime (const time_t *tim_p) { time_t tim =3D *tim_p; struct tm *rtm; - DWORD tzid; - TIME_ZONE_INFORMATION tz; - - tzid =3D GetTimeZoneInformation (&tz); - - if (tzid =3D=3D TIME_ZONE_ID_DAYLIGHT) - tim -=3D (tz.Bias + tz.DaylightBias) * SECSPERMIN; - else - tim -=3D (tz.Bias + tz.StandardBias) * SECSPERMIN; =20 + tzset(); +=20 + tim -=3D _timezone; +=20 rtm =3D corelocaltime (&tim); =20 - rtm->tm_isdst =3D (tzid =3D=3D TIME_ZONE_ID_DAYLIGHT); + rtm->tm_isdst =3D _daylight; =20 syscall_printf ("%x =3D localtime (%x)", rtm, tim_p); =20 @@ -565,63 +535,9 @@ ftime (struct timeb *tp) return 0; } =20 -/* These variables are initialized by tzset. The macro versions are - defined in time.h, and indirect through the __imp_ pointers. */ - -#undef _timezone -#undef _daylight -#undef _tzname - -#if 0 -time_t __declspec(dllexport) _timezone; -int __declspec(dllexport) _daylight; -char __declspec(dllexport) *_tzname[2] =3D { (char *) "GMT", (char *) " = " }; -#endif - -/* tzset: POSIX 8.3.2.1 */ -/* This function initializes timezone variables. */ -/* changed to cygwin_tzset when localtime.c was added - dj */ +/* obsolete, changed to cygwin_tzset when localtime.c was added - dj */ extern "C" void cygwin_tzset () { -#if 0 -#ifdef _MT_SAFE - char *buf1=3D_reent_winsup()->_buf1; - char *buf2=3D_reent_winsup()->_buf2; -#else - static NO_COPY char buf1[33] =3D {0}; - static NO_COPY char buf2[33] =3D {0}; -#endif - - /* FIXME: This function should examine the TZ environment variable. - Right now it just always sets information based on the system - time zone. */ - - DWORD tzid; - TIME_ZONE_INFORMATION tz; - - tzid =3D GetTimeZoneInformation (&tz); - - if (tzid =3D=3D TIME_ZONE_ID_DAYLIGHT) - _timezone =3D (tz.Bias + tz.DaylightBias) * SECSPERMIN; - else - _timezone =3D (tz.Bias + tz.StandardBias) * SECSPERMIN; - _daylight =3D (tzid =3D=3D TIME_ZONE_ID_DAYLIGHT); - - /* from localtime.c */ - strcpy(buf1, tzname[0]); - _tzname[0] =3D buf1; - strcpy(buf2, tzname[1]); - _tzname[1] =3D buf2; - - WideCharToMultiByte (CP_ACP, 0, tz.StandardName, -1, buf1, sizeof = buf1 - 1, - NULL, NULL); - buf1[sizeof buf1 - 1] =3D '\0'; - _tzname[0] =3D buf1; - WideCharToMultiByte (CP_ACP, 0, tz.DaylightName, -1, buf2, sizeof = buf2 - 1, - NULL, NULL); - buf2[sizeof buf2 - 1] =3D '\0'; - _tzname[1] =3D buf2; -#endif } ------=_NextPart_000_0001_01BEF3FC.AF40F2D0--