Kouhei Sutou
null+****@clear*****
Fri Jan 30 14:55:37 JST 2015
Kouhei Sutou 2015-01-30 14:55:37 +0900 (Fri, 30 Jan 2015) New Revision: 39a8807f32f4ca7539f205220fa8d30111e72ba9 https://github.com/groonga/groonga/commit/39a8807f32f4ca7539f205220fa8d30111e72ba9 Message: Use localtime_s() on MSVC GitHub: fix #237 Patch by Susumu Yata. Thanks!!! Modified files: build/ac_macros/check_functions.m4 config.h.cmake lib/ctx.c Modified: build/ac_macros/check_functions.m4 (+1 -0) =================================================================== --- build/ac_macros/check_functions.m4 2015-01-30 14:46:18 +0900 (961a4fe) +++ build/ac_macros/check_functions.m4 2015-01-30 14:55:37 +0900 (0d98c54) @@ -5,6 +5,7 @@ AC_CHECK_FUNCS(_strnicmp) AC_CHECK_FUNCS(_strtoui64) AC_CHECK_FUNCS(close) AC_CHECK_FUNCS(gmtime_r) +AC_CHECK_FUNCS(localtime_s) AC_CHECK_FUNCS(localtime_r) AC_CHECK_FUNCS(mkostemp) AC_CHECK_FUNCS(open) Modified: config.h.cmake (+1 -0) =================================================================== --- config.h.cmake 2015-01-30 14:46:18 +0900 (8efa7d1) +++ config.h.cmake 2015-01-30 14:55:37 +0900 (807d3ff) @@ -143,6 +143,7 @@ #cmakedefine HAVE_FPCLASSIFY #cmakedefine HAVE_GMTIME_R #cmakedefine HAVE_LOCALTIME_R +#cmakedefine HAVE_LOCALTIME_S #cmakedefine HAVE_MKOSTEMP #cmakedefine HAVE_OPEN #cmakedefine HAVE_READ Modified: lib/ctx.c (+9 -3) =================================================================== --- lib/ctx.c 2015-01-30 14:46:18 +0900 (ff61f91) +++ lib/ctx.c 2015-01-30 14:55:37 +0900 (668cd34) @@ -133,14 +133,20 @@ grn_rc grn_timeval2str(grn_ctx *ctx, grn_timeval *tv, char *buf) { struct tm *ltm; -#ifdef HAVE_LOCALTIME_R +#ifdef HAVE_LOCALTIME_S + struct tm tm; + time_t t = tv->tv_sec; + ltm = (localtime_s(&tm, &t) == 0) ? &tm : NULL; +#else /* HAVE_LOCALTIME_S */ +# ifdef HAVE_LOCALTIME_R struct tm tm; time_t t = tv->tv_sec; ltm = localtime_r(&t, &tm); -#else /* HAVE_LOCALTIME_R */ +# else /* HAVE_LOCALTIME_R */ time_t tvsec = (time_t) tv->tv_sec; ltm = localtime(&tvsec); -#endif /* HAVE_LOCALTIME_R */ +# endif /* HAVE_LOCALTIME_R */ +#endif /* HAVE_LOCALTIME_S */ if (!ltm) { SERR("localtime"); } snprintf(buf, GRN_TIMEVAL_STR_SIZE - 1, GRN_TIMEVAL_STR_FORMAT, ltm->tm_year + 1900, ltm->tm_mon + 1, ltm->tm_mday, -------------- next part -------------- HTML����������������������������...Download