summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2017-05-23 10:50:50 +0800
committerruki <[email protected]>2017-05-23 10:55:06 +0800
commit5e5897bfb063f13282dabf6ecea7a1c3000664e4 (patch)
tree1870c36844d68a6990d642071cfb71aaa64e65f3 /core/src
parentffa57872e4e1df66db1df8174ffcde4ff0dcd296 (diff)
modify some code styles
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/os/getown.c6
-rw-r--r--core/src/xmake/os/gid.c22
-rw-r--r--core/src/xmake/os/uid.c22
3 files changed, 33 insertions, 17 deletions
diff --git a/core/src/xmake/os/getown.c b/core/src/xmake/os/getown.c
index aa4e2de66..9a3889a1a 100644
--- a/core/src/xmake/os/getown.c
+++ b/core/src/xmake/os/getown.c
@@ -36,10 +36,14 @@
#ifndef TB_CONFIG_OS_WINDOWS
# include <unistd.h>
# include <sys/stat.h>
+#endif
/* //////////////////////////////////////////////////////////////////////////////////////
* implementation
*/
+
+#ifndef TB_CONFIG_OS_WINDOWS
+
// get owner by a given path
tb_int_t xm_os_getown(lua_State* lua)
{
@@ -52,7 +56,7 @@ tb_int_t xm_os_getown(lua_State* lua)
// get stat
struct stat sts;
- if(stat(pathname, &sts) != 0)
+ if (stat(pathname, &sts) != 0)
return 0;
// push
diff --git a/core/src/xmake/os/gid.c b/core/src/xmake/os/gid.c
index 7d949ebc6..603aad8b1 100644
--- a/core/src/xmake/os/gid.c
+++ b/core/src/xmake/os/gid.c
@@ -36,10 +36,12 @@
#ifndef TB_CONFIG_OS_WINDOWS
# include <unistd.h>
# include <errno.h>
+#endif
/* //////////////////////////////////////////////////////////////////////////////////////
* implementation
*/
+#ifndef TB_CONFIG_OS_WINDOWS
// get & set gid
tb_int_t xm_os_gid(lua_State* lua)
@@ -47,10 +49,9 @@ tb_int_t xm_os_gid(lua_State* lua)
// check
tb_assert_and_check_return_val(lua, 0);
- tb_int_t rgidset = -1, egidset = -1;
-
+ tb_int_t rgidset = -1;
+ tb_int_t egidset = -1;
tb_int_t argc = lua_gettop(lua);
-
if (argc == 1)
{
if (lua_istable(lua, 1))
@@ -80,17 +81,20 @@ tb_int_t xm_os_gid(lua_State* lua)
rgidset = (tb_int_t)lua_tonumber(lua, -1);
}
lua_pop(lua, 1);
- } else if (lua_isnumber(lua, 1))
+ }
+ else if (lua_isnumber(lua, 1))
{
// os.gid(gid)
rgidset = egidset = (tb_int_t)lua_tonumber(lua, 1);
- } else
+ }
+ else
{
lua_pushfstring(lua, "invalid argument type(%s) for os.gid", luaL_typename(lua, 1));
lua_error(lua);
return 0;
}
- } else if (argc == 2)
+ }
+ else if (argc == 2)
{
// os.gid(rgid, egid)
if (!lua_isnil(lua, 1))
@@ -113,7 +117,8 @@ tb_int_t xm_os_gid(lua_State* lua)
}
egidset = (tb_int_t)lua_tonumber(lua, 2);
}
- } else if (argc != 0)
+ }
+ else if (argc != 0)
{
lua_pushstring(lua, "invalid argument count for os.gid");
lua_error(lua);
@@ -132,7 +137,8 @@ tb_int_t xm_os_gid(lua_State* lua)
}
// get gid & egid
- gid_t gid = getgid(), egid = getegid();
+ gid_t gid = getgid();
+ gid_t egid = getegid();
// push
lua_pushstring(lua, "rgid");
diff --git a/core/src/xmake/os/uid.c b/core/src/xmake/os/uid.c
index 4bcc9d122..0c5c583c3 100644
--- a/core/src/xmake/os/uid.c
+++ b/core/src/xmake/os/uid.c
@@ -36,10 +36,12 @@
#ifndef TB_CONFIG_OS_WINDOWS
# include <unistd.h>
# include <errno.h>
+#endif
/* //////////////////////////////////////////////////////////////////////////////////////
* implementation
*/
+#ifndef TB_CONFIG_OS_WINDOWS
// get & set uid
tb_int_t xm_os_uid(lua_State* lua)
@@ -47,10 +49,9 @@ tb_int_t xm_os_uid(lua_State* lua)
// check
tb_assert_and_check_return_val(lua, 0);
- tb_int_t ruidset = -1, euidset = -1;
-
+ tb_int_t ruidset = -1;
+ tb_int_t euidset = -1;
tb_int_t argc = lua_gettop(lua);
-
if (argc == 1)
{
if (lua_istable(lua, 1))
@@ -80,17 +81,20 @@ tb_int_t xm_os_uid(lua_State* lua)
ruidset = (tb_int_t)lua_tonumber(lua, -1);
}
lua_pop(lua, 1);
- } else if (lua_isnumber(lua, 1))
+ }
+ else if (lua_isnumber(lua, 1))
{
// os.uid(uid)
ruidset = euidset = (tb_int_t)lua_tonumber(lua, 1);
- } else
+ }
+ else
{
lua_pushfstring(lua, "invalid argument type(%s) for os.uid", luaL_typename(lua, 1));
lua_error(lua);
return 0;
}
- } else if (argc == 2)
+ }
+ else if (argc == 2)
{
// os.uid(ruid, euid)
if (!lua_isnil(lua, 1))
@@ -113,7 +117,8 @@ tb_int_t xm_os_uid(lua_State* lua)
}
euidset = (tb_int_t)lua_tonumber(lua, 2);
}
- } else if (argc != 0)
+ }
+ else if (argc != 0)
{
lua_pushstring(lua, "invalid argument count for os.uid");
lua_error(lua);
@@ -132,7 +137,8 @@ tb_int_t xm_os_uid(lua_State* lua)
}
// get uid & euid
- uid_t uid = getuid(), euid = geteuid();
+ uid_t uid = getuid();
+ uid_t euid = geteuid();
// push
lua_pushstring(lua, "ruid");