Navigation Menu

Skip to content

Commit

Permalink
windows: try to add "_" prefix
Browse files Browse the repository at this point in the history
Because gmtime_s() and localtime_s() aren't found on MSVC.
  • Loading branch information
kou committed Jan 30, 2015
1 parent caf5b43 commit 4b6f2ba
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions build/ac_macros/check_functions.m4
@@ -1,12 +1,12 @@
# -*- autoconf -*-

AC_CHECK_FUNCS(_gmtime_s)
AC_CHECK_FUNCS(_localtime_s)
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)
AC_CHECK_FUNCS(mkostemp)
AC_CHECK_FUNCS(open)
Expand Down
4 changes: 2 additions & 2 deletions config.h.cmake
Expand Up @@ -133,6 +133,8 @@
#cmakedefine HAVE_MECAB_DICTIONARY_INFO_T

/* functions */
#cmakedefine HAVE__GMTIME_S
#cmakedefine HAVE__LOCALTIME_S
#cmakedefine HAVE__STRICMP
#cmakedefine HAVE__STRNICMP
#cmakedefine HAVE__STRTOUI64
Expand All @@ -141,9 +143,7 @@
#cmakedefine HAVE_CLOCK_GETTIME
#cmakedefine HAVE_CLOSE
#cmakedefine HAVE_FPCLASSIFY
#cmakedefine HAVE_GMTIME_S
#cmakedefine HAVE_GMTIME_R
#cmakedefine HAVE_LOCALTIME_S
#cmakedefine HAVE_LOCALTIME_R
#cmakedefine HAVE_MKOSTEMP
#cmakedefine HAVE_OPEN
Expand Down
10 changes: 5 additions & 5 deletions lib/ctx.c
Expand Up @@ -134,12 +134,12 @@ grn_timeval2str(grn_ctx *ctx, grn_timeval *tv, char *buf)
{
struct tm *ltm;
const char *function_name;
#ifdef HAVE_LOCALTIME_S
#ifdef HAVE__LOCALTIME_S
struct tm tm;
time_t t = tv->tv_sec;
function_name = "localtime_s";
ltm = (localtime_s(&tm, &t) == 0) ? &tm : NULL;
#else /* HAVE_LOCALTIME_S */
function_name = "_localtime_s";
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;
Expand All @@ -150,7 +150,7 @@ grn_timeval2str(grn_ctx *ctx, grn_timeval *tv, char *buf)
function_name = "localtime";
ltm = localtime(&tvsec);
# endif /* HAVE_LOCALTIME_R */
#endif /* HAVE_LOCALTIME_S */
#endif /* HAVE__LOCALTIME_S */
if (!ltm) { SERR(function_name); }
snprintf(buf, GRN_TIMEVAL_STR_SIZE - 1, GRN_TIMEVAL_STR_FORMAT,
ltm->tm_year + 1900, ltm->tm_mon + 1, ltm->tm_mday,
Expand Down
8 changes: 4 additions & 4 deletions lib/str.c
Expand Up @@ -2441,11 +2441,11 @@ grn_text_time2rfc1123(grn_ctx *ctx, grn_obj *bulk, int sec)
{
time_t tsec;
struct tm *t;
#ifdef HAVE_GMTIME_S
#ifdef HAVE__GMTIME_S
struct tm tm;
tsec = (time_t)sec;
t = (gmtime_s(&tm, &tsec) == 0) ? &tm : NULL;
#else /* HAVE_GMTIME_S */
t = (_gmtime_s(&tm, &tsec) == 0) ? &tm : NULL;
#else /* HAVE__GMTIME_S */
# ifdef HAVE_GMTIME_R
struct tm tm;
tsec = (time_t)sec;
Expand All @@ -2454,7 +2454,7 @@ grn_text_time2rfc1123(grn_ctx *ctx, grn_obj *bulk, int sec)
tsec = (time_t)sec;
t = gmtime(&tsec);
# endif /* HAVE_GMTIME_R */
#endif /* HAVE_GMTIME_S */
#endif /* HAVE__GMTIME_S */
if (t) {
GRN_TEXT_SET(ctx, bulk, weekdays[t->tm_wday], 3);
GRN_TEXT_PUTS(ctx, bulk, ", ");
Expand Down

0 comments on commit 4b6f2ba

Please sign in to comment.