[Groonga-commit] groonga/groonga at 5ea8804 [master] Use gmtime_s() on MSVC

Back to archive index

Kouhei Sutou null+****@clear*****
Fri Jan 30 14:59:25 JST 2015


Kouhei Sutou	2015-01-30 14:59:25 +0900 (Fri, 30 Jan 2015)

  New Revision: 5ea88043f110e960527229cdb7829b537318115c
  https://github.com/groonga/groonga/commit/5ea88043f110e960527229cdb7829b537318115c

  Message:
    Use gmtime_s() on MSVC

  Modified files:
    build/ac_macros/check_functions.m4
    config.h.cmake
    lib/str.c

  Modified: build/ac_macros/check_functions.m4 (+1 -0)
===================================================================
--- build/ac_macros/check_functions.m4    2015-01-30 14:55:37 +0900 (0d98c54)
+++ build/ac_macros/check_functions.m4    2015-01-30 14:59:25 +0900 (462f63d)
@@ -4,6 +4,7 @@ AC_CHECK_FUNCS(_stricmp)
 AC_CHECK_FUNCS(_strnicmp)
 AC_CHECK_FUNCS(_strtoui64)
 AC_CHECK_FUNCS(close)
+AC_CHECK_FUNCS(gmtime_s)
 AC_CHECK_FUNCS(gmtime_r)
 AC_CHECK_FUNCS(localtime_s)
 AC_CHECK_FUNCS(localtime_r)

  Modified: config.h.cmake (+1 -0)
===================================================================
--- config.h.cmake    2015-01-30 14:55:37 +0900 (807d3ff)
+++ config.h.cmake    2015-01-30 14:59:25 +0900 (f63d318)
@@ -141,6 +141,7 @@
 #cmakedefine HAVE_CLOCK_GETTIME
 #cmakedefine HAVE_CLOSE
 #cmakedefine HAVE_FPCLASSIFY
+#cmakedefine HAVE_GMTIME_S
 #cmakedefine HAVE_GMTIME_R
 #cmakedefine HAVE_LOCALTIME_R
 #cmakedefine HAVE_LOCALTIME_S

  Modified: lib/str.c (+9 -3)
===================================================================
--- lib/str.c    2015-01-30 14:55:37 +0900 (f6096cf)
+++ lib/str.c    2015-01-30 14:59:25 +0900 (c04feae)
@@ -2441,14 +2441,20 @@ grn_text_time2rfc1123(grn_ctx *ctx, grn_obj *bulk, int sec)
 {
   time_t tsec;
   struct tm *t;
-#ifdef HAVE_GMTIME_R
+#ifdef HAVE_GMTIME_S
+  struct tm tm;
+  tsec = (time_t)sec;
+  t = (gmtime_s(&tm, &tsec) == 0) ? &tm : NULL;
+#else /* HAVE_GMTIME_S */
+# ifdef HAVE_GMTIME_R
   struct tm tm;
   tsec = (time_t)sec;
   t = gmtime_r(&tsec, &tm);
-#else /* HAVE_GMTIME_R */
+# else /* HAVE_GMTIME_R */
   tsec = (time_t)sec;
   t = gmtime(&tsec);
-#endif /* HAVE_GMTIME_R */
+# endif /* HAVE_GMTIME_R */
+#endif /* HAVE_GMTIME_S */
   if (t) {
     GRN_TEXT_SET(ctx, bulk, weekdays[t->tm_wday], 3);
     GRN_TEXT_PUTS(ctx, bulk, ", ");
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index