From c89c94bf89e98c8e42e786aacc0b334a57474179 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 9 Nov 2025 19:11:32 +0800 Subject: format code --- core/src/xmake/string/convert.c | 94 +++++++++++++++++++------------------- core/src/xmake/string/endswith.c | 15 +++--- core/src/xmake/string/lastof.c | 48 +++++++++---------- core/src/xmake/string/prefix.h | 3 -- core/src/xmake/string/split.c | 76 +++++++++++++++--------------- core/src/xmake/string/startswith.c | 13 +++--- core/src/xmake/string/trim.c | 55 +++++++++++----------- 7 files changed, 150 insertions(+), 154 deletions(-) (limited to 'core/src/xmake/string') diff --git a/core/src/xmake/string/convert.c b/core/src/xmake/string/convert.c index 0001b7f9c..65750d95e 100644 --- a/core/src/xmake/string/convert.c +++ b/core/src/xmake/string/convert.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "convert" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "convert" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -35,54 +35,51 @@ */ // the charset entry type -typedef struct __xm_charset_entry_t -{ +typedef struct __xm_charset_entry_t { // the charset type - tb_size_t type; + tb_size_t type; // the charset name - tb_char_t const* name; - -}xm_charset_entry_t, *xm_charset_entry_ref_t; + tb_char_t const *name; +} xm_charset_entry_t, *xm_charset_entry_ref_t; // the charsets, @note: type & name is sorted -static xm_charset_entry_t g_charsets[] = -{ - {TB_CHARSET_TYPE_ANSI, "ansi" } -, {TB_CHARSET_TYPE_ASCII, "ascii" } -, {TB_CHARSET_TYPE_GB2312, "gb2312" } -, {TB_CHARSET_TYPE_GBK, "gbk" } -, {TB_CHARSET_TYPE_ISO8859, "iso8859" } -, {TB_CHARSET_TYPE_UCS2 | TB_CHARSET_TYPE_NE, "ucs2" } -, {TB_CHARSET_TYPE_UCS4 | TB_CHARSET_TYPE_NE, "ucs4" } -, {TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_NE, "utf16" } -, {TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_BE, "utf16be" } -, {TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_LE, "utf16le" } -, {TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_NE, "utf32" } -, {TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_BE, "utf32be" } -, {TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_LE, "utf32le" } -, {TB_CHARSET_TYPE_UTF8, "utf8" } +static xm_charset_entry_t g_charsets[] = { + { TB_CHARSET_TYPE_ANSI, "ansi" }, + { TB_CHARSET_TYPE_ASCII, "ascii" }, + { TB_CHARSET_TYPE_GB2312, "gb2312" }, + { TB_CHARSET_TYPE_GBK, "gbk" }, + { TB_CHARSET_TYPE_ISO8859, "iso8859" }, + { TB_CHARSET_TYPE_UCS2 | TB_CHARSET_TYPE_NE, "ucs2" }, + { TB_CHARSET_TYPE_UCS4 | TB_CHARSET_TYPE_NE, "ucs4" }, + { TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_NE, "utf16" }, + { TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_BE, "utf16be" }, + { TB_CHARSET_TYPE_UTF16 | TB_CHARSET_TYPE_LE, "utf16le" }, + { TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_NE, "utf32" }, + { TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_BE, "utf32be" }, + { TB_CHARSET_TYPE_UTF32 | TB_CHARSET_TYPE_LE, "utf32le" }, + { TB_CHARSET_TYPE_UTF8, "utf8" }, }; /* ////////////////////////////////////////////////////////////////////////////////////// * finder */ -static tb_long_t xm_string_charset_comp_by_name(tb_iterator_ref_t iterator, tb_cpointer_t item, tb_cpointer_t name) -{ - return tb_stricmp(((xm_charset_entry_ref_t)item)->name, (tb_char_t const*)name); +static tb_long_t xm_string_charset_comp_by_name(tb_iterator_ref_t iterator, tb_cpointer_t item, tb_cpointer_t name) { + return tb_stricmp(((xm_charset_entry_ref_t)item)->name, (tb_char_t const *)name); } -static xm_charset_entry_ref_t xm_string_charset_find_by_name(tb_char_t const* name) -{ +static xm_charset_entry_ref_t xm_string_charset_find_by_name(tb_char_t const *name) { // make iterator tb_array_iterator_t array_iterator; - tb_iterator_ref_t iterator = tb_array_iterator_init_mem(&array_iterator, g_charsets, tb_arrayn(g_charsets), sizeof(xm_charset_entry_t)); + tb_iterator_ref_t iterator = + tb_array_iterator_init_mem(&array_iterator, g_charsets, tb_arrayn(g_charsets), sizeof(xm_charset_entry_t)); tb_assert_and_check_return_val(iterator, tb_null); // find it by the binary search tb_size_t itor = tb_binary_find_all_if(iterator, xm_string_charset_comp_by_name, name); if (itor != tb_iterator_tail(iterator)) return (xm_charset_entry_ref_t)tb_iterator_item(iterator, itor); - else return tb_null; + else + return tb_null; } /* ////////////////////////////////////////////////////////////////////////////////////// @@ -100,16 +97,15 @@ static xm_charset_entry_ref_t xm_string_charset_find_by_name(tb_char_t const* na * local result = string.convert(str, "utf8", "gb2312") * @endcode */ -tb_int_t xm_string_convert(lua_State* lua) -{ +tb_int_t xm_string_convert(lua_State *lua) { // check tb_assert_and_check_return_val(lua, 0); // get the string and charset types size_t src_size = 0; - tb_char_t const* src_cstr = luaL_checklstring(lua, 1, &src_size); - tb_char_t const* ftype_cstr = luaL_checkstring(lua, 2); - tb_char_t const* ttype_cstr = luaL_checkstring(lua, 3); + tb_char_t const *src_cstr = luaL_checklstring(lua, 1, &src_size); + tb_char_t const *ftype_cstr = luaL_checkstring(lua, 2); + tb_char_t const *ttype_cstr = luaL_checkstring(lua, 3); tb_check_return_val(src_cstr && ftype_cstr && ttype_cstr, 0); // find charsets @@ -120,18 +116,24 @@ tb_int_t xm_string_convert(lua_State* lua) tb_check_return_val(fcharset && tcharset, 0); // empty string? - if (!src_size) lua_pushstring(lua, ""); - else - { + if (!src_size) + lua_pushstring(lua, ""); + else { // convert string - tb_long_t dst_size = 0; - tb_size_t dst_maxn = (tb_size_t)src_size << 2; - tb_byte_t* dst_data = tb_malloc_bytes(dst_maxn); - if (dst_data && dst_maxn && (dst_size = tb_charset_conv_data(fcharset->type, tcharset->type, (tb_byte_t const*)src_cstr, (tb_size_t)src_size, dst_data, dst_maxn)) >= 0 && dst_size < dst_maxn) - { + tb_long_t dst_size = 0; + tb_size_t dst_maxn = (tb_size_t)src_size << 2; + tb_byte_t *dst_data = tb_malloc_bytes(dst_maxn); + if (dst_data && dst_maxn && + (dst_size = tb_charset_conv_data(fcharset->type, + tcharset->type, + (tb_byte_t const *)src_cstr, + (tb_size_t)src_size, + dst_data, + dst_maxn)) >= 0 && + dst_size < dst_maxn) { lua_pushlstring(lua, (tb_char_t const *)dst_data, dst_size); - } - else lua_pushnil(lua); + } else + lua_pushnil(lua); tb_free(dst_data); } diff --git a/core/src/xmake/string/endswith.c b/core/src/xmake/string/endswith.c index e6bb8b9c4..5905610f6 100644 --- a/core/src/xmake/string/endswith.c +++ b/core/src/xmake/string/endswith.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "endswith" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "endswith" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,16 +33,15 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_string_endswith(lua_State* lua) -{ +tb_int_t xm_string_endswith(lua_State *lua) { // check tb_assert_and_check_return_val(lua, 0); // get the string and suffix - size_t string_size = 0; - size_t suffix_size = 0; - tb_char_t const* string = luaL_checklstring(lua, 1, &string_size); - tb_char_t const* suffix = luaL_checklstring(lua, 2, &suffix_size); + size_t string_size = 0; + size_t suffix_size = 0; + tb_char_t const *string = luaL_checklstring(lua, 1, &string_size); + tb_char_t const *suffix = luaL_checklstring(lua, 2, &suffix_size); tb_check_return_val(string && suffix, 0); // string:endswith(suffix)? diff --git a/core/src/xmake/string/lastof.c b/core/src/xmake/string/lastof.c index 8e6f42300..c9df2213d 100644 --- a/core/src/xmake/string/lastof.c +++ b/core/src/xmake/string/lastof.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "string_lastof" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "string_lastof" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,16 +33,14 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * private implementation */ -static tb_void_t xm_string_lastof_str(lua_State* lua, tb_char_t const* cstr, tb_size_t nstr, tb_char_t const* csubstr, tb_size_t nsubstr) -{ +static tb_void_t xm_string_lastof_str( + lua_State *lua, tb_char_t const *cstr, tb_size_t nstr, tb_char_t const *csubstr, tb_size_t nsubstr) { // find it - tb_char_t const* curr = tb_null; - tb_char_t const* next = cstr; - do - { + tb_char_t const *curr = tb_null; + tb_char_t const *next = cstr; + do { next = tb_strstr(next, csubstr); // faster than tb_strnstr() - if (next) - { + if (next) { curr = next; next += nsubstr; } @@ -50,14 +48,17 @@ static tb_void_t xm_string_lastof_str(lua_State* lua, tb_char_t const* cstr, tb_ } while (!next); // found? - if (curr) lua_pushinteger(lua, curr - cstr + 1); - else lua_pushnil(lua); + if (curr) + lua_pushinteger(lua, curr - cstr + 1); + else + lua_pushnil(lua); } -static tb_void_t xm_string_lastof_chr(lua_State* lua, tb_char_t const* cstr, tb_size_t nstr, tb_char_t ch) -{ - tb_char_t const* pos = tb_strrchr(cstr, ch); // faster than tb_strnrchr() - if (pos) lua_pushinteger(lua, pos - cstr + 1); - else lua_pushnil(lua); +static tb_void_t xm_string_lastof_chr(lua_State *lua, tb_char_t const *cstr, tb_size_t nstr, tb_char_t ch) { + tb_char_t const *pos = tb_strrchr(cstr, ch); // faster than tb_strnrchr() + if (pos) + lua_pushinteger(lua, pos - cstr + 1); + else + lua_pushnil(lua); } /* ////////////////////////////////////////////////////////////////////////////////////// @@ -69,22 +70,23 @@ static tb_void_t xm_string_lastof_chr(lua_State* lua, tb_char_t const* cstr, tb_ * @param str the string * @param substr the substring */ -tb_int_t xm_string_lastof(lua_State* lua) -{ +tb_int_t xm_string_lastof(lua_State *lua) { // check tb_assert_and_check_return_val(lua, 0); // get string size_t nstr = 0; - tb_char_t const* cstr = luaL_checklstring(lua, 1, &nstr); + tb_char_t const *cstr = luaL_checklstring(lua, 1, &nstr); // get substring size_t nsubstr = 0; - tb_char_t const* csubstr = luaL_checklstring(lua, 2, &nsubstr); + tb_char_t const *csubstr = luaL_checklstring(lua, 2, &nsubstr); // lastof it lua_newtable(lua); - if (nsubstr == 1) xm_string_lastof_chr(lua, cstr, (tb_size_t)nstr, csubstr[0]); - else xm_string_lastof_str(lua, cstr, (tb_size_t)nstr, csubstr, nsubstr); + if (nsubstr == 1) + xm_string_lastof_chr(lua, cstr, (tb_size_t)nstr, csubstr[0]); + else + xm_string_lastof_str(lua, cstr, (tb_size_t)nstr, csubstr, nsubstr); return 1; } diff --git a/core/src/xmake/string/prefix.h b/core/src/xmake/string/prefix.h index 8f9e53d94..890fc368c 100644 --- a/core/src/xmake/string/prefix.h +++ b/core/src/xmake/string/prefix.h @@ -26,7 +26,4 @@ */ #include "../prefix.h" - #endif - - diff --git a/core/src/xmake/string/split.c b/core/src/xmake/string/split.c index c035a5fab..be2904f99 100644 --- a/core/src/xmake/string/split.c +++ b/core/src/xmake/string/split.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "string_split" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "string_split" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,15 +33,18 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * private implementation */ -static tb_void_t xm_string_split_str(lua_State* lua, tb_char_t const* cstr, tb_size_t nstr, tb_char_t const* cdls, tb_size_t ndls, tb_bool_t strict, tb_int_t limit) -{ - tb_int_t num = 0; - tb_char_t const* end = cstr + nstr; - tb_char_t const* pos = tb_strstr(cstr, cdls); // faster than tb_strnstr() - while (pos && pos < end) - { - if (pos > cstr || strict) - { +static tb_void_t xm_string_split_str(lua_State *lua, + tb_char_t const *cstr, + tb_size_t nstr, + tb_char_t const *cdls, + tb_size_t ndls, + tb_bool_t strict, + tb_int_t limit) { + tb_int_t num = 0; + tb_char_t const *end = cstr + nstr; + tb_char_t const *pos = tb_strstr(cstr, cdls); // faster than tb_strnstr() + while (pos && pos < end) { + if (pos > cstr || strict) { if (limit > 0 && num + 1 >= limit) break; @@ -50,28 +53,23 @@ static tb_void_t xm_string_split_str(lua_State* lua, tb_char_t const* cstr, tb_s } cstr = pos + ndls; - pos = tb_strstr(cstr, cdls); + pos = tb_strstr(cstr, cdls); } - if (cstr < end) - { + if (cstr < end) { lua_pushlstring(lua, cstr, end - cstr); lua_rawseti(lua, -2, ++num); - } - else if (strict && (limit < 0 || num < limit) && cstr == end) - { + } else if (strict && (limit < 0 || num < limit) && cstr == end) { lua_pushliteral(lua, ""); lua_rawseti(lua, -2, ++num); } } -static tb_void_t xm_string_split_chr(lua_State* lua, tb_char_t const* cstr, tb_size_t nstr, tb_char_t ch, tb_bool_t strict, tb_int_t limit) -{ - tb_int_t num = 0; - tb_char_t const* end = cstr + nstr; - tb_char_t const* pos = tb_strchr(cstr, ch); // faster than tb_strnchr() - while (pos && pos < end) - { - if (pos > cstr || strict) - { +static tb_void_t xm_string_split_chr( + lua_State *lua, tb_char_t const *cstr, tb_size_t nstr, tb_char_t ch, tb_bool_t strict, tb_int_t limit) { + tb_int_t num = 0; + tb_char_t const *end = cstr + nstr; + tb_char_t const *pos = tb_strchr(cstr, ch); // faster than tb_strnchr() + while (pos && pos < end) { + if (pos > cstr || strict) { if (limit > 0 && num + 1 >= limit) break; @@ -80,15 +78,12 @@ static tb_void_t xm_string_split_chr(lua_State* lua, tb_char_t const* cstr, tb_s } cstr = pos + 1; - pos = tb_strchr(cstr, ch); + pos = tb_strchr(cstr, ch); } - if (cstr < end) - { + if (cstr < end) { lua_pushlstring(lua, cstr, end - cstr); lua_rawseti(lua, -2, ++num); - } - else if (strict && (limit < 0 || num < limit) && cstr == end) - { + } else if (strict && (limit < 0 || num < limit) && cstr == end) { lua_pushliteral(lua, ""); lua_rawseti(lua, -2, ++num); } @@ -105,28 +100,29 @@ static tb_void_t xm_string_split_chr(lua_State* lua, tb_char_t const* cstr, tb_s * @param strict is strict? * @param limit the limit count */ -tb_int_t xm_string_split(lua_State* lua) -{ +tb_int_t xm_string_split(lua_State *lua) { // check tb_assert_and_check_return_val(lua, 0); // get string size_t nstr = 0; - tb_char_t const* cstr = luaL_checklstring(lua, 1, &nstr); + tb_char_t const *cstr = luaL_checklstring(lua, 1, &nstr); // get delimiter size_t ndls = 0; - tb_char_t const* cdls = luaL_checklstring(lua, 2, &ndls); + tb_char_t const *cdls = luaL_checklstring(lua, 2, &ndls); // is strict? - tb_bool_t const strict = (tb_bool_t)lua_toboolean(lua, 3); + tb_bool_t const strict = (tb_bool_t)lua_toboolean(lua, 3); // get limit count - tb_int_t const limit = (tb_int_t)luaL_optinteger(lua, 4, -1); + tb_int_t const limit = (tb_int_t)luaL_optinteger(lua, 4, -1); // split it lua_newtable(lua); - if (ndls == 1) xm_string_split_chr(lua, cstr, (tb_size_t)nstr, cdls[0], strict, limit); - else xm_string_split_str(lua, cstr, (tb_size_t)nstr, cdls, ndls, strict, limit); + if (ndls == 1) + xm_string_split_chr(lua, cstr, (tb_size_t)nstr, cdls[0], strict, limit); + else + xm_string_split_str(lua, cstr, (tb_size_t)nstr, cdls, ndls, strict, limit); return 1; } diff --git a/core/src/xmake/string/startswith.c b/core/src/xmake/string/startswith.c index d904de3cb..c7fe9dcca 100644 --- a/core/src/xmake/string/startswith.c +++ b/core/src/xmake/string/startswith.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "startswith" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "startswith" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,15 +33,14 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * implementation */ -tb_int_t xm_string_startswith(lua_State* lua) -{ +tb_int_t xm_string_startswith(lua_State *lua) { // check tb_assert_and_check_return_val(lua, 0); // get the string and prefix - size_t prefix_size = 0; - tb_char_t const* string = luaL_checkstring(lua, 1); - tb_char_t const* prefix = luaL_checklstring(lua, 2, &prefix_size); + size_t prefix_size = 0; + tb_char_t const *string = luaL_checkstring(lua, 1); + tb_char_t const *prefix = luaL_checklstring(lua, 2, &prefix_size); tb_check_return_val(string && prefix, 0); // string:startswith(prefix)? diff --git a/core/src/xmake/string/trim.c b/core/src/xmake/string/trim.c index 42a4b846c..d22f86666 100644 --- a/core/src/xmake/string/trim.c +++ b/core/src/xmake/string/trim.c @@ -22,8 +22,8 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * trace */ -#define TB_TRACE_MODULE_NAME "string_trim" -#define TB_TRACE_MODULE_DEBUG (0) +#define TB_TRACE_MODULE_NAME "string_trim" +#define TB_TRACE_MODULE_DEBUG (0) /* ////////////////////////////////////////////////////////////////////////////////////// * includes @@ -33,13 +33,12 @@ /* ////////////////////////////////////////////////////////////////////////////////////// * private implementation */ -static tb_void_t xm_string_trim_space(tb_char_t const** psstr, tb_char_t const** pestr, tb_int_t mode) -{ +static tb_void_t xm_string_trim_space(tb_char_t const **psstr, tb_char_t const **pestr, tb_int_t mode) { // check tb_assert(psstr && pestr && *psstr && *pestr); - tb_char_t const* p = *psstr; - tb_char_t const* e = *pestr; + tb_char_t const *p = *psstr; + tb_char_t const *e = *pestr; // trim left? if (mode <= 0) @@ -47,8 +46,7 @@ static tb_void_t xm_string_trim_space(tb_char_t const** psstr, tb_char_t const** p++; // trim right - if (mode >= 0) - { + if (mode >= 0) { e--; while (e >= p && tb_isspace(*e)) e--; @@ -60,23 +58,27 @@ static tb_void_t xm_string_trim_space(tb_char_t const** psstr, tb_char_t const** *pestr = e; } -static tb_char_t const* xm_string_ltrim(tb_char_t const* sstr, tb_char_t const* estr, tb_char_t const* ctrim, size_t ntrim) -{ +static tb_char_t const *xm_string_ltrim(tb_char_t const *sstr, + tb_char_t const *estr, + tb_char_t const *ctrim, + size_t ntrim) { // check tb_assert(sstr && estr && ctrim); - tb_char_t const* p = sstr; + tb_char_t const *p = sstr; while (p < estr && tb_strnchr(ctrim, ntrim, *p)) p++; return p; } -static tb_char_t const* xm_string_rtrim(tb_char_t const* sstr, tb_char_t const* estr, tb_char_t const* ctrim, size_t ntrim) -{ +static tb_char_t const *xm_string_rtrim(tb_char_t const *sstr, + tb_char_t const *estr, + tb_char_t const *ctrim, + size_t ntrim) { // check tb_assert(sstr && estr && ctrim); - tb_char_t const* p = estr - 1; + tb_char_t const *p = estr - 1; while (p >= sstr && tb_strnchr(ctrim, ntrim, *p)) p--; return p + 1; @@ -97,30 +99,29 @@ static tb_char_t const* xm_string_rtrim(tb_char_t const* sstr, tb_char_t const* * local result = string.trim(str, "(", -1) * @endcode */ -tb_int_t xm_string_trim(lua_State* lua) -{ +tb_int_t xm_string_trim(lua_State *lua) { // check tb_assert_and_check_return_val(lua, 0); size_t lstr, ltrim; - tb_char_t const* sstr = luaL_checklstring(lua, 1, &lstr); - tb_char_t const* estr = sstr + lstr; - tb_char_t const* trimchars = luaL_optlstring(lua, 2, "", <rim); + tb_char_t const *sstr = luaL_checklstring(lua, 1, &lstr); + tb_char_t const *estr = sstr + lstr; + tb_char_t const *trimchars = luaL_optlstring(lua, 2, "", <rim); tb_int_t const trimtype = (tb_int_t)luaL_optinteger(lua, 3, 0); - do - { + do { tb_assert_and_check_break(sstr && trimchars); tb_check_break(lstr != 0); - tb_char_t const* const rsstr = sstr; - tb_char_t const* const restr = estr; + tb_char_t const *const rsstr = sstr; + tb_char_t const *const restr = estr; if (ltrim == 0) xm_string_trim_space(&sstr, &estr, trimtype); - else - { + else { // trim chars - if (trimtype <= 0) sstr = xm_string_ltrim(sstr, estr, trimchars, ltrim); - if (trimtype >= 0) estr = xm_string_rtrim(sstr, estr, trimchars, ltrim); + if (trimtype <= 0) + sstr = xm_string_ltrim(sstr, estr, trimchars, ltrim); + if (trimtype >= 0) + estr = xm_string_rtrim(sstr, estr, trimchars, ltrim); } // no trimed chars -- cgit v1.3.1 From 39189e3a1bd2979b7b454547b03e5926a8027431 Mon Sep 17 00:00:00 2001 From: ruki Date: Sun, 9 Nov 2025 19:54:35 +0800 Subject: remove unused comments --- core/src/xmake/base64/decode.c | 1 - core/src/xmake/base64/encode.c | 1 - core/src/xmake/bloom_filter/bloom_filter_clear.c | 1 - core/src/xmake/bloom_filter/bloom_filter_close.c | 1 - core/src/xmake/bloom_filter/bloom_filter_data.c | 1 - .../src/xmake/bloom_filter/bloom_filter_data_set.c | 1 - core/src/xmake/bloom_filter/bloom_filter_get.c | 1 - core/src/xmake/bloom_filter/bloom_filter_open.c | 1 - core/src/xmake/bloom_filter/bloom_filter_set.c | 1 - core/src/xmake/bloom_filter/bloom_filter_size.c | 1 - core/src/xmake/engine.c | 24 ---------------------- core/src/xmake/fwatcher/add.c | 1 - core/src/xmake/fwatcher/close.c | 1 - core/src/xmake/fwatcher/open.c | 1 - core/src/xmake/fwatcher/remove.c | 1 - core/src/xmake/fwatcher/wait.c | 1 - core/src/xmake/hash/md5.c | 2 -- core/src/xmake/hash/rand128.c | 1 - core/src/xmake/hash/rand32.c | 1 - core/src/xmake/hash/rand64.c | 1 - core/src/xmake/hash/sha.c | 2 -- core/src/xmake/hash/uuid4.c | 1 - core/src/xmake/hash/xxhash.c | 2 -- core/src/xmake/io/file_close.c | 4 ---- core/src/xmake/io/file_flush.c | 2 -- core/src/xmake/io/file_isatty.c | 1 - core/src/xmake/io/file_open.c | 4 ---- core/src/xmake/io/file_rawfd.c | 1 - core/src/xmake/io/file_read.c | 13 ------------ core/src/xmake/io/file_readable.c | 1 - core/src/xmake/io/file_seek.c | 1 - core/src/xmake/io/file_size.c | 1 - core/src/xmake/io/file_write.c | 4 ---- core/src/xmake/io/filelock_close.c | 2 -- core/src/xmake/io/filelock_lock.c | 1 - core/src/xmake/io/filelock_open.c | 1 - core/src/xmake/io/filelock_trylock.c | 1 - core/src/xmake/io/filelock_unlock.c | 1 - core/src/xmake/io/pipe_close.c | 1 - core/src/xmake/io/pipe_connect.c | 1 - core/src/xmake/io/pipe_open.c | 1 - core/src/xmake/io/pipe_openpair.c | 1 - core/src/xmake/io/pipe_read.c | 1 - core/src/xmake/io/pipe_wait.c | 1 - core/src/xmake/io/pipe_write.c | 1 - core/src/xmake/io/poller_insert.c | 1 - core/src/xmake/io/poller_modify.c | 1 - core/src/xmake/io/poller_remove.c | 1 - core/src/xmake/io/poller_spank.c | 1 - core/src/xmake/io/poller_support.c | 1 - core/src/xmake/io/poller_wait.c | 3 --- core/src/xmake/io/socket_accept.c | 1 - core/src/xmake/io/socket_bind.c | 1 - core/src/xmake/io/socket_close.c | 1 - core/src/xmake/io/socket_connect.c | 1 - core/src/xmake/io/socket_ctrl.c | 1 - core/src/xmake/io/socket_kill.c | 1 - core/src/xmake/io/socket_listen.c | 1 - core/src/xmake/io/socket_open.c | 1 - core/src/xmake/io/socket_peeraddr.c | 1 - core/src/xmake/io/socket_rawfd.c | 1 - core/src/xmake/io/socket_recv.c | 1 - core/src/xmake/io/socket_recvfrom.c | 1 - core/src/xmake/io/socket_send.c | 1 - core/src/xmake/io/socket_sendfile.c | 1 - core/src/xmake/io/socket_sendto.c | 1 - core/src/xmake/io/socket_wait.c | 1 - core/src/xmake/io/stdfile.c | 1 - core/src/xmake/libc/byteof.c | 1 - core/src/xmake/libc/dataptr.c | 1 - core/src/xmake/libc/free.c | 1 - core/src/xmake/libc/malloc.c | 1 - core/src/xmake/libc/memcpy.c | 1 - core/src/xmake/libc/memmov.c | 1 - core/src/xmake/libc/memset.c | 1 - core/src/xmake/libc/setbyte.c | 1 - core/src/xmake/libc/strndup.c | 1 - core/src/xmake/lz4/block_compress.c | 1 - core/src/xmake/lz4/block_decompress.c | 1 - core/src/xmake/lz4/compress.c | 1 - core/src/xmake/lz4/compress_file.c | 2 -- core/src/xmake/lz4/compress_stream_close.c | 1 - core/src/xmake/lz4/compress_stream_open.c | 1 - core/src/xmake/lz4/compress_stream_read.c | 1 - core/src/xmake/lz4/compress_stream_write.c | 1 - core/src/xmake/lz4/decompress.c | 1 - core/src/xmake/lz4/decompress_file.c | 2 -- core/src/xmake/lz4/decompress_stream_close.c | 1 - core/src/xmake/lz4/decompress_stream_open.c | 1 - core/src/xmake/lz4/decompress_stream_read.c | 1 - core/src/xmake/lz4/decompress_stream_write.c | 1 - core/src/xmake/lz4/prefix.h | 4 ---- core/src/xmake/os/args.c | 2 -- core/src/xmake/os/argv.c | 1 - core/src/xmake/os/chdir.c | 2 -- core/src/xmake/os/cpdir.c | 1 - core/src/xmake/os/cpfile.c | 1 - core/src/xmake/os/cpuinfo.c | 1 - core/src/xmake/os/curdir.c | 1 - core/src/xmake/os/emptydir.c | 2 -- core/src/xmake/os/exists.c | 1 - core/src/xmake/os/filesize.c | 1 - core/src/xmake/os/find.c | 6 ------ core/src/xmake/os/fscase.c | 1 - core/src/xmake/os/getenv.c | 2 -- core/src/xmake/os/getenvs.c | 3 --- core/src/xmake/os/getown.c | 2 -- core/src/xmake/os/getpid.c | 1 - core/src/xmake/os/getwinsize.c | 2 -- core/src/xmake/os/gid.c | 2 -- core/src/xmake/os/isdir.c | 1 - core/src/xmake/os/isfile.c | 1 - core/src/xmake/os/islink.c | 1 - core/src/xmake/os/link.c | 2 -- core/src/xmake/os/mclock.c | 2 -- core/src/xmake/os/meminfo.c | 1 - core/src/xmake/os/mkdir.c | 2 -- core/src/xmake/os/mtime.c | 1 - core/src/xmake/os/readlink.c | 2 -- core/src/xmake/os/rename.c | 1 - core/src/xmake/os/rmdir.c | 6 ------ core/src/xmake/os/rmfile.c | 1 - core/src/xmake/os/setenv.c | 1 - core/src/xmake/os/signal.c | 1 - core/src/xmake/os/strerror.c | 1 - core/src/xmake/os/syserror.c | 1 - core/src/xmake/os/tmpdir.c | 1 - core/src/xmake/os/touch.c | 1 - core/src/xmake/os/uid.c | 2 -- core/src/xmake/package/loadxmi.c | 1 - core/src/xmake/path/absolute.c | 1 - core/src/xmake/path/directory.c | 1 - core/src/xmake/path/is_absolute.c | 1 - core/src/xmake/path/relative.c | 1 - core/src/xmake/path/translate.c | 1 - core/src/xmake/process/close.c | 1 - core/src/xmake/process/kill.c | 1 - core/src/xmake/process/open.c | 1 - core/src/xmake/process/openv.c | 2 -- core/src/xmake/process/wait.c | 2 -- core/src/xmake/readline/add_history.c | 2 -- core/src/xmake/readline/clear_history.c | 2 -- core/src/xmake/readline/history_list.c | 2 -- core/src/xmake/readline/readline.c | 2 -- core/src/xmake/sandbox/interactive.c | 6 ------ core/src/xmake/semver/compare.c | 2 -- core/src/xmake/semver/parse.c | 2 -- core/src/xmake/semver/satisfies.c | 1 - core/src/xmake/semver/select.c | 3 --- core/src/xmake/semver/semver.c | 1 - core/src/xmake/string/convert.c | 2 -- core/src/xmake/string/endswith.c | 2 -- core/src/xmake/string/lastof.c | 1 - core/src/xmake/string/split.c | 1 - core/src/xmake/string/startswith.c | 2 -- core/src/xmake/string/trim.c | 5 ----- core/src/xmake/thread/thread_exit.c | 1 - core/src/xmake/thread/thread_init.c | 1 - core/src/xmake/thread/thread_resume.c | 1 - core/src/xmake/thread/thread_suspend.c | 1 - core/src/xmake/thread/thread_wait.c | 1 - core/src/xmake/tty/term_mode.c | 1 - core/src/xmake/utils/bin2c.c | 1 - core/src/xmake/winos/ansi.c | 6 ------ core/src/xmake/winos/logical_drives.c | 1 - core/src/xmake/winos/registry_keys.c | 2 -- core/src/xmake/winos/registry_query.c | 2 -- core/src/xmake/winos/registry_values.c | 3 --- core/src/xmake/winos/short_path.c | 1 - core/src/xmake/xmake.c | 5 ----- 170 files changed, 285 deletions(-) (limited to 'core/src/xmake/string') diff --git a/core/src/xmake/base64/decode.c b/core/src/xmake/base64/decode.c index 41555f5cc..cb1b7eb82 100644 --- a/core/src/xmake/base64/decode.c +++ b/core/src/xmake/base64/decode.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_base64_decode(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the string diff --git a/core/src/xmake/base64/encode.c b/core/src/xmake/base64/encode.c index cf2135e56..d896cb55e 100644 --- a/core/src/xmake/base64/encode.c +++ b/core/src/xmake/base64/encode.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_base64_encode(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get data and size diff --git a/core/src/xmake/bloom_filter/bloom_filter_clear.c b/core/src/xmake/bloom_filter/bloom_filter_clear.c index 3f6e36bd0..2657cc5dc 100644 --- a/core/src/xmake/bloom_filter/bloom_filter_clear.c +++ b/core/src/xmake/bloom_filter/bloom_filter_clear.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_bloom_filter_clear(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/bloom_filter/bloom_filter_close.c b/core/src/xmake/bloom_filter/bloom_filter_close.c index 5c916b460..59d3e59a1 100644 --- a/core/src/xmake/bloom_filter/bloom_filter_close.c +++ b/core/src/xmake/bloom_filter/bloom_filter_close.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_bloom_filter_close(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/bloom_filter/bloom_filter_data.c b/core/src/xmake/bloom_filter/bloom_filter_data.c index e37aea966..9d6f34e64 100644 --- a/core/src/xmake/bloom_filter/bloom_filter_data.c +++ b/core/src/xmake/bloom_filter/bloom_filter_data.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_bloom_filter_data(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/bloom_filter/bloom_filter_data_set.c b/core/src/xmake/bloom_filter/bloom_filter_data_set.c index a6949d730..984ec6562 100644 --- a/core/src/xmake/bloom_filter/bloom_filter_data_set.c +++ b/core/src/xmake/bloom_filter/bloom_filter_data_set.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_bloom_filter_data_set(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/bloom_filter/bloom_filter_get.c b/core/src/xmake/bloom_filter/bloom_filter_get.c index 755446a09..dd1f8d1e6 100644 --- a/core/src/xmake/bloom_filter/bloom_filter_get.c +++ b/core/src/xmake/bloom_filter/bloom_filter_get.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_bloom_filter_get(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/bloom_filter/bloom_filter_open.c b/core/src/xmake/bloom_filter/bloom_filter_open.c index 68af8ae92..be364be91 100644 --- a/core/src/xmake/bloom_filter/bloom_filter_open.c +++ b/core/src/xmake/bloom_filter/bloom_filter_open.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_bloom_filter_open(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get arguments diff --git a/core/src/xmake/bloom_filter/bloom_filter_set.c b/core/src/xmake/bloom_filter/bloom_filter_set.c index 9387d5354..51d85d0a7 100644 --- a/core/src/xmake/bloom_filter/bloom_filter_set.c +++ b/core/src/xmake/bloom_filter/bloom_filter_set.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_bloom_filter_set(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/bloom_filter/bloom_filter_size.c b/core/src/xmake/bloom_filter/bloom_filter_size.c index 219035fe7..977b455f3 100644 --- a/core/src/xmake/bloom_filter/bloom_filter_size.c +++ b/core/src/xmake/bloom_filter/bloom_filter_size.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_bloom_filter_size(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/engine.c b/core/src/xmake/engine.c index a65395423..7a07d72da 100644 --- a/core/src/xmake/engine.c +++ b/core/src/xmake/engine.c @@ -705,7 +705,6 @@ static tb_byte_t g_xmake_xmz_data[] = { * private implementation */ static tb_bool_t xm_engine_save_arguments(xm_engine_t *engine, tb_int_t argc, tb_char_t **argv, tb_char_t **taskargv) { - // check tb_assert_and_check_return_val(engine && engine->lua && argc >= 1 && argv, tb_false); #if defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_COMPILER_LIKE_UNIX) @@ -745,7 +744,6 @@ static tb_bool_t xm_engine_save_arguments(xm_engine_t *engine, tb_int_t argc, tb } static tb_bool_t xm_engine_get_program_file(xm_engine_t *engine, tb_char_t **argv, tb_char_t *path, tb_size_t maxn) { - // check tb_assert_and_check_return_val(engine && path && maxn, tb_false); /* we cache it, because the current path will be changed in thread. @@ -774,13 +772,11 @@ static tb_bool_t xm_engine_get_program_file(xm_engine_t *engine, tb_char_t **arg tb_wchar_t buf[TB_PATH_MAXN] = { 0 }; tb_size_t size = (tb_size_t)GetModuleFileNameW(tb_null, buf, (DWORD)TB_PATH_MAXN); tb_assert_and_check_break(size < TB_PATH_MAXN); - // end buf[size] = L'\0'; size = tb_wcstombs(path, buf, maxn); tb_assert_and_check_break(size < maxn); path[size] = '\0'; - // ok ok = tb_true; #elif defined(TB_CONFIG_OS_MACOSX) || defined(TB_CONFIG_OS_IOS) @@ -855,9 +851,7 @@ static tb_bool_t xm_engine_get_program_file(xm_engine_t *engine, tb_char_t **arg } while (0); - // ok? if (ok) { - // trace tb_trace_d("programfile: %s", path); // cache it @@ -894,7 +888,6 @@ static tb_bool_t xm_engine_get_program_directory(xm_engine_t *engine, tb_char_t *path, tb_size_t maxn, tb_char_t const *programfile) { - // check tb_assert_and_check_return_val(engine && path && maxn, tb_false); static tb_char_t s_program_directory[TB_PATH_MAXN] = { 0 }; @@ -980,9 +973,7 @@ static tb_bool_t xm_engine_get_program_directory(xm_engine_t *engine, } while (0); - // ok? if (ok) { - // trace tb_trace_d("programdir: %s", path); // cache it @@ -993,12 +984,10 @@ static tb_bool_t xm_engine_get_program_directory(xm_engine_t *engine, lua_setglobal(engine->lua, "_PROGRAM_DIR"); } - // ok? return ok; } static tb_bool_t xm_engine_get_project_directory(xm_engine_t *engine, tb_char_t *path, tb_size_t maxn) { - // check tb_assert_and_check_return_val(engine && path && maxn, tb_false); tb_bool_t ok = tb_false; @@ -1011,14 +1000,12 @@ static tb_bool_t xm_engine_get_project_directory(xm_engine_t *engine, tb_char_t break; } - // trace tb_trace_d("project: %s", path); // save the directory to the global variable: _PROJECT_DIR lua_pushstring(engine->lua, path); lua_setglobal(engine->lua, "_PROJECT_DIR"); - // ok ok = tb_true; } while (0); @@ -1027,7 +1014,6 @@ static tb_bool_t xm_engine_get_project_directory(xm_engine_t *engine, tb_char_t if (!ok) tb_printf("error: not found the project directory!\n"); - // ok? return ok; } @@ -1061,7 +1047,6 @@ static tb_void_t xm_engine_signal_handler(tb_int_t signo) { #endif static tb_void_t xm_engine_init_host(xm_engine_t *engine) { - // check tb_assert_and_check_return(engine && engine->lua); // init system host @@ -1146,7 +1131,6 @@ static __tb_inline__ tb_char_t const *xm_engine_xmake_arch() { } static tb_void_t xm_engine_init_arch(xm_engine_t *engine) { - // check tb_assert_and_check_return(engine && engine->lua); // init xmake arch @@ -1225,7 +1209,6 @@ static tb_void_t xm_engine_init_arch(xm_engine_t *engine) { } static tb_void_t xm_engine_init_features(xm_engine_t *engine) { - // check tb_assert_and_check_return(engine && engine->lua); // init features @@ -1660,7 +1643,6 @@ xm_engine_ref_t xm_engine_init(tb_char_t const *name, xm_engine_lni_initalizer_c return (xm_engine_ref_t)engine; } tb_void_t xm_engine_exit(xm_engine_ref_t self) { - // check xm_engine_t *engine = (xm_engine_t *)self; tb_assert_and_check_return(engine); @@ -1678,7 +1660,6 @@ tb_void_t xm_engine_exit(xm_engine_ref_t self) { tb_free(engine); } tb_int_t xm_engine_main(xm_engine_ref_t self, tb_int_t argc, tb_char_t **argv, tb_char_t **taskargv) { - // check xm_engine_t *engine = (xm_engine_t *)self; tb_assert_and_check_return_val(engine && engine->lua, -1); @@ -1719,7 +1700,6 @@ tb_int_t xm_engine_main(xm_engine_ref_t self, tb_int_t argc, tb_char_t **argv, t return -1; } - // trace tb_trace_d("main: %s", path); // load and execute the main script @@ -1741,7 +1721,6 @@ tb_int_t xm_engine_main(xm_engine_ref_t self, tb_int_t argc, tb_char_t **argv, t return (tb_int_t)lua_tonumber(engine->lua, -1); } tb_void_t xm_engine_register(xm_engine_ref_t self, tb_char_t const *module, luaL_Reg const funcs[]) { - // check xm_engine_t *engine = (xm_engine_t *)self; tb_assert_and_check_return(engine && engine->lua && module && funcs); @@ -1753,7 +1732,6 @@ tb_void_t xm_engine_register(xm_engine_ref_t self, tb_char_t const *module, luaL } #ifdef XM_EMBED_ENABLE tb_void_t xm_engine_add_embedfiles(xm_engine_ref_t self, tb_byte_t const *data, tb_size_t size) { - // check xm_engine_t *engine = (xm_engine_t *)self; tb_assert_and_check_return(engine && engine->embedcount < tb_arrayn(engine->embedsize) && data && size); @@ -1763,14 +1741,12 @@ tb_void_t xm_engine_add_embedfiles(xm_engine_ref_t self, tb_byte_t const *data, } #endif lua_State *xm_engine_lua(xm_engine_ref_t self) { - // check xm_engine_t *engine = (xm_engine_t *)self; tb_assert_and_check_return_val(engine, tb_null); return engine->lua; } tb_poller_ref_t xm_engine_poller(xm_engine_ref_t self) { - // check xm_engine_t *engine = (xm_engine_t *)self; tb_assert_and_check_return_val(engine, tb_null); diff --git a/core/src/xmake/fwatcher/add.c b/core/src/xmake/fwatcher/add.c index cda233104..77c23ea48 100644 --- a/core/src/xmake/fwatcher/add.c +++ b/core/src/xmake/fwatcher/add.c @@ -36,7 +36,6 @@ // fwatcher.add(watchdir, recursion) tb_int_t xm_fwatcher_add(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/fwatcher/close.c b/core/src/xmake/fwatcher/close.c index 8f6a680be..a5501d906 100644 --- a/core/src/xmake/fwatcher/close.c +++ b/core/src/xmake/fwatcher/close.c @@ -36,7 +36,6 @@ // fwatcher.close(p) tb_int_t xm_fwatcher_close(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/fwatcher/open.c b/core/src/xmake/fwatcher/open.c index 05173660e..13ab91d5a 100644 --- a/core/src/xmake/fwatcher/open.c +++ b/core/src/xmake/fwatcher/open.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_fwatcher_open(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // init fwatcher diff --git a/core/src/xmake/fwatcher/remove.c b/core/src/xmake/fwatcher/remove.c index d7ef4d289..6285b0649 100644 --- a/core/src/xmake/fwatcher/remove.c +++ b/core/src/xmake/fwatcher/remove.c @@ -36,7 +36,6 @@ // fwatcher.remove(watchdir) tb_int_t xm_fwatcher_remove(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/fwatcher/wait.c b/core/src/xmake/fwatcher/wait.c index d4e64347f..42b01b8aa 100644 --- a/core/src/xmake/fwatcher/wait.c +++ b/core/src/xmake/fwatcher/wait.c @@ -36,7 +36,6 @@ // fwatcher.wait(p) tb_int_t xm_fwatcher_wait(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/hash/md5.c b/core/src/xmake/hash/md5.c index 91f7eafc9..3c871b063 100644 --- a/core/src/xmake/hash/md5.c +++ b/core/src/xmake/hash/md5.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_hash_md5(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is bytes? get data and size @@ -81,7 +80,6 @@ tb_int_t xm_hash_md5(lua_State *lua) { // read data tb_long_t real = tb_stream_read(stream, data, sizeof(data)); - // ok? if (real > 0) tb_md5_spak(&md5, data, real); // no data? continue it diff --git a/core/src/xmake/hash/rand128.c b/core/src/xmake/hash/rand128.c index bb844aee9..625e75326 100644 --- a/core/src/xmake/hash/rand128.c +++ b/core/src/xmake/hash/rand128.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_hash_rand128(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); static union { diff --git a/core/src/xmake/hash/rand32.c b/core/src/xmake/hash/rand32.c index a8a2dc054..844dd83e7 100644 --- a/core/src/xmake/hash/rand32.c +++ b/core/src/xmake/hash/rand32.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_hash_rand32(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); static tb_uint64_t s_seed = 0; diff --git a/core/src/xmake/hash/rand64.c b/core/src/xmake/hash/rand64.c index 05b861327..0f9e39069 100644 --- a/core/src/xmake/hash/rand64.c +++ b/core/src/xmake/hash/rand64.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_hash_rand64(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); static union { diff --git a/core/src/xmake/hash/sha.c b/core/src/xmake/hash/sha.c index 12d98b860..158a09208 100644 --- a/core/src/xmake/hash/sha.c +++ b/core/src/xmake/hash/sha.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_hash_sha(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get mode @@ -88,7 +87,6 @@ tb_int_t xm_hash_sha(lua_State *lua) { // read data tb_long_t real = tb_stream_read(stream, data, sizeof(data)); - // ok? if (real > 0) tb_sha_spak(&sha, data, real); // no data? continue it diff --git a/core/src/xmake/hash/uuid4.c b/core/src/xmake/hash/uuid4.c index d99e849d8..8712e9efa 100644 --- a/core/src/xmake/hash/uuid4.c +++ b/core/src/xmake/hash/uuid4.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_hash_uuid4(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the name diff --git a/core/src/xmake/hash/xxhash.c b/core/src/xmake/hash/xxhash.c index 49e1199e8..7a55ce63d 100644 --- a/core/src/xmake/hash/xxhash.c +++ b/core/src/xmake/hash/xxhash.c @@ -38,7 +38,6 @@ * implementation */ tb_int_t xm_hash_xxhash(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get mode @@ -115,7 +114,6 @@ tb_int_t xm_hash_xxhash(lua_State *lua) { // read data tb_long_t real = tb_stream_read(stream, data, sizeof(data)); - // ok? if (real > 0) { if (mode == 32 || mode == 64) XM_XXH3_64bits_update(state, data, real); diff --git a/core/src/xmake/io/file_close.c b/core/src/xmake/io/file_close.c index e00946dd0..6547b8156 100644 --- a/core/src/xmake/io/file_close.c +++ b/core/src/xmake/io/file_close.c @@ -36,7 +36,6 @@ // io.file_close(file) tb_int_t xm_io_file_close(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is user data? @@ -49,7 +48,6 @@ tb_int_t xm_io_file_close(lua_State *lua) { // close file if (xm_io_file_is_file(file)) { - // check tb_assert(file->u.file_ref); #ifdef TB_CONFIG_OS_WINDOWS @@ -90,7 +88,6 @@ tb_int_t xm_io_file_close(lua_State *lua) { // gc will free it if no any refs for lua_newuserdata() // ... - // ok lua_pushboolean(lua, tb_true); return 1; } else // for stdfile (gc/close) @@ -102,7 +99,6 @@ tb_int_t xm_io_file_close(lua_State *lua) { // gc will free it if no any refs for lua_newuserdata() // ... - // ok lua_pushboolean(lua, tb_true); return 1; } diff --git a/core/src/xmake/io/file_flush.c b/core/src/xmake/io/file_flush.c index 5aa3e9f58..e5776a60e 100644 --- a/core/src/xmake/io/file_flush.c +++ b/core/src/xmake/io/file_flush.c @@ -39,7 +39,6 @@ static tb_bool_t xm_io_std_flush_impl(xm_io_file_t *file) { } static tb_bool_t xm_io_file_flush_impl(xm_io_file_t *file) { - // check tb_assert_and_check_return_val(xm_io_file_is_file(file), tb_false); #ifdef TB_CONFIG_OS_WINDOWS @@ -61,7 +60,6 @@ static tb_bool_t xm_io_file_flush_impl(xm_io_file_t *file) { // io.file_flush(file) tb_int_t xm_io_file_flush(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is user data? diff --git a/core/src/xmake/io/file_isatty.c b/core/src/xmake/io/file_isatty.c index 645431398..264cabd53 100644 --- a/core/src/xmake/io/file_isatty.c +++ b/core/src/xmake/io/file_isatty.c @@ -36,7 +36,6 @@ // io.file_isatty(file) tb_int_t xm_io_file_isatty(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is user data? diff --git a/core/src/xmake/io/file_open.c b/core/src/xmake/io/file_open.c index 56c0848fd..f4a080077 100644 --- a/core/src/xmake/io/file_open.c +++ b/core/src/xmake/io/file_open.c @@ -44,7 +44,6 @@ * private implementation */ static tb_size_t xm_io_file_detect_charset(tb_byte_t const **data_ptr, tb_long_t size) { - // check tb_assert(data_ptr && *data_ptr); tb_byte_t const *data = *data_ptr; @@ -142,7 +141,6 @@ static tb_size_t xm_io_file_detect_charset(tb_byte_t const **data_ptr, tb_long_t return charset; } static tb_size_t xm_io_file_detect_encoding(tb_stream_ref_t stream, tb_long_t *pbomoff) { - // check tb_assert_and_check_return_val(stream && pbomoff, XM_IO_FILE_ENCODING_BINARY); // detect encoding @@ -163,7 +161,6 @@ static tb_size_t xm_io_file_detect_encoding(tb_stream_ref_t stream, tb_long_t *p // io.file_open(path, modestr) tb_int_t xm_io_file_open(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get file path and mode @@ -261,7 +258,6 @@ tb_int_t xm_io_file_open(lua_State *lua) { if (bomoff > 0 && !tb_stream_seek(stream, bomoff)) break; - // ok open_ok = tb_true; } while (0); diff --git a/core/src/xmake/io/file_rawfd.c b/core/src/xmake/io/file_rawfd.c index f4dc3ffee..c94dc4a98 100644 --- a/core/src/xmake/io/file_rawfd.c +++ b/core/src/xmake/io/file_rawfd.c @@ -52,7 +52,6 @@ * e.g. set VS_UNICODE_OUTPUT=fd to enable vs unicode output, @see https://github.com/xmake-io/xmake/issues/528 */ tb_int_t xm_io_file_rawfd(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is user data? diff --git a/core/src/xmake/io/file_read.c b/core/src/xmake/io/file_read.c index 2f349edb5..2be05a05a 100644 --- a/core/src/xmake/io/file_read.c +++ b/core/src/xmake/io/file_read.c @@ -44,7 +44,6 @@ typedef enum __xm_pushline_state_e { * implementation */ static tb_long_t xm_io_file_buffer_readline(tb_stream_ref_t stream, tb_buffer_ref_t line) { - // check tb_assert_and_check_return_val(stream && line, -1); // read line and reserve crlf @@ -79,7 +78,6 @@ static tb_long_t xm_io_file_buffer_readline(tb_stream_ref_t stream, tb_buffer_re } } - // ok? tb_size_t linesize = tb_buffer_size(line); if (linesize) return linesize; @@ -90,7 +88,6 @@ static tb_int_t xm_io_file_buffer_pushline(tb_buffer_ref_t buf, xm_io_file_t *file, tb_char_t const *continuation, tb_bool_t keep_crlf) { - // check tb_assert(buf && file && continuation && xm_io_file_is_file(file) && file->u.file_ref); // is binary? @@ -166,7 +163,6 @@ static tb_int_t xm_io_file_buffer_pushline(tb_buffer_ref_t buf, return result; } static tb_int_t xm_io_file_read_all_directly(lua_State *lua, xm_io_file_t *file) { - // check tb_assert(lua && file && xm_io_file_is_file(file) && file->u.file_ref); // init buffer @@ -201,7 +197,6 @@ static tb_int_t xm_io_file_read_all_directly(lua_State *lua, xm_io_file_t *file) return 1; } static tb_int_t xm_io_file_read_all(lua_State *lua, xm_io_file_t *file, tb_char_t const *continuation) { - // check tb_assert(lua && file && continuation && xm_io_file_is_file(file) && file->u.file_ref); // is binary? read all directly @@ -242,7 +237,6 @@ static tb_int_t xm_io_file_read_line(lua_State *lua, xm_io_file_t *file, tb_char_t const *continuation, tb_bool_t keep_crlf) { - // check tb_assert(lua && file && continuation && xm_io_file_is_file(file) && file->u.file_ref); // init buffer @@ -278,7 +272,6 @@ static tb_int_t xm_io_file_read_line(lua_State *lua, } static tb_int_t xm_io_file_read_n(lua_State *lua, xm_io_file_t *file, tb_char_t const *continuation, tb_long_t n) { - // check tb_assert(lua && file && continuation && xm_io_file_is_file(file) && file->u.file_ref); // check continuation @@ -314,7 +307,6 @@ static tb_size_t xm_io_file_std_buffer_pushline(tb_buffer_ref_t buf, xm_io_file_t *file, tb_char_t const *continuation, tb_bool_t keep_crlf) { - // check tb_assert(buf && file && continuation && xm_io_file_is_std(file)); // get input buffer @@ -367,7 +359,6 @@ static tb_int_t xm_io_file_std_read_line(lua_State *lua, xm_io_file_t *file, tb_char_t const *continuation, tb_bool_t keep_crlf) { - // check tb_assert(lua && file && continuation && xm_io_file_is_std(file)); // init buffer @@ -403,7 +394,6 @@ static tb_int_t xm_io_file_std_read_line(lua_State *lua, } static tb_int_t xm_io_file_std_read_all(lua_State *lua, xm_io_file_t *file, tb_char_t const *continuation) { - // check tb_assert(lua && file && continuation && xm_io_file_is_std(file)); // init buffer @@ -436,7 +426,6 @@ static tb_int_t xm_io_file_std_read_all(lua_State *lua, xm_io_file_t *file, tb_c } static tb_int_t xm_io_file_std_read_n(lua_State *lua, xm_io_file_t *file, tb_char_t const *continuation, tb_long_t n) { - // check tb_assert(lua && file && continuation && xm_io_file_is_std(file)); // check continuation @@ -466,7 +455,6 @@ static tb_int_t xm_io_file_std_read_n(lua_State *lua, xm_io_file_t *file, tb_cha } static tb_int_t xm_io_file_std_read_num(lua_State *lua, xm_io_file_t *file, tb_char_t const *continuation) { - // check tb_assert(lua && file && continuation && xm_io_file_is_std(file)); // check continuation @@ -490,7 +478,6 @@ static tb_int_t xm_io_file_std_read_num(lua_State *lua, xm_io_file_t *file, tb_c * io.file_read(file, 10) */ tb_int_t xm_io_file_read(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is user data? diff --git a/core/src/xmake/io/file_readable.c b/core/src/xmake/io/file_readable.c index e3cca2dc9..5f9a84329 100644 --- a/core/src/xmake/io/file_readable.c +++ b/core/src/xmake/io/file_readable.c @@ -35,7 +35,6 @@ */ tb_int_t xm_io_file_readable(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is user data? diff --git a/core/src/xmake/io/file_seek.c b/core/src/xmake/io/file_seek.c index ea053302b..421e5cdf1 100644 --- a/core/src/xmake/io/file_seek.c +++ b/core/src/xmake/io/file_seek.c @@ -36,7 +36,6 @@ // io.file_seek(file, [whence [, offset]]) tb_int_t xm_io_file_seek(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is user data? diff --git a/core/src/xmake/io/file_size.c b/core/src/xmake/io/file_size.c index df83a96b9..34f519306 100644 --- a/core/src/xmake/io/file_size.c +++ b/core/src/xmake/io/file_size.c @@ -36,7 +36,6 @@ // io.file_size(file) tb_int_t xm_io_file_size(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is user data? diff --git a/core/src/xmake/io/file_write.c b/core/src/xmake/io/file_write.c index bfe7321f3..5f70e1a49 100644 --- a/core/src/xmake/io/file_write.c +++ b/core/src/xmake/io/file_write.c @@ -34,7 +34,6 @@ * private implementation */ static tb_void_t xm_io_file_write_file_utfbom(xm_io_file_t *file) { - // check tb_assert(file && xm_io_file_is_file(file) && file->u.file_ref); // write bom @@ -60,7 +59,6 @@ static tb_void_t xm_io_file_write_file_directly(xm_io_file_t *file, tb_byte_t co tb_stream_bwrit(file->u.file_ref, data, size); } static tb_void_t xm_io_file_write_file_transcrlf(xm_io_file_t *file, tb_byte_t const *data, tb_size_t size) { - // check tb_assert(file && data && xm_io_file_is_file(file) && file->u.file_ref); #ifdef TB_CONFIG_OS_WINDOWS @@ -105,7 +103,6 @@ static tb_void_t xm_io_file_write_file_transcrlf(xm_io_file_t *file, tb_byte_t c #endif } static tb_void_t xm_io_file_write_std(xm_io_file_t *file, tb_byte_t const *data, tb_size_t size) { - // check tb_assert(file && data && xm_io_file_is_std(file)); // check type @@ -122,7 +119,6 @@ static tb_void_t xm_io_file_write_std(xm_io_file_t *file, tb_byte_t const *data, // io.file_write(file, ...) tb_int_t xm_io_file_write(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is user data? diff --git a/core/src/xmake/io/filelock_close.c b/core/src/xmake/io/filelock_close.c index ad628cb5c..02a2fb039 100644 --- a/core/src/xmake/io/filelock_close.c +++ b/core/src/xmake/io/filelock_close.c @@ -36,7 +36,6 @@ // io.filelock_close(lock) tb_int_t xm_io_filelock_close(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check lock? @@ -53,6 +52,5 @@ tb_int_t xm_io_filelock_close(lua_State *lua) { // save result: ok lua_pushboolean(lua, tb_true); - // ok return 1; } diff --git a/core/src/xmake/io/filelock_lock.c b/core/src/xmake/io/filelock_lock.c index 109bb6dcd..9e0c2493e 100644 --- a/core/src/xmake/io/filelock_lock.c +++ b/core/src/xmake/io/filelock_lock.c @@ -40,7 +40,6 @@ * shared lock: io.filelock_lock(lock, "/xxxx/filelock", {shared = true}) */ tb_int_t xm_io_filelock_lock(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get option argument diff --git a/core/src/xmake/io/filelock_open.c b/core/src/xmake/io/filelock_open.c index 171c6c86a..e9687ba54 100644 --- a/core/src/xmake/io/filelock_open.c +++ b/core/src/xmake/io/filelock_open.c @@ -38,7 +38,6 @@ * io.filelock_open(path) */ tb_int_t xm_io_filelock_open(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get file path diff --git a/core/src/xmake/io/filelock_trylock.c b/core/src/xmake/io/filelock_trylock.c index d1a204d30..aaf1da246 100644 --- a/core/src/xmake/io/filelock_trylock.c +++ b/core/src/xmake/io/filelock_trylock.c @@ -40,7 +40,6 @@ * shared lock: io.filelock_trylock("/xxxx/filelock", {shared = true}) */ tb_int_t xm_io_filelock_trylock(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get option argument diff --git a/core/src/xmake/io/filelock_unlock.c b/core/src/xmake/io/filelock_unlock.c index 0eaa2bc98..94dfe1b7d 100644 --- a/core/src/xmake/io/filelock_unlock.c +++ b/core/src/xmake/io/filelock_unlock.c @@ -36,7 +36,6 @@ // io.filelock_unlock(lock) tb_int_t xm_io_filelock_unlock(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check lock? diff --git a/core/src/xmake/io/pipe_close.c b/core/src/xmake/io/pipe_close.c index a3adb6d8c..23e200606 100644 --- a/core/src/xmake/io/pipe_close.c +++ b/core/src/xmake/io/pipe_close.c @@ -36,7 +36,6 @@ // io.pipe_close(pipe) tb_int_t xm_io_pipe_close(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check pipe? diff --git a/core/src/xmake/io/pipe_connect.c b/core/src/xmake/io/pipe_connect.c index 985817386..f13f612f9 100644 --- a/core/src/xmake/io/pipe_connect.c +++ b/core/src/xmake/io/pipe_connect.c @@ -36,7 +36,6 @@ // io.pipe_connect(pipefile) tb_int_t xm_io_pipe_connect(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check pipe diff --git a/core/src/xmake/io/pipe_open.c b/core/src/xmake/io/pipe_open.c index d0dbe66e9..d82406dee 100644 --- a/core/src/xmake/io/pipe_open.c +++ b/core/src/xmake/io/pipe_open.c @@ -38,7 +38,6 @@ * io.pipe_open(name, mode, buffsize) */ tb_int_t xm_io_pipe_open(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get pipe name and mode diff --git a/core/src/xmake/io/pipe_openpair.c b/core/src/xmake/io/pipe_openpair.c index c95d13a62..dd2205613 100644 --- a/core/src/xmake/io/pipe_openpair.c +++ b/core/src/xmake/io/pipe_openpair.c @@ -38,7 +38,6 @@ * io.pipe_openpair(mode, buffsize) */ tb_int_t xm_io_pipe_openpair(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get pipe mode diff --git a/core/src/xmake/io/pipe_read.c b/core/src/xmake/io/pipe_read.c index fb82c1ebd..637fb3b7d 100644 --- a/core/src/xmake/io/pipe_read.c +++ b/core/src/xmake/io/pipe_read.c @@ -36,7 +36,6 @@ // real, data_or_errors = io.pipe_read(pipefile, size) tb_int_t xm_io_pipe_read(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check pipe file diff --git a/core/src/xmake/io/pipe_wait.c b/core/src/xmake/io/pipe_wait.c index 67d189892..785efe950 100644 --- a/core/src/xmake/io/pipe_wait.c +++ b/core/src/xmake/io/pipe_wait.c @@ -36,7 +36,6 @@ // io.pipe_wait(pipefile, events, timeout) tb_int_t xm_io_pipe_wait(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check pipe? diff --git a/core/src/xmake/io/pipe_write.c b/core/src/xmake/io/pipe_write.c index 9b0869299..2f2865c47 100644 --- a/core/src/xmake/io/pipe_write.c +++ b/core/src/xmake/io/pipe_write.c @@ -36,7 +36,6 @@ // io.pipe_write(pipefile, data, start, last) tb_int_t xm_io_pipe_write(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check pipe diff --git a/core/src/xmake/io/poller_insert.c b/core/src/xmake/io/poller_insert.c index 2b24b3b1e..81f66cce9 100644 --- a/core/src/xmake/io/poller_insert.c +++ b/core/src/xmake/io/poller_insert.c @@ -37,7 +37,6 @@ // io.poller_insert(obj:otype(), obj:cdata(), events) tb_int_t xm_io_poller_insert(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/io/poller_modify.c b/core/src/xmake/io/poller_modify.c index 77dff2fbf..f9283aecb 100644 --- a/core/src/xmake/io/poller_modify.c +++ b/core/src/xmake/io/poller_modify.c @@ -37,7 +37,6 @@ // io.poller_modify(obj:otype(), obj:cdata(), events) tb_int_t xm_io_poller_modify(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/io/poller_remove.c b/core/src/xmake/io/poller_remove.c index 34242808f..3127bf2b4 100644 --- a/core/src/xmake/io/poller_remove.c +++ b/core/src/xmake/io/poller_remove.c @@ -37,7 +37,6 @@ // io.poller_remove(obj:otype(), obj) tb_int_t xm_io_poller_remove(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/io/poller_spank.c b/core/src/xmake/io/poller_spank.c index 1656a537e..7fdb38605 100644 --- a/core/src/xmake/io/poller_spank.c +++ b/core/src/xmake/io/poller_spank.c @@ -37,7 +37,6 @@ // io.poller_spank() tb_int_t xm_io_poller_spank(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // spank the poller, break the tb_poller_wait() and return all events diff --git a/core/src/xmake/io/poller_support.c b/core/src/xmake/io/poller_support.c index d53cdc1ed..d63f8da34 100644 --- a/core/src/xmake/io/poller_support.c +++ b/core/src/xmake/io/poller_support.c @@ -37,7 +37,6 @@ // io.poller_support(events) tb_int_t xm_io_poller_support(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get events diff --git a/core/src/xmake/io/poller_wait.c b/core/src/xmake/io/poller_wait.c index 141c4640b..f1e4ed7a7 100644 --- a/core/src/xmake/io/poller_wait.c +++ b/core/src/xmake/io/poller_wait.c @@ -38,7 +38,6 @@ static tb_void_t xm_io_poller_event(tb_poller_ref_t poller, tb_poller_object_ref_t object, tb_long_t events, tb_cpointer_t priv) { - // check xm_poller_state_t *state = (xm_poller_state_t *)tb_poller_priv(poller); tb_assert_and_check_return(state && state->lua); @@ -76,7 +75,6 @@ static tb_void_t xm_io_poller_event(tb_poller_ref_t poller, // local events, count = io.poller_wait(timeout) tb_int_t xm_io_poller_wait(lua_State *lua) { - // check tb_poller_ref_t poller = xm_io_poller(lua); tb_assert_and_check_return_val(poller && lua, 0); @@ -101,7 +99,6 @@ tb_int_t xm_io_poller_wait(lua_State *lua) { return 2; } - // failed lua_pop(lua, 1); lua_pushnil(lua); lua_pushinteger(lua, -1); diff --git a/core/src/xmake/io/socket_accept.c b/core/src/xmake/io/socket_accept.c index 5a303ef74..77a6c6c86 100644 --- a/core/src/xmake/io/socket_accept.c +++ b/core/src/xmake/io/socket_accept.c @@ -36,7 +36,6 @@ // local sock = io.socket_accept(sock) tb_int_t xm_io_socket_accept(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/io/socket_bind.c b/core/src/xmake/io/socket_bind.c index 9ba441a6f..d1a30789a 100644 --- a/core/src/xmake/io/socket_bind.c +++ b/core/src/xmake/io/socket_bind.c @@ -36,7 +36,6 @@ // io.socket_bind(sock, addr, port, family) tb_int_t xm_io_socket_bind(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check socket diff --git a/core/src/xmake/io/socket_close.c b/core/src/xmake/io/socket_close.c index d53228fe7..922987c10 100644 --- a/core/src/xmake/io/socket_close.c +++ b/core/src/xmake/io/socket_close.c @@ -36,7 +36,6 @@ // io.socket_close(sock) tb_int_t xm_io_socket_close(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/io/socket_connect.c b/core/src/xmake/io/socket_connect.c index 63d355fb4..94c2f1e8d 100644 --- a/core/src/xmake/io/socket_connect.c +++ b/core/src/xmake/io/socket_connect.c @@ -36,7 +36,6 @@ // io.socket_connect(sock, addr, port, family) tb_int_t xm_io_socket_connect(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check socket diff --git a/core/src/xmake/io/socket_ctrl.c b/core/src/xmake/io/socket_ctrl.c index c16f2c20d..0a51d65bc 100644 --- a/core/src/xmake/io/socket_ctrl.c +++ b/core/src/xmake/io/socket_ctrl.c @@ -36,7 +36,6 @@ // io.socket_ctrl(sock, code, value) tb_int_t xm_io_socket_ctrl(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check socket diff --git a/core/src/xmake/io/socket_kill.c b/core/src/xmake/io/socket_kill.c index eb2956e53..63e110257 100644 --- a/core/src/xmake/io/socket_kill.c +++ b/core/src/xmake/io/socket_kill.c @@ -36,7 +36,6 @@ // local sock = io.socket_kill(sock) tb_int_t xm_io_socket_kill(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/io/socket_listen.c b/core/src/xmake/io/socket_listen.c index 6fece6087..3aa541016 100644 --- a/core/src/xmake/io/socket_listen.c +++ b/core/src/xmake/io/socket_listen.c @@ -36,7 +36,6 @@ // io.socket_listen(sock, backlog) tb_int_t xm_io_socket_listen(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/io/socket_open.c b/core/src/xmake/io/socket_open.c index 4189607c7..cae80d182 100644 --- a/core/src/xmake/io/socket_open.c +++ b/core/src/xmake/io/socket_open.c @@ -38,7 +38,6 @@ * io.socket_open(socktype, family) */ tb_int_t xm_io_socket_open(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get socket type diff --git a/core/src/xmake/io/socket_peeraddr.c b/core/src/xmake/io/socket_peeraddr.c index bcc03c289..e1ad43931 100644 --- a/core/src/xmake/io/socket_peeraddr.c +++ b/core/src/xmake/io/socket_peeraddr.c @@ -44,7 +44,6 @@ /* io.socket_peeraddr(sock) */ tb_int_t xm_io_socket_peeraddr(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/io/socket_rawfd.c b/core/src/xmake/io/socket_rawfd.c index 672a9dafa..6340c0c19 100644 --- a/core/src/xmake/io/socket_rawfd.c +++ b/core/src/xmake/io/socket_rawfd.c @@ -44,7 +44,6 @@ /* io.socket_rawfd(sock) */ tb_int_t xm_io_socket_rawfd(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/io/socket_recv.c b/core/src/xmake/io/socket_recv.c index cecdbb031..ed629a8f5 100644 --- a/core/src/xmake/io/socket_recv.c +++ b/core/src/xmake/io/socket_recv.c @@ -36,7 +36,6 @@ // real, data_or_errors = io.socket_recv(sock, size) tb_int_t xm_io_socket_recv(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check socket diff --git a/core/src/xmake/io/socket_recvfrom.c b/core/src/xmake/io/socket_recvfrom.c index bc8f53bf8..8601f6302 100644 --- a/core/src/xmake/io/socket_recvfrom.c +++ b/core/src/xmake/io/socket_recvfrom.c @@ -36,7 +36,6 @@ // real, data_or_errors, addr, port = io.socket_recvfrom(sock, size) tb_int_t xm_io_socket_recvfrom(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check socket diff --git a/core/src/xmake/io/socket_send.c b/core/src/xmake/io/socket_send.c index 1b99d8d08..d83b02add 100644 --- a/core/src/xmake/io/socket_send.c +++ b/core/src/xmake/io/socket_send.c @@ -36,7 +36,6 @@ // io.socket_send(sock, data, start, last) tb_int_t xm_io_socket_send(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check socket diff --git a/core/src/xmake/io/socket_sendfile.c b/core/src/xmake/io/socket_sendfile.c index b5e6e10d6..0d4be4219 100644 --- a/core/src/xmake/io/socket_sendfile.c +++ b/core/src/xmake/io/socket_sendfile.c @@ -36,7 +36,6 @@ // io.socket_sendfile(sock, file, start, last) tb_int_t xm_io_socket_sendfile(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check socket diff --git a/core/src/xmake/io/socket_sendto.c b/core/src/xmake/io/socket_sendto.c index cde81febf..15403d4d8 100644 --- a/core/src/xmake/io/socket_sendto.c +++ b/core/src/xmake/io/socket_sendto.c @@ -36,7 +36,6 @@ // io.socket_sendto(sock, data, addr, port) tb_int_t xm_io_socket_sendto(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check socket diff --git a/core/src/xmake/io/socket_wait.c b/core/src/xmake/io/socket_wait.c index fd9900e21..42674f4f9 100644 --- a/core/src/xmake/io/socket_wait.c +++ b/core/src/xmake/io/socket_wait.c @@ -36,7 +36,6 @@ // io.socket_wait(sock, events, timeout) tb_int_t xm_io_socket_wait(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check socket? diff --git a/core/src/xmake/io/stdfile.c b/core/src/xmake/io/stdfile.c index 05e1fcf2a..0dcb43501 100644 --- a/core/src/xmake/io/stdfile.c +++ b/core/src/xmake/io/stdfile.c @@ -144,7 +144,6 @@ static xm_io_file_t *xm_io_stdfile_new(lua_State *lua, tb_size_t type) { // io.stdfile(stdin: 1, stdout: 2, stderr: 3) tb_int_t xm_io_stdfile(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get std type diff --git a/core/src/xmake/libc/byteof.c b/core/src/xmake/libc/byteof.c index be8820ff9..dac772e9b 100644 --- a/core/src/xmake/libc/byteof.c +++ b/core/src/xmake/libc/byteof.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_libc_byteof(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get data diff --git a/core/src/xmake/libc/dataptr.c b/core/src/xmake/libc/dataptr.c index 50b063b4e..363853800 100644 --- a/core/src/xmake/libc/dataptr.c +++ b/core/src/xmake/libc/dataptr.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_libc_dataptr(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_pointer_t data = tb_null; diff --git a/core/src/xmake/libc/free.c b/core/src/xmake/libc/free.c index ad12ccfc9..6f0d70f3d 100644 --- a/core/src/xmake/libc/free.c +++ b/core/src/xmake/libc/free.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_libc_free(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // do free diff --git a/core/src/xmake/libc/malloc.c b/core/src/xmake/libc/malloc.c index 8e2380955..faaa00e97 100644 --- a/core/src/xmake/libc/malloc.c +++ b/core/src/xmake/libc/malloc.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_libc_malloc(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // do malloc diff --git a/core/src/xmake/libc/memcpy.c b/core/src/xmake/libc/memcpy.c index 6baf66d39..e0e8b1492 100644 --- a/core/src/xmake/libc/memcpy.c +++ b/core/src/xmake/libc/memcpy.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_libc_memcpy(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // do memcpy diff --git a/core/src/xmake/libc/memmov.c b/core/src/xmake/libc/memmov.c index f43bccea6..66120e168 100644 --- a/core/src/xmake/libc/memmov.c +++ b/core/src/xmake/libc/memmov.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_libc_memmov(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // do memmov diff --git a/core/src/xmake/libc/memset.c b/core/src/xmake/libc/memset.c index 2c0936017..4f8864842 100644 --- a/core/src/xmake/libc/memset.c +++ b/core/src/xmake/libc/memset.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_libc_memset(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // do memset diff --git a/core/src/xmake/libc/setbyte.c b/core/src/xmake/libc/setbyte.c index 7ae959014..d53c30229 100644 --- a/core/src/xmake/libc/setbyte.c +++ b/core/src/xmake/libc/setbyte.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_libc_setbyte(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get data diff --git a/core/src/xmake/libc/strndup.c b/core/src/xmake/libc/strndup.c index d7d1204a0..f61cebb2c 100644 --- a/core/src/xmake/libc/strndup.c +++ b/core/src/xmake/libc/strndup.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_libc_strndup(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // do strndup diff --git a/core/src/xmake/lz4/block_compress.c b/core/src/xmake/lz4/block_compress.c index 2c7f0c00f..53b592a22 100644 --- a/core/src/xmake/lz4/block_compress.c +++ b/core/src/xmake/lz4/block_compress.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_block_compress(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get data and size diff --git a/core/src/xmake/lz4/block_decompress.c b/core/src/xmake/lz4/block_decompress.c index f2f76a4bf..2a6ed1d20 100644 --- a/core/src/xmake/lz4/block_decompress.c +++ b/core/src/xmake/lz4/block_decompress.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_block_decompress(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get data and size diff --git a/core/src/xmake/lz4/compress.c b/core/src/xmake/lz4/compress.c index 352945d1f..69af51113 100644 --- a/core/src/xmake/lz4/compress.c +++ b/core/src/xmake/lz4/compress.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_compress(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get data and size diff --git a/core/src/xmake/lz4/compress_file.c b/core/src/xmake/lz4/compress_file.c index be48184bd..48596e17b 100644 --- a/core/src/xmake/lz4/compress_file.c +++ b/core/src/xmake/lz4/compress_file.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_compress_file(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the file paths @@ -91,7 +90,6 @@ tb_int_t xm_lz4_compress_file(lua_State *lua) { } xm_lz4_cstream_exit(stream_lz4); - // ok? lua_pushboolean(lua, ok); return 1; } diff --git a/core/src/xmake/lz4/compress_stream_close.c b/core/src/xmake/lz4/compress_stream_close.c index 2bec169d0..d1f534cde 100644 --- a/core/src/xmake/lz4/compress_stream_close.c +++ b/core/src/xmake/lz4/compress_stream_close.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_compress_stream_close(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/lz4/compress_stream_open.c b/core/src/xmake/lz4/compress_stream_open.c index e4fd1de8b..d4ac50667 100644 --- a/core/src/xmake/lz4/compress_stream_open.c +++ b/core/src/xmake/lz4/compress_stream_open.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_compress_stream_open(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); xm_lz4_cstream_t *stream = xm_lz4_cstream_init(); diff --git a/core/src/xmake/lz4/compress_stream_read.c b/core/src/xmake/lz4/compress_stream_read.c index 7338ede02..ff1315c3e 100644 --- a/core/src/xmake/lz4/compress_stream_read.c +++ b/core/src/xmake/lz4/compress_stream_read.c @@ -35,7 +35,6 @@ */ tb_int_t xm_lz4_compress_stream_read(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check handle diff --git a/core/src/xmake/lz4/compress_stream_write.c b/core/src/xmake/lz4/compress_stream_write.c index aa6b87e85..730a4f986 100644 --- a/core/src/xmake/lz4/compress_stream_write.c +++ b/core/src/xmake/lz4/compress_stream_write.c @@ -35,7 +35,6 @@ */ tb_int_t xm_lz4_compress_stream_write(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check handle diff --git a/core/src/xmake/lz4/decompress.c b/core/src/xmake/lz4/decompress.c index c5382747d..51a50c112 100644 --- a/core/src/xmake/lz4/decompress.c +++ b/core/src/xmake/lz4/decompress.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_decompress(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get data and size diff --git a/core/src/xmake/lz4/decompress_file.c b/core/src/xmake/lz4/decompress_file.c index b65ee87a0..7d91c5be4 100644 --- a/core/src/xmake/lz4/decompress_file.c +++ b/core/src/xmake/lz4/decompress_file.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_decompress_file(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the file paths @@ -91,7 +90,6 @@ tb_int_t xm_lz4_decompress_file(lua_State *lua) { } xm_lz4_dstream_exit(stream_lz4); - // ok? lua_pushboolean(lua, ok); return 1; } diff --git a/core/src/xmake/lz4/decompress_stream_close.c b/core/src/xmake/lz4/decompress_stream_close.c index ead2e3493..89c868c53 100644 --- a/core/src/xmake/lz4/decompress_stream_close.c +++ b/core/src/xmake/lz4/decompress_stream_close.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_decompress_stream_close(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/lz4/decompress_stream_open.c b/core/src/xmake/lz4/decompress_stream_open.c index 673038e80..eb3db7193 100644 --- a/core/src/xmake/lz4/decompress_stream_open.c +++ b/core/src/xmake/lz4/decompress_stream_open.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_lz4_decompress_stream_open(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); xm_lz4_dstream_t *stream = xm_lz4_dstream_init(); diff --git a/core/src/xmake/lz4/decompress_stream_read.c b/core/src/xmake/lz4/decompress_stream_read.c index 5f6486166..85ecdbe9f 100644 --- a/core/src/xmake/lz4/decompress_stream_read.c +++ b/core/src/xmake/lz4/decompress_stream_read.c @@ -35,7 +35,6 @@ */ tb_int_t xm_lz4_decompress_stream_read(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check handle diff --git a/core/src/xmake/lz4/decompress_stream_write.c b/core/src/xmake/lz4/decompress_stream_write.c index 7fa45544c..4359a41d7 100644 --- a/core/src/xmake/lz4/decompress_stream_write.c +++ b/core/src/xmake/lz4/decompress_stream_write.c @@ -35,7 +35,6 @@ */ tb_int_t xm_lz4_decompress_stream_write(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check handle diff --git a/core/src/xmake/lz4/prefix.h b/core/src/xmake/lz4/prefix.h index 996e53093..534e5361a 100644 --- a/core/src/xmake/lz4/prefix.h +++ b/core/src/xmake/lz4/prefix.h @@ -131,7 +131,6 @@ static __tb_inline__ tb_long_t xm_lz4_cstream_write(xm_lz4_cstream_t *stream, tb_byte_t const *idata, tb_size_t isize, tb_bool_t end) { - // check tb_assert_and_check_return_val(stream && stream->cctx && idata && isize, -1); tb_assert_and_check_return_val(isize <= stream->write_maxn, -1); tb_assert_and_check_return_val(stream->buffer_size + isize < stream->buffer_maxn, -1); @@ -162,7 +161,6 @@ static __tb_inline__ tb_long_t xm_lz4_cstream_write(xm_lz4_cstream_t *stream, } static __tb_inline__ tb_long_t xm_lz4_cstream_read(xm_lz4_cstream_t *stream, tb_byte_t *odata, tb_size_t osize) { - // check tb_assert_and_check_return_val(stream && stream->cctx && odata && osize, -1); tb_assert_and_check_return_val(osize >= stream->header_size, -1); @@ -224,7 +222,6 @@ static __tb_inline__ tb_long_t xm_lz4_dstream_write(xm_lz4_dstream_t *stream, tb_byte_t const *idata, tb_size_t isize, tb_bool_t end) { - // check tb_assert_and_check_return_val(stream && stream->dctx && idata && isize, -1); // read header first @@ -279,7 +276,6 @@ static __tb_inline__ tb_long_t xm_lz4_dstream_write(xm_lz4_dstream_t *stream, } static __tb_inline__ tb_long_t xm_lz4_dstream_read(xm_lz4_dstream_t *stream, tb_byte_t *odata, tb_size_t osize) { - // check tb_assert_and_check_return_val(stream && stream->dctx && stream->buffer && odata && osize, -1); tb_check_return_val(stream->buffer_size, 0); diff --git a/core/src/xmake/os/args.c b/core/src/xmake/os/args.c index d220e0350..8b2c002c9 100644 --- a/core/src/xmake/os/args.c +++ b/core/src/xmake/os/args.c @@ -35,7 +35,6 @@ */ static tb_void_t tb_os_args_append( tb_string_ref_t result, tb_char_t const *cstr, tb_size_t size, tb_bool_t escape, tb_bool_t nowrap) { - // check tb_assert_and_check_return(size < TB_PATH_MAXN); // need wrap quote? @@ -74,7 +73,6 @@ static tb_void_t tb_os_args_append( */ // os.args({"xx", "yy"}, {escape = true}) tb_int_t xm_os_args(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // escape '\\' characters in global? diff --git a/core/src/xmake/os/argv.c b/core/src/xmake/os/argv.c index 89635fb2d..f7230d057 100644 --- a/core/src/xmake/os/argv.c +++ b/core/src/xmake/os/argv.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_argv(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the argument string diff --git a/core/src/xmake/os/chdir.c b/core/src/xmake/os/chdir.c index 537d6506c..73619122c 100644 --- a/core/src/xmake/os/chdir.c +++ b/core/src/xmake/os/chdir.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_chdir(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path @@ -44,6 +43,5 @@ tb_int_t xm_os_chdir(lua_State *lua) { // done os.chdir(path) lua_pushboolean(lua, tb_directory_current_set(path)); - // ok return 1; } diff --git a/core/src/xmake/os/cpdir.c b/core/src/xmake/os/cpdir.c index e2f2b89ee..0df435436 100644 --- a/core/src/xmake/os/cpdir.c +++ b/core/src/xmake/os/cpdir.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_cpdir(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the source and destination diff --git a/core/src/xmake/os/cpfile.c b/core/src/xmake/os/cpfile.c index b6597f87f..7291385a7 100644 --- a/core/src/xmake/os/cpfile.c +++ b/core/src/xmake/os/cpfile.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_cpfile(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the source and destination diff --git a/core/src/xmake/os/cpuinfo.c b/core/src/xmake/os/cpuinfo.c index a2ac1bbe4..f8ef7d46b 100644 --- a/core/src/xmake/os/cpuinfo.c +++ b/core/src/xmake/os/cpuinfo.c @@ -237,7 +237,6 @@ static tb_float_t xm_os_cpuinfo_usagerate() { * } */ tb_int_t xm_os_cpuinfo(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // init table diff --git a/core/src/xmake/os/curdir.c b/core/src/xmake/os/curdir.c index b2ca8a273..2d27cf905 100644 --- a/core/src/xmake/os/curdir.c +++ b/core/src/xmake/os/curdir.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_curdir(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // os.curdir() diff --git a/core/src/xmake/os/emptydir.c b/core/src/xmake/os/emptydir.c index 79ebd9807..aab016d28 100644 --- a/core/src/xmake/os/emptydir.c +++ b/core/src/xmake/os/emptydir.c @@ -34,7 +34,6 @@ * private implementation */ static tb_long_t xm_os_emptydir_walk(tb_char_t const *path, tb_file_info_t const *info, tb_cpointer_t priv) { - // check tb_bool_t *is_emptydir = (tb_bool_t *)priv; tb_assert_and_check_return_val(path && info && is_emptydir, TB_DIRECTORY_WALK_CODE_END); @@ -50,7 +49,6 @@ static tb_long_t xm_os_emptydir_walk(tb_char_t const *path, tb_file_info_t const * implementation */ tb_int_t xm_os_emptydir(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the directory diff --git a/core/src/xmake/os/exists.c b/core/src/xmake/os/exists.c index 403a1285d..9bb244510 100644 --- a/core/src/xmake/os/exists.c +++ b/core/src/xmake/os/exists.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_exists(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/os/filesize.c b/core/src/xmake/os/filesize.c index 115ab5665..a99651fbf 100644 --- a/core/src/xmake/os/filesize.c +++ b/core/src/xmake/os/filesize.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_filesize(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/os/find.c b/core/src/xmake/os/find.c index 91c5b0261..2ed5611ad 100644 --- a/core/src/xmake/os/find.c +++ b/core/src/xmake/os/find.c @@ -34,7 +34,6 @@ * private implementation */ static tb_long_t xm_os_find_walk(tb_char_t const *path, tb_file_info_t const *info, tb_cpointer_t priv) { - // check tb_value_ref_t tuple = (tb_value_ref_t)priv; tb_assert_and_check_return_val(path && info && tuple, TB_DIRECTORY_WALK_CODE_END); @@ -56,7 +55,6 @@ static tb_long_t xm_os_find_walk(tb_char_t const *path, tb_file_info_t const *in // the count tb_size_t *pcount = &(tuple[3].ul); - // trace tb_trace_d("path[%c]: %s", info->type == TB_FILE_TYPE_DIRECTORY ? 'd' : 'f', path); // we can ignore it directly if this path is file, but we need directory @@ -70,7 +68,6 @@ static tb_long_t xm_os_find_walk(tb_char_t const *path, tb_file_info_t const *in lua_pushstring(lua, path); lua_pushstring(lua, pattern); if (lua_pcall(lua, 2, 1, 0)) { - // trace tb_printf("error: call string.match(%s, %s) failed: %s!\n", path, pattern, lua_tostring(lua, -1)); return TB_DIRECTORY_WALK_CODE_END; } @@ -87,7 +84,6 @@ static tb_long_t xm_os_find_walk(tb_char_t const *path, tb_file_info_t const *in tb_char_t const *rootdir = luaL_checklstring(lua, 1, &rootlen); tb_assert_and_check_return_val(rootdir && rootlen, TB_DIRECTORY_WALK_CODE_END); - // check tb_assert(!tb_strncmp(path, rootdir, rootlen)); tb_assert(rootlen + 1 <= tb_strlen(path)); @@ -108,7 +104,6 @@ static tb_long_t xm_os_find_walk(tb_char_t const *path, tb_file_info_t const *in lua_pushstring(lua, path); lua_pushstring(lua, exclude); if (lua_pcall(lua, 2, 1, 0)) { - // trace tb_printf("error: call string.match(%s, %s) failed: %s!\n", path, exclude, @@ -163,7 +158,6 @@ static tb_long_t xm_os_find_walk(tb_char_t const *path, tb_file_info_t const *in * implementation */ tb_int_t xm_os_find(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the root directory diff --git a/core/src/xmake/os/fscase.c b/core/src/xmake/os/fscase.c index 6fa1c1c4a..b24a36e50 100644 --- a/core/src/xmake/os/fscase.c +++ b/core/src/xmake/os/fscase.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_fscase(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); #if ((TB_VERSION_MAJOR * 100) + (TB_VERSION_MINOR * 10) + TB_VERSION_ALTER) >= 174 diff --git a/core/src/xmake/os/getenv.c b/core/src/xmake/os/getenv.c index 84411ae1a..dc5578ebe 100644 --- a/core/src/xmake/os/getenv.c +++ b/core/src/xmake/os/getenv.c @@ -45,7 +45,6 @@ * implementation */ tb_int_t xm_os_getenv(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the name @@ -89,6 +88,5 @@ tb_int_t xm_os_getenv(lua_State *lua) { // exit values tb_string_exit(&values); - // ok return 1; } diff --git a/core/src/xmake/os/getenvs.c b/core/src/xmake/os/getenvs.c index a3bc546b4..70c6af7bf 100644 --- a/core/src/xmake/os/getenvs.c +++ b/core/src/xmake/os/getenvs.c @@ -57,7 +57,6 @@ extern tb_char_t **environ; * implementation */ static tb_void_t xm_os_getenvs_trim(tb_char_t const **sstr, tb_char_t const **estr) { - // check tb_assert(sstr && estr && *sstr && *estr); tb_char_t const *p = *sstr; @@ -77,7 +76,6 @@ static tb_void_t xm_os_getenvs_trim(tb_char_t const **sstr, tb_char_t const **es } static tb_void_t xm_os_getenvs_process_line(lua_State *lua, tb_char_t const *line) { - // check tb_assert_and_check_return(lua && line); tb_size_t n = tb_strlen(line); @@ -124,7 +122,6 @@ static tb_void_t xm_os_getenvs_process_line(lua_State *lua, tb_char_t const *lin } tb_int_t xm_os_getenvs(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // init table diff --git a/core/src/xmake/os/getown.c b/core/src/xmake/os/getown.c index 54e2b589e..ef7846ad1 100644 --- a/core/src/xmake/os/getown.c +++ b/core/src/xmake/os/getown.c @@ -42,7 +42,6 @@ // get owner by a given path tb_int_t xm_os_getown(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the pathname @@ -63,7 +62,6 @@ tb_int_t xm_os_getown(lua_State *lua) { lua_pushinteger(lua, sts.st_gid); lua_settable(lua, -3); - // ok return 1; } diff --git a/core/src/xmake/os/getpid.c b/core/src/xmake/os/getpid.c index 70b63804a..ad1a6f880 100644 --- a/core/src/xmake/os/getpid.c +++ b/core/src/xmake/os/getpid.c @@ -40,7 +40,6 @@ * implementation */ tb_int_t xm_os_getpid(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); #ifdef TB_CONFIG_OS_WINDOWS diff --git a/core/src/xmake/os/getwinsize.c b/core/src/xmake/os/getwinsize.c index 9757867a9..6faef97d0 100644 --- a/core/src/xmake/os/getwinsize.c +++ b/core/src/xmake/os/getwinsize.c @@ -43,7 +43,6 @@ // get console window size tb_int_t xm_os_getwinsize(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // init default window size (we will not consider winsize limit if cannot get it) @@ -80,6 +79,5 @@ tb_int_t xm_os_getwinsize(lua_State *lua) { lua_pushinteger(lua, h); lua_settable(lua, -3); - // ok return 1; } diff --git a/core/src/xmake/os/gid.c b/core/src/xmake/os/gid.c index cd5915cd4..feb13791b 100644 --- a/core/src/xmake/os/gid.c +++ b/core/src/xmake/os/gid.c @@ -41,7 +41,6 @@ // get & set gid tb_int_t xm_os_gid(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_int_t rgidset = -1; @@ -124,7 +123,6 @@ tb_int_t xm_os_gid(lua_State *lua) { lua_pushinteger(lua, egid); lua_settable(lua, -3); - // ok return 1; } diff --git a/core/src/xmake/os/isdir.c b/core/src/xmake/os/isdir.c index 6126ed6a8..f182e029d 100644 --- a/core/src/xmake/os/isdir.c +++ b/core/src/xmake/os/isdir.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_isdir(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/os/isfile.c b/core/src/xmake/os/isfile.c index f015b5f59..d7b1d66f2 100644 --- a/core/src/xmake/os/isfile.c +++ b/core/src/xmake/os/isfile.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_isfile(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/os/islink.c b/core/src/xmake/os/islink.c index 2de7e24fd..51181ecd2 100644 --- a/core/src/xmake/os/islink.c +++ b/core/src/xmake/os/islink.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_islink(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/os/link.c b/core/src/xmake/os/link.c index 696355177..cead7f88c 100644 --- a/core/src/xmake/os/link.c +++ b/core/src/xmake/os/link.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_link(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the source and destination @@ -45,6 +44,5 @@ tb_int_t xm_os_link(lua_State *lua) { // do os.link(src, dst) lua_pushboolean(lua, tb_file_link(src, dst)); - // ok return 1; } diff --git a/core/src/xmake/os/mclock.c b/core/src/xmake/os/mclock.c index f6bc138d3..5fa440db6 100644 --- a/core/src/xmake/os/mclock.c +++ b/core/src/xmake/os/mclock.c @@ -36,12 +36,10 @@ // os.mclock() tb_int_t xm_os_mclock(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // save result lua_pushnumber(lua, (lua_Number)tb_mclock()); - // ok return 1; } diff --git a/core/src/xmake/os/meminfo.c b/core/src/xmake/os/meminfo.c index 3c0b71d80..1e6e5f422 100644 --- a/core/src/xmake/os/meminfo.c +++ b/core/src/xmake/os/meminfo.c @@ -159,7 +159,6 @@ static tb_bool_t xm_os_meminfo_stats(tb_int_t *ptotalsize, tb_int_t *pavailsize) * implementation */ tb_int_t xm_os_meminfo(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // init table diff --git a/core/src/xmake/os/mkdir.c b/core/src/xmake/os/mkdir.c index badc50fd6..19507b5aa 100644 --- a/core/src/xmake/os/mkdir.c +++ b/core/src/xmake/os/mkdir.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_mkdir(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path @@ -48,6 +47,5 @@ tb_int_t xm_os_mkdir(lua_State *lua) { else lua_pushboolean(lua, tb_true); - // ok return 1; } diff --git a/core/src/xmake/os/mtime.c b/core/src/xmake/os/mtime.c index a3d9c44de..73014666b 100644 --- a/core/src/xmake/os/mtime.c +++ b/core/src/xmake/os/mtime.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_mtime(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/os/readlink.c b/core/src/xmake/os/readlink.c index 26ef78819..603ab7104 100644 --- a/core/src/xmake/os/readlink.c +++ b/core/src/xmake/os/readlink.c @@ -37,7 +37,6 @@ * implementation */ tb_int_t xm_os_readlink(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path @@ -69,6 +68,5 @@ tb_int_t xm_os_readlink(lua_State *lua) { lua_pushnil(lua); #endif - // ok return 1; } diff --git a/core/src/xmake/os/rename.c b/core/src/xmake/os/rename.c index 2f43797db..0cc469ded 100644 --- a/core/src/xmake/os/rename.c +++ b/core/src/xmake/os/rename.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_rename(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the source and destination diff --git a/core/src/xmake/os/rmdir.c b/core/src/xmake/os/rmdir.c index dd549adac..f04ba2a9c 100644 --- a/core/src/xmake/os/rmdir.c +++ b/core/src/xmake/os/rmdir.c @@ -34,7 +34,6 @@ * private implementation */ static tb_long_t xm_os_rmdir_empty(tb_char_t const *path, tb_file_info_t const *info, tb_cpointer_t priv) { - // check tb_bool_t *is_emptydir = (tb_bool_t *)priv; tb_assert_and_check_return_val(path && info && is_emptydir, TB_DIRECTORY_WALK_CODE_END); @@ -47,7 +46,6 @@ static tb_long_t xm_os_rmdir_empty(tb_char_t const *path, tb_file_info_t const * return TB_DIRECTORY_WALK_CODE_CONTINUE; } static tb_long_t xm_os_rmdir_remove(tb_char_t const *path, tb_file_info_t const *info, tb_cpointer_t priv) { - // check tb_assert_and_check_return_val(path, TB_DIRECTORY_WALK_CODE_END); // is directory? @@ -56,7 +54,6 @@ static tb_long_t xm_os_rmdir_remove(tb_char_t const *path, tb_file_info_t const tb_bool_t is_emptydir = tb_true; tb_directory_walk(path, tb_false, tb_true, xm_os_rmdir_empty, &is_emptydir); - // trace tb_trace_d("path: %s, emptydir: %u", path, is_emptydir); // remove empty directory @@ -70,7 +67,6 @@ static tb_long_t xm_os_rmdir_remove(tb_char_t const *path, tb_file_info_t const * implementation */ tb_int_t xm_os_rmdir(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path @@ -89,10 +85,8 @@ tb_int_t xm_os_rmdir(lua_State *lua) { if (is_emptydir) tb_directory_remove(path); - // trace tb_trace_d("path: %s, emptydir: %u", path, is_emptydir); - // ok? lua_pushboolean(lua, !tb_file_info(path, tb_null)); } else { // os.rmdir(path) diff --git a/core/src/xmake/os/rmfile.c b/core/src/xmake/os/rmfile.c index f4b204e25..2032d4ee2 100644 --- a/core/src/xmake/os/rmfile.c +++ b/core/src/xmake/os/rmfile.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_rmfile(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/os/setenv.c b/core/src/xmake/os/setenv.c index 99a9bf44e..be375b2f4 100644 --- a/core/src/xmake/os/setenv.c +++ b/core/src/xmake/os/setenv.c @@ -35,7 +35,6 @@ */ // ok = os.setenv(name, value) tb_int_t xm_os_setenv(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the name and value diff --git a/core/src/xmake/os/signal.c b/core/src/xmake/os/signal.c index c1f43ad6b..4d9e8a4c5 100644 --- a/core/src/xmake/os/signal.c +++ b/core/src/xmake/os/signal.c @@ -101,7 +101,6 @@ static tb_void_t xm_os_signal_handler(tb_int_t signo_native) { * implementation */ tb_int_t xm_os_signal(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); g_lua = lua; tb_int_t handler = XM_OS_SIGFUN; diff --git a/core/src/xmake/os/strerror.c b/core/src/xmake/os/strerror.c index 955ca8e24..c1ae41039 100644 --- a/core/src/xmake/os/strerror.c +++ b/core/src/xmake/os/strerror.c @@ -40,7 +40,6 @@ * implementation */ tb_int_t xm_os_strerror(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get syserror state diff --git a/core/src/xmake/os/syserror.c b/core/src/xmake/os/syserror.c index b96a9894f..3ef2a5c52 100644 --- a/core/src/xmake/os/syserror.c +++ b/core/src/xmake/os/syserror.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_syserror(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get syserror state diff --git a/core/src/xmake/os/tmpdir.c b/core/src/xmake/os/tmpdir.c index 68b99ee8f..4396603d4 100644 --- a/core/src/xmake/os/tmpdir.c +++ b/core/src/xmake/os/tmpdir.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_tmpdir(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // os.tmpdir() diff --git a/core/src/xmake/os/touch.c b/core/src/xmake/os/touch.c index 4e0bd5af8..5c470440b 100644 --- a/core/src/xmake/os/touch.c +++ b/core/src/xmake/os/touch.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_os_touch(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_char_t const *path = luaL_checkstring(lua, 1); diff --git a/core/src/xmake/os/uid.c b/core/src/xmake/os/uid.c index b6413a5e5..2785437d0 100644 --- a/core/src/xmake/os/uid.c +++ b/core/src/xmake/os/uid.c @@ -41,7 +41,6 @@ // get & set uid tb_int_t xm_os_uid(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_int_t ruidset = -1; @@ -124,7 +123,6 @@ tb_int_t xm_os_uid(lua_State *lua) { lua_pushinteger(lua, euid); lua_settable(lua, -3); - // ok return 1; } diff --git a/core/src/xmake/package/loadxmi.c b/core/src/xmake/package/loadxmi.c index 894141414..15a579f91 100644 --- a/core/src/xmake/package/loadxmi.c +++ b/core/src/xmake/package/loadxmi.c @@ -43,7 +43,6 @@ typedef int (*xm_setup_func_t)(xmi_lua_ops_t *ops); * implementation */ tb_int_t xm_package_loadxmi(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_char_t const *path = luaL_checkstring(lua, 1); diff --git a/core/src/xmake/path/absolute.c b/core/src/xmake/path/absolute.c index 781d2f5e4..9b05bc07d 100644 --- a/core/src/xmake/path/absolute.c +++ b/core/src/xmake/path/absolute.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_path_absolute(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/path/directory.c b/core/src/xmake/path/directory.c index aca226a89..0c7d77f2d 100644 --- a/core/src/xmake/path/directory.c +++ b/core/src/xmake/path/directory.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_path_directory(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/path/is_absolute.c b/core/src/xmake/path/is_absolute.c index 120476242..7ac489e26 100644 --- a/core/src/xmake/path/is_absolute.c +++ b/core/src/xmake/path/is_absolute.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_path_is_absolute(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/path/relative.c b/core/src/xmake/path/relative.c index c6ddad14d..5d3beaaa5 100644 --- a/core/src/xmake/path/relative.c +++ b/core/src/xmake/path/relative.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_path_relative(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/path/translate.c b/core/src/xmake/path/translate.c index 422cd0320..7611d188a 100644 --- a/core/src/xmake/path/translate.c +++ b/core/src/xmake/path/translate.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_path_translate(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the path diff --git a/core/src/xmake/process/close.c b/core/src/xmake/process/close.c index 272a02259..fc57453e6 100644 --- a/core/src/xmake/process/close.c +++ b/core/src/xmake/process/close.c @@ -36,7 +36,6 @@ // process.close(p) tb_int_t xm_process_close(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/process/kill.c b/core/src/xmake/process/kill.c index 7eb4f8fd7..4859027b4 100644 --- a/core/src/xmake/process/kill.c +++ b/core/src/xmake/process/kill.c @@ -36,7 +36,6 @@ // process.kill(p) tb_int_t xm_process_kill(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/process/open.c b/core/src/xmake/process/open.c index 8ed62a0cd..f0885719a 100644 --- a/core/src/xmake/process/open.c +++ b/core/src/xmake/process/open.c @@ -42,7 +42,6 @@ * envs = {"PATH=xxx", "XXX=yyy"}}) */ tb_int_t xm_process_open(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get command diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c index e605822b1..99a6133d0 100644 --- a/core/src/xmake/process/openv.c +++ b/core/src/xmake/process/openv.c @@ -46,7 +46,6 @@ * envs = {"PATH=xxx", "XXX=yyy"}}) */ tb_int_t xm_process_openv(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // check argv @@ -323,6 +322,5 @@ tb_int_t xm_process_openv(lua_State *lua) { tb_free(argv); argv = tb_null; - // ok return 1; } diff --git a/core/src/xmake/process/wait.c b/core/src/xmake/process/wait.c index 2914d87cc..84d3b7079 100644 --- a/core/src/xmake/process/wait.c +++ b/core/src/xmake/process/wait.c @@ -36,7 +36,6 @@ // ok, status = process.wait(proc, timeout) tb_int_t xm_process_wait(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? @@ -62,6 +61,5 @@ tb_int_t xm_process_wait(lua_State *lua) { lua_pushinteger(lua, ok); lua_pushinteger(lua, status); - // ok return 2; } diff --git a/core/src/xmake/readline/add_history.c b/core/src/xmake/readline/add_history.c index f928cc446..8f0c1cf4d 100644 --- a/core/src/xmake/readline/add_history.c +++ b/core/src/xmake/readline/add_history.c @@ -37,7 +37,6 @@ // add_history wrapper tb_int_t xm_readline_add_history(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get history @@ -47,7 +46,6 @@ tb_int_t xm_readline_add_history(lua_State *lua) { // call add_history add_history(history); - // ok return 0; } #endif diff --git a/core/src/xmake/readline/clear_history.c b/core/src/xmake/readline/clear_history.c index 11f7ab30c..0235ea4ee 100644 --- a/core/src/xmake/readline/clear_history.c +++ b/core/src/xmake/readline/clear_history.c @@ -37,7 +37,6 @@ // clear_history wrapper tb_int_t xm_readline_clear_history(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); #ifdef TB_CONFIG_OS_MACOSX @@ -48,7 +47,6 @@ tb_int_t xm_readline_clear_history(lua_State *lua) { clear_history(); #endif - // ok return 0; } diff --git a/core/src/xmake/readline/history_list.c b/core/src/xmake/readline/history_list.c index 56d84e114..45267edd5 100644 --- a/core/src/xmake/readline/history_list.c +++ b/core/src/xmake/readline/history_list.c @@ -37,7 +37,6 @@ // history_list wrapper tb_int_t xm_readline_history_list(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // history list @@ -70,7 +69,6 @@ tb_int_t xm_readline_history_list(lua_State *lua) { } #endif - // ok return 1; } diff --git a/core/src/xmake/readline/readline.c b/core/src/xmake/readline/readline.c index 6675c6de2..b6988e35c 100644 --- a/core/src/xmake/readline/readline.c +++ b/core/src/xmake/readline/readline.c @@ -38,7 +38,6 @@ // readline wrapper tb_int_t xm_readline_readline(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the prompt @@ -55,7 +54,6 @@ tb_int_t xm_readline_readline(lua_State *lua) { } else lua_pushnil(lua); - // ok return 1; } diff --git a/core/src/xmake/sandbox/interactive.c b/core/src/xmake/sandbox/interactive.c index 01bac19b4..9e94f876d 100644 --- a/core/src/xmake/sandbox/interactive.c +++ b/core/src/xmake/sandbox/interactive.c @@ -121,7 +121,6 @@ static tb_int_t xm_sandbox_docall(lua_State *lua, tb_int_t narg, tb_int_t clear) if (status != 0) lua_gc(lua, LUA_GCCOLLECT, 0); - // ok? return status; } @@ -158,7 +157,6 @@ static tb_size_t xm_sandbox_readline(tb_char_t *data, tb_size_t maxn, tb_char_t if (size >= maxn) return 0; - // ok return size; } #else @@ -189,7 +187,6 @@ static tb_int_t xm_sandbox_pushline(lua_State *lua, tb_char_t const *prompt2) { // push line lua_pushstring(lua, data); - // ok return 1; } @@ -228,7 +225,6 @@ static tb_int_t xm_sandbox_loadline(lua_State *lua, tb_int_t top) { // attempt to load "return ..." status = luaL_loadbuffer(lua, data, size + 7, "=stdin"); - // ok? if (status != LUA_ERRSYNTAX) return status; @@ -292,7 +288,6 @@ static tb_int_t xm_sandbox_loadline(lua_State *lua, tb_int_t top) { // sandbox.interactive() tb_int_t xm_sandbox_interactive(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); /* get init stack top @@ -358,6 +353,5 @@ tb_int_t xm_sandbox_interactive(lua_State *lua) { tb_printl(""); tb_print_sync(); - // end return 0; } diff --git a/core/src/xmake/semver/compare.c b/core/src/xmake/semver/compare.c index 87e2356a3..8310b73fc 100644 --- a/core/src/xmake/semver/compare.c +++ b/core/src/xmake/semver/compare.c @@ -36,7 +36,6 @@ // semver.compare("v1.0.1-beta", "1.2") > 0? tb_int_t xm_semver_compare(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the version1 string @@ -66,7 +65,6 @@ tb_int_t xm_semver_compare(lua_State *lua) { // do compare lua_pushinteger(lua, semver_pcmp(&semver1, &semver2)); - // end semver_dtor(&semver1); semver_dtor(&semver2); return 1; diff --git a/core/src/xmake/semver/parse.c b/core/src/xmake/semver/parse.c index e9dc221ee..63bd47f93 100644 --- a/core/src/xmake/semver/parse.c +++ b/core/src/xmake/semver/parse.c @@ -55,7 +55,6 @@ * */ tb_int_t xm_semver_parse(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the version string @@ -70,7 +69,6 @@ tb_int_t xm_semver_parse(lua_State *lua) { return 2; } - // ok lua_pushsemver(lua, &semver); semver_dtor(&semver); return 1; diff --git a/core/src/xmake/semver/satisfies.c b/core/src/xmake/semver/satisfies.c index 55c0decb9..a7c47f4fa 100644 --- a/core/src/xmake/semver/satisfies.c +++ b/core/src/xmake/semver/satisfies.c @@ -39,7 +39,6 @@ * semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') => true */ tb_int_t xm_semver_satisfies(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the version string diff --git a/core/src/xmake/semver/select.c b/core/src/xmake/semver/select.c index 373a71711..7109bfc83 100644 --- a/core/src/xmake/semver/select.c +++ b/core/src/xmake/semver/select.c @@ -75,7 +75,6 @@ static tb_bool_t xm_semver_select_from_versions_tags1( // exit the popped semver semver_dtor(&top); - // ok return tb_true; } static tb_bool_t xm_semver_select_from_versions_tags2( @@ -173,7 +172,6 @@ static tb_bool_t xm_semver_select_latest_from_versions_tags(lua_State *lua, * local versioninfo, errors = semver.select(">=1.5.0 <1.6", {"1.5.0", "1.5.1"}, {"v1.5.0", ..}, {"latest", "dev"}) */ tb_int_t xm_semver_select(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // select version @@ -260,6 +258,5 @@ tb_int_t xm_semver_select(lua_State *lua) { return 2; } - // ok return 1; } diff --git a/core/src/xmake/semver/semver.c b/core/src/xmake/semver/semver.c index 4fe48e5e9..bd13828fa 100644 --- a/core/src/xmake/semver/semver.c +++ b/core/src/xmake/semver/semver.c @@ -34,7 +34,6 @@ * implementation */ tb_void_t lua_pushsemver(lua_State *lua, semver_t const *semver) { - // check tb_assert(lua && semver); // return a semver table diff --git a/core/src/xmake/string/convert.c b/core/src/xmake/string/convert.c index 65750d95e..88dc5ceb1 100644 --- a/core/src/xmake/string/convert.c +++ b/core/src/xmake/string/convert.c @@ -98,7 +98,6 @@ static xm_charset_entry_ref_t xm_string_charset_find_by_name(tb_char_t const *na * @endcode */ tb_int_t xm_string_convert(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the string and charset types @@ -137,6 +136,5 @@ tb_int_t xm_string_convert(lua_State *lua) { tb_free(dst_data); } - // ok return 1; } diff --git a/core/src/xmake/string/endswith.c b/core/src/xmake/string/endswith.c index 5905610f6..f7e5e1805 100644 --- a/core/src/xmake/string/endswith.c +++ b/core/src/xmake/string/endswith.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_string_endswith(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the string and suffix @@ -47,6 +46,5 @@ tb_int_t xm_string_endswith(lua_State *lua) { // string:endswith(suffix)? lua_pushboolean(lua, string_size >= suffix_size && !tb_strcmp(string + string_size - suffix_size, suffix)); - // ok return 1; } diff --git a/core/src/xmake/string/lastof.c b/core/src/xmake/string/lastof.c index c9df2213d..0d52e01ac 100644 --- a/core/src/xmake/string/lastof.c +++ b/core/src/xmake/string/lastof.c @@ -71,7 +71,6 @@ static tb_void_t xm_string_lastof_chr(lua_State *lua, tb_char_t const *cstr, tb_ * @param substr the substring */ tb_int_t xm_string_lastof(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get string diff --git a/core/src/xmake/string/split.c b/core/src/xmake/string/split.c index be2904f99..56e8a636d 100644 --- a/core/src/xmake/string/split.c +++ b/core/src/xmake/string/split.c @@ -101,7 +101,6 @@ static tb_void_t xm_string_split_chr( * @param limit the limit count */ tb_int_t xm_string_split(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get string diff --git a/core/src/xmake/string/startswith.c b/core/src/xmake/string/startswith.c index c7fe9dcca..04b53ffa7 100644 --- a/core/src/xmake/string/startswith.c +++ b/core/src/xmake/string/startswith.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_string_startswith(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the string and prefix @@ -46,6 +45,5 @@ tb_int_t xm_string_startswith(lua_State *lua) { // string:startswith(prefix)? lua_pushboolean(lua, !tb_strncmp(string, prefix, (tb_size_t)prefix_size)); - // ok return 1; } diff --git a/core/src/xmake/string/trim.c b/core/src/xmake/string/trim.c index d22f86666..c1dcdad8d 100644 --- a/core/src/xmake/string/trim.c +++ b/core/src/xmake/string/trim.c @@ -34,7 +34,6 @@ * private implementation */ static tb_void_t xm_string_trim_space(tb_char_t const **psstr, tb_char_t const **pestr, tb_int_t mode) { - // check tb_assert(psstr && pestr && *psstr && *pestr); tb_char_t const *p = *psstr; @@ -62,7 +61,6 @@ static tb_char_t const *xm_string_ltrim(tb_char_t const *sstr, tb_char_t const *estr, tb_char_t const *ctrim, size_t ntrim) { - // check tb_assert(sstr && estr && ctrim); tb_char_t const *p = sstr; @@ -75,7 +73,6 @@ static tb_char_t const *xm_string_rtrim(tb_char_t const *sstr, tb_char_t const *estr, tb_char_t const *ctrim, size_t ntrim) { - // check tb_assert(sstr && estr && ctrim); tb_char_t const *p = estr - 1; @@ -100,7 +97,6 @@ static tb_char_t const *xm_string_rtrim(tb_char_t const *sstr, * @endcode */ tb_int_t xm_string_trim(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); size_t lstr, ltrim; @@ -127,7 +123,6 @@ tb_int_t xm_string_trim(lua_State *lua) { // no trimed chars tb_check_break(sstr != rsstr || estr != restr); - // ok lua_pushlstring(lua, sstr, estr - sstr); return 1; diff --git a/core/src/xmake/thread/thread_exit.c b/core/src/xmake/thread/thread_exit.c index a91018ac6..ae828805e 100644 --- a/core/src/xmake/thread/thread_exit.c +++ b/core/src/xmake/thread/thread_exit.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_thread_exit(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/thread/thread_init.c b/core/src/xmake/thread/thread_init.c index 60d694ae1..2a792463a 100644 --- a/core/src/xmake/thread/thread_init.c +++ b/core/src/xmake/thread/thread_init.c @@ -81,7 +81,6 @@ static tb_int_t xm_thread_func(tb_cpointer_t priv) { * implementation */ tb_int_t xm_thread_init(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_bool_t ok = tb_false; diff --git a/core/src/xmake/thread/thread_resume.c b/core/src/xmake/thread/thread_resume.c index 9a3630338..45253b418 100644 --- a/core/src/xmake/thread/thread_resume.c +++ b/core/src/xmake/thread/thread_resume.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_thread_resume(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/thread/thread_suspend.c b/core/src/xmake/thread/thread_suspend.c index dcb24c4f6..1df3063ef 100644 --- a/core/src/xmake/thread/thread_suspend.c +++ b/core/src/xmake/thread/thread_suspend.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_thread_suspend(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/thread/thread_wait.c b/core/src/xmake/thread/thread_wait.c index 4a921f39c..8ceb45524 100644 --- a/core/src/xmake/thread/thread_wait.c +++ b/core/src/xmake/thread/thread_wait.c @@ -34,7 +34,6 @@ * implementation */ tb_int_t xm_thread_wait(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // is pointer? diff --git a/core/src/xmake/tty/term_mode.c b/core/src/xmake/tty/term_mode.c index 78380de5f..34998c60b 100644 --- a/core/src/xmake/tty/term_mode.c +++ b/core/src/xmake/tty/term_mode.c @@ -41,7 +41,6 @@ * local oldmode = tty.term_mode(stdtype, newmode) */ tb_int_t xm_tty_term_mode(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); #ifdef TB_CONFIG_OS_WINDOWS diff --git a/core/src/xmake/utils/bin2c.c b/core/src/xmake/utils/bin2c.c index fef00fb4e..77a1b2a8c 100644 --- a/core/src/xmake/utils/bin2c.c +++ b/core/src/xmake/utils/bin2c.c @@ -101,7 +101,6 @@ static tb_bool_t xm_utils_bin2c_dump(tb_stream_ref_t istream, * local ok, errors = utils.bin2c(binaryfile, outputfile, linewidth, nozeroend) */ tb_int_t xm_utils_bin2c(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the binaryfile diff --git a/core/src/xmake/winos/ansi.c b/core/src/xmake/winos/ansi.c index 137f18742..48bb9df82 100644 --- a/core/src/xmake/winos/ansi.c +++ b/core/src/xmake/winos/ansi.c @@ -36,7 +36,6 @@ */ static tb_int_t xm_expand_cp(tb_int_t cp) { - // check tb_assert_and_check_return_val(cp >= 0 && cp <= 65535, 0); if (cp == CP_OEMCP) @@ -47,7 +46,6 @@ static tb_int_t xm_expand_cp(tb_int_t cp) { } tb_int_t xm_winos_console_cp(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_int_t n = lua_gettop(lua); @@ -66,7 +64,6 @@ tb_int_t xm_winos_console_cp(lua_State *lua) { } tb_int_t xm_winos_console_output_cp(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_int_t n = lua_gettop(lua); @@ -85,7 +82,6 @@ tb_int_t xm_winos_console_output_cp(lua_State *lua) { } tb_int_t xm_winos_cp_info(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); lua_Integer cp = luaL_checkinteger(lua, 1); @@ -138,7 +134,6 @@ tb_int_t xm_winos_cp_info(lua_State *lua) { } tb_int_t xm_winos_ansi_cp(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_uint_t cp = GetACP(); @@ -147,7 +142,6 @@ tb_int_t xm_winos_ansi_cp(lua_State *lua) { } tb_int_t xm_winos_oem_cp(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); tb_uint_t cp = GetOEMCP(); diff --git a/core/src/xmake/winos/logical_drives.c b/core/src/xmake/winos/logical_drives.c index 48b05886e..7227069b9 100644 --- a/core/src/xmake/winos/logical_drives.c +++ b/core/src/xmake/winos/logical_drives.c @@ -73,6 +73,5 @@ tb_int_t xm_winos_logical_drives(lua_State *lua) { tb_free(data); data = tb_null; - // ok return 1; } diff --git a/core/src/xmake/winos/registry_keys.c b/core/src/xmake/winos/registry_keys.c index 42a37e33d..7daf44ff4 100644 --- a/core/src/xmake/winos/registry_keys.c +++ b/core/src/xmake/winos/registry_keys.c @@ -168,7 +168,6 @@ static tb_void_t xm_winos_registry_enum_keys(xm_winos_registry_enum_info_t *info * end) */ tb_int_t xm_winos_registry_keys(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the arguments @@ -231,7 +230,6 @@ tb_int_t xm_winos_registry_keys(lua_State *lua) { } while (0); - // ok? if (ok) { lua_pushinteger(lua, count); return 1; diff --git a/core/src/xmake/winos/registry_query.c b/core/src/xmake/winos/registry_query.c index 23fda76ff..5e98af2cd 100644 --- a/core/src/xmake/winos/registry_query.c +++ b/core/src/xmake/winos/registry_query.c @@ -46,7 +46,6 @@ typedef BOOL(WINAPI *xm_RegGetValueW_t)( * local value, errors = winos.registry_query("HKEY_LOCAL_MACHINE", "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug", "Debugger") */ tb_int_t xm_winos_registry_query(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the arguments @@ -226,6 +225,5 @@ tb_int_t xm_winos_registry_query(lua_State *lua) { tb_free(value_w); value_w = tb_null; - // ok? return ok ? 1 : 2; } diff --git a/core/src/xmake/winos/registry_values.c b/core/src/xmake/winos/registry_values.c index 1f72d978b..6bda8e690 100644 --- a/core/src/xmake/winos/registry_values.c +++ b/core/src/xmake/winos/registry_values.c @@ -43,7 +43,6 @@ * end) */ tb_int_t xm_winos_registry_values(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the arguments @@ -156,7 +155,6 @@ tb_int_t xm_winos_registry_values(lua_State *lua) { } } - // ok if (i == value_name_num) ok = tb_true; @@ -167,7 +165,6 @@ tb_int_t xm_winos_registry_values(lua_State *lua) { RegCloseKey(keynew); keynew = tb_null; - // ok? if (ok) { lua_pushinteger(lua, count); return 1; diff --git a/core/src/xmake/winos/short_path.c b/core/src/xmake/winos/short_path.c index 5c6e20b30..9c2192787 100644 --- a/core/src/xmake/winos/short_path.c +++ b/core/src/xmake/winos/short_path.c @@ -39,7 +39,6 @@ * local short_path, errors = winos.short_path(long_path) */ tb_int_t xm_winos_short_path(lua_State *lua) { - // check tb_assert_and_check_return_val(lua, 0); // get the arguments diff --git a/core/src/xmake/xmake.c b/core/src/xmake/xmake.c index 89b288c79..8d4a77284 100644 --- a/core/src/xmake/xmake.c +++ b/core/src/xmake/xmake.c @@ -52,7 +52,6 @@ static __tb_inline__ tb_bool_t xm_check_mode(tb_size_t mode) { } #endif - // ok return tb_true; } static __tb_inline__ tb_bool_t xm_version_check(tb_hize_t build) { @@ -60,7 +59,6 @@ static __tb_inline__ tb_bool_t xm_version_check(tb_hize_t build) { tb_version_t const *version = xm_version(); tb_used(version); - // ok if ((build / 100) == (XM_VERSION_BUILD / 100)) { tb_trace_d("version: %s", XM_VERSION_STRING); return tb_true; @@ -76,7 +74,6 @@ static __tb_inline__ tb_bool_t xm_version_check(tb_hize_t build) { * implementation */ tb_bool_t xm_init_(tb_size_t mode, tb_hize_t build) { - // trace tb_trace_d("init: .."); // check mode @@ -95,10 +92,8 @@ tb_bool_t xm_init_(tb_size_t mode, tb_hize_t build) { return tb_false; #endif - // trace tb_trace_d("init: ok"); - // ok return tb_true; } tb_void_t xm_exit() { -- cgit v1.3.1 From 2c387895657ae13cd717d7f42f5baed5eb028a8e Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 10 Nov 2025 21:00:21 +0800 Subject: format more if-else codes in core --- core/src/xmake/path/directory.c | 5 ++-- core/src/xmake/path/translate.c | 8 ++++--- core/src/xmake/process/close.c | 3 ++- core/src/xmake/process/kill.c | 3 ++- core/src/xmake/process/open.c | 15 +++++++----- core/src/xmake/process/openv.c | 27 ++++++++++++++-------- core/src/xmake/readline/clear_history.c | 3 ++- core/src/xmake/readline/readline.c | 3 ++- core/src/xmake/sandbox/interactive.c | 39 +++++++++++++++++++++----------- core/src/xmake/semver/select.c | 8 ++++--- core/src/xmake/semver/semver.c | 10 ++++---- core/src/xmake/string/convert.c | 12 ++++++---- core/src/xmake/string/lastof.c | 15 +++++++----- core/src/xmake/string/split.c | 11 +++++---- core/src/xmake/string/trim.c | 25 ++++++++++++-------- core/src/xmake/thread/event_exit.c | 2 +- core/src/xmake/thread/event_incref.c | 2 +- core/src/xmake/thread/event_post.c | 2 +- core/src/xmake/thread/event_wait.c | 2 +- core/src/xmake/thread/mutex_exit.c | 2 +- core/src/xmake/thread/mutex_incref.c | 2 +- core/src/xmake/thread/mutex_lock.c | 2 +- core/src/xmake/thread/mutex_trylock.c | 2 +- core/src/xmake/thread/mutex_unlock.c | 2 +- core/src/xmake/thread/prefix.h | 25 ++++++++++++-------- core/src/xmake/thread/queue_clear.c | 2 +- core/src/xmake/thread/queue_exit.c | 2 +- core/src/xmake/thread/queue_incref.c | 2 +- core/src/xmake/thread/queue_init.c | 3 ++- core/src/xmake/thread/queue_pop.c | 7 +++--- core/src/xmake/thread/queue_push.c | 2 +- core/src/xmake/thread/queue_size.c | 2 +- core/src/xmake/thread/semaphore_exit.c | 2 +- core/src/xmake/thread/semaphore_incref.c | 2 +- core/src/xmake/thread/semaphore_post.c | 2 +- core/src/xmake/thread/semaphore_wait.c | 2 +- core/src/xmake/thread/sharedata_clear.c | 2 +- core/src/xmake/thread/sharedata_exit.c | 2 +- core/src/xmake/thread/sharedata_get.c | 2 +- core/src/xmake/thread/sharedata_incref.c | 2 +- core/src/xmake/thread/sharedata_set.c | 2 +- core/src/xmake/thread/thread_resume.c | 3 ++- core/src/xmake/thread/thread_suspend.c | 3 ++- core/src/xmake/thread/thread_wait.c | 3 ++- core/src/xmake/tty/term_mode.c | 3 ++- core/src/xmake/utils/bin2c.c | 3 ++- core/src/xmake/winos/ansi.c | 6 +++-- core/src/xmake/winos/logical_drives.c | 3 ++- core/src/xmake/winos/registry_keys.c | 32 ++++++++++++++------------ core/src/xmake/winos/registry_query.c | 29 +++++++++++++----------- core/src/xmake/winos/registry_values.c | 26 +++++++++++---------- 51 files changed, 226 insertions(+), 153 deletions(-) (limited to 'core/src/xmake/string') diff --git a/core/src/xmake/path/directory.c b/core/src/xmake/path/directory.c index 0c7d77f2d..7a6b37863 100644 --- a/core/src/xmake/path/directory.c +++ b/core/src/xmake/path/directory.c @@ -43,9 +43,10 @@ tb_int_t xm_path_directory(lua_State *lua) { // do path:directory() tb_char_t data[TB_PATH_MAXN]; tb_char_t const *dir = tb_path_directory(path, data, sizeof(data)); - if (dir) + if (dir) { lua_pushstring(lua, dir); - else + } else { lua_pushnil(lua); + } return 1; } diff --git a/core/src/xmake/path/translate.c b/core/src/xmake/path/translate.c index 7611d188a..8d1debda0 100644 --- a/core/src/xmake/path/translate.c +++ b/core/src/xmake/path/translate.c @@ -46,17 +46,19 @@ tb_int_t xm_path_translate(lua_State *lua) { 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) + if (size) { lua_pushlstring(lua, data, (size_t)size); - else + } else { lua_pushnil(lua); + } return 1; } diff --git a/core/src/xmake/process/close.c b/core/src/xmake/process/close.c index fc57453e6..bd39d49ee 100644 --- a/core/src/xmake/process/close.c +++ b/core/src/xmake/process/close.c @@ -39,8 +39,9 @@ tb_int_t xm_process_close(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // is pointer? - if (!xm_lua_ispointer(lua, 1)) + if (!xm_lua_ispointer(lua, 1)) { return 0; + } // get the process tb_process_ref_t process = (tb_process_ref_t)xm_lua_topointer(lua, 1); diff --git a/core/src/xmake/process/kill.c b/core/src/xmake/process/kill.c index 4859027b4..21cc68149 100644 --- a/core/src/xmake/process/kill.c +++ b/core/src/xmake/process/kill.c @@ -39,8 +39,9 @@ tb_int_t xm_process_kill(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // is pointer? - if (!xm_lua_ispointer(lua, 1)) + if (!xm_lua_ispointer(lua, 1)) { return 0; + } // get the process tb_process_ref_t process = (tb_process_ref_t)xm_lua_topointer(lua, 1); diff --git a/core/src/xmake/process/open.c b/core/src/xmake/process/open.c index f0885719a..669e90ff1 100644 --- a/core/src/xmake/process/open.c +++ b/core/src/xmake/process/open.c @@ -68,8 +68,9 @@ tb_int_t xm_process_open(lua_State *lua) { // is detached? lua_pushstring(lua, "detach"); lua_gettable(lua, 2); - if (lua_toboolean(lua, -1)) + if (lua_toboolean(lua, -1)) { attr.flags |= TB_PROCESS_FLAG_DETACH; + } lua_pop(lua, 1); // get curdir @@ -161,9 +162,9 @@ tb_int_t xm_process_open(lua_State *lua) { // is string? if (lua_isstring(lua, -1)) { // add this environment value - if (envn + 1 < tb_arrayn(envs)) + if (envn + 1 < tb_arrayn(envs)) { envs[envn++] = lua_tostring(lua, -1); - else { + } else { // error lua_pushfstring(lua, "envs is too large(%d > %d) for process.openv", @@ -239,14 +240,16 @@ tb_int_t xm_process_open(lua_State *lua) { } // set the new environments - if (envn > 0) + if (envn > 0) { attr.envp = envs; + } // init process tb_process_ref_t process = (tb_process_ref_t)tb_process_init_cmd(command, &attr); - if (process) + if (process) { xm_lua_pushpointer(lua, (tb_pointer_t)process); - else + } else { lua_pushnil(lua); + } return 1; } diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c index 99a6133d0..1b95c45fe 100644 --- a/core/src/xmake/process/openv.c +++ b/core/src/xmake/process/openv.c @@ -117,15 +117,17 @@ tb_int_t xm_process_openv(lua_State *lua) { // is detached? lua_pushstring(lua, "detach"); lua_gettable(lua, 3); - if (lua_toboolean(lua, -1)) + if (lua_toboolean(lua, -1)) { attr.flags |= TB_PROCESS_FLAG_DETACH; + } lua_pop(lua, 1); // is exclusive? lua_pushstring(lua, "exclusive"); lua_gettable(lua, 3); - if (lua_toboolean(lua, -1)) + if (lua_toboolean(lua, -1)) { exclusive = tb_true; + } lua_pop(lua, 1); // get curdir @@ -217,9 +219,9 @@ tb_int_t xm_process_openv(lua_State *lua) { // is string? if (lua_isstring(lua, -1)) { // add this environment value - if (envn + 1 < tb_arrayn(envs)) + if (envn + 1 < tb_arrayn(envs)) { envs[envn++] = lua_tostring(lua, -1); - else { + } else { // error lua_pushfstring(lua, "envs is too large(%d > %d) for process.openv", @@ -295,31 +297,36 @@ tb_int_t xm_process_openv(lua_State *lua) { } // set the new environments - if (envn > 0) + if (envn > 0) { attr.envp = envs; + } /* we need to ignore SIGINT and SIGQUIT if we enter exclusive mode * @see https://github.com/xmake-io/xmake/discussions/2893 */ #if defined(SIGINT) - if (exclusive) + if (exclusive) { signal(SIGINT, SIG_IGN); + } #endif #if defined(SIGQUIT) - if (exclusive) + if (exclusive) { signal(SIGQUIT, SIG_IGN); + } #endif // init process tb_process_ref_t process = (tb_process_ref_t)tb_process_init(shellname, argv, &attr); - if (process) + if (process) { xm_lua_pushpointer(lua, (tb_pointer_t)process); - else + } else { lua_pushnil(lua); + } // exit argv - if (argv) + if (argv) { tb_free(argv); + } argv = tb_null; return 1; diff --git a/core/src/xmake/readline/clear_history.c b/core/src/xmake/readline/clear_history.c index 0235ea4ee..d29690bea 100644 --- a/core/src/xmake/readline/clear_history.c +++ b/core/src/xmake/readline/clear_history.c @@ -41,8 +41,9 @@ tb_int_t xm_readline_clear_history(lua_State *lua) { #ifdef TB_CONFIG_OS_MACOSX // call clear_history (will crash on macOS) - for (tb_int_t i = history_length - 1; i >= 0; --i) + for (tb_int_t i = history_length - 1; i >= 0; --i) { remove_history(i); + } #else clear_history(); #endif diff --git a/core/src/xmake/readline/readline.c b/core/src/xmake/readline/readline.c index b6988e35c..fa3e631cc 100644 --- a/core/src/xmake/readline/readline.c +++ b/core/src/xmake/readline/readline.c @@ -51,8 +51,9 @@ tb_int_t xm_readline_readline(lua_State *lua) { // free it tb_free(line); - } else + } else { lua_pushnil(lua); + } return 1; } diff --git a/core/src/xmake/sandbox/interactive.c b/core/src/xmake/sandbox/interactive.c index 9e94f876d..ac3566577 100644 --- a/core/src/xmake/sandbox/interactive.c +++ b/core/src/xmake/sandbox/interactive.c @@ -65,8 +65,9 @@ static tb_void_t xm_sandbox_report(lua_State *lua) { if (!lua_isnil(lua, -1)) { // get message tb_char_t const *msg = lua_tostring(lua, -1); - if (!msg) + if (!msg) { msg = "(error object is not a string)"; + } // print it tb_printl(msg); @@ -81,8 +82,9 @@ static tb_void_t xm_sandbox_report(lua_State *lua) { static tb_int_t xm_sandbox_traceback(lua_State *lua) { if (!lua_isstring(lua, 1)) { // non-string error object? try metamethod. - if (lua_isnoneornil(lua, 1) || !luaL_callmeta(lua, 1, "__tostring") || !lua_isstring(lua, -1)) + if (lua_isnoneornil(lua, 1) || !luaL_callmeta(lua, 1, "__tostring") || !lua_isstring(lua, -1)) { return 1; // return non-string error object. + } // replace object by result of __tostring metamethod. lua_remove(lua, 1); @@ -118,8 +120,9 @@ static tb_int_t xm_sandbox_docall(lua_State *lua, tb_int_t narg, tb_int_t clear) lua_remove(lua, errfunc); // force a complete garbage collection in case of errors - if (status != 0) + if (status != 0) { lua_gc(lua, LUA_GCCOLLECT, 0); + } return status; } @@ -154,8 +157,9 @@ static tb_size_t xm_sandbox_readline(tb_char_t *data, tb_size_t maxn, tb_char_t free((void *)line); // truncated? - if (size >= maxn) + if (size >= maxn) { return 0; + } return size; } @@ -166,8 +170,9 @@ static tb_size_t xm_sandbox_readline(tb_char_t *data, tb_size_t maxn, tb_char_t tb_print_sync(); // get input buffer - if (tb_stdfile_gets(tb_stdfile_input(), data, maxn)) + if (tb_stdfile_gets(tb_stdfile_input(), data, maxn)) { return tb_strlen(data); + } #endif // no more input @@ -181,8 +186,9 @@ static tb_int_t xm_sandbox_pushline(lua_State *lua, tb_char_t const *prompt2) { tb_size_t size = xm_sandbox_readline(data, sizeof(data), prompt2); if (size) { // split line '\0' - if (data[size - 1] == '\n') + if (data[size - 1] == '\n') { data[size - 1] = '\0'; + } // push line lua_pushstring(lua, data); @@ -216,8 +222,9 @@ static tb_int_t xm_sandbox_loadline(lua_State *lua, tb_int_t top) { tb_size_t size = xm_sandbox_readline(data + 7, sizeof(data) - 7, prompt); if (size) { // split line '\0' - if (data[size - 1] == '\n') + if (data[size - 1] == '\n') { data[--size] = '\0'; + } // patch "return " tb_memcpy(data, "return ", 7); @@ -225,8 +232,9 @@ static tb_int_t xm_sandbox_loadline(lua_State *lua, tb_int_t top) { // attempt to load "return ..." status = luaL_loadbuffer(lua, data, size + 7, "=stdin"); - if (status != LUA_ERRSYNTAX) + if (status != LUA_ERRSYNTAX) { return status; + } // pop error msg lua_pop(lua, 1); @@ -246,12 +254,14 @@ static tb_int_t xm_sandbox_loadline(lua_State *lua, tb_int_t top) { status = luaL_loadbuffer(lua, lua_tostring(lua, -1), (size_t)lua_strlen(lua, -1), "=stdin"); // complete? - if (!xm_sandbox_incomplete(lua, status)) + if (!xm_sandbox_incomplete(lua, status)) { break; + } // get more input - if (!xm_sandbox_pushline(lua, prompt2)) + if (!xm_sandbox_pushline(lua, prompt2)) { return -1; + } // cancel multi-line input? if (!tb_strcmp(lua_tostring(lua, -1), "q")) { @@ -313,10 +323,11 @@ tb_int_t xm_sandbox_interactive(lua_State *lua) { lua_getfield(lua, 1, "$interactive_setfenv"); lua_pushvalue(lua, -2); lua_pushvalue(lua, 1); - if (lua_pcall(lua, 2, 0, 0) != 0) + if (lua_pcall(lua, 2, 0, 0) != 0) { tb_printl(lua_pushfstring(lua, "error calling " LUA_QL("$interactive_setfenv") " (%s)", lua_tostring(lua, -1))); + } #endif /* run script @@ -327,8 +338,9 @@ tb_int_t xm_sandbox_interactive(lua_State *lua) { } // report errors - if (status) + if (status) { xm_sandbox_report(lua); + } // print any results if (status == 0 && lua_gettop(lua) > top) { @@ -342,9 +354,10 @@ tb_int_t xm_sandbox_interactive(lua_State *lua) { */ lua_getfield(lua, 1, "$interactive_dump"); // load $interactive_dump() from sandbox_scope lua_insert(lua, -(count + 1)); - if (lua_pcall(lua, count, 0, 0) != 0) + if (lua_pcall(lua, count, 0, 0) != 0) { tb_printl( lua_pushfstring(lua, "error calling " LUA_QL("$interactive_dump") " (%s)", lua_tostring(lua, -1))); + } } } diff --git a/core/src/xmake/semver/select.c b/core/src/xmake/semver/select.c index 7109bfc83..de3904288 100644 --- a/core/src/xmake/semver/select.c +++ b/core/src/xmake/semver/select.c @@ -47,10 +47,11 @@ static tb_bool_t xm_semver_select_from_versions_tags1( tb_char_t const *source_str = luaL_checkstring(lua, -1); if (source_str && semver_tryn(semver, source_str, tb_strlen(source_str)) == 0) { - if (semver_range_pmatch(semver, range)) + if (semver_range_pmatch(semver, range)) { semvers_ppush(matches, *semver); - else + } else { semver_dtor(semver); + } } lua_pop(lua, 1); } @@ -138,8 +139,9 @@ static tb_bool_t xm_semver_select_latest_from_versions_tags(lua_State *lua, lua_gettable(lua, fromidx); tb_char_t const *source_str = luaL_checkstring(lua, -1); - if (source_str && semver_tryn(semver, source_str, tb_strlen(source_str)) == 0) + if (source_str && semver_tryn(semver, source_str, tb_strlen(source_str)) == 0) { semvers_ppush(matches, *semver); + } lua_pop(lua, 1); } diff --git a/core/src/xmake/semver/semver.c b/core/src/xmake/semver/semver.c index bd13828fa..201f83435 100644 --- a/core/src/xmake/semver/semver.c +++ b/core/src/xmake/semver/semver.c @@ -61,10 +61,11 @@ tb_void_t lua_pushsemver(lua_State *lua, semver_t const *semver) { tb_uchar_t i = 0; semver_id_t const *id = &semver->prerelease; while (id && id->len) { - if (id->numeric) + if (id->numeric) { lua_pushinteger(lua, id->num); - else + } else { lua_pushlstring(lua, id->raw, id->len); + } id = id->next; lua_rawseti(lua, -2, ++i); } @@ -76,10 +77,11 @@ tb_void_t lua_pushsemver(lua_State *lua, semver_t const *semver) { lua_newtable(lua); id = &semver->build; while (id && id->len) { - if (id->numeric) + if (id->numeric) { lua_pushinteger(lua, id->num); - else + } else { lua_pushlstring(lua, id->raw, id->len); + } id = id->next; lua_rawseti(lua, -2, ++i); } diff --git a/core/src/xmake/string/convert.c b/core/src/xmake/string/convert.c index 88dc5ceb1..b3adaf8b8 100644 --- a/core/src/xmake/string/convert.c +++ b/core/src/xmake/string/convert.c @@ -76,10 +76,11 @@ static xm_charset_entry_ref_t xm_string_charset_find_by_name(tb_char_t const *na // find it by the binary search tb_size_t itor = tb_binary_find_all_if(iterator, xm_string_charset_comp_by_name, name); - if (itor != tb_iterator_tail(iterator)) + if (itor != tb_iterator_tail(iterator)) { return (xm_charset_entry_ref_t)tb_iterator_item(iterator, itor); - else + } else { return tb_null; + } } /* ////////////////////////////////////////////////////////////////////////////////////// @@ -115,9 +116,9 @@ tb_int_t xm_string_convert(lua_State *lua) { tb_check_return_val(fcharset && tcharset, 0); // empty string? - if (!src_size) + if (!src_size) { lua_pushstring(lua, ""); - else { + } else { // convert string tb_long_t dst_size = 0; tb_size_t dst_maxn = (tb_size_t)src_size << 2; @@ -131,8 +132,9 @@ tb_int_t xm_string_convert(lua_State *lua) { dst_maxn)) >= 0 && dst_size < dst_maxn) { lua_pushlstring(lua, (tb_char_t const *)dst_data, dst_size); - } else + } else { lua_pushnil(lua); + } tb_free(dst_data); } diff --git a/core/src/xmake/string/lastof.c b/core/src/xmake/string/lastof.c index 0d52e01ac..8785e3987 100644 --- a/core/src/xmake/string/lastof.c +++ b/core/src/xmake/string/lastof.c @@ -48,17 +48,19 @@ static tb_void_t xm_string_lastof_str( } while (!next); // found? - if (curr) + if (curr) { lua_pushinteger(lua, curr - cstr + 1); - else + } else { lua_pushnil(lua); + } } static tb_void_t xm_string_lastof_chr(lua_State *lua, tb_char_t const *cstr, tb_size_t nstr, tb_char_t ch) { tb_char_t const *pos = tb_strrchr(cstr, ch); // faster than tb_strnrchr() - if (pos) + if (pos) { lua_pushinteger(lua, pos - cstr + 1); - else + } else { lua_pushnil(lua); + } } /* ////////////////////////////////////////////////////////////////////////////////////// @@ -83,9 +85,10 @@ tb_int_t xm_string_lastof(lua_State *lua) { // lastof it lua_newtable(lua); - if (nsubstr == 1) + if (nsubstr == 1) { xm_string_lastof_chr(lua, cstr, (tb_size_t)nstr, csubstr[0]); - else + } else { xm_string_lastof_str(lua, cstr, (tb_size_t)nstr, csubstr, nsubstr); + } return 1; } diff --git a/core/src/xmake/string/split.c b/core/src/xmake/string/split.c index 56e8a636d..5ca0c92bb 100644 --- a/core/src/xmake/string/split.c +++ b/core/src/xmake/string/split.c @@ -45,8 +45,9 @@ static tb_void_t xm_string_split_str(lua_State *lua, tb_char_t const *pos = tb_strstr(cstr, cdls); // faster than tb_strnstr() while (pos && pos < end) { if (pos > cstr || strict) { - if (limit > 0 && num + 1 >= limit) + if (limit > 0 && num + 1 >= limit) { break; + } lua_pushlstring(lua, cstr, pos - cstr); lua_rawseti(lua, -2, ++num); @@ -70,8 +71,9 @@ static tb_void_t xm_string_split_chr( tb_char_t const *pos = tb_strchr(cstr, ch); // faster than tb_strnchr() while (pos && pos < end) { if (pos > cstr || strict) { - if (limit > 0 && num + 1 >= limit) + if (limit > 0 && num + 1 >= limit) { break; + } lua_pushlstring(lua, cstr, pos - cstr); lua_rawseti(lua, -2, ++num); @@ -119,9 +121,10 @@ tb_int_t xm_string_split(lua_State *lua) { // split it lua_newtable(lua); - if (ndls == 1) + if (ndls == 1) { xm_string_split_chr(lua, cstr, (tb_size_t)nstr, cdls[0], strict, limit); - else + } else { xm_string_split_str(lua, cstr, (tb_size_t)nstr, cdls, ndls, strict, limit); + } return 1; } diff --git a/core/src/xmake/string/trim.c b/core/src/xmake/string/trim.c index c1dcdad8d..54e6e4b5a 100644 --- a/core/src/xmake/string/trim.c +++ b/core/src/xmake/string/trim.c @@ -40,15 +40,18 @@ static tb_void_t xm_string_trim_space(tb_char_t const **psstr, tb_char_t const * tb_char_t const *e = *pestr; // trim left? - if (mode <= 0) - while (p < e && tb_isspace(*p)) + if (mode <= 0) { + while (p < e && tb_isspace(*p)) { p++; + } + } // trim right if (mode >= 0) { e--; - while (e >= p && tb_isspace(*e)) + while (e >= p && tb_isspace(*e)) { e--; + } e++; } @@ -64,8 +67,9 @@ static tb_char_t const *xm_string_ltrim(tb_char_t const *sstr, tb_assert(sstr && estr && ctrim); tb_char_t const *p = sstr; - while (p < estr && tb_strnchr(ctrim, ntrim, *p)) + while (p < estr && tb_strnchr(ctrim, ntrim, *p)) { p++; + } return p; } @@ -76,8 +80,9 @@ static tb_char_t const *xm_string_rtrim(tb_char_t const *sstr, tb_assert(sstr && estr && ctrim); tb_char_t const *p = estr - 1; - while (p >= sstr && tb_strnchr(ctrim, ntrim, *p)) + while (p >= sstr && tb_strnchr(ctrim, ntrim, *p)) { p--; + } return p + 1; } @@ -110,14 +115,16 @@ tb_int_t xm_string_trim(lua_State *lua) { tb_char_t const *const rsstr = sstr; tb_char_t const *const restr = estr; - if (ltrim == 0) + if (ltrim == 0) { xm_string_trim_space(&sstr, &estr, trimtype); - else { + } else { // trim chars - if (trimtype <= 0) + if (trimtype <= 0) { sstr = xm_string_ltrim(sstr, estr, trimchars, ltrim); - if (trimtype >= 0) + } + if (trimtype >= 0) { estr = xm_string_rtrim(sstr, estr, trimchars, ltrim); + } } // no trimed chars diff --git a/core/src/xmake/thread/event_exit.c b/core/src/xmake/thread/event_exit.c index 501a72a8f..a9b16db6c 100644 --- a/core/src/xmake/thread/event_exit.c +++ b/core/src/xmake/thread/event_exit.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_event_exit.c + * @file event_exit.c * */ diff --git a/core/src/xmake/thread/event_incref.c b/core/src/xmake/thread/event_incref.c index 28c631056..9a2b6163a 100644 --- a/core/src/xmake/thread/event_incref.c +++ b/core/src/xmake/thread/event_incref.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_event_incref.c + * @file event_incref.c * */ diff --git a/core/src/xmake/thread/event_post.c b/core/src/xmake/thread/event_post.c index 0762f6af1..fea3fdd82 100644 --- a/core/src/xmake/thread/event_post.c +++ b/core/src/xmake/thread/event_post.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_event_lock.c + * @file event_post.c * */ diff --git a/core/src/xmake/thread/event_wait.c b/core/src/xmake/thread/event_wait.c index 73e476427..ae4453d5e 100644 --- a/core/src/xmake/thread/event_wait.c +++ b/core/src/xmake/thread/event_wait.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_event_wait.c + * @file event_wait.c * */ diff --git a/core/src/xmake/thread/mutex_exit.c b/core/src/xmake/thread/mutex_exit.c index f415de339..6d79e6197 100644 --- a/core/src/xmake/thread/mutex_exit.c +++ b/core/src/xmake/thread/mutex_exit.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_mutex_exit.c + * @file mutex_exit.c * */ diff --git a/core/src/xmake/thread/mutex_incref.c b/core/src/xmake/thread/mutex_incref.c index 3706ec276..d76f49daf 100644 --- a/core/src/xmake/thread/mutex_incref.c +++ b/core/src/xmake/thread/mutex_incref.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_mutex_incref.c + * @file mutex_incref.c * */ diff --git a/core/src/xmake/thread/mutex_lock.c b/core/src/xmake/thread/mutex_lock.c index f5e9154ae..711c3a07b 100644 --- a/core/src/xmake/thread/mutex_lock.c +++ b/core/src/xmake/thread/mutex_lock.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_mutex_lock.c + * @file mutex_lock.c * */ diff --git a/core/src/xmake/thread/mutex_trylock.c b/core/src/xmake/thread/mutex_trylock.c index fdc90e883..7149a2b62 100644 --- a/core/src/xmake/thread/mutex_trylock.c +++ b/core/src/xmake/thread/mutex_trylock.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_mutex_trylock.c + * @file mutex_trylock.c * */ diff --git a/core/src/xmake/thread/mutex_unlock.c b/core/src/xmake/thread/mutex_unlock.c index 93503e197..a73d04dc1 100644 --- a/core/src/xmake/thread/mutex_unlock.c +++ b/core/src/xmake/thread/mutex_unlock.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_mutex_unlock.c + * @file mutex_unlock.c * */ diff --git a/core/src/xmake/thread/prefix.h b/core/src/xmake/thread/prefix.h index 9b038a8cb..2ddd14adf 100644 --- a/core/src/xmake/thread/prefix.h +++ b/core/src/xmake/thread/prefix.h @@ -92,50 +92,55 @@ typedef struct __xm_thread_sharedata_t { // get the thread event from arguments static __tb_inline__ xm_thread_event_t *xm_thread_event_get(lua_State *lua, tb_int_t index) { xm_thread_event_t *thread_event = tb_null; - if (xm_lua_isinteger(lua, index)) + if (xm_lua_isinteger(lua, index)) { thread_event = (xm_thread_event_t *)(tb_size_t)(tb_long_t)lua_tointeger(lua, index); - else if (xm_lua_ispointer(lua, index)) + } else if (xm_lua_ispointer(lua, index)) { thread_event = (xm_thread_event_t *)xm_lua_topointer(lua, index); + } return thread_event; } // get the thread mutex from arguments static __tb_inline__ xm_thread_mutex_t *xm_thread_mutex_get(lua_State *lua, tb_int_t index) { xm_thread_mutex_t *thread_mutex = tb_null; - if (xm_lua_isinteger(lua, index)) + if (xm_lua_isinteger(lua, index)) { thread_mutex = (xm_thread_mutex_t *)(tb_size_t)(tb_long_t)lua_tointeger(lua, index); - else if (xm_lua_ispointer(lua, index)) + } else if (xm_lua_ispointer(lua, index)) { thread_mutex = (xm_thread_mutex_t *)xm_lua_topointer(lua, index); + } return thread_mutex; } // get the thread semaphore from arguments static __tb_inline__ xm_thread_semaphore_t *xm_thread_semaphore_get(lua_State *lua, tb_int_t index) { xm_thread_semaphore_t *thread_semaphore = tb_null; - if (xm_lua_isinteger(lua, index)) + if (xm_lua_isinteger(lua, index)) { thread_semaphore = (xm_thread_semaphore_t *)(tb_size_t)(tb_long_t)lua_tointeger(lua, index); - else if (xm_lua_ispointer(lua, index)) + } else if (xm_lua_ispointer(lua, index)) { thread_semaphore = (xm_thread_semaphore_t *)xm_lua_topointer(lua, index); + } return thread_semaphore; } // get the thread queue from arguments static __tb_inline__ xm_thread_queue_t *xm_thread_queue_get(lua_State *lua, tb_int_t index) { xm_thread_queue_t *thread_queue = tb_null; - if (xm_lua_isinteger(lua, index)) + if (xm_lua_isinteger(lua, index)) { thread_queue = (xm_thread_queue_t *)(tb_size_t)(tb_long_t)lua_tointeger(lua, index); - else if (xm_lua_ispointer(lua, index)) + } else if (xm_lua_ispointer(lua, index)) { thread_queue = (xm_thread_queue_t *)xm_lua_topointer(lua, index); + } return thread_queue; } // get the thread sharedata from arguments static __tb_inline__ xm_thread_sharedata_t *xm_thread_sharedata_get(lua_State *lua, tb_int_t index) { xm_thread_sharedata_t *thread_sharedata = tb_null; - if (xm_lua_isinteger(lua, index)) + if (xm_lua_isinteger(lua, index)) { thread_sharedata = (xm_thread_sharedata_t *)(tb_size_t)(tb_long_t)lua_tointeger(lua, index); - else if (xm_lua_ispointer(lua, index)) + } else if (xm_lua_ispointer(lua, index)) { thread_sharedata = (xm_thread_sharedata_t *)xm_lua_topointer(lua, index); + } return thread_sharedata; } diff --git a/core/src/xmake/thread/queue_clear.c b/core/src/xmake/thread/queue_clear.c index 021475a14..533c035ed 100644 --- a/core/src/xmake/thread/queue_clear.c +++ b/core/src/xmake/thread/queue_clear.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_queue_clear.c + * @file queue_clear.c * */ diff --git a/core/src/xmake/thread/queue_exit.c b/core/src/xmake/thread/queue_exit.c index c30c6b97c..de051250e 100644 --- a/core/src/xmake/thread/queue_exit.c +++ b/core/src/xmake/thread/queue_exit.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_queue_exit.c + * @file queue_exit.c * */ diff --git a/core/src/xmake/thread/queue_incref.c b/core/src/xmake/thread/queue_incref.c index 9dd88b013..2322ce241 100644 --- a/core/src/xmake/thread/queue_incref.c +++ b/core/src/xmake/thread/queue_incref.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_queue_incref.c + * @file queue_incref.c * */ diff --git a/core/src/xmake/thread/queue_init.c b/core/src/xmake/thread/queue_init.c index 20c08ce50..a0d683dd3 100644 --- a/core/src/xmake/thread/queue_init.c +++ b/core/src/xmake/thread/queue_init.c @@ -37,8 +37,9 @@ static tb_void_t xm_thread_value_free(tb_element_ref_t element, tb_pointer_t buf xm_thread_value_t *item = (xm_thread_value_t *)buff; if (item) { if (item->kind == XM_THREAD_VALUE_STR) { - if (item->u.string) + if (item->u.string) { tb_free((tb_pointer_t)item->u.string); + } item->u.string = tb_null; } item->size = 0; diff --git a/core/src/xmake/thread/queue_pop.c b/core/src/xmake/thread/queue_pop.c index ef5f761ec..256cb151e 100644 --- a/core/src/xmake/thread/queue_pop.c +++ b/core/src/xmake/thread/queue_pop.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_queue_pop.c + * @file queue_pop.c * */ @@ -51,10 +51,11 @@ tb_int_t xm_thread_queue_pop(lua_State *lua) { tb_bool_t ok = tb_false; switch (item->kind) { case XM_THREAD_VALUE_STR: - if (item->size) + if (item->size) { lua_pushlstring(lua, item->u.string, item->size); - else + } else { lua_pushliteral(lua, ""); + } ok = tb_true; break; case XM_THREAD_VALUE_INT: diff --git a/core/src/xmake/thread/queue_push.c b/core/src/xmake/thread/queue_push.c index 058ac8f81..0a9ff63e1 100644 --- a/core/src/xmake/thread/queue_push.c +++ b/core/src/xmake/thread/queue_push.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_queue_push.c + * @file queue_push.c * */ diff --git a/core/src/xmake/thread/queue_size.c b/core/src/xmake/thread/queue_size.c index 68a9b5a91..9adfbe028 100644 --- a/core/src/xmake/thread/queue_size.c +++ b/core/src/xmake/thread/queue_size.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_queue_lock.c + * @file queue_size.c * */ diff --git a/core/src/xmake/thread/semaphore_exit.c b/core/src/xmake/thread/semaphore_exit.c index bbc426917..ca6386757 100644 --- a/core/src/xmake/thread/semaphore_exit.c +++ b/core/src/xmake/thread/semaphore_exit.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_semaphore_exit.c + * @file semaphore_exit.c * */ diff --git a/core/src/xmake/thread/semaphore_incref.c b/core/src/xmake/thread/semaphore_incref.c index 129a2177d..315332981 100644 --- a/core/src/xmake/thread/semaphore_incref.c +++ b/core/src/xmake/thread/semaphore_incref.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_semaphore_incref.c + * @file semaphore_incref.c * */ diff --git a/core/src/xmake/thread/semaphore_post.c b/core/src/xmake/thread/semaphore_post.c index d709e5a5e..20aea4dc0 100644 --- a/core/src/xmake/thread/semaphore_post.c +++ b/core/src/xmake/thread/semaphore_post.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_semaphore_lock.c + * @file semaphore_post.c * */ diff --git a/core/src/xmake/thread/semaphore_wait.c b/core/src/xmake/thread/semaphore_wait.c index 40337a117..1c886d1bc 100644 --- a/core/src/xmake/thread/semaphore_wait.c +++ b/core/src/xmake/thread/semaphore_wait.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_semaphore_unlock.c + * @file semaphore_wait.c * */ diff --git a/core/src/xmake/thread/sharedata_clear.c b/core/src/xmake/thread/sharedata_clear.c index 426785e0e..e55d5b059 100644 --- a/core/src/xmake/thread/sharedata_clear.c +++ b/core/src/xmake/thread/sharedata_clear.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_sharedata_clear.c + * @file sharedata_clear.c * */ diff --git a/core/src/xmake/thread/sharedata_exit.c b/core/src/xmake/thread/sharedata_exit.c index ad017f2b6..419718f0f 100644 --- a/core/src/xmake/thread/sharedata_exit.c +++ b/core/src/xmake/thread/sharedata_exit.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_sharedata_exit.c + * @file sharedata_exit.c * */ diff --git a/core/src/xmake/thread/sharedata_get.c b/core/src/xmake/thread/sharedata_get.c index 51ebdf62f..6699a7500 100644 --- a/core/src/xmake/thread/sharedata_get.c +++ b/core/src/xmake/thread/sharedata_get.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_sharedata_get.c + * @file sharedata_get.c * */ diff --git a/core/src/xmake/thread/sharedata_incref.c b/core/src/xmake/thread/sharedata_incref.c index 3c11f7d15..8706c00a3 100644 --- a/core/src/xmake/thread/sharedata_incref.c +++ b/core/src/xmake/thread/sharedata_incref.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_sharedata_incref.c + * @file sharedata_incref.c * */ diff --git a/core/src/xmake/thread/sharedata_set.c b/core/src/xmake/thread/sharedata_set.c index 9a4ad3cbd..2bd66d1f9 100644 --- a/core/src/xmake/thread/sharedata_set.c +++ b/core/src/xmake/thread/sharedata_set.c @@ -15,7 +15,7 @@ * Copyright (C) 2015-present, Xmake Open Source Community. * * @author ruki - * @file thread_sharedata_set.c + * @file sharedata_set.c * */ diff --git a/core/src/xmake/thread/thread_resume.c b/core/src/xmake/thread/thread_resume.c index 45253b418..d9ab421cf 100644 --- a/core/src/xmake/thread/thread_resume.c +++ b/core/src/xmake/thread/thread_resume.c @@ -37,8 +37,9 @@ tb_int_t xm_thread_resume(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // is pointer? - if (!xm_lua_ispointer(lua, 1)) + if (!xm_lua_ispointer(lua, 1)) { return 0; + } // get thread xm_thread_t *thread = (xm_thread_t *)xm_lua_topointer(lua, 1); diff --git a/core/src/xmake/thread/thread_suspend.c b/core/src/xmake/thread/thread_suspend.c index 1df3063ef..7eb6a6a36 100644 --- a/core/src/xmake/thread/thread_suspend.c +++ b/core/src/xmake/thread/thread_suspend.c @@ -37,8 +37,9 @@ tb_int_t xm_thread_suspend(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // is pointer? - if (!xm_lua_ispointer(lua, 1)) + if (!xm_lua_ispointer(lua, 1)) { return 0; + } // get thread xm_thread_t *thread = (xm_thread_t *)xm_lua_topointer(lua, 1); diff --git a/core/src/xmake/thread/thread_wait.c b/core/src/xmake/thread/thread_wait.c index 8ceb45524..8c9ffab18 100644 --- a/core/src/xmake/thread/thread_wait.c +++ b/core/src/xmake/thread/thread_wait.c @@ -37,8 +37,9 @@ tb_int_t xm_thread_wait(lua_State *lua) { tb_assert_and_check_return_val(lua, 0); // is pointer? - if (!xm_lua_ispointer(lua, 1)) + if (!xm_lua_ispointer(lua, 1)) { return 0; + } // get thread xm_thread_t *thread = (xm_thread_t *)xm_lua_topointer(lua, 1); diff --git a/core/src/xmake/tty/term_mode.c b/core/src/xmake/tty/term_mode.c index 34998c60b..df5af5b4c 100644 --- a/core/src/xmake/tty/term_mode.c +++ b/core/src/xmake/tty/term_mode.c @@ -65,8 +65,9 @@ tb_int_t xm_tty_term_mode(lua_State *lua) { GetConsoleMode(console_handle, &mode); if (lua_isnumber(lua, 2)) { tb_int_t newmode = (tb_int_t)lua_tointeger(lua, 2); - if (console_handle != INVALID_HANDLE_VALUE) + if (console_handle != INVALID_HANDLE_VALUE) { SetConsoleMode(console_handle, (DWORD)newmode); + } } #else tb_int_t mode = 0; diff --git a/core/src/xmake/utils/bin2c.c b/core/src/xmake/utils/bin2c.c index 77a1b2a8c..61befeaa9 100644 --- a/core/src/xmake/utils/bin2c.c +++ b/core/src/xmake/utils/bin2c.c @@ -74,8 +74,9 @@ static tb_bool_t xm_utils_bin2c_dump(tb_stream_ref_t istream, if (first) { first = tb_false; line[linesize++] = ' '; - } else + } else { line[linesize++] = ','; + } linesize += xm_utils_bin2c_hex2str(line + linesize, data[i]); for (i = 1; i < need; i++) { diff --git a/core/src/xmake/winos/ansi.c b/core/src/xmake/winos/ansi.c index 48bb9df82..9646db59b 100644 --- a/core/src/xmake/winos/ansi.c +++ b/core/src/xmake/winos/ansi.c @@ -38,10 +38,12 @@ static tb_int_t xm_expand_cp(tb_int_t cp) { tb_assert_and_check_return_val(cp >= 0 && cp <= 65535, 0); - if (cp == CP_OEMCP) + if (cp == CP_OEMCP) { return GetOEMCP(); - if (cp == CP_ACP) + } + if (cp == CP_ACP) { return GetACP(); + } return cp; } diff --git a/core/src/xmake/winos/logical_drives.c b/core/src/xmake/winos/logical_drives.c index 7227069b9..9f6df60ea 100644 --- a/core/src/xmake/winos/logical_drives.c +++ b/core/src/xmake/winos/logical_drives.c @@ -69,8 +69,9 @@ tb_int_t xm_winos_logical_drives(lua_State *lua) { } while (0); // exit data - if (data) + if (data) { tb_free(data); + } data = tb_null; return 1; diff --git a/core/src/xmake/winos/registry_keys.c b/core/src/xmake/winos/registry_keys.c index 7daf44ff4..49ddf613f 100644 --- a/core/src/xmake/winos/registry_keys.c +++ b/core/src/xmake/winos/registry_keys.c @@ -138,20 +138,23 @@ static tb_void_t xm_winos_registry_enum_keys(xm_winos_registry_enum_info_t *info } // enum all subkeys - if (recursion > 0 || recursion < 0) + if (recursion > 0 || recursion < 0) { xm_winos_registry_enum_keys(info, key_path, recursion > 0 ? recursion - 1 : recursion); + } } } while (0); // exit registry key - if (keynew) + if (keynew) { RegCloseKey(keynew); + } keynew = tb_null; // free key path - if (key_path) + if (key_path) { tb_free(key_path); + } key_path = tb_null; } @@ -183,25 +186,25 @@ tb_int_t xm_winos_registry_keys(lua_State *lua) { HKEY key = tb_null; do { // get registry rootkey - if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) + if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) { key = HKEY_CLASSES_ROOT; - else if (!tb_strcmp(rootkey, "HKCR")) + } else if (!tb_strcmp(rootkey, "HKCR")) { key = HKEY_CLASSES_ROOT; - else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG")) + } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG")) { key = HKEY_CURRENT_CONFIG; - else if (!tb_strcmp(rootkey, "HKCC")) + } else if (!tb_strcmp(rootkey, "HKCC")) { key = HKEY_CURRENT_CONFIG; - else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER")) + } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER")) { key = HKEY_CURRENT_USER; - else if (!tb_strcmp(rootkey, "HKCU")) + } else if (!tb_strcmp(rootkey, "HKCU")) { key = HKEY_CURRENT_USER; - else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE")) + } else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE")) { key = HKEY_LOCAL_MACHINE; - else if (!tb_strcmp(rootkey, "HKLM")) + } else if (!tb_strcmp(rootkey, "HKLM")) { key = HKEY_LOCAL_MACHINE; - else if (!tb_strcmp(rootkey, "HKEY_USERS")) + } else if (!tb_strcmp(rootkey, "HKEY_USERS")) { key = HKEY_USERS; - else { + } else { lua_pushnil(lua); lua_pushfstring(lua, "invalid registry rootkey: %s", rootkey); break; @@ -233,6 +236,7 @@ tb_int_t xm_winos_registry_keys(lua_State *lua) { if (ok) { lua_pushinteger(lua, count); return 1; - } else + } else { return 2; + } } diff --git a/core/src/xmake/winos/registry_query.c b/core/src/xmake/winos/registry_query.c index 5e98af2cd..bfaebe744 100644 --- a/core/src/xmake/winos/registry_query.c +++ b/core/src/xmake/winos/registry_query.c @@ -63,25 +63,25 @@ tb_int_t xm_winos_registry_query(lua_State *lua) { tb_size_t value_n = (tb_size_t)-1; do { // get registry rootkey - if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) + if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) { key = HKEY_CLASSES_ROOT; - else if (!tb_strcmp(rootkey, "HKCR")) + } else if (!tb_strcmp(rootkey, "HKCR")) { key = HKEY_CLASSES_ROOT; - else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG")) + } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG")) { key = HKEY_CURRENT_CONFIG; - else if (!tb_strcmp(rootkey, "HKCC")) + } else if (!tb_strcmp(rootkey, "HKCC")) { key = HKEY_CURRENT_CONFIG; - else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER")) + } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER")) { key = HKEY_CURRENT_USER; - else if (!tb_strcmp(rootkey, "HKCU")) + } else if (!tb_strcmp(rootkey, "HKCU")) { key = HKEY_CURRENT_USER; - else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE")) + } else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE")) { key = HKEY_LOCAL_MACHINE; - else if (!tb_strcmp(rootkey, "HKLM")) + } else if (!tb_strcmp(rootkey, "HKLM")) { key = HKEY_LOCAL_MACHINE; - else if (!tb_strcmp(rootkey, "HKEY_USERS")) + } else if (!tb_strcmp(rootkey, "HKEY_USERS")) { key = HKEY_USERS; - else { + } else { lua_pushnil(lua); lua_pushfstring(lua, "invalid registry rootkey: %s", rootkey); break; @@ -213,16 +213,19 @@ tb_int_t xm_winos_registry_query(lua_State *lua) { } while (0); // exit registry key - if (keynew) + if (keynew) { RegCloseKey(keynew); + } keynew = tb_null; // exit value - if (value) + if (value) { tb_free(value); + } value = tb_null; - if (value_w) + if (value_w) { tb_free(value_w); + } value_w = tb_null; return ok ? 1 : 2; diff --git a/core/src/xmake/winos/registry_values.c b/core/src/xmake/winos/registry_values.c index 6bda8e690..543665853 100644 --- a/core/src/xmake/winos/registry_values.c +++ b/core/src/xmake/winos/registry_values.c @@ -58,25 +58,25 @@ tb_int_t xm_winos_registry_values(lua_State *lua) { HKEY keynew = tb_null; do { // get registry rootkey - if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) + if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) { key = HKEY_CLASSES_ROOT; - else if (!tb_strcmp(rootkey, "HKCR")) + } else if (!tb_strcmp(rootkey, "HKCR")) { key = HKEY_CLASSES_ROOT; - else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG")) + } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG")) { key = HKEY_CURRENT_CONFIG; - else if (!tb_strcmp(rootkey, "HKCC")) + } else if (!tb_strcmp(rootkey, "HKCC")) { key = HKEY_CURRENT_CONFIG; - else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER")) + } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER")) { key = HKEY_CURRENT_USER; - else if (!tb_strcmp(rootkey, "HKCU")) + } else if (!tb_strcmp(rootkey, "HKCU")) { key = HKEY_CURRENT_USER; - else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE")) + } else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE")) { key = HKEY_LOCAL_MACHINE; - else if (!tb_strcmp(rootkey, "HKLM")) + } else if (!tb_strcmp(rootkey, "HKLM")) { key = HKEY_LOCAL_MACHINE; - else if (!tb_strcmp(rootkey, "HKEY_USERS")) + } else if (!tb_strcmp(rootkey, "HKEY_USERS")) { key = HKEY_USERS; - else { + } else { lua_pushnil(lua); lua_pushfstring(lua, "invalid registry rootkey: %s", rootkey); break; @@ -161,13 +161,15 @@ tb_int_t xm_winos_registry_values(lua_State *lua) { } while (0); // exit registry key - if (keynew) + if (keynew) { RegCloseKey(keynew); + } keynew = tb_null; if (ok) { lua_pushinteger(lua, count); return 1; - } else + } else { return 2; + } } -- cgit v1.3.1