diff options
| author | Lua Team <team@lua.org> | 2006-01-12 12:00:00 +0000 |
|---|---|---|
| committer | repogen <> | 2006-01-12 12:00:00 +0000 |
| commit | 4f266285f998d0d14c4e83cc29772f0de1a7fbba (patch) | |
| tree | a122a829730d9f96e3a4e2bf65347490a8759800 /src/loslib.c | |
| parent | b3196343ba1a5dfe10e68eb9c61dc0ad5bb961a8 (diff) | |
| download | lua-github-4f266285f998d0d14c4e83cc29772f0de1a7fbba.tar.gz | |
Lua 5.1-rc15.1-rc1
Diffstat (limited to 'src/loslib.c')
| -rw-r--r-- | src/loslib.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/src/loslib.c b/src/loslib.c index 01458b90..235377e4 100644 --- a/src/loslib.c +++ b/src/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.14 2005/10/21 13:47:42 roberto Exp $ +** $Id: loslib.c,v 1.16 2005/12/22 16:19:56 roberto Exp $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -37,26 +37,26 @@ static int os_pushresult (lua_State *L, int i, const char *filename) { } -static int io_execute (lua_State *L) { +static int os_execute (lua_State *L) { lua_pushinteger(L, system(luaL_optstring(L, 1, NULL))); return 1; } -static int io_remove (lua_State *L) { +static int os_remove (lua_State *L) { const char *filename = luaL_checkstring(L, 1); return os_pushresult(L, remove(filename) == 0, filename); } -static int io_rename (lua_State *L) { +static int os_rename (lua_State *L) { const char *fromname = luaL_checkstring(L, 1); const char *toname = luaL_checkstring(L, 2); return os_pushresult(L, rename(fromname, toname) == 0, fromname); } -static int io_tmpname (lua_State *L) { +static int os_tmpname (lua_State *L) { char buff[LUA_TMPNAMBUFSIZE]; int err; lua_tmpnam(buff, err); @@ -67,13 +67,13 @@ static int io_tmpname (lua_State *L) { } -static int io_getenv (lua_State *L) { +static int os_getenv (lua_State *L) { lua_pushstring(L, getenv(luaL_checkstring(L, 1))); /* if NULL push nil */ return 1; } -static int io_clock (lua_State *L) { +static int os_clock (lua_State *L) { lua_pushnumber(L, ((lua_Number)clock())/(lua_Number)CLOCKS_PER_SEC); return 1; } @@ -123,7 +123,7 @@ static int getfield (lua_State *L, const char *key, int d) { } -static int io_date (lua_State *L) { +static int os_date (lua_State *L) { const char *s = luaL_optstring(L, 1, "%c"); time_t t = lua_isnoneornil(L, 2) ? time(NULL) : (time_t)luaL_checknumber(L, 2); @@ -159,7 +159,7 @@ static int io_date (lua_State *L) { } -static int io_time (lua_State *L) { +static int os_time (lua_State *L) { time_t t; if (lua_isnoneornil(L, 1)) /* called without args? */ t = time(NULL); /* get current time */ @@ -179,12 +179,12 @@ static int io_time (lua_State *L) { if (t == (time_t)(-1)) lua_pushnil(L); else - lua_pushnumber(L, t); + lua_pushnumber(L, (lua_Number)t); return 1; } -static int io_difftime (lua_State *L) { +static int os_difftime (lua_State *L) { lua_pushnumber(L, difftime((time_t)(luaL_checknumber(L, 1)), (time_t)(luaL_optnumber(L, 2, 0)))); return 1; @@ -193,7 +193,7 @@ static int io_difftime (lua_State *L) { /* }====================================================== */ -static int io_setloc (lua_State *L) { +static int os_setlocale (lua_State *L) { static const int cat[] = {LC_ALL, LC_COLLATE, LC_CTYPE, LC_MONETARY, LC_NUMERIC, LC_TIME}; static const char *const catnames[] = {"all", "collate", "ctype", "monetary", @@ -206,23 +206,23 @@ static int io_setloc (lua_State *L) { } -static int io_exit (lua_State *L) { +static int os_exit (lua_State *L) { exit(luaL_optint(L, 1, EXIT_SUCCESS)); return 0; /* to avoid warnings */ } static const luaL_Reg syslib[] = { - {"clock", io_clock}, - {"date", io_date}, - {"difftime", io_difftime}, - {"execute", io_execute}, - {"exit", io_exit}, - {"getenv", io_getenv}, - {"remove", io_remove}, - {"rename", io_rename}, - {"setlocale", io_setloc}, - {"time", io_time}, - {"tmpname", io_tmpname}, + {"clock", os_clock}, + {"date", os_date}, + {"difftime", os_difftime}, + {"execute", os_execute}, + {"exit", os_exit}, + {"getenv", os_getenv}, + {"remove", os_remove}, + {"rename", os_rename}, + {"setlocale", os_setlocale}, + {"time", os_time}, + {"tmpname", os_tmpname}, {NULL, NULL} }; |
