diff --git a/stix/lib/exec.c b/stix/lib/exec.c index 46e1fe8..b826d27 100644 --- a/stix/lib/exec.c +++ b/stix/lib/exec.c @@ -1207,14 +1207,13 @@ static int prim_log (stix_t* stix, stix_ooi_t nargs) STIX_ASSERT (nargs >= 2); - level = STIX_STACK_GET(stix, stix->sp - nargs + 1); + level = STIX_STACK_GETARG(stix, nargs, 0); if (!STIX_OOP_IS_SMOOI(level)) mask = STIX_LOG_APP | STIX_LOG_INFO; else mask = STIX_LOG_APP | STIX_OOP_TO_SMOOI(level); - for (k = nargs - 1; k > 0; ) + for (k = 1; k < nargs; k++) { - --k; - msg = STIX_STACK_GET(stix, stix->sp - k); + msg = STIX_STACK_GETARG (stix, nargs, k); if (msg == stix->_nil || msg == stix->_true || msg == stix->_false) { diff --git a/stix/lib/main.c b/stix/lib/main.c index 26a59b5..f336b0f 100644 --- a/stix/lib/main.c +++ b/stix/lib/main.c @@ -406,6 +406,7 @@ static void log_write (stix_t* stix, stix_oow_t mask, const stix_ooch_t* msg, st stix_oow_t ucslen, bcslen, msgidx; int n; char ts[32]; + size_t tslen; struct tm tm, *tmp; time_t now; @@ -420,8 +421,13 @@ static void log_write (stix_t* stix, stix_oow_t mask, const stix_ooch_t* msg, st #else tmp = localtime_r (&now, &tm); #endif - strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp); - write_all (1, ts, strlen(ts)); + tslen = strftime (ts, sizeof(ts), "%Y-%m-%d %H:%M:%S %z ", tmp); + if (tslen == 0) + { + strcpy (ts, "0000-00-00 00:00:00 +0000"); + tslen = 25; + } + write_all (1, ts, tslen); msgidx = 0; while (len > 0)