summaryrefslogtreecommitdiff
path: root/external/mit/lua/dist/src/loslib.c
diff options
context:
space:
mode:
authormbalmer <mbalmer@NetBSD.org>2015-10-08 13:21:00 +0000
committermbalmer <mbalmer@NetBSD.org>2015-10-08 13:21:00 +0000
commit649cf8e53381cbc6057d92bbf44588bb7024bdd2 (patch)
tree37d60c2028507b3425901810054e008ce1f65440 /external/mit/lua/dist/src/loslib.c
parent14a62719979f511f0c63a80b66d3ca7202ffc862 (diff)
update after conflict resolution
Diffstat (limited to 'external/mit/lua/dist/src/loslib.c')
-rw-r--r--external/mit/lua/dist/src/loslib.c76
1 files changed, 46 insertions, 30 deletions
diff --git a/external/mit/lua/dist/src/loslib.c b/external/mit/lua/dist/src/loslib.c
index 4c147571d0b..1c768daa5ae 100644
--- a/external/mit/lua/dist/src/loslib.c
+++ b/external/mit/lua/dist/src/loslib.c
@@ -1,5 +1,7 @@
+/* $NetBSD: loslib.c,v 1.4 2015/10/08 13:21:00 mbalmer Exp $ */
+
/*
-** $Id: loslib.c,v 1.3 2015/02/02 14:03:05 lneto Exp $
+** Id: loslib.c,v 1.57 2015/04/10 17:41:04 roberto Exp
** Standard Operating System library
** See Copyright Notice in lua.h
*/
@@ -22,10 +24,12 @@
#include "lualib.h"
-#if !defined(LUA_STRFTIMEOPTIONS) /* { */
/*
+** {==================================================================
** list of valid conversion specifiers for the 'strftime' function
+** ===================================================================
*/
+#if !defined(LUA_STRFTIMEOPTIONS) /* { */
#if defined(LUA_USE_C89)
#define LUA_STRFTIMEOPTIONS { "aAbBcdHIjmMpSUwWxXyYz%", "" }
@@ -37,8 +41,14 @@
#endif
#endif /* } */
+/* }================================================================== */
+/*
+** {==================================================================
+** Configuration for time-related stuff
+** ===================================================================
+*/
#if !defined(l_time_t) /* { */
/*
@@ -51,12 +61,38 @@
#endif /* } */
+#if !defined(l_gmtime) /* { */
+/*
+** By default, Lua uses gmtime/localtime, except when POSIX is available,
+** where it uses gmtime_r/localtime_r
+*/
+
+#if defined(LUA_USE_POSIX) /* { */
+
+#define l_gmtime(t,r) gmtime_r(t,r)
+#define l_localtime(t,r) localtime_r(t,r)
+
+#else /* }{ */
+
+/* ISO C definitions */
+#define l_gmtime(t,r) ((void)(r)->tm_sec, gmtime(t))
+#define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t))
+
+#endif /* } */
+
+#endif /* } */
+
+/* }================================================================== */
+
-#if !defined(lua_tmpnam) /* { */
/*
-** By default, Lua uses tmpnam except when POSIX is available, where it
-** uses mkstemp.
+** {==================================================================
+** Configuration for 'tmpnam':
+** By default, Lua uses tmpnam except when POSIX is available, where
+** it uses mkstemp.
+** ===================================================================
*/
+#if !defined(lua_tmpnam) /* { */
#if defined(LUA_USE_POSIX) /* { */
@@ -83,31 +119,10 @@
#endif /* } */
#endif /* } */
+/* }================================================================== */
-#if !defined(l_gmtime) /* { */
-/*
-** By default, Lua uses gmtime/localtime, except when POSIX is available,
-** where it uses gmtime_r/localtime_r
-*/
-
-#if defined(LUA_USE_POSIX) /* { */
-
-#define l_gmtime(t,r) gmtime_r(t,r)
-#define l_localtime(t,r) localtime_r(t,r)
-
-#else /* }{ */
-
-/* ISO C definitions */
-#define l_gmtime(t,r) ((void)(r)->tm_sec, gmtime(t))
-#define l_localtime(t,r) ((void)(r)->tm_sec, localtime(t))
-
-#endif /* } */
-
-#endif /* } */
-
-
static int os_execute (lua_State *L) {
const char *cmd = luaL_optstring(L, 1, NULL);
@@ -287,7 +302,7 @@ static int os_time (lua_State *L) {
t = mktime(&ts);
}
if (t != (time_t)(l_timet)t)
- luaL_error(L, "time result cannot be represented in this Lua instalation");
+ luaL_error(L, "time result cannot be represented in this Lua installation");
else if (t == (time_t)(-1))
lua_pushnil(L);
else
@@ -297,8 +312,9 @@ static int os_time (lua_State *L) {
static int os_difftime (lua_State *L) {
- double res = difftime((l_checktime(L, 1)), (l_checktime(L, 2)));
- lua_pushnumber(L, (lua_Number)res);
+ time_t t1 = l_checktime(L, 1);
+ time_t t2 = l_checktime(L, 2);
+ lua_pushnumber(L, (lua_Number)difftime(t1, t2));
return 1;
}