[Groonga-commit] groonga/groonga at 2c6ccad [master] Configure struct tm.tm_gmtoff

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Jul 2 18:43:04 JST 2018


Kouhei Sutou	2018-07-02 18:43:04 +0900 (Mon, 02 Jul 2018)

  New Revision: 2c6ccad847d627ec89874d70d422eff38785403f
  https://github.com/groonga/groonga/commit/2c6ccad847d627ec89874d70d422eff38785403f

  Message:
    Configure struct tm.tm_gmtoff

  Modified files:
    CMakeLists.txt
    config.h.cmake
    configure.ac
    plugins/functions/time.c

  Modified: CMakeLists.txt (+7 -0)
===================================================================
--- CMakeLists.txt    2018-07-02 16:57:52 +0900 (7dc602047)
+++ CMakeLists.txt    2018-07-02 18:43:04 +0900 (38f824876)
@@ -67,6 +67,7 @@ include(CheckIncludeFile)
 include(CheckFunctionExists)
 include(CheckLibraryExists)
 include(CheckSymbolExists)
+include(CheckStructHasMember)
 include(CheckCCompilerFlag)
 include(CheckCXXCompilerFlag)
 include(FindPkgConfig)
@@ -283,6 +284,12 @@ if(GRN_EMBED)
   endif()
 endif()
 
+check_struct_has_member(
+  "struct tm",
+  "tm_gmtoff",
+  "include.h",
+  HAVE_STRUCT_TM_TM_GMTOFF)
+
 if(UNIX)
   ac_check_headers(pthread.h)
   ac_check_lib(pthread pthread_mutex_init)

  Modified: config.h.cmake (+3 -0)
===================================================================
--- config.h.cmake    2018-07-02 16:57:52 +0900 (bfd0cbdc0)
+++ config.h.cmake    2018-07-02 18:43:04 +0900 (5ee382357)
@@ -125,6 +125,9 @@
 #cmakedefine HAVE_LIBM
 #cmakedefine HAVE_LIBRT
 
+/* members */
+#cmakedefine HAVE_STRUCT_TM_TM_GMTOFF
+
 /* structs */
 #cmakedefine HAVE_MECAB_DICTIONARY_INFO_T
 

  Modified: configure.ac (+7 -0)
===================================================================
--- configure.ac    2018-07-02 16:57:52 +0900 (8fac20231)
+++ configure.ac    2018-07-02 18:43:04 +0900 (80ba56e29)
@@ -386,6 +386,13 @@ AC_SYS_LARGEFILE
 AC_TYPE_OFF_T
 AC_TYPE_SIZE_T
 AC_CHECK_SIZEOF(off_t)
+AC_CHECK_MEMBERS(
+  [struct tm.tm_gmtoff],
+  ,
+  ,
+  [
+#include <time.h>
+  ])
 
 # MAP_HUGETLB
 AC_ARG_ENABLE(map-hugetlb,

  Modified: plugins/functions/time.c (+7 -3)
===================================================================
--- plugins/functions/time.c    2018-07-02 16:57:52 +0900 (8b03d5ece)
+++ plugins/functions/time.c    2018-07-02 18:43:04 +0900 (3722e879f)
@@ -20,6 +20,10 @@
 # define GRN_PLUGIN_FUNCTION_TAG functions_time
 #endif /* GRN_EMBEDDED */
 
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
 #include <groonga/plugin.h>
 
 #include <math.h>
@@ -523,13 +527,13 @@ func_time_format_iso8601(grn_ctx *ctx, int n_args, grn_obj **args,
                     tm.tm_min,
                     tm.tm_sec,
                     (int32_t)(time_raw % GRN_TIME_USEC_PER_SEC));
-#if defined(__linux__)
+#ifdef HAVE_STRUCT_TM_TM_GMTOFF
     grn_text_printf(ctx,
                     formatted_time,
                     "%+03d:%02d",
                     (int32_t)(tm.tm_gmtoff / 3600),
                     abs(tm.tm_gmtoff % 3600));
-#elif defined(WIN32)
+#elif defined(WIN32) /* HAVE_STRUCT_TM_TM_GMTOFF */
     {
       long gmtoff;
       if (_get_timezone(gmtoff) == 0) {
@@ -540,7 +544,7 @@ func_time_format_iso8601(grn_ctx *ctx, int n_args, grn_obj **args,
                         abs(gmtoff % 3600));
       }
     }
-#endif
+#endif /* HAVE_STRUCT_TM_TM_GMTOFF */
     return formatted_time;
   }
 }
-------------- next part --------------
HTML����������������������������...
URL: https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20180702/3d030c4b/attachment-0001.htm 



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