diff options
| author | ruki <[email protected]> | 2025-11-10 06:35:04 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-10 06:35:04 +0800 |
| commit | 2b01e46fcf619aaecb8435b0fac975e3aff0587f (patch) | |
| tree | 8f005a8dfc3272e9f027560e5e1b5881a7a8bc70 /core/src/xmake/path | |
| parent | a1b0ec856e2c22aac84022feb05b6687912e3d6e (diff) | |
| parent | 2c387895657ae13cd717d7f42f5baed5eb028a8e (diff) | |
Merge pull request #7008 from xmake-io/format
format code
Diffstat (limited to 'core/src/xmake/path')
| -rw-r--r-- | core/src/xmake/path/absolute.c | 12 | ||||
| -rw-r--r-- | core/src/xmake/path/directory.c | 21 | ||||
| -rw-r--r-- | core/src/xmake/path/is_absolute.c | 10 | ||||
| -rw-r--r-- | core/src/xmake/path/prefix.h | 3 | ||||
| -rw-r--r-- | core/src/xmake/path/relative.c | 12 | ||||
| -rw-r--r-- | core/src/xmake/path/translate.c | 23 |
6 files changed, 37 insertions, 44 deletions
diff --git a/core/src/xmake/path/absolute.c b/core/src/xmake/path/absolute.c index a780cdce8..9b05bc07d 100644 --- a/core/src/xmake/path/absolute.c +++ b/core/src/xmake/path/absolute.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "absolute" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "absolute" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,17 +33,15 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_path_absolute(lua_State* lua) -{ - // check +tb_int_t xm_path_absolute(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // get the path - tb_char_t const* path = luaL_checkstring(lua, 1); + tb_char_t const *path = luaL_checkstring(lua, 1); tb_check_return_val(path, 0); // get the root - tb_char_t const* root = luaL_optstring(lua, 2, tb_null); + tb_char_t const *root = luaL_optstring(lua, 2, tb_null); // do path:absolute(root) tb_char_t data[TB_PATH_MAXN]; diff --git a/core/src/xmake/path/directory.c b/core/src/xmake/path/directory.c index 2af805d45..7a6b37863 100644 --- a/core/src/xmake/path/directory.c +++ b/core/src/xmake/path/directory.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "directory" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "directory" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,19 +33,20 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_path_directory(lua_State* lua) -{ - // check +tb_int_t xm_path_directory(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // get the path - tb_char_t const* path = luaL_checkstring(lua, 1); + tb_char_t const *path = luaL_checkstring(lua, 1); tb_check_return_val(path, 0); // do path:directory() - tb_char_t data[TB_PATH_MAXN]; - tb_char_t const* dir = tb_path_directory(path, data, sizeof(data)); - if (dir) lua_pushstring(lua, dir); - else lua_pushnil(lua); + tb_char_t data[TB_PATH_MAXN]; + tb_char_t const *dir = tb_path_directory(path, data, sizeof(data)); + if (dir) { + lua_pushstring(lua, dir); + } else { + lua_pushnil(lua); + } return 1; } diff --git a/core/src/xmake/path/is_absolute.c b/core/src/xmake/path/is_absolute.c index 7ced8d3fe..7ac489e26 100644 --- a/core/src/xmake/path/is_absolute.c +++ b/core/src/xmake/path/is_absolute.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "is_absolute" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "is_absolute" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,13 +33,11 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_path_is_absolute(lua_State* lua) -{ - // check +tb_int_t xm_path_is_absolute(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // get the path - tb_char_t const* path = luaL_checkstring(lua, 1); + tb_char_t const *path = luaL_checkstring(lua, 1); tb_check_return_val(path, 0); // path:is_absolute() diff --git a/core/src/xmake/path/prefix.h b/core/src/xmake/path/prefix.h index 3fe86b204..c87dc37bf 100644 --- a/core/src/xmake/path/prefix.h +++ b/core/src/xmake/path/prefix.h @@ -26,7 +26,4 @@ */ #include "../prefix.h" - #endif - - diff --git a/core/src/xmake/path/relative.c b/core/src/xmake/path/relative.c index ec1dcc215..5d3beaaa5 100644 --- a/core/src/xmake/path/relative.c +++ b/core/src/xmake/path/relative.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "relative" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "relative" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,17 +33,15 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_path_relative(lua_State* lua) -{ - // check +tb_int_t xm_path_relative(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // get the path - tb_char_t const* path = luaL_checkstring(lua, 1); + tb_char_t const *path = luaL_checkstring(lua, 1); tb_check_return_val(path, 0); // get the root - tb_char_t const* root = luaL_optstring(lua, 2, tb_null); + tb_char_t const *root = luaL_optstring(lua, 2, tb_null); // path:relative(root) tb_char_t data[TB_PATH_MAXN]; diff --git a/core/src/xmake/path/translate.c b/core/src/xmake/path/translate.c index ecb545098..8d1debda0 100644 --- a/core/src/xmake/path/translate.c +++ b/core/src/xmake/path/translate.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "translate" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "translate" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,31 +33,32 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_path_translate(lua_State* lua) -{ - // check +tb_int_t xm_path_translate(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // get the path size_t path_size = 0; - tb_char_t const* path = luaL_checklstring(lua, 1, &path_size); + tb_char_t const *path = luaL_checklstring(lua, 1, &path_size); tb_check_return_val(path, 0); // get the option argument, e.g. {normalize = true} tb_bool_t normalize = tb_false; - if (lua_istable(lua, 2)) - { + if (lua_istable(lua, 2)) { lua_pushstring(lua, "normalize"); lua_gettable(lua, 2); - if (lua_toboolean(lua, -1)) + if (lua_toboolean(lua, -1)) { normalize = tb_true; + } lua_pop(lua, 1); } // do path:translate() tb_char_t data[TB_PATH_MAXN]; tb_size_t size = tb_path_translate_to(path, (tb_size_t)path_size, data, sizeof(data), normalize); - if (size) lua_pushlstring(lua, data, (size_t)size); - else lua_pushnil(lua); + if (size) { + lua_pushlstring(lua, data, (size_t)size); + } else { + lua_pushnil(lua); + } return 1; } |
