なかだです。

At Tue, 11 Dec 2007 16:24:21 +0900,
Martin Duerst wrote in [ruby-dev:32536]:
> 原因を考えますと、今日久しぶりに cygwin を更新したことがあります。
> 何がどう変わったかはよく分かりませんが、cygwin の CVS を調べると
> http://cygwin.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/include/cygwin/time.h?cvsroot=src
> 当たりに最近ずいぶん色々変更がありました。

わたなべさんによると、最近は頻繁に変更が入っているので、今は手を
出さないほうがいいだろう、だそうです。

ただ、timezoneの変更についてはPOSIXとの互換性のためと思われるの
で、戻されることはないでしょう。


Index: configure.in =================================================================== --- configure.in (revision 14210) +++ configure.in (working copy) @@ -437,5 +437,4 @@ human*) ac_cv_func_getpgrp_void=yes beos*) ac_cv_func_link=no;; cygwin*) rb_cv_have_daylight=no - ac_cv_var_tzname=no ac_cv_func__setjmp=no ac_cv_func_setitimer=no @@ -609,5 +608,5 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid setsid telldir seekdir fchmod cosh sinh tanh log2 round\ setuid setgid daemon select_large_fdset setenv unsetenv\ - mktime timegm clock_gettime) + mktime timegm clock_gettime gettimeofday) AC_ARG_ENABLE(setreuid, [ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.], @@ -635,4 +634,28 @@ if test "$rb_cv_have_daylight" = yes; th AC_DEFINE(HAVE_DAYLIGHT) fi +AC_DEFUN([RUBY_CHECK_VARTYPE], [dnl +AC_CACHE_CHECK([for external $1], rb_cv_var_$1, + [rb_cv_var_$1=no + AC_TRY_COMPILE([#define _XOPEN_SOURCE 1 + $2 + void *t;], + [t = &(&$1)[0];], + [for t in $3; do + AC_TRY_COMPILE([#define _XOPEN_SOURCE 1 + $2 + extern $t $1;], + [void *t = &(&$1)[0];], + [rb_cv_var_$1=$t; break]) + done])]) +if test "[$rb_cv_var_]$1" != no; then + AC_DEFINE(HAVE_VAR_[]m4_toupper($1)) + AC_DEFINE(TYPEOF_VAR_[]m4_toupper($1), $rb_cv_var_$1) +fi]) +RUBY_CHECK_VARTYPE(timezone, [#include <time.h>], [long int]) +RUBY_CHECK_VARTYPE(altzone, [#include <time.h>], [long int]) +if test "$rb_cv_var_timezone" = no; then + AC_CHECK_FUNCS(timezone) +fi + AC_CACHE_CHECK(for negative time_t for gmtime(3), rb_cv_negative_time_t, [AC_TRY_RUN([ @@ -1214,5 +1237,5 @@ case "$target_os" in AC_CHECK_LIB(signal, _harderr) AC_CHECK_LIB(hmem, hmemset) - AC_CHECK_FUNCS(select gettimeofday) + AC_CHECK_FUNCS(select) AC_CACHE_CHECK(whether PD libc _dtos18 fail to convert big number, rb_cv_missing__dtos18, Index: missing/strftime.c =================================================================== --- missing/strftime.c (revision 14210) +++ missing/strftime.c (working copy) @@ -116,15 +116,20 @@ extern char *strchr(); #define range(low, item, hi) max(low, min(item, hi)) +#ifdef __CYGWIN__ +#define DLL_IMPORT __declspec(dllimport) +#endif +#ifdef __WIN32__ +#define DLL_IMPORT __declspec(dllimport) +#endif #if !defined(OS2) && !defined(MSDOS) && defined(HAVE_TZNAME) -extern char *tzname[2]; -extern int daylight; -#ifdef SOLARIS -extern long timezone, altzone; -#else -#ifdef __hpux -extern long timezone; -#else -extern int timezone, altzone; +extern DLL_IMPORT char *tzname[2]; +#ifdef HAVE_DAYLIGHT +extern DLL_IMPORT int daylight; +#endif +#ifdef HAVE_VAR_TIMEZONE +extern DLL_IMPORT TYPEOF_VAR_TIMEZONE timezone; #endif +#ifdef HAVE_VAR_ALTZONE +extern DLL_IMPORT TYPEOF_VAR_ALTZONE altzone; #endif #endif @@ -190,14 +195,6 @@ strftime(char *s, size_t maxsize, const #ifndef HAVE_TM_ZONE #ifndef HAVE_TM_NAME -#ifndef HAVE_TZNAME - extern char *timezone(); struct timeval tv; struct timezone zone; -#else -#ifdef __hpux - struct timeval tv; - struct timezone zone; -#endif -#endif /* HAVE_TZNAME */ #endif /* HAVE_TM_NAME */ #endif /* HAVE_TM_ZONE */ @@ -423,19 +420,16 @@ strftime(char *s, size_t maxsize, const off = timeptr->tm_gmtoff / 60; #else /* !HAVE_TM_ZONE */ -#if HAVE_TZNAME - /* - * Systems with tzname[] probably have timezone as - * secs west of GMT. Convert to mins east of GMT. - */ -#ifdef __hpux +#ifdef HAVE_GETTIMEOFDAY gettimeofday(&tv, &zone); off = -zone.tz_minuteswest; #else +#if HAVE_VAR_TIMEZONE +#if HAVE_VAR_ALTZONE off = -(daylight ? timezone : altzone) / 60; +#else + off = -timezone / 60; +#endif +#endif #endif -#else /* !HAVE_TZNAME */ - gettimeofday(&tv, &zone); - off = -zone.tz_minuteswest; -#endif /* !HAVE_TZNAME */ #endif /* !HAVE_TM_ZONE */ #endif /* !HAVE_TM_NAME */ @@ -461,11 +455,13 @@ strftime(char *s, size_t maxsize, const strcpy(tbuf, timeptr->tm_name); #else +#ifdef HAVE_TIMEZONE gettimeofday(& tv, & zone); -#ifdef __CYGWIN__ +#ifdef TIMEZONE_VOID strcpy(tbuf, timezone()); #else strcpy(tbuf, timezone(zone.tz_minuteswest, timeptr->tm_isdst > 0)); -#endif +#endif /* TIMEZONE_VOID */ +#endif /* HAVE_TIMEZONE */ #endif /* HAVE_TM_NAME */ #endif /* HAVE_TM_ZONE */ @@ -646,5 +642,5 @@ iso8601wknum(const struct tm *timeptr) */ - int weeknum, jan1day, diff; + int weeknum, jan1day; /* get week number, Monday as first day of the week */
-- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦