From e2a7646b75d5c5688460dfa0d7ca56f485d76611 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Fri, 28 Apr 2017 23:25:21 +0000 Subject: [PATCH] added strftime %z check into configure.ac --- moo/configure | 46 ++++++++++++++++++++++++++++++++++++++++++++ moo/configure.ac | 28 +++++++++++++++++++++++++++ moo/kernel/Mill.moo | 10 ---------- moo/lib/main.c | 6 +++--- moo/lib/moo-cfg.h.in | 3 +++ 5 files changed, 80 insertions(+), 13 deletions(-) diff --git a/moo/configure b/moo/configure index 0a3f114..e947686 100755 --- a/moo/configure +++ b/moo/configure @@ -19110,6 +19110,52 @@ fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for strftime %z" >&5 +$as_echo_n "checking for strftime %z... " >&6; } +if test "$cross_compiling" = yes; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unknown" >&5 +$as_echo "unknown" >&6; } + +$as_echo "#define HAVE_STRFTIME_SMALL_Z 1" >>confdefs.h + + + +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #if defined(HAVE_SYS_TIME_H) + #include + #endif + #if defined(HAVE_TIME_H) + #include + #endif + int main () + { + char buf[100]; + time_t t = 0; + strftime (buf, sizeof(buf), "%z", gmtime(&t)); + return strcmp(buf, "%z") == 0? 1: 0; + } +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +$as_echo "#define HAVE_STRFTIME_SMALL_Z 1" >>confdefs.h + + +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + # The cast to long int works around a bug in the HP C Compiler # version HP92453-01 B.11.11.23709.GP, which incorrectly rejects # declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. diff --git a/moo/configure.ac b/moo/configure.ac index 9295ed8..1c6048f 100644 --- a/moo/configure.ac +++ b/moo/configure.ac @@ -213,6 +213,34 @@ AC_TRY_LINK( [AC_MSG_RESULT(no)] ) +AC_MSG_CHECKING([for strftime %z]) +AC_TRY_RUN( + [#include + #if defined(HAVE_SYS_TIME_H) + #include + #endif + #if defined(HAVE_TIME_H) + #include + #endif + int main () + { + char buf[100]; + time_t t = 0; + strftime (buf, sizeof(buf), "%z", gmtime(&t)); + return strcmp(buf, "%z") == 0? 1: 0; + }], + [ + AC_MSG_RESULT(yes) + AC_DEFINE([HAVE_STRFTIME_SMALL_Z], [1], [strftime supports %z]) + ], + [AC_MSG_RESULT(no)], + [ + dnl cross-compiling, assume yes + AC_MSG_RESULT(unknown) + AC_DEFINE([HAVE_STRFTIME_SMALL_Z], [1], [strftime supports %z]) + ] +) + dnl check the size of primitive data types AC_CHECK_SIZEOF(char,,[[]]) AC_CHECK_SIZEOF(short,,[[]]) diff --git a/moo/kernel/Mill.moo b/moo/kernel/Mill.moo index 88e3b65..d6e0da6 100644 --- a/moo/kernel/Mill.moo +++ b/moo/kernel/Mill.moo @@ -85,16 +85,6 @@ class MyObject(Object) ] on: Exception do: [:ex | ('Exception caught - ' & ex asString) dump ].*) ffi := FFI new: '/lib64/libc.so.6'. - (* - (ffi isError) - ifTrue: [System logNl: 'cannot open libc.so' ] - ifFalse: [ - (ffi call: #getpid signature: ')i' arguments: nil) dump. - (ffi call: #printf signature: 's|iis)i' arguments: #(S'A=>%d B=>%d Hello, world %s\n' 1 2 'fly away')) dump. - (ffi call: #printf signature: 's|iis)i' arguments: #(S'A=>%d B=>%d Hello, world %s\n' 1 2 'jump down')) dump. - ffi close. - ]. - *) if (ffi isError) { System logNl: 'cannot open libc.so' diff --git a/moo/lib/main.c b/moo/lib/main.c index a78b35b..6c7b611 100644 --- a/moo/lib/main.c +++ b/moo/lib/main.c @@ -660,10 +660,10 @@ if (mask & MOO_LOG_GC) return; /* don't show gc logs */ } #else tmp = localtime_r (&now, &tm); - #if defined(__sun) && defined(__SVR4) /* TODO: better check on support of %z */ - tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp); - #else + #if defined(HAVE_STRFTIME_SMALL_Z) tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp); + #else + tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %Z ", tmp); #endif if (tslen == 0) { diff --git a/moo/lib/moo-cfg.h.in b/moo/lib/moo-cfg.h.in index e009376..a5917c2 100644 --- a/moo/lib/moo-cfg.h.in +++ b/moo/lib/moo-cfg.h.in @@ -217,6 +217,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H +/* strftime supports %z */ +#undef HAVE_STRFTIME_SMALL_Z + /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H