changing {} style to match majority of previous style
This commit is contained in:
@@ -77,8 +77,7 @@
|
||||
|
||||
|
||||
|
||||
static int os_execute(lua_State *L)
|
||||
{
|
||||
static int os_execute(lua_State *L) {
|
||||
const char *cmd = luaL_optstring(L, 1, NULL);
|
||||
int stat = system(cmd);
|
||||
if (cmd != NULL)
|
||||
@@ -90,23 +89,20 @@ static int os_execute(lua_State *L)
|
||||
}
|
||||
|
||||
|
||||
static int os_remove(lua_State *L)
|
||||
{
|
||||
static int os_remove(lua_State *L) {
|
||||
const char *filename = luaL_checkstring(L, 1);
|
||||
return luaL_fileresult(L, remove(filename) == 0, filename);
|
||||
}
|
||||
|
||||
|
||||
static int os_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 luaL_fileresult(L, rename(fromname, toname) == 0, NULL);
|
||||
}
|
||||
|
||||
|
||||
static int os_tmpname(lua_State *L)
|
||||
{
|
||||
static int os_tmpname(lua_State *L) {
|
||||
char buff[LUA_TMPNAMBUFSIZE];
|
||||
int err;
|
||||
lua_tmpnam(buff, err);
|
||||
@@ -117,15 +113,13 @@ static int os_tmpname(lua_State *L)
|
||||
}
|
||||
|
||||
|
||||
static int os_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 os_clock(lua_State *L)
|
||||
{
|
||||
static int os_clock(lua_State *L) {
|
||||
lua_pushnumber(L, ((lua_Number)clock()) / (lua_Number)CLOCKS_PER_SEC);
|
||||
return 1;
|
||||
}
|
||||
@@ -139,22 +133,19 @@ static int os_clock(lua_State *L)
|
||||
** =======================================================
|
||||
*/
|
||||
|
||||
static void setfield(lua_State *L, const char *key, int value)
|
||||
{
|
||||
static void setfield(lua_State *L, const char *key, int value) {
|
||||
lua_pushinteger(L, value);
|
||||
lua_setfield(L, -2, key);
|
||||
}
|
||||
|
||||
static void setboolfield(lua_State *L, const char *key, int value)
|
||||
{
|
||||
static void setboolfield(lua_State *L, const char *key, int value) {
|
||||
if (value < 0) /* undefined? */
|
||||
return; /* does not set field */
|
||||
lua_pushboolean(L, value);
|
||||
lua_setfield(L, -2, key);
|
||||
}
|
||||
|
||||
static int getboolfield(lua_State *L, const char *key)
|
||||
{
|
||||
static int getboolfield(lua_State *L, const char *key) {
|
||||
int res;
|
||||
lua_getfield(L, -1, key);
|
||||
res = lua_isnil(L, -1) ? -1 : lua_toboolean(L, -1);
|
||||
@@ -163,8 +154,7 @@ static int getboolfield(lua_State *L, const char *key)
|
||||
}
|
||||
|
||||
|
||||
static int getfield(lua_State *L, const char *key, int d)
|
||||
{
|
||||
static int getfield(lua_State *L, const char *key, int d) {
|
||||
int res, isnum;
|
||||
lua_getfield(L, -1, key);
|
||||
res = (int)lua_tointegerx(L, -1, &isnum);
|
||||
@@ -178,8 +168,7 @@ static int getfield(lua_State *L, const char *key, int d)
|
||||
}
|
||||
|
||||
|
||||
static const char *checkoption(lua_State *L, const char *conv, char *buff)
|
||||
{
|
||||
static const char *checkoption(lua_State *L, const char *conv, char *buff) {
|
||||
static const char *const options[] = LUA_STRFTIMEOPTIONS;
|
||||
unsigned int i;
|
||||
for (i = 0; i < sizeof(options) / sizeof(options[0]); i += 2) {
|
||||
@@ -202,8 +191,7 @@ static const char *checkoption(lua_State *L, const char *conv, char *buff)
|
||||
}
|
||||
|
||||
|
||||
static int os_date(lua_State *L)
|
||||
{
|
||||
static int os_date(lua_State *L) {
|
||||
const char *s = luaL_optstring(L, 1, "%c");
|
||||
time_t t = luaL_opt(L, (time_t)luaL_checknumber, 2, time(NULL));
|
||||
struct tm tmr, *stm;
|
||||
@@ -247,8 +235,7 @@ static int os_date(lua_State *L)
|
||||
}
|
||||
|
||||
|
||||
static int os_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 */
|
||||
@@ -273,8 +260,7 @@ static int os_time(lua_State *L)
|
||||
}
|
||||
|
||||
|
||||
static int os_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;
|
||||
@@ -283,8 +269,7 @@ static int os_difftime(lua_State *L)
|
||||
/* }====================================================== */
|
||||
|
||||
|
||||
static int os_setlocale(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
|
||||
};
|
||||
@@ -298,8 +283,7 @@ static int os_setlocale(lua_State *L)
|
||||
}
|
||||
|
||||
|
||||
static int os_exit(lua_State *L)
|
||||
{
|
||||
static int os_exit(lua_State *L) {
|
||||
int status;
|
||||
if (lua_isboolean(L, 1))
|
||||
status = (lua_toboolean(L, 1) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||
@@ -331,8 +315,7 @@ static const luaL_Reg syslib[] = {
|
||||
|
||||
|
||||
|
||||
LUAMOD_API int luaopen_os(lua_State *L)
|
||||
{
|
||||
LUAMOD_API int luaopen_os(lua_State *L) {
|
||||
luaL_newlib(L, syslib);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user