summaryrefslogtreecommitdiff
path: root/core/src
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-10 23:20:11 +0800
committerruki <[email protected]>2025-11-10 23:20:11 +0800
commitef701a4dce8b7d9a663e084d1fc0b243ddae9397 (patch)
tree45fd20851dd3480bd042dd14af77286c4289d190 /core/src
parent6db4c62a474e380071625fa5cb7743972a562940 (diff)
format core code again
Diffstat (limited to 'core/src')
-rw-r--r--core/src/xmake/base64/decode.c2
-rw-r--r--core/src/xmake/base64/encode.c2
-rw-r--r--core/src/xmake/bloom_filter/bloom_filter_data_set.c2
-rw-r--r--core/src/xmake/curses/curses.c66
-rw-r--r--core/src/xmake/fwatcher/wait.c2
-rw-r--r--core/src/xmake/hash/md5.c4
-rw-r--r--core/src/xmake/hash/prefix.h14
-rw-r--r--core/src/xmake/hash/rand128.c2
-rw-r--r--core/src/xmake/hash/rand32.c4
-rw-r--r--core/src/xmake/hash/rand64.c2
-rw-r--r--core/src/xmake/hash/sha.c8
-rw-r--r--core/src/xmake/hash/xxhash.c32
-rw-r--r--core/src/xmake/io/file_close.c2
-rw-r--r--core/src/xmake/io/file_flush.c2
-rw-r--r--core/src/xmake/io/file_open.c46
-rw-r--r--core/src/xmake/io/file_read.c40
-rw-r--r--core/src/xmake/io/file_seek.c2
-rw-r--r--core/src/xmake/io/file_write.c10
-rw-r--r--core/src/xmake/io/filelock_open.c2
-rw-r--r--core/src/xmake/io/iscygpty.c18
-rw-r--r--core/src/xmake/io/pipe_write.c2
-rw-r--r--core/src/xmake/io/poller.h2
-rw-r--r--core/src/xmake/io/poller_insert.c2
-rw-r--r--core/src/xmake/io/poller_modify.c2
-rw-r--r--core/src/xmake/io/poller_wait.c8
-rw-r--r--core/src/xmake/io/prefix.h12
-rw-r--r--core/src/xmake/io/socket_peeraddr.c4
-rw-r--r--core/src/xmake/io/socket_recvfrom.c4
-rw-r--r--core/src/xmake/io/socket_send.c2
-rw-r--r--core/src/xmake/io/socket_sendto.c4
-rw-r--r--core/src/xmake/io/stdfile.c4
-rw-r--r--core/src/xmake/libc/malloc.c2
-rw-r--r--core/src/xmake/libc/memcpy.c6
-rw-r--r--core/src/xmake/libc/memmov.c6
-rw-r--r--core/src/xmake/libc/memset.c4
-rw-r--r--core/src/xmake/lz4/block_compress.c4
-rw-r--r--core/src/xmake/lz4/block_decompress.c4
-rw-r--r--core/src/xmake/lz4/compress.c10
-rw-r--r--core/src/xmake/lz4/compress_file.c2
-rw-r--r--core/src/xmake/lz4/compress_stream_write.c2
-rw-r--r--core/src/xmake/lz4/decompress.c12
-rw-r--r--core/src/xmake/lz4/decompress_file.c2
-rw-r--r--core/src/xmake/lz4/decompress_stream_write.c2
-rw-r--r--core/src/xmake/lz4/prefix.h32
-rw-r--r--core/src/xmake/os/args.c12
-rw-r--r--core/src/xmake/os/argv.c12
-rw-r--r--core/src/xmake/os/cpuinfo.c50
-rw-r--r--core/src/xmake/os/find.c4
-rw-r--r--core/src/xmake/os/getenvs.c10
-rw-r--r--core/src/xmake/os/meminfo.c14
-rw-r--r--core/src/xmake/os/readlink.c2
-rw-r--r--core/src/xmake/os/setenv.c6
-rw-r--r--core/src/xmake/os/syserror.c2
-rw-r--r--core/src/xmake/package/loadxmi.c4
-rw-r--r--core/src/xmake/path/translate.c2
-rw-r--r--core/src/xmake/process/open.c26
-rw-r--r--core/src/xmake/process/openv.c26
-rw-r--r--core/src/xmake/sandbox/interactive.c2
-rw-r--r--core/src/xmake/semver/select.c14
-rw-r--r--core/src/xmake/semver/semver.c2
-rw-r--r--core/src/xmake/string/endswith.c8
-rw-r--r--core/src/xmake/string/lastof.c4
-rw-r--r--core/src/xmake/string/split.c8
-rw-r--r--core/src/xmake/string/startswith.c6
-rw-r--r--core/src/xmake/string/trim.c8
-rw-r--r--core/src/xmake/thread/event_init.c2
-rw-r--r--core/src/xmake/thread/mutex_init.c2
-rw-r--r--core/src/xmake/thread/prefix.h22
-rw-r--r--core/src/xmake/thread/queue_init.c2
-rw-r--r--core/src/xmake/thread/queue_push.c4
-rw-r--r--core/src/xmake/thread/semaphore_init.c2
-rw-r--r--core/src/xmake/thread/sharedata_init.c2
-rw-r--r--core/src/xmake/thread/sharedata_set.c4
-rw-r--r--core/src/xmake/thread/thread_init.c10
-rw-r--r--core/src/xmake/tty/term_mode.c2
-rw-r--r--core/src/xmake/utils/bin2c.c2
-rw-r--r--core/src/xmake/winos/logical_drives.c2
-rw-r--r--core/src/xmake/winos/registry_keys.c56
-rw-r--r--core/src/xmake/winos/registry_query.c14
-rw-r--r--core/src/xmake/winos/registry_values.c16
-rw-r--r--core/src/xmake/winos/short_path.c2
81 files changed, 381 insertions, 381 deletions
diff --git a/core/src/xmake/base64/decode.c b/core/src/xmake/base64/decode.c
index cb1b7eb82..7c5f05bae 100644
--- a/core/src/xmake/base64/decode.c
+++ b/core/src/xmake/base64/decode.c
@@ -37,7 +37,7 @@ tb_int_t xm_base64_decode(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get the string
- size_t size = 0;
+ size_t size = 0;
tb_char_t const *cstr = luaL_checklstring(lua, 1, &size);
tb_check_return_val(cstr && size, 0);
diff --git a/core/src/xmake/base64/encode.c b/core/src/xmake/base64/encode.c
index d5ce56306..b9a9092d3 100644
--- a/core/src/xmake/base64/encode.c
+++ b/core/src/xmake/base64/encode.c
@@ -37,7 +37,7 @@ tb_int_t xm_base64_encode(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 1)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1);
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 6d2d48606..3918913b1 100644
--- a/core/src/xmake/bloom_filter/bloom_filter_data_set.c
+++ b/core/src/xmake/bloom_filter/bloom_filter_data_set.c
@@ -46,7 +46,7 @@ tb_int_t xm_bloom_filter_data_set(lua_State *lua) {
tb_check_return_val(filter, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 2)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2);
diff --git a/core/src/xmake/curses/curses.c b/core/src/xmake/curses/curses.c
index 4f8c03028..95a0fcdac 100644
--- a/core/src/xmake/curses/curses.c
+++ b/core/src/xmake/curses/curses.c
@@ -217,7 +217,7 @@ static WINDOW *xm_curses_window_check(lua_State *lua, int index) {
// tostring(window)
static int xm_curses_window_tostring(lua_State *lua) {
- WINDOW **w = xm_curses_window_get(lua, 1);
+ WINDOW **w = xm_curses_window_get(lua, 1);
char const *s = NULL;
if (*w)
s = (char const *)lua_touserdata(lua, 1);
@@ -228,8 +228,8 @@ static int xm_curses_window_tostring(lua_State *lua) {
// window:move(y, x)
static int xm_curses_window_move(lua_State *lua) {
WINDOW *w = xm_curses_window_check(lua, 1);
- int y = luaL_checkint(lua, 2);
- int x = luaL_checkint(lua, 3);
+ int y = luaL_checkint(lua, 2);
+ int x = luaL_checkint(lua, 3);
lua_pushboolean(lua, XM_CURSES_OK(wmove(w, y, x)));
return 1;
}
@@ -237,7 +237,7 @@ static int xm_curses_window_move(lua_State *lua) {
// window:getyx(y, x)
static int xm_curses_window_getyx(lua_State *lua) {
WINDOW *w = xm_curses_window_check(lua, 1);
- int y, x;
+ int y, x;
getyx(w, y, x);
lua_pushnumber(lua, y);
lua_pushnumber(lua, x);
@@ -247,7 +247,7 @@ static int xm_curses_window_getyx(lua_State *lua) {
// window:getmaxyx(y, x)
static int xm_curses_window_getmaxyx(lua_State *lua) {
WINDOW *w = xm_curses_window_check(lua, 1);
- int y, x;
+ int y, x;
getmaxyx(w, y, x);
lua_pushnumber(lua, y);
lua_pushnumber(lua, x);
@@ -266,17 +266,17 @@ static int xm_curses_window_delwin(lua_State *lua) {
// window:addch(ch)
static int xm_curses_window_addch(lua_State *lua) {
- WINDOW *w = xm_curses_window_check(lua, 1);
- chtype ch = xm_curses_checkch(lua, 2);
+ WINDOW *w = xm_curses_window_check(lua, 1);
+ chtype ch = xm_curses_checkch(lua, 2);
lua_pushboolean(lua, XM_CURSES_OK(waddch(w, ch)));
return 1;
}
// window:addnstr(str)
static int xm_curses_window_addnstr(lua_State *lua) {
- WINDOW *w = xm_curses_window_check(lua, 1);
+ WINDOW *w = xm_curses_window_check(lua, 1);
const char *str = luaL_checkstring(lua, 2);
- int n = luaL_optint(lua, 3, -1);
+ int n = luaL_optint(lua, 3, -1);
if (n < 0)
n = (int)lua_strlen(lua, 2);
lua_pushboolean(lua, XM_CURSES_OK(waddnstr(w, str, n)));
@@ -285,8 +285,8 @@ static int xm_curses_window_addnstr(lua_State *lua) {
// window:keypad(true)
static int xm_curses_window_keypad(lua_State *lua) {
- WINDOW *w = xm_curses_window_check(lua, 1);
- int enabled = lua_isnoneornil(lua, 2) ? 1 : lua_toboolean(lua, 2);
+ WINDOW *w = xm_curses_window_check(lua, 1);
+ int enabled = lua_isnoneornil(lua, 2) ? 1 : lua_toboolean(lua, 2);
if (enabled) {
// on WIN32 ALT keys need to be mapped, so to make sure you get the wanted keys,
// only makes sense when using keypad(true) and echo(false)
@@ -298,24 +298,24 @@ static int xm_curses_window_keypad(lua_State *lua) {
// window:meta(true)
static int xm_curses_window_meta(lua_State *lua) {
- WINDOW *w = xm_curses_window_check(lua, 1);
- int enabled = lua_toboolean(lua, 2);
+ WINDOW *w = xm_curses_window_check(lua, 1);
+ int enabled = lua_toboolean(lua, 2);
lua_pushboolean(lua, XM_CURSES_OK(meta(w, enabled)));
return 1;
}
// window:nodelay(true)
static int xm_curses_window_nodelay(lua_State *lua) {
- WINDOW *w = xm_curses_window_check(lua, 1);
- int enabled = lua_toboolean(lua, 2);
+ WINDOW *w = xm_curses_window_check(lua, 1);
+ int enabled = lua_toboolean(lua, 2);
lua_pushboolean(lua, XM_CURSES_OK(nodelay(w, enabled)));
return 1;
}
// window:leaveok(true)
static int xm_curses_window_leaveok(lua_State *lua) {
- WINDOW *w = xm_curses_window_check(lua, 1);
- int enabled = lua_toboolean(lua, 2);
+ WINDOW *w = xm_curses_window_check(lua, 1);
+ int enabled = lua_toboolean(lua, 2);
lua_pushboolean(lua, XM_CURSES_OK(leaveok(w, enabled)));
return 1;
}
@@ -323,7 +323,7 @@ static int xm_curses_window_leaveok(lua_State *lua) {
// window:getch()
static int xm_curses_window_getch(lua_State *lua) {
WINDOW *w = xm_curses_window_check(lua, 1);
- int c = xm_curses_window_getch_impl(w);
+ int c = xm_curses_window_getch_impl(w);
if (c == ERR)
return 0;
lua_pushnumber(lua, c);
@@ -332,39 +332,39 @@ static int xm_curses_window_getch(lua_State *lua) {
// window:attroff(attrs)
static int xm_curses_window_attroff(lua_State *lua) {
- WINDOW *w = xm_curses_window_check(lua, 1);
- int attrs = luaL_checkint(lua, 2);
+ WINDOW *w = xm_curses_window_check(lua, 1);
+ int attrs = luaL_checkint(lua, 2);
lua_pushboolean(lua, XM_CURSES_OK(wattroff(w, attrs)));
return 1;
}
// window:attron(attrs)
static int xm_curses_window_attron(lua_State *lua) {
- WINDOW *w = xm_curses_window_check(lua, 1);
- int attrs = luaL_checkint(lua, 2);
+ WINDOW *w = xm_curses_window_check(lua, 1);
+ int attrs = luaL_checkint(lua, 2);
lua_pushboolean(lua, XM_CURSES_OK(wattron(w, attrs)));
return 1;
}
// window:attrset(attrs)
static int xm_curses_window_attrset(lua_State *lua) {
- WINDOW *w = xm_curses_window_check(lua, 1);
- int attrs = luaL_checkint(lua, 2);
+ WINDOW *w = xm_curses_window_check(lua, 1);
+ int attrs = luaL_checkint(lua, 2);
lua_pushboolean(lua, XM_CURSES_OK(wattrset(w, attrs)));
return 1;
}
// window:copywin(...)
static int xm_curses_window_copywin(lua_State *lua) {
- WINDOW *srcwin = xm_curses_window_check(lua, 1);
- WINDOW *dstwin = xm_curses_window_check(lua, 2);
- int sminrow = luaL_checkint(lua, 3);
- int smincol = luaL_checkint(lua, 4);
- int dminrow = luaL_checkint(lua, 5);
- int dmincol = luaL_checkint(lua, 6);
- int dmaxrow = luaL_checkint(lua, 7);
- int dmaxcol = luaL_checkint(lua, 8);
- int overlay = lua_toboolean(lua, 9);
+ WINDOW *srcwin = xm_curses_window_check(lua, 1);
+ WINDOW *dstwin = xm_curses_window_check(lua, 2);
+ int sminrow = luaL_checkint(lua, 3);
+ int smincol = luaL_checkint(lua, 4);
+ int dminrow = luaL_checkint(lua, 5);
+ int dmincol = luaL_checkint(lua, 6);
+ int dmaxrow = luaL_checkint(lua, 7);
+ int dmaxcol = luaL_checkint(lua, 8);
+ int overlay = lua_toboolean(lua, 9);
lua_pushboolean(lua,
XM_CURSES_OK(
copywin(srcwin, dstwin, sminrow, smincol, dminrow, dmincol, dmaxrow, dmaxcol, overlay)));
diff --git a/core/src/xmake/fwatcher/wait.c b/core/src/xmake/fwatcher/wait.c
index 0602c931c..585037886 100644
--- a/core/src/xmake/fwatcher/wait.c
+++ b/core/src/xmake/fwatcher/wait.c
@@ -52,7 +52,7 @@ tb_int_t xm_fwatcher_wait(lua_State *lua) {
// wait fwatcher event
tb_fwatcher_event_t event;
- tb_long_t ok = tb_fwatcher_wait(fwatcher, &event, timeout);
+ tb_long_t ok = tb_fwatcher_wait(fwatcher, &event, timeout);
// save result
lua_pushinteger(lua, ok);
diff --git a/core/src/xmake/hash/md5.c b/core/src/xmake/hash/md5.c
index 6d18b72ba..56f68d99e 100644
--- a/core/src/xmake/hash/md5.c
+++ b/core/src/xmake/hash/md5.c
@@ -39,7 +39,7 @@ tb_int_t xm_hash_md5(lua_State *lua) {
// is bytes? get data and size
if (xm_lua_isinteger(lua, 1) && xm_lua_isinteger(lua, 2)) {
tb_byte_t const *data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1);
- tb_size_t size = (tb_size_t)lua_tointeger(lua, 2);
+ tb_size_t size = (tb_size_t)lua_tointeger(lua, 2);
if (!data || !size) {
lua_pushnil(lua);
lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size);
@@ -65,7 +65,7 @@ tb_int_t xm_hash_md5(lua_State *lua) {
tb_check_return_val(filename, 0);
// load data from file
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
tb_stream_ref_t stream = tb_stream_init_from_file(filename, TB_FILE_MODE_RO);
if (stream) {
// open stream
diff --git a/core/src/xmake/hash/prefix.h b/core/src/xmake/hash/prefix.h
index 99a8e4e6d..f486105e1 100644
--- a/core/src/xmake/hash/prefix.h
+++ b/core/src/xmake/hash/prefix.h
@@ -39,9 +39,9 @@ static __tb_inline__ tb_uint64_t xm_hash_xorshift64(tb_uint64_t x) {
// http://xorshift.di.unimi.it/xorshift128plus.c
static __tb_inline__ tb_uint64_t xm_hash_xorshift128(tb_uint64_t *s) {
- tb_uint64_t s1 = s[0];
+ tb_uint64_t s1 = s[0];
tb_uint64_t const s0 = s[1];
- s[0] = s0;
+ s[0] = s0;
s1 ^= s1 << 23;
s[1] = s1 ^ s0 ^ (s1 >> 18) ^ (s0 >> 5);
return s[1] + s0;
@@ -49,13 +49,13 @@ static __tb_inline__ tb_uint64_t xm_hash_xorshift128(tb_uint64_t *s) {
static __tb_inline__ tb_size_t xm_hash_make_cstr(tb_char_t hash[256], tb_byte_t const *data, tb_size_t size) {
static tb_char_t const *digits_table = "0123456789abcdef";
- tb_size_t i = 0;
- tb_byte_t value;
- tb_char_t *s = hash;
+ tb_size_t i = 0;
+ tb_byte_t value;
+ tb_char_t *s = hash;
for (i = 0; i < size; ++i) {
value = data[i];
- s[0] = digits_table[(value >> 4) & 15];
- s[1] = digits_table[value & 15];
+ s[0] = digits_table[(value >> 4) & 15];
+ s[1] = digits_table[value & 15];
s += 2;
}
*s = '\0';
diff --git a/core/src/xmake/hash/rand128.c b/core/src/xmake/hash/rand128.c
index 625e75326..888e55e79 100644
--- a/core/src/xmake/hash/rand128.c
+++ b/core/src/xmake/hash/rand128.c
@@ -37,7 +37,7 @@ tb_int_t xm_hash_rand128(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
static union {
- tb_byte_t b[16];
+ tb_byte_t b[16];
tb_uint64_t word[2];
} s_seed = { 0 };
if (!s_seed.word[0] && !s_seed.word[1]) {
diff --git a/core/src/xmake/hash/rand32.c b/core/src/xmake/hash/rand32.c
index 7f5286b8e..9e5b486e4 100644
--- a/core/src/xmake/hash/rand32.c
+++ b/core/src/xmake/hash/rand32.c
@@ -42,9 +42,9 @@ tb_int_t xm_hash_rand32(lua_State *lua) {
}
s_seed = xm_hash_xorshift64(s_seed);
- tb_char_t s[256];
+ tb_char_t s[256];
tb_uint32_t word = (s_seed >> 32) ^ (s_seed & 0xffffffff);
- tb_size_t n = xm_hash_make_cstr(s, (tb_byte_t const *)&word, 4);
+ tb_size_t n = xm_hash_make_cstr(s, (tb_byte_t const *)&word, 4);
lua_pushlstring(lua, s, n);
return 1;
diff --git a/core/src/xmake/hash/rand64.c b/core/src/xmake/hash/rand64.c
index ea9539ced..ca761bb31 100644
--- a/core/src/xmake/hash/rand64.c
+++ b/core/src/xmake/hash/rand64.c
@@ -37,7 +37,7 @@ tb_int_t xm_hash_rand64(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
static union {
- tb_byte_t b[8];
+ tb_byte_t b[8];
tb_uint64_t word;
} s_seed = { 0 };
if (!s_seed.word) {
diff --git a/core/src/xmake/hash/sha.c b/core/src/xmake/hash/sha.c
index 7ddcab62f..8140c796c 100644
--- a/core/src/xmake/hash/sha.c
+++ b/core/src/xmake/hash/sha.c
@@ -42,7 +42,7 @@ tb_int_t xm_hash_sha(lua_State *lua) {
// is bytes? get data and size
if (xm_lua_isinteger(lua, 2) && xm_lua_isinteger(lua, 3)) {
tb_byte_t const *data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2);
- tb_size_t size = (tb_size_t)lua_tointeger(lua, 3);
+ tb_size_t size = (tb_size_t)lua_tointeger(lua, 3);
if (!data || !size) {
lua_pushnil(lua);
lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size);
@@ -51,7 +51,7 @@ tb_int_t xm_hash_sha(lua_State *lua) {
tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t));
// compute sha
- tb_sha_t sha;
+ tb_sha_t sha;
tb_byte_t buffer[32];
tb_sha_init(&sha, mode);
tb_sha_spak(&sha, data, size);
@@ -59,7 +59,7 @@ tb_int_t xm_hash_sha(lua_State *lua) {
// make sha string
tb_char_t s[256];
- tb_size_t n = sha.digest_len << 2;
+ tb_size_t n = sha.digest_len << 2;
tb_size_t len = xm_hash_make_cstr(s, buffer, n);
// save result
@@ -72,7 +72,7 @@ tb_int_t xm_hash_sha(lua_State *lua) {
tb_check_return_val(filename, 0);
// load data from file
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
tb_stream_ref_t stream = tb_stream_init_from_file(filename, TB_FILE_MODE_RO);
if (stream) {
// open stream
diff --git a/core/src/xmake/hash/xxhash.c b/core/src/xmake/hash/xxhash.c
index a7fe4a985..bd40e47c7 100644
--- a/core/src/xmake/hash/xxhash.c
+++ b/core/src/xmake/hash/xxhash.c
@@ -51,7 +51,7 @@ tb_int_t xm_hash_xxhash(lua_State *lua) {
// is bytes? get data and size
if (xm_lua_isinteger(lua, 2) && xm_lua_isinteger(lua, 3)) {
tb_byte_t const *data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2);
- tb_size_t size = (tb_size_t)lua_tointeger(lua, 3);
+ tb_size_t size = (tb_size_t)lua_tointeger(lua, 3);
if (!data || !size) {
lua_pushnil(lua);
lua_pushfstring(lua, "invalid data(%p) and size(%d)!", data, (tb_int_t)size);
@@ -61,19 +61,19 @@ tb_int_t xm_hash_xxhash(lua_State *lua) {
// compuate hash
tb_byte_t const *buffer = tb_null;
- tb_uint32_t value32;
- XXH64_hash_t value64;
- XXH128_hash_t value128;
+ tb_uint32_t value32;
+ XXH64_hash_t value64;
+ XXH128_hash_t value128;
if (mode == 128) {
value128 = XM_XXH3_128bits(data, size);
- buffer = (tb_byte_t const *)&value128;
+ buffer = (tb_byte_t const *)&value128;
} else if (mode == 64) {
value64 = XM_XXH3_64bits(data, size);
- buffer = (tb_byte_t const *)&value64;
+ buffer = (tb_byte_t const *)&value64;
} else if (mode == 32) {
value64 = XM_XXH3_64bits(data, size);
value32 = (value64 >> 32) ^ (value64 & 0xffffffff);
- buffer = (tb_byte_t const *)&value32;
+ buffer = (tb_byte_t const *)&value32;
}
if (!buffer) {
lua_pushnil(lua);
@@ -83,7 +83,7 @@ tb_int_t xm_hash_xxhash(lua_State *lua) {
// make xxhash string
tb_char_t s[256];
- tb_size_t n = mode >> 3;
+ tb_size_t n = mode >> 3;
tb_size_t len = xm_hash_make_cstr(s, buffer, n);
// save result
@@ -96,7 +96,7 @@ tb_int_t xm_hash_xxhash(lua_State *lua) {
tb_check_return_val(filename, 0);
// load data from file
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
tb_stream_ref_t stream = tb_stream_init_from_file(filename, TB_FILE_MODE_RO);
if (stream) {
// open stream
@@ -139,24 +139,24 @@ tb_int_t xm_hash_xxhash(lua_State *lua) {
// compuate hash
tb_byte_t const *buffer;
- tb_uint32_t value32;
- XXH64_hash_t value64;
- XXH128_hash_t value128;
+ tb_uint32_t value32;
+ XXH64_hash_t value64;
+ XXH128_hash_t value128;
if (mode == 128) {
value128 = XM_XXH3_128bits_digest(state);
- buffer = (tb_byte_t const *)&value128;
+ buffer = (tb_byte_t const *)&value128;
} else if (mode == 64) {
value64 = XM_XXH3_64bits_digest(state);
- buffer = (tb_byte_t const *)&value64;
+ buffer = (tb_byte_t const *)&value64;
} else if (mode == 32) {
value64 = XM_XXH3_64bits_digest(state);
value32 = (value64 >> 32) ^ (value64 & 0xffffffff);
- buffer = (tb_byte_t const *)&value32;
+ buffer = (tb_byte_t const *)&value32;
}
// make xxhash string
tb_char_t s[256];
- tb_size_t n = mode >> 3;
+ tb_size_t n = mode >> 3;
tb_size_t len = xm_hash_make_cstr(s, buffer, n);
// save result
diff --git a/core/src/xmake/io/file_close.c b/core/src/xmake/io/file_close.c
index cbcb237af..bb5cf1060 100644
--- a/core/src/xmake/io/file_close.c
+++ b/core/src/xmake/io/file_close.c
@@ -53,7 +53,7 @@ tb_int_t xm_io_file_close(lua_State *lua) {
#ifdef TB_CONFIG_OS_WINDOWS
// write cached data first
tb_byte_t const *odata = tb_buffer_data(&file->wcache);
- tb_size_t osize = tb_buffer_size(&file->wcache);
+ tb_size_t osize = tb_buffer_size(&file->wcache);
if (odata && osize) {
if (!tb_stream_bwrit(file->u.file_ref, odata, osize))
return tb_false;
diff --git a/core/src/xmake/io/file_flush.c b/core/src/xmake/io/file_flush.c
index 73652ce20..ffeb890f9 100644
--- a/core/src/xmake/io/file_flush.c
+++ b/core/src/xmake/io/file_flush.c
@@ -44,7 +44,7 @@ static tb_bool_t xm_io_file_flush_impl(xm_io_file_t *file) {
#ifdef TB_CONFIG_OS_WINDOWS
// write cached data first
tb_byte_t const *odata = tb_buffer_data(&file->wcache);
- tb_size_t osize = tb_buffer_size(&file->wcache);
+ tb_size_t osize = tb_buffer_size(&file->wcache);
if (odata && osize) {
if (!tb_stream_bwrit(file->u.file_ref, odata, osize))
return tb_false;
diff --git a/core/src/xmake/io/file_open.c b/core/src/xmake/io/file_open.c
index 901a3f86d..f11b9feb3 100644
--- a/core/src/xmake/io/file_open.c
+++ b/core/src/xmake/io/file_open.c
@@ -46,8 +46,8 @@
static tb_size_t xm_io_file_detect_charset(tb_byte_t const **data_ptr, tb_long_t size) {
tb_assert(data_ptr && *data_ptr);
- tb_byte_t const *data = *data_ptr;
- tb_size_t charset = XM_IO_FILE_ENCODING_BINARY;
+ tb_byte_t const *data = *data_ptr;
+ tb_size_t charset = XM_IO_FILE_ENCODING_BINARY;
do {
// is luajit bitcode? open as binary
if (size >= 3 && data[0] == 27 && data[1] == 'L' && data[2] == 'J') {
@@ -77,9 +77,9 @@ static tb_size_t xm_io_file_detect_charset(tb_byte_t const **data_ptr, tb_long_t
tb_sint16_t utf16be_conf = 0;
tb_sint16_t utf16le_conf = 0;
- tb_sint16_t utf8_conf = 0;
- tb_sint16_t ascii_conf = 0;
- tb_sint16_t zero_count = 0;
+ tb_sint16_t utf8_conf = 0;
+ tb_sint16_t ascii_conf = 0;
+ tb_sint16_t zero_count = 0;
for (tb_long_t i = 0; i < (size - 4) && i < CHECK_SIZE; i++) {
if (data[i] == 0) {
zero_count++;
@@ -150,13 +150,13 @@ static tb_size_t xm_io_file_detect_encoding(tb_stream_ref_t stream, tb_long_t *p
tb_assert_and_check_return_val(stream && pbomoff, XM_IO_FILE_ENCODING_BINARY);
// detect encoding
- tb_byte_t *data = tb_null;
- tb_size_t encoding = XM_IO_FILE_ENCODING_BINARY;
- tb_long_t size = tb_stream_peek(stream, &data, CHECK_SIZE);
+ tb_byte_t *data = tb_null;
+ tb_size_t encoding = XM_IO_FILE_ENCODING_BINARY;
+ tb_long_t size = tb_stream_peek(stream, &data, CHECK_SIZE);
if (size > 0) {
tb_byte_t const *p = data;
- encoding = xm_io_file_detect_charset(&p, size);
- *pbomoff = p - data;
+ encoding = xm_io_file_detect_charset(&p, size);
+ *pbomoff = p - data;
}
return encoding;
}
@@ -170,7 +170,7 @@ tb_int_t xm_io_file_open(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get file path and mode
- tb_char_t const *path = luaL_checkstring(lua, 1);
+ tb_char_t const *path = luaL_checkstring(lua, 1);
tb_char_t const *modestr = luaL_optstring(lua, 2, "r");
tb_assert_and_check_return_val(path && modestr, 0);
@@ -190,10 +190,10 @@ tb_int_t xm_io_file_open(lua_State *lua) {
}
// get file encoding
- tb_long_t bomoff = 0;
- tb_stream_ref_t stream = tb_null;
- tb_bool_t update = !!tb_strchr(modestr, '+');
- tb_size_t encoding = XM_IO_FILE_ENCODING_UNKNOWN;
+ tb_long_t bomoff = 0;
+ tb_stream_ref_t stream = tb_null;
+ tb_bool_t update = !!tb_strchr(modestr, '+');
+ tb_size_t encoding = XM_IO_FILE_ENCODING_UNKNOWN;
if (modestr[1] == 'b' || (update && modestr[2] == 'b')) {
encoding = XM_IO_FILE_ENCODING_BINARY;
} else if (tb_strstr(modestr, "utf8") || tb_strstr(modestr, "utf-8")) {
@@ -236,9 +236,9 @@ tb_int_t xm_io_file_open(lua_State *lua) {
}
// open file
- tb_bool_t open_ok = tb_false;
+ tb_bool_t open_ok = tb_false;
tb_stream_ref_t file_ref = tb_null;
- tb_stream_ref_t fstream = tb_null;
+ tb_stream_ref_t fstream = tb_null;
do {
// init stream from file
stream = stream ? stream : tb_stream_init_from_file(path, mode);
@@ -298,12 +298,12 @@ tb_int_t xm_io_file_open(lua_State *lua) {
// init file
file->u.file_ref = file_ref;
- file->stream = stream;
- file->fstream = fstream;
- file->mode = mode;
- file->type = XM_IO_FILE_TYPE_FILE;
- file->encoding = encoding;
- file->utfbom = utfbom;
+ file->stream = stream;
+ file->fstream = fstream;
+ file->mode = mode;
+ file->type = XM_IO_FILE_TYPE_FILE;
+ file->encoding = encoding;
+ file->utfbom = utfbom;
// init the read/write line cache buffer
tb_buffer_init(&file->rcache);
diff --git a/core/src/xmake/io/file_read.c b/core/src/xmake/io/file_read.c
index 0b255f4c1..6b7e560ce 100644
--- a/core/src/xmake/io/file_read.c
+++ b/core/src/xmake/io/file_read.c
@@ -47,10 +47,10 @@ static tb_long_t xm_io_file_buffer_readline(tb_stream_ref_t stream, tb_buffer_re
tb_assert_and_check_return_val(stream && line, -1);
// read line and reserve crlf
- tb_bool_t eof = tb_false;
- tb_hize_t offset = 0;
- tb_byte_t *data = tb_null;
- tb_hong_t size = tb_stream_size(stream);
+ tb_bool_t eof = tb_false;
+ tb_hize_t offset = 0;
+ tb_byte_t *data = tb_null;
+ tb_hong_t size = tb_stream_size(stream);
while (size < 0 || (offset = tb_stream_offset(stream)) < size) {
tb_long_t real = tb_stream_peek(stream, &data, XM_IO_BLOCK_MAXN);
if (real > 0) {
@@ -85,17 +85,17 @@ static tb_long_t xm_io_file_buffer_readline(tb_stream_ref_t stream, tb_buffer_re
return (eof || tb_stream_beof(stream)) ? -1 : 0;
}
}
-static tb_int_t xm_io_file_buffer_pushline(tb_buffer_ref_t buf,
- xm_io_file_t *file,
+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) {
+ tb_bool_t keep_crlf) {
tb_assert(buf && file && continuation && xm_io_file_is_file(file) && file->u.file_ref);
// is binary?
tb_bool_t is_binary = file->encoding == XM_IO_FILE_ENCODING_BINARY;
if (is_binary) {
continuation = "";
- keep_crlf = tb_true;
+ keep_crlf = tb_true;
}
// clear line buffer
@@ -105,9 +105,9 @@ static tb_int_t xm_io_file_buffer_pushline(tb_buffer_ref_t buf,
tb_long_t size = xm_io_file_buffer_readline(file->u.file_ref, &file->rcache);
// translate line data
- tb_int_t result = PL_FAIL;
- tb_char_t *data = tb_null;
- tb_size_t conlen = tb_strlen(continuation);
+ tb_int_t result = PL_FAIL;
+ tb_char_t *data = tb_null;
+ tb_size_t conlen = tb_strlen(continuation);
do {
// eof?
if (size < 0) {
@@ -244,10 +244,10 @@ static tb_int_t xm_io_file_read_all(lua_State *lua, xm_io_file_t *file, tb_char_
}
}
-static tb_int_t xm_io_file_read_line(lua_State *lua,
- xm_io_file_t *file,
+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) {
+ tb_bool_t keep_crlf) {
tb_assert(lua && file && continuation && xm_io_file_is_file(file) && file->u.file_ref);
// init buffer
@@ -319,10 +319,10 @@ static tb_int_t xm_io_file_read_n(lua_State *lua, xm_io_file_t *file, tb_char_t
return 1;
}
-static tb_size_t xm_io_file_std_buffer_pushline(tb_buffer_ref_t buf,
- xm_io_file_t *file,
+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) {
+ tb_bool_t keep_crlf) {
tb_assert(buf && file && continuation && xm_io_file_is_std(file));
// get input buffer
@@ -376,10 +376,10 @@ static tb_size_t xm_io_file_std_buffer_pushline(tb_buffer_ref_t buf,
return result;
}
-static tb_int_t xm_io_file_std_read_line(lua_State *lua,
- xm_io_file_t *file,
+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) {
+ tb_bool_t keep_crlf) {
tb_assert(lua && file && continuation && xm_io_file_is_std(file));
// init buffer
diff --git a/core/src/xmake/io/file_seek.c b/core/src/xmake/io/file_seek.c
index c7c043e7a..4c2d17b71 100644
--- a/core/src/xmake/io/file_seek.c
+++ b/core/src/xmake/io/file_seek.c
@@ -49,7 +49,7 @@ tb_int_t xm_io_file_seek(lua_State *lua) {
// get whence and offset
tb_char_t const *whence = luaL_optstring(lua, 2, "cur");
- tb_hong_t offset = (tb_hong_t)luaL_optnumber(lua, 3, 0);
+ tb_hong_t offset = (tb_hong_t)luaL_optnumber(lua, 3, 0);
tb_assert_and_check_return_val(whence, 0);
// seek file
diff --git a/core/src/xmake/io/file_write.c b/core/src/xmake/io/file_write.c
index 08655379a..fdfd5afe7 100644
--- a/core/src/xmake/io/file_write.c
+++ b/core/src/xmake/io/file_write.c
@@ -65,7 +65,7 @@ static tb_void_t xm_io_file_write_file_transcrlf(xm_io_file_t *file, tb_byte_t c
// write cached data first
tb_byte_t const *odata = tb_buffer_data(&file->wcache);
- tb_size_t osize = tb_buffer_size(&file->wcache);
+ tb_size_t osize = tb_buffer_size(&file->wcache);
if (odata && osize) {
if (!tb_stream_bwrit(file->u.file_ref, odata, osize))
return;
@@ -73,8 +73,8 @@ static tb_void_t xm_io_file_write_file_transcrlf(xm_io_file_t *file, tb_byte_t c
}
// write data by lines
- tb_char_t const *p = (tb_char_t const *)data;
- tb_char_t const *e = p + size;
+ tb_char_t const *p = (tb_char_t const *)data;
+ tb_char_t const *e = p + size;
tb_char_t const *lf = tb_null;
while (p < e) {
lf = tb_strnchr(p, e - p, '\n');
@@ -135,8 +135,8 @@ tb_int_t xm_io_file_write(lua_State *lua) {
tb_bool_t is_binary = file->encoding == XM_IO_FILE_ENCODING_BINARY;
for (tb_int_t i = 2; i <= narg; i++) {
// get data
- size_t datasize = 0;
- tb_byte_t const *data = tb_null;
+ size_t datasize = 0;
+ tb_byte_t const *data = tb_null;
if (lua_isstring(lua, i)) {
data = (tb_byte_t const *)luaL_checklstring(lua, i, &datasize);
} else if (lua_istable(lua, i)) {
diff --git a/core/src/xmake/io/filelock_open.c b/core/src/xmake/io/filelock_open.c
index 2afb173d3..85df2bba7 100644
--- a/core/src/xmake/io/filelock_open.c
+++ b/core/src/xmake/io/filelock_open.c
@@ -45,7 +45,7 @@ tb_int_t xm_io_filelock_open(lua_State *lua) {
tb_assert_and_check_return_val(path, 0);
// init file lock
- tb_long_t tryn = 2;
+ tb_long_t tryn = 2;
tb_filelock_ref_t lock = tb_null;
while (!lock && tryn-- > 0) {
lock = tb_filelock_init_from_path(path,
diff --git a/core/src/xmake/io/iscygpty.c b/core/src/xmake/io/iscygpty.c
index 656e86fe7..e46d8c41f 100644
--- a/core/src/xmake/io/iscygpty.c
+++ b/core/src/xmake/io/iscygpty.c
@@ -60,17 +60,17 @@
#define USE_DYNFILEID // we need to enable it for supporting xp
#endif
#ifdef USE_DYNFILEID
-typedef BOOL(WINAPI *pfnGetFileInformationByHandleEx)(HANDLE hFile,
+typedef BOOL(WINAPI *pfnGetFileInformationByHandleEx)(HANDLE hFile,
FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
- LPVOID lpFileInformation,
- DWORD dwBufferSize);
+ LPVOID lpFileInformation,
+ DWORD dwBufferSize);
static pfnGetFileInformationByHandleEx pGetFileInformationByHandleEx = NULL;
#ifndef USE_FILEEXTD
-static BOOL WINAPI stub_GetFileInformationByHandleEx(HANDLE hFile,
+static BOOL WINAPI stub_GetFileInformationByHandleEx(HANDLE hFile,
FILE_INFO_BY_HANDLE_CLASS FileInformationClass,
- LPVOID lpFileInformation,
- DWORD dwBufferSize) {
+ LPVOID lpFileInformation,
+ DWORD dwBufferSize) {
return FALSE;
}
#endif
@@ -101,9 +101,9 @@ int is_cygpty(HANDLE h) {
#if defined(STUB_IMPL)
return 0;
#elif _WIN32_WINNT >= 0x0600
- int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * (MAX_PATH - 1);
+ int size = sizeof(FILE_NAME_INFO) + sizeof(WCHAR) * (MAX_PATH - 1);
FILE_NAME_INFO *nameinfo;
- WCHAR *p = NULL;
+ WCHAR *p = NULL;
setup_fileid_api();
@@ -122,7 +122,7 @@ int is_cygpty(HANDLE h) {
* '\{cygwin,msys}-XXXXXXXXXXXXXXXX-ptyN-{from,to}-master' */
if (pGetFileInformationByHandleEx(h, FileNameInfo, nameinfo, size)) {
nameinfo->FileName[nameinfo->FileNameLength / sizeof(WCHAR)] = L'\0';
- p = nameinfo->FileName;
+ p = nameinfo->FileName;
if (is_wprefix(p, L"\\cygwin-")) { /* Cygwin */
p += 8;
} else if (is_wprefix(p, L"\\msys-")) { /* MSYS and MSYS2 */
diff --git a/core/src/xmake/io/pipe_write.c b/core/src/xmake/io/pipe_write.c
index d3098dd60..9ca1417a1 100644
--- a/core/src/xmake/io/pipe_write.c
+++ b/core/src/xmake/io/pipe_write.c
@@ -50,7 +50,7 @@ tb_int_t xm_io_pipe_write(lua_State *lua) {
tb_check_return_val(pipefile, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 2)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2);
diff --git a/core/src/xmake/io/poller.h b/core/src/xmake/io/poller.h
index 3c5937a68..4e7313691 100644
--- a/core/src/xmake/io/poller.h
+++ b/core/src/xmake/io/poller.h
@@ -33,7 +33,7 @@
// the poller state in wait events
typedef struct __xm_poller_state_t {
lua_State *lua;
- tb_int_t events_count;
+ tb_int_t events_count;
} xm_poller_state_t;
/* //////////////////////////////////////////////////////////////////////////////////////
diff --git a/core/src/xmake/io/poller_insert.c b/core/src/xmake/io/poller_insert.c
index 81f66cce9..38fb4097a 100644
--- a/core/src/xmake/io/poller_insert.c
+++ b/core/src/xmake/io/poller_insert.c
@@ -51,7 +51,7 @@ tb_int_t xm_io_poller_insert(lua_State *lua) {
// get cdata
tb_char_t const *cdata_str = tb_null;
- tb_pointer_t cdata = (tb_pointer_t)xm_lua_topointer2(lua, 2, &cdata_str);
+ tb_pointer_t cdata = (tb_pointer_t)xm_lua_topointer2(lua, 2, &cdata_str);
tb_check_return_val(cdata, 0);
// get events
diff --git a/core/src/xmake/io/poller_modify.c b/core/src/xmake/io/poller_modify.c
index f9283aecb..fc99a9352 100644
--- a/core/src/xmake/io/poller_modify.c
+++ b/core/src/xmake/io/poller_modify.c
@@ -51,7 +51,7 @@ tb_int_t xm_io_poller_modify(lua_State *lua) {
// get cdata
tb_char_t const *cdata_str = tb_null;
- tb_pointer_t cdata = (tb_pointer_t)xm_lua_topointer2(lua, 2, &cdata_str);
+ tb_pointer_t cdata = (tb_pointer_t)xm_lua_topointer2(lua, 2, &cdata_str);
tb_check_return_val(cdata, 0);
// get events
diff --git a/core/src/xmake/io/poller_wait.c b/core/src/xmake/io/poller_wait.c
index dc1418a03..b704e3cf4 100644
--- a/core/src/xmake/io/poller_wait.c
+++ b/core/src/xmake/io/poller_wait.c
@@ -34,10 +34,10 @@
/* //////////////////////////////////////////////////////////////////////////////////////
* private implementation
*/
-static tb_void_t xm_io_poller_event(tb_poller_ref_t poller,
+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) {
+ tb_long_t events,
+ tb_cpointer_t priv) {
xm_poller_state_t *state = (xm_poller_state_t *)tb_poller_priv(poller);
tb_assert_and_check_return(state && state->lua);
@@ -85,7 +85,7 @@ tb_int_t xm_io_poller_wait(lua_State *lua) {
// reset events count
xm_poller_state_t *state = (xm_poller_state_t *)tb_poller_priv(poller);
- state->events_count = 0;
+ state->events_count = 0;
// wait it
lua_newtable(lua);
diff --git a/core/src/xmake/io/prefix.h b/core/src/xmake/io/prefix.h
index 4d312583c..7c339cf36 100644
--- a/core/src/xmake/io/prefix.h
+++ b/core/src/xmake/io/prefix.h
@@ -82,12 +82,12 @@ typedef struct __xm_io_file_t {
tb_stream_ref_t stream; // the file stream for XM_IO_FILE_TYPE_FILE
tb_stream_ref_t fstream; // the file charset stream filter
- tb_size_t mode; // tb_file_mode_t
- tb_size_t type; // xm_io_file_type_e
- tb_size_t encoding; // value of xm_io_file_encoding_e or tb_charset_type_e
- tb_bool_t utfbom; // write utf-bom for utf encoding?
- tb_buffer_t rcache; // the read line cache buffer
- tb_buffer_t wcache; // the write line cache buffer
+ tb_size_t mode; // tb_file_mode_t
+ tb_size_t type; // xm_io_file_type_e
+ tb_size_t encoding; // value of xm_io_file_encoding_e or tb_charset_type_e
+ tb_bool_t utfbom; // write utf-bom for utf encoding?
+ tb_buffer_t rcache; // the read line cache buffer
+ tb_buffer_t wcache; // the write line cache buffer
} xm_io_file_t;
// check pipe file
diff --git a/core/src/xmake/io/socket_peeraddr.c b/core/src/xmake/io/socket_peeraddr.c
index 686d46799..f28f84bb1 100644
--- a/core/src/xmake/io/socket_peeraddr.c
+++ b/core/src/xmake/io/socket_peeraddr.c
@@ -56,8 +56,8 @@ tb_int_t xm_io_socket_peeraddr(lua_State *lua) {
tb_check_return_val(sock, 0);
// get peer address
- tb_ipaddr_t addr;
- tb_char_t data[256];
+ tb_ipaddr_t addr;
+ tb_char_t data[256];
tb_char_t const *cstr = tb_null;
if (tb_socket_peer(sock, &addr) && (cstr = tb_ipaddr_cstr(&addr, data, sizeof(data)))) {
lua_pushstring(lua, cstr);
diff --git a/core/src/xmake/io/socket_recvfrom.c b/core/src/xmake/io/socket_recvfrom.c
index 5e212bed8..ff4315f1e 100644
--- a/core/src/xmake/io/socket_recvfrom.c
+++ b/core/src/xmake/io/socket_recvfrom.c
@@ -75,14 +75,14 @@ tb_int_t xm_io_socket_recvfrom(lua_State *lua) {
// recv data
tb_ipaddr_t ipaddr;
tb_ipaddr_clear(&ipaddr);
- tb_int_t retn = 1;
+ tb_int_t retn = 1;
tb_long_t real = tb_socket_urecv(sock, &ipaddr, data, size);
lua_pushinteger(lua, (tb_int_t)real);
if (real > 0) {
retn = 2;
lua_pushnil(lua);
if (!tb_ipaddr_is_empty(&ipaddr)) {
- tb_char_t buffer[256];
+ tb_char_t buffer[256];
tb_char_t const *ipstr = tb_ipaddr_ip_cstr(&ipaddr, buffer, sizeof(buffer));
if (ipstr) {
lua_pushstring(lua, ipstr);
diff --git a/core/src/xmake/io/socket_send.c b/core/src/xmake/io/socket_send.c
index 3a11d0d43..4de7023ab 100644
--- a/core/src/xmake/io/socket_send.c
+++ b/core/src/xmake/io/socket_send.c
@@ -50,7 +50,7 @@ tb_int_t xm_io_socket_send(lua_State *lua) {
tb_check_return_val(sock, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 2)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2);
diff --git a/core/src/xmake/io/socket_sendto.c b/core/src/xmake/io/socket_sendto.c
index ccbbb1cc2..17f7e4ca2 100644
--- a/core/src/xmake/io/socket_sendto.c
+++ b/core/src/xmake/io/socket_sendto.c
@@ -50,7 +50,7 @@ tb_int_t xm_io_socket_sendto(lua_State *lua) {
tb_check_return_val(sock, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 2)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2);
@@ -67,7 +67,7 @@ tb_int_t xm_io_socket_sendto(lua_State *lua) {
// get address
tb_char_t const *addr = lua_tostring(lua, 4);
- tb_uint16_t port = (tb_uint16_t)luaL_checknumber(lua, 5);
+ tb_uint16_t port = (tb_uint16_t)luaL_checknumber(lua, 5);
if (!addr || !port) {
lua_pushinteger(lua, -1);
lua_pushliteral(lua, "invalid address!");
diff --git a/core/src/xmake/io/stdfile.c b/core/src/xmake/io/stdfile.c
index ac77b272d..db420d41b 100644
--- a/core/src/xmake/io/stdfile.c
+++ b/core/src/xmake/io/stdfile.c
@@ -54,7 +54,7 @@
static tb_size_t xm_io_stdfile_isatty(tb_size_t type) {
tb_bool_t answer = tb_false;
#if defined(TB_CONFIG_OS_WINDOWS)
- DWORD mode;
+ DWORD mode;
HANDLE console_handle = tb_null;
switch (type) {
case XM_IO_FILE_TYPE_STDIN:
@@ -98,7 +98,7 @@ static tb_size_t xm_io_stdfile_isatty(tb_size_t type) {
static tb_void_t xm_io_stdfile_init_buffer(tb_size_t type) {
#if !defined(TB_CONFIG_OS_WINDOWS)
struct stat stats;
- tb_int_t size = BUFSIZ;
+ tb_int_t size = BUFSIZ;
if (fstat(fileno(stdout), &stats) != -1) {
size = stats.st_blksize;
}
diff --git a/core/src/xmake/libc/malloc.c b/core/src/xmake/libc/malloc.c
index 6bda4167d..5385f15b4 100644
--- a/core/src/xmake/libc/malloc.c
+++ b/core/src/xmake/libc/malloc.c
@@ -38,7 +38,7 @@ tb_int_t xm_libc_malloc(lua_State *lua) {
// do malloc
tb_pointer_t data = tb_null;
- tb_long_t size = (tb_long_t)luaL_checkinteger(lua, 1);
+ tb_long_t size = (tb_long_t)luaL_checkinteger(lua, 1);
if (size > 0) {
data = tb_malloc(size);
}
diff --git a/core/src/xmake/libc/memcpy.c b/core/src/xmake/libc/memcpy.c
index ce5e34312..08b328d8c 100644
--- a/core/src/xmake/libc/memcpy.c
+++ b/core/src/xmake/libc/memcpy.c
@@ -37,9 +37,9 @@ tb_int_t xm_libc_memcpy(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// do memcpy
- tb_pointer_t dst = (tb_pointer_t)(tb_size_t)luaL_checkinteger(lua, 1);
- tb_pointer_t src = (tb_pointer_t)(tb_size_t)luaL_checkinteger(lua, 2);
- tb_int_t size = (tb_int_t)lua_tointeger(lua, 3);
+ tb_pointer_t dst = (tb_pointer_t)(tb_size_t)luaL_checkinteger(lua, 1);
+ tb_pointer_t src = (tb_pointer_t)(tb_size_t)luaL_checkinteger(lua, 2);
+ tb_int_t size = (tb_int_t)lua_tointeger(lua, 3);
if (dst && src && size > 0) {
tb_memcpy(dst, src, size);
}
diff --git a/core/src/xmake/libc/memmov.c b/core/src/xmake/libc/memmov.c
index 1843a4301..763cc06f0 100644
--- a/core/src/xmake/libc/memmov.c
+++ b/core/src/xmake/libc/memmov.c
@@ -37,9 +37,9 @@ tb_int_t xm_libc_memmov(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// do memmov
- tb_pointer_t dst = (tb_pointer_t)(tb_size_t)luaL_checkinteger(lua, 1);
- tb_pointer_t src = (tb_pointer_t)(tb_size_t)luaL_checkinteger(lua, 2);
- tb_int_t size = (tb_int_t)lua_tointeger(lua, 3);
+ tb_pointer_t dst = (tb_pointer_t)(tb_size_t)luaL_checkinteger(lua, 1);
+ tb_pointer_t src = (tb_pointer_t)(tb_size_t)luaL_checkinteger(lua, 2);
+ tb_int_t size = (tb_int_t)lua_tointeger(lua, 3);
if (dst && src && size > 0) {
tb_memmov(dst, src, size);
}
diff --git a/core/src/xmake/libc/memset.c b/core/src/xmake/libc/memset.c
index 01b4f3f89..bce0156ef 100644
--- a/core/src/xmake/libc/memset.c
+++ b/core/src/xmake/libc/memset.c
@@ -38,8 +38,8 @@ tb_int_t xm_libc_memset(lua_State *lua) {
// do memset
tb_pointer_t data = (tb_pointer_t)(tb_size_t)luaL_checkinteger(lua, 1);
- tb_char_t ch = (tb_char_t)lua_tointeger(lua, 2);
- tb_int_t size = (tb_int_t)lua_tointeger(lua, 3);
+ tb_char_t ch = (tb_char_t)lua_tointeger(lua, 2);
+ tb_int_t size = (tb_int_t)lua_tointeger(lua, 3);
if (data && size > 0) {
tb_memset(data, ch, size);
}
diff --git a/core/src/xmake/lz4/block_compress.c b/core/src/xmake/lz4/block_compress.c
index 34fb06def..2d8e8ae36 100644
--- a/core/src/xmake/lz4/block_compress.c
+++ b/core/src/xmake/lz4/block_compress.c
@@ -37,7 +37,7 @@ tb_int_t xm_lz4_block_compress(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get data and size
- tb_int_t size = 0;
+ tb_int_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 1)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1);
@@ -53,7 +53,7 @@ tb_int_t xm_lz4_block_compress(lua_State *lua) {
tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t));
// do compress
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
tb_byte_t *output_data = tb_null;
tb_byte_t buffer[8192];
do {
diff --git a/core/src/xmake/lz4/block_decompress.c b/core/src/xmake/lz4/block_decompress.c
index 07c80236d..52d4fa3d3 100644
--- a/core/src/xmake/lz4/block_decompress.c
+++ b/core/src/xmake/lz4/block_decompress.c
@@ -37,7 +37,7 @@ tb_int_t xm_lz4_block_decompress(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 1)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1);
@@ -61,7 +61,7 @@ tb_int_t xm_lz4_block_decompress(lua_State *lua) {
}
// do decompress
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
tb_byte_t *output_data = tb_null;
tb_byte_t buffer[8192];
do {
diff --git a/core/src/xmake/lz4/compress.c b/core/src/xmake/lz4/compress.c
index dffda1f23..6a9e3fad3 100644
--- a/core/src/xmake/lz4/compress.c
+++ b/core/src/xmake/lz4/compress.c
@@ -37,7 +37,7 @@ tb_int_t xm_lz4_compress(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 1)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1);
@@ -53,10 +53,10 @@ tb_int_t xm_lz4_compress(lua_State *lua) {
tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t));
// do compress
- tb_bool_t ok = tb_false;
- tb_char_t const *error = tb_null;
- tb_byte_t *output_data = tb_null;
- tb_byte_t buffer[8192];
+ tb_bool_t ok = tb_false;
+ tb_char_t const *error = tb_null;
+ tb_byte_t *output_data = tb_null;
+ tb_byte_t buffer[8192];
do {
tb_size_t output_size = LZ4F_compressFrameBound(size, tb_null);
tb_assert_and_check_break(output_size);
diff --git a/core/src/xmake/lz4/compress_file.c b/core/src/xmake/lz4/compress_file.c
index 552ece99d..d54781db7 100644
--- a/core/src/xmake/lz4/compress_file.c
+++ b/core/src/xmake/lz4/compress_file.c
@@ -46,7 +46,7 @@ tb_int_t xm_lz4_compress_file(lua_State *lua) {
tb_check_return_val(stream_lz4, 0);
// do compress
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
tb_stream_ref_t istream = tb_stream_init_from_file(srcpath, TB_FILE_MODE_RO);
tb_stream_ref_t ostream = tb_stream_init_from_file(dstpath,
TB_FILE_MODE_RW | TB_FILE_MODE_CREAT | TB_FILE_MODE_TRUNC);
diff --git a/core/src/xmake/lz4/compress_stream_write.c b/core/src/xmake/lz4/compress_stream_write.c
index 8a4276318..1be30226d 100644
--- a/core/src/xmake/lz4/compress_stream_write.c
+++ b/core/src/xmake/lz4/compress_stream_write.c
@@ -49,7 +49,7 @@ tb_int_t xm_lz4_compress_stream_write(lua_State *lua) {
tb_check_return_val(stream, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 2)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2);
diff --git a/core/src/xmake/lz4/decompress.c b/core/src/xmake/lz4/decompress.c
index 500e932a1..406a7c850 100644
--- a/core/src/xmake/lz4/decompress.c
+++ b/core/src/xmake/lz4/decompress.c
@@ -37,7 +37,7 @@ tb_int_t xm_lz4_decompress(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 1)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 1);
@@ -53,10 +53,10 @@ tb_int_t xm_lz4_decompress(lua_State *lua) {
tb_assert_static(sizeof(lua_Integer) >= sizeof(tb_pointer_t));
// do decompress
- tb_bool_t ok = tb_false;
- LZ4F_errorCode_t code;
+ tb_bool_t ok = tb_false;
+ LZ4F_errorCode_t code;
LZ4F_decompressionContext_t ctx = tb_null;
- tb_buffer_t result;
+ tb_buffer_t result;
do {
tb_buffer_init(&result);
@@ -68,9 +68,9 @@ tb_int_t xm_lz4_decompress(lua_State *lua) {
tb_byte_t buffer[8192];
tb_bool_t failed = tb_false;
while (1) {
- size_t advance = (size_t)size;
+ size_t advance = (size_t)size;
size_t buffer_size = sizeof(buffer);
- code = LZ4F_decompress(ctx, buffer, &buffer_size, data, &advance, tb_null);
+ code = LZ4F_decompress(ctx, buffer, &buffer_size, data, &advance, tb_null);
if (LZ4F_isError(code)) {
failed = tb_true;
break;
diff --git a/core/src/xmake/lz4/decompress_file.c b/core/src/xmake/lz4/decompress_file.c
index accc993f8..2a79456fd 100644
--- a/core/src/xmake/lz4/decompress_file.c
+++ b/core/src/xmake/lz4/decompress_file.c
@@ -46,7 +46,7 @@ tb_int_t xm_lz4_decompress_file(lua_State *lua) {
tb_check_return_val(stream_lz4, 0);
// do decompress
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
tb_stream_ref_t istream = tb_stream_init_from_file(srcpath, TB_FILE_MODE_RO);
tb_stream_ref_t ostream = tb_stream_init_from_file(dstpath,
TB_FILE_MODE_RW | TB_FILE_MODE_CREAT | TB_FILE_MODE_TRUNC);
diff --git a/core/src/xmake/lz4/decompress_stream_write.c b/core/src/xmake/lz4/decompress_stream_write.c
index 94be0533e..3ab6ce92e 100644
--- a/core/src/xmake/lz4/decompress_stream_write.c
+++ b/core/src/xmake/lz4/decompress_stream_write.c
@@ -49,7 +49,7 @@ tb_int_t xm_lz4_decompress_stream_write(lua_State *lua) {
tb_check_return_val(stream, 0);
// get data and size
- tb_size_t size = 0;
+ tb_size_t size = 0;
tb_byte_t const *data = tb_null;
if (xm_lua_isinteger(lua, 2)) {
data = (tb_byte_t const *)(tb_size_t)(tb_long_t)lua_tointeger(lua, 2);
diff --git a/core/src/xmake/lz4/prefix.h b/core/src/xmake/lz4/prefix.h
index 534e5361a..b39a38566 100644
--- a/core/src/xmake/lz4/prefix.h
+++ b/core/src/xmake/lz4/prefix.h
@@ -56,22 +56,22 @@ typedef unsigned int LZ4_u32;
// the lz4 compress stream type
typedef struct __xm_lz4_cstream_t {
LZ4F_cctx *cctx;
- LZ4_byte *buffer;
- tb_size_t buffer_size;
- tb_size_t buffer_maxn;
- tb_size_t write_maxn;
- tb_size_t header_size;
- LZ4_byte header[LZ4F_HEADER_SIZE_MAX];
+ LZ4_byte *buffer;
+ tb_size_t buffer_size;
+ tb_size_t buffer_maxn;
+ tb_size_t write_maxn;
+ tb_size_t header_size;
+ LZ4_byte header[LZ4F_HEADER_SIZE_MAX];
} xm_lz4_cstream_t;
// the lz4 decompress stream type
typedef struct __xm_lz4_dstream_t {
LZ4F_dctx *dctx;
- LZ4_byte *buffer;
- tb_size_t buffer_size;
- tb_size_t buffer_maxn;
- tb_size_t header_size;
- LZ4_byte header[LZ4F_HEADER_SIZE_MAX];
+ LZ4_byte *buffer;
+ tb_size_t buffer_size;
+ tb_size_t buffer_maxn;
+ tb_size_t header_size;
+ LZ4_byte header[LZ4F_HEADER_SIZE_MAX];
} xm_lz4_dstream_t;
/* //////////////////////////////////////////////////////////////////////////////////////
@@ -93,17 +93,17 @@ static __tb_inline__ tb_void_t xm_lz4_cstream_exit(xm_lz4_cstream_t *stream) {
}
static __tb_inline__ xm_lz4_cstream_t *xm_lz4_cstream_init() {
- tb_size_t ret;
- tb_bool_t ok = tb_false;
- xm_lz4_cstream_t *stream = tb_null;
+ tb_size_t ret;
+ tb_bool_t ok = tb_false;
+ xm_lz4_cstream_t *stream = tb_null;
LZ4F_preferences_t const *prefsPtr = tb_null;
do {
stream = tb_malloc0_type(xm_lz4_cstream_t);
tb_assert_and_check_break(stream);
- stream->write_maxn = 64 * 1024;
+ stream->write_maxn = 64 * 1024;
stream->buffer_maxn = LZ4F_compressBound(stream->write_maxn, prefsPtr);
- stream->buffer = (LZ4_byte *)tb_malloc(stream->buffer_maxn);
+ stream->buffer = (LZ4_byte *)tb_malloc(stream->buffer_maxn);
tb_assert_and_check_break(stream->buffer);
ret = LZ4F_createCompressionContext(&stream->cctx, LZ4F_getVersion());
diff --git a/core/src/xmake/os/args.c b/core/src/xmake/os/args.c
index b48445c89..02c576aef 100644
--- a/core/src/xmake/os/args.c
+++ b/core/src/xmake/os/args.c
@@ -38,9 +38,9 @@ static tb_void_t tb_os_args_append(
tb_assert_and_check_return(size < TB_PATH_MAXN);
// need wrap quote?
- tb_char_t ch;
- tb_char_t const *p = cstr;
- tb_bool_t wrap_quote = tb_false;
+ tb_char_t ch;
+ tb_char_t const *p = cstr;
+ tb_bool_t wrap_quote = tb_false;
if (!nowrap) {
while ((ch = *p)) {
if (ch == ' ') {
@@ -119,14 +119,14 @@ tb_int_t xm_os_args(lua_State *lua) {
if (lua_istable(lua, -1)) { // is path instance?
lua_pushstring(lua, "_STR");
lua_gettable(lua, -2);
- size_t size = 0;
+ size_t size = 0;
tb_char_t const *cstr = luaL_checklstring(lua, -1, &size);
if (cstr && size) {
tb_os_args_append(&result, cstr, size, escape, nowrap);
}
lua_pop(lua, 1);
} else {
- size_t size = 0;
+ size_t size = 0;
tb_char_t const *cstr = luaL_checklstring(lua, -1, &size);
if (cstr && size) {
tb_os_args_append(&result, cstr, size, escape, nowrap);
@@ -135,7 +135,7 @@ tb_int_t xm_os_args(lua_State *lua) {
lua_pop(lua, 1);
}
} else {
- size_t size = 0;
+ size_t size = 0;
tb_char_t const *cstr = luaL_checklstring(lua, 1, &size);
if (cstr && size) {
tb_os_args_append(&result, cstr, size, escape, nowrap);
diff --git a/core/src/xmake/os/argv.c b/core/src/xmake/os/argv.c
index 12b1f88ec..09a9d27ec 100644
--- a/core/src/xmake/os/argv.c
+++ b/core/src/xmake/os/argv.c
@@ -61,12 +61,12 @@ tb_int_t xm_os_argv(lua_State *lua) {
}
// parse command to the arguments
- tb_int_t i = 1;
- tb_int_t skip = 0;
- tb_int_t escape = 0;
- tb_char_t quote = 0;
- tb_char_t ch = 0;
- tb_char_t const *p = args;
+ tb_int_t i = 1;
+ tb_int_t skip = 0;
+ tb_int_t escape = 0;
+ tb_char_t quote = 0;
+ tb_char_t ch = 0;
+ tb_char_t const *p = args;
while ((ch = *p)) {
// no escape now?
if (!escape) {
diff --git a/core/src/xmake/os/cpuinfo.c b/core/src/xmake/os/cpuinfo.c
index 7be9172cc..47542a4b4 100644
--- a/core/src/xmake/os/cpuinfo.c
+++ b/core/src/xmake/os/cpuinfo.c
@@ -65,15 +65,15 @@ static tb_uint64_t xm_os_cpuinfo_subtract_times(FILETIME const *one, FILETIME co
static tb_float_t xm_os_cpuinfo_usagerate() {
#if defined(TB_CONFIG_OS_MACOSX)
- tb_float_t usagerate = 0;
- natural_t cpu_count = 0;
+ tb_float_t usagerate = 0;
+ natural_t cpu_count = 0;
processor_info_array_t cpuinfo;
mach_msg_type_number_t cpuinfo_count;
- static tb_hong_t s_time = 0;
+ static tb_hong_t s_time = 0;
if (tb_mclock() - s_time > 1000 &&
host_processor_info(mach_host_self(), PROCESSOR_CPU_LOAD_INFO, &cpu_count, &cpuinfo, &cpuinfo_count) ==
KERN_SUCCESS) {
- static processor_info_array_t s_cpuinfo_prev = tb_null;
+ static processor_info_array_t s_cpuinfo_prev = tb_null;
static mach_msg_type_number_t s_cpuinfo_count_prev = 0;
for (tb_int_t i = 0; i < cpu_count; ++i) {
tb_int_t use, total;
@@ -96,27 +96,27 @@ static tb_float_t xm_os_cpuinfo_usagerate() {
if (s_cpuinfo_prev) {
vm_deallocate(mach_task_self(), (vm_address_t)s_cpuinfo_prev, sizeof(integer_t) * s_cpuinfo_count_prev);
}
- s_time = tb_mclock();
- s_cpuinfo_prev = cpuinfo;
+ s_time = tb_mclock();
+ s_cpuinfo_prev = cpuinfo;
s_cpuinfo_count_prev = cpuinfo_count;
}
return cpu_count > 0 ? usagerate / cpu_count : 0;
#elif defined(TB_CONFIG_OS_WINDOWS)
// kernel include idle_time
tb_float_t usagerate = 0;
- FILETIME idle, kernel, user;
+ FILETIME idle, kernel, user;
if (GetSystemTimes(&idle, &kernel, &user)) {
- static FILETIME idle_prev = { 0 };
+ static FILETIME idle_prev = { 0 };
static FILETIME kernel_prev = { 0 };
- static FILETIME user_prev = { 0 };
+ static FILETIME user_prev = { 0 };
if (idle_prev.dwLowDateTime != 0 && idle_prev.dwHighDateTime != 0) {
- tb_uint64_t idle_diff = xm_os_cpuinfo_subtract_times(&idle, &idle_prev);
+ tb_uint64_t idle_diff = xm_os_cpuinfo_subtract_times(&idle, &idle_prev);
tb_uint64_t kernel_diff = xm_os_cpuinfo_subtract_times(&kernel, &kernel_prev);
- tb_uint64_t user_diff = xm_os_cpuinfo_subtract_times(&user, &user_prev);
+ tb_uint64_t user_diff = xm_os_cpuinfo_subtract_times(&user, &user_prev);
// kernel_time - idle_time = kernel_time, because kernel include idle_time
- tb_uint64_t sys_total = kernel_diff + user_diff;
+ tb_uint64_t sys_total = kernel_diff + user_diff;
tb_uint64_t kernel_total = kernel_diff - idle_diff;
// sometimes kernel_time > idle_time
@@ -125,7 +125,7 @@ static tb_float_t xm_os_cpuinfo_usagerate() {
}
}
- idle_prev = idle;
+ idle_prev = idle;
kernel_prev = kernel;
user_prev = user;
}
@@ -135,8 +135,8 @@ static tb_float_t xm_os_cpuinfo_usagerate() {
if (tb_file_info("/proc/stat", tb_null)) {
FILE *fp = fopen("/proc/stat", "r");
if (fp) {
- tb_char_t line[8192];
- static tb_int64_t total_prev = 0;
+ tb_char_t line[8192];
+ static tb_int64_t total_prev = 0;
static tb_int64_t active_prev = 0;
while (!feof(fp)) {
/* cpu 548760 0 867417 102226682 12430 0 9089 0 0 0
@@ -172,10 +172,10 @@ static tb_float_t xm_os_cpuinfo_usagerate() {
&guest_nice)) {
tb_int64_t active = (tb_int64_t)(user + nice + sys + irq + softirq + steal + guest +
guest_nice);
- tb_int64_t total = (tb_int64_t)(user + nice + sys + idle + iowait + irq + softirq + steal +
+ tb_int64_t total = (tb_int64_t)(user + nice + sys + idle + iowait + irq + softirq + steal +
guest + guest_nice);
if (total_prev > 0 && active_prev > 0) {
- tb_int64_t total_diff = total - total_prev;
+ tb_int64_t total_diff = total - total_prev;
tb_int64_t active_diff = active - active_prev;
if (total_diff > 0) {
usagerate = (tb_float_t)((tb_double_t)active_diff / total_diff);
@@ -199,29 +199,29 @@ static tb_float_t xm_os_cpuinfo_usagerate() {
#define CP_IDLE 4
#define CPUSTATES 5
- static tb_int64_t total_prev = 0;
+ static tb_int64_t total_prev = 0;
static tb_int64_t active_prev = 0;
- tb_float_t usagerate = 0;
- long states[CPUSTATES] = { 0 };
- size_t states_size = sizeof(states);
+ tb_float_t usagerate = 0;
+ long states[CPUSTATES] = { 0 };
+ size_t states_size = sizeof(states);
if (sysctlbyname("kern.cp_time", &states, &states_size, tb_null, 0) == 0) {
tb_long_t user = states[CP_USER];
tb_long_t nice = states[CP_NICE];
- tb_long_t sys = states[CP_SYS];
+ tb_long_t sys = states[CP_SYS];
tb_long_t intr = states[CP_INTR];
tb_long_t idle = states[CP_IDLE];
tb_int64_t active = user + nice + sys + intr;
- tb_int64_t total = user + nice + sys + idle + intr;
+ tb_int64_t total = user + nice + sys + idle + intr;
if (total_prev > 0 && active_prev > 0) {
- tb_int64_t total_diff = total - total_prev;
+ tb_int64_t total_diff = total - total_prev;
tb_int64_t active_diff = active - active_prev;
if (total_diff > 0) {
usagerate = (tb_float_t)((tb_double_t)active_diff / total_diff);
}
}
- total_prev = total;
+ total_prev = total;
active_prev = active;
}
return usagerate;
diff --git a/core/src/xmake/os/find.c b/core/src/xmake/os/find.c
index 144ab4daa..aa40bf5bb 100644
--- a/core/src/xmake/os/find.c
+++ b/core/src/xmake/os/find.c
@@ -82,7 +82,7 @@ static tb_long_t xm_os_find_walk(tb_char_t const *path, tb_file_info_t const *in
tb_bool_t excluded = tb_false;
if (lua_istable(lua, 5)) {
// the root directory
- size_t rootlen = 0;
+ size_t rootlen = 0;
tb_char_t const *rootdir = luaL_checklstring(lua, 1, &rootlen);
tb_assert_and_check_return_val(rootdir && rootlen, TB_DIRECTORY_WALK_CODE_END);
@@ -95,7 +95,7 @@ static tb_long_t xm_os_find_walk(tb_char_t const *path, tb_file_info_t const *in
}
// exclude paths
- tb_int_t i = 0;
+ tb_int_t i = 0;
tb_int_t count = (tb_int_t)lua_objlen(lua, 5);
for (i = 0; i < count && !excluded; i++) {
// get exclude
diff --git a/core/src/xmake/os/getenvs.c b/core/src/xmake/os/getenvs.c
index 1576c101d..bfe673438 100644
--- a/core/src/xmake/os/getenvs.c
+++ b/core/src/xmake/os/getenvs.c
@@ -103,12 +103,12 @@ static tb_void_t xm_os_getenvs_process_line(lua_State *lua, tb_char_t const *lin
xm_os_getenvs_trim(&value_start, &value_end);
// get key and value lengths
- tb_size_t key_len = key_end - key_start;
+ tb_size_t key_len = key_end - key_start;
tb_size_t value_len = value_end > value_start ? value_end - value_start : 0;
// handle Windows-specific PATH conversion
tb_char_t const *final_key_start = key_start;
- tb_size_t final_key_len = key_len;
+ tb_size_t final_key_len = key_len;
#if defined(TB_CONFIG_OS_WINDOWS) && !defined(TB_COMPILER_LIKE_UNIX)
if (key_len == 4 && tb_strnicmp(key_start, "path", 4) == 0) {
// use "PATH" instead of "path"
@@ -134,9 +134,9 @@ tb_int_t xm_os_getenvs(lua_State *lua) {
tb_wchar_t const *p = (tb_wchar_t const *)GetEnvironmentStringsW();
if (p) {
tb_char_t *data = tb_null;
- tb_size_t maxn = 0;
- tb_char_t line[TB_PATH_MAXN];
- tb_size_t n = 0;
+ tb_size_t maxn = 0;
+ tb_char_t line[TB_PATH_MAXN];
+ tb_size_t n = 0;
while (*p) {
n = tb_wcslen(p);
if (n + 1 < tb_arrayn(line)) {
diff --git a/core/src/xmake/os/meminfo.c b/core/src/xmake/os/meminfo.c
index 44fbb7770..96db76f0d 100644
--- a/core/src/xmake/os/meminfo.c
+++ b/core/src/xmake/os/meminfo.c
@@ -62,7 +62,7 @@ static tb_bool_t xm_os_meminfo_stats(tb_int_t *ptotalsize, tb_int_t *pavailsize)
vm_statistics64_data_t vmstat;
mach_msg_type_number_t count = HOST_VM_INFO64_COUNT;
if (host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info_t)&vmstat, &count) == KERN_SUCCESS) {
- tb_int_t pagesize = (tb_int_t)tb_page_size();
+ tb_int_t pagesize = (tb_int_t)tb_page_size();
tb_int64_t totalsize = (tb_int64_t)(vmstat.inactive_count + vmstat.free_count + vmstat.active_count +
vmstat.wire_count
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
@@ -94,15 +94,15 @@ static tb_bool_t xm_os_meminfo_stats(tb_int_t *ptotalsize, tb_int_t *pavailsize)
if (fp) {
// 8192 should be enough for the foreseeable future.
tb_char_t buffer[8192];
- size_t len = fread(buffer, 1, sizeof(buffer) - 1, fp);
+ size_t len = fread(buffer, 1, sizeof(buffer) - 1, fp);
if (!ferror(fp) && len) {
tb_int64_t totalsize = xm_os_meminfo_get_value(buffer, "MemTotal:");
tb_int64_t availsize = xm_os_meminfo_get_value(buffer, "MemAvailable:");
if (availsize <= 0) {
- tb_int64_t cachesize = xm_os_meminfo_get_value(buffer, "Cached:");
- tb_int64_t freesize = xm_os_meminfo_get_value(buffer, "MemFree:");
+ tb_int64_t cachesize = xm_os_meminfo_get_value(buffer, "Cached:");
+ tb_int64_t freesize = xm_os_meminfo_get_value(buffer, "MemFree:");
tb_int64_t buffersize = xm_os_meminfo_get_value(buffer, "Buffers:");
- tb_int64_t shmemsize = xm_os_meminfo_get_value(buffer, "Shmem:");
+ tb_int64_t shmemsize = xm_os_meminfo_get_value(buffer, "Shmem:");
if (cachesize >= 0 && freesize >= 0 && buffersize >= 0 && shmemsize >= 0) {
availsize = freesize + buffersize + cachesize - shmemsize;
}
@@ -110,7 +110,7 @@ static tb_bool_t xm_os_meminfo_stats(tb_int_t *ptotalsize, tb_int_t *pavailsize)
if (totalsize > 0 && availsize >= 0) {
*ptotalsize = (tb_int_t)(totalsize / 1024);
*pavailsize = (tb_int_t)(availsize / 1024);
- ok = tb_true;
+ ok = tb_true;
}
}
fclose(fp);
@@ -134,7 +134,7 @@ static tb_bool_t xm_os_meminfo_stats(tb_int_t *ptotalsize, tb_int_t *pavailsize)
}
#elif defined(TB_CONFIG_OS_BSD) && !defined(__OpenBSD__)
unsigned long totalsize;
- size_t size = sizeof(totalsize);
+ size_t size = sizeof(totalsize);
if (sysctlbyname("hw.physmem", &totalsize, &size, tb_null, 0) != 0) {
return tb_false;
}
diff --git a/core/src/xmake/os/readlink.c b/core/src/xmake/os/readlink.c
index c1a45cf4b..87f4f0833 100644
--- a/core/src/xmake/os/readlink.c
+++ b/core/src/xmake/os/readlink.c
@@ -50,7 +50,7 @@ tb_int_t xm_os_readlink(lua_State *lua) {
tb_char_t srcpath[TB_PATH_MAXN];
tb_long_t size = readlink(path, srcpath, TB_PATH_MAXN);
if (size == TB_PATH_MAXN) {
- tb_size_t maxn = TB_PATH_MAXN * 2;
+ tb_size_t maxn = TB_PATH_MAXN * 2;
tb_char_t *data = (tb_char_t *)tb_malloc(maxn);
if (data) {
tb_long_t size = readlink(path, data, maxn);
diff --git a/core/src/xmake/os/setenv.c b/core/src/xmake/os/setenv.c
index be375b2f4..5e3744415 100644
--- a/core/src/xmake/os/setenv.c
+++ b/core/src/xmake/os/setenv.c
@@ -38,9 +38,9 @@ tb_int_t xm_os_setenv(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get the name and value
- size_t value_size = 0;
- tb_char_t const *name = luaL_checkstring(lua, 1);
- tb_char_t const *value = luaL_checklstring(lua, 2, &value_size);
+ size_t value_size = 0;
+ tb_char_t const *name = luaL_checkstring(lua, 1);
+ tb_char_t const *value = luaL_checklstring(lua, 2, &value_size);
tb_check_return_val(name, 0);
// set it
diff --git a/core/src/xmake/os/syserror.c b/core/src/xmake/os/syserror.c
index 3ef2a5c52..85309ac4d 100644
--- a/core/src/xmake/os/syserror.c
+++ b/core/src/xmake/os/syserror.c
@@ -37,7 +37,7 @@ tb_int_t xm_os_syserror(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get syserror state
- tb_int_t err = 0;
+ tb_int_t err = 0;
tb_size_t syserror = tb_syserror_state();
switch (syserror) {
case TB_STATE_SYSERROR_NOT_PERM:
diff --git a/core/src/xmake/package/loadxmi.c b/core/src/xmake/package/loadxmi.c
index 15a579f91..e0b90cb3e 100644
--- a/core/src/xmake/package/loadxmi.c
+++ b/core/src/xmake/package/loadxmi.c
@@ -76,8 +76,8 @@ tb_int_t xm_package_loadxmi(lua_State *lua) {
}
// setup lua interfaces
- static xmi_lua_ops_t s_luaops = { 0 };
- static tb_bool_t s_luaops_inited = tb_false;
+ static xmi_lua_ops_t s_luaops = { 0 };
+ static tb_bool_t s_luaops_inited = tb_false;
if (!s_luaops_inited) {
// get functions
#ifdef XMI_USE_LUAJIT
diff --git a/core/src/xmake/path/translate.c b/core/src/xmake/path/translate.c
index 8d1debda0..0c2b22a1b 100644
--- a/core/src/xmake/path/translate.c
+++ b/core/src/xmake/path/translate.c
@@ -37,7 +37,7 @@ tb_int_t xm_path_translate(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get the path
- size_t path_size = 0;
+ size_t path_size = 0;
tb_char_t const *path = luaL_checklstring(lua, 1, &path_size);
tb_check_return_val(path, 0);
diff --git a/core/src/xmake/process/open.c b/core/src/xmake/process/open.c
index 669e90ff1..b6cf272b2 100644
--- a/core/src/xmake/process/open.c
+++ b/core/src/xmake/process/open.c
@@ -45,25 +45,25 @@ tb_int_t xm_process_open(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get command
- size_t command_size = 0;
- tb_char_t const *command = luaL_checklstring(lua, 1, &command_size);
+ size_t command_size = 0;
+ tb_char_t const *command = luaL_checklstring(lua, 1, &command_size);
tb_check_return_val(command, 0);
// init attributes
tb_process_attr_t attr = { 0 };
// get option arguments
- tb_size_t envn = 0;
- tb_char_t const *envs[1024] = { 0 };
- tb_char_t const *inpath = tb_null;
- tb_char_t const *outpath = tb_null;
- tb_char_t const *errpath = tb_null;
- xm_io_file_t *infile = tb_null;
- xm_io_file_t *outfile = tb_null;
- xm_io_file_t *errfile = tb_null;
- tb_pipe_file_ref_t inpipe = tb_null;
- tb_pipe_file_ref_t outpipe = tb_null;
- tb_pipe_file_ref_t errpipe = tb_null;
+ tb_size_t envn = 0;
+ tb_char_t const *envs[1024] = { 0 };
+ tb_char_t const *inpath = tb_null;
+ tb_char_t const *outpath = tb_null;
+ tb_char_t const *errpath = tb_null;
+ xm_io_file_t *infile = tb_null;
+ xm_io_file_t *outfile = tb_null;
+ xm_io_file_t *errfile = tb_null;
+ tb_pipe_file_ref_t inpipe = tb_null;
+ tb_pipe_file_ref_t outpipe = tb_null;
+ tb_pipe_file_ref_t errpipe = tb_null;
if (lua_istable(lua, 2)) {
// is detached?
lua_pushstring(lua, "detach");
diff --git a/core/src/xmake/process/openv.c b/core/src/xmake/process/openv.c
index 1b95c45fe..223d2d774 100644
--- a/core/src/xmake/process/openv.c
+++ b/core/src/xmake/process/openv.c
@@ -65,7 +65,7 @@ tb_int_t xm_process_openv(lua_State *lua) {
tb_check_return_val(argn >= 0, 0);
// get arguments
- tb_size_t argi = 0;
+ tb_size_t argi = 0;
tb_char_t const **argv = tb_nalloc0_type(1 + argn + 1, tb_char_t const *);
tb_check_return_val(argv, 0);
@@ -101,18 +101,18 @@ tb_int_t xm_process_openv(lua_State *lua) {
tb_process_attr_t attr = { 0 };
// get option arguments
- tb_bool_t exclusive = tb_false;
- tb_size_t envn = 0;
- tb_char_t const *envs[1024] = { 0 };
- tb_char_t const *inpath = tb_null;
- tb_char_t const *outpath = tb_null;
- tb_char_t const *errpath = tb_null;
- xm_io_file_t *infile = tb_null;
- xm_io_file_t *outfile = tb_null;
- xm_io_file_t *errfile = tb_null;
- tb_pipe_file_ref_t inpipe = tb_null;
- tb_pipe_file_ref_t outpipe = tb_null;
- tb_pipe_file_ref_t errpipe = tb_null;
+ tb_bool_t exclusive = tb_false;
+ tb_size_t envn = 0;
+ tb_char_t const *envs[1024] = { 0 };
+ tb_char_t const *inpath = tb_null;
+ tb_char_t const *outpath = tb_null;
+ tb_char_t const *errpath = tb_null;
+ xm_io_file_t *infile = tb_null;
+ xm_io_file_t *outfile = tb_null;
+ xm_io_file_t *errfile = tb_null;
+ tb_pipe_file_ref_t inpipe = tb_null;
+ tb_pipe_file_ref_t outpipe = tb_null;
+ tb_pipe_file_ref_t errpipe = tb_null;
if (lua_istable(lua, 3)) {
// is detached?
lua_pushstring(lua, "detach");
diff --git a/core/src/xmake/sandbox/interactive.c b/core/src/xmake/sandbox/interactive.c
index ac3566577..24443b8ee 100644
--- a/core/src/xmake/sandbox/interactive.c
+++ b/core/src/xmake/sandbox/interactive.c
@@ -217,7 +217,7 @@ static tb_int_t xm_sandbox_loadline(lua_State *lua, tb_int_t top) {
lua_pop(lua, 1);
// read first line
- tb_int_t status;
+ tb_int_t status;
tb_char_t data[LUA_PROMPT_BUFSIZE];
tb_size_t size = xm_sandbox_readline(data + 7, sizeof(data) - 7, prompt);
if (size) {
diff --git a/core/src/xmake/semver/select.c b/core/src/xmake/semver/select.c
index de3904288..283afb050 100644
--- a/core/src/xmake/semver/select.c
+++ b/core/src/xmake/semver/select.c
@@ -87,7 +87,7 @@ static tb_bool_t xm_semver_select_from_versions_tags2(
lua_gettable(lua, fromidx);
tb_char_t const *source_str = luaL_checkstring(lua, -1);
- tb_size_t source_len = tb_strlen(source_str);
+ tb_size_t source_len = tb_strlen(source_str);
lua_pop(lua, 1);
if (source_len == version_len && tb_strncmp(source_str, version_str, version_len) == 0) {
lua_createtable(lua, 0, 2);
@@ -111,7 +111,7 @@ static tb_bool_t xm_semver_select_from_branches(lua_State *lua,
lua_gettable(lua, fromidx);
tb_char_t const *source_str = luaL_checkstring(lua, -1);
- tb_size_t source_len = tb_strlen(source_str);
+ tb_size_t source_len = tb_strlen(source_str);
lua_pop(lua, 1);
if (source_len == range_len && tb_memcmp(source_str, range_str, source_len) == 0) {
lua_createtable(lua, 0, 2);
@@ -177,12 +177,12 @@ tb_int_t xm_semver_select(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// select version
- tb_bool_t ok = tb_false;
- tb_bool_t is_range = tb_false;
+ tb_bool_t ok = tb_false;
+ tb_bool_t is_range = tb_false;
tb_char_t const *range_str = tb_null;
- semver_t semver = { 0 };
- semvers_t matches = { 0 };
- semver_range_t range = { 0 };
+ semver_t semver = { 0 };
+ semvers_t matches = { 0 };
+ semver_range_t range = { 0 };
do {
// get the version range string
range_str = luaL_checkstring(lua, 1);
diff --git a/core/src/xmake/semver/semver.c b/core/src/xmake/semver/semver.c
index 201f83435..f03faaf97 100644
--- a/core/src/xmake/semver/semver.c
+++ b/core/src/xmake/semver/semver.c
@@ -58,7 +58,7 @@ tb_void_t lua_pushsemver(lua_State *lua, semver_t const *semver) {
lua_pushstring(lua, "prerelease");
lua_newtable(lua);
- tb_uchar_t i = 0;
+ tb_uchar_t i = 0;
semver_id_t const *id = &semver->prerelease;
while (id && id->len) {
if (id->numeric) {
diff --git a/core/src/xmake/string/endswith.c b/core/src/xmake/string/endswith.c
index f7e5e1805..83cd51063 100644
--- a/core/src/xmake/string/endswith.c
+++ b/core/src/xmake/string/endswith.c
@@ -37,10 +37,10 @@ tb_int_t xm_string_endswith(lua_State *lua) {
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 8785e3987..9ac6c6784 100644
--- a/core/src/xmake/string/lastof.c
+++ b/core/src/xmake/string/lastof.c
@@ -76,11 +76,11 @@ tb_int_t xm_string_lastof(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get string
- size_t nstr = 0;
+ size_t nstr = 0;
tb_char_t const *cstr = luaL_checklstring(lua, 1, &nstr);
// get substring
- size_t nsubstr = 0;
+ size_t nsubstr = 0;
tb_char_t const *csubstr = luaL_checklstring(lua, 2, &nsubstr);
// lastof it
diff --git a/core/src/xmake/string/split.c b/core/src/xmake/string/split.c
index 5ca0c92bb..03c5f04fa 100644
--- a/core/src/xmake/string/split.c
+++ b/core/src/xmake/string/split.c
@@ -40,7 +40,7 @@ static tb_void_t xm_string_split_str(lua_State *lua,
tb_size_t ndls,
tb_bool_t strict,
tb_int_t limit) {
- tb_int_t num = 0;
+ 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) {
@@ -66,7 +66,7 @@ static tb_void_t xm_string_split_str(lua_State *lua,
}
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_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) {
@@ -106,11 +106,11 @@ tb_int_t xm_string_split(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get string
- size_t nstr = 0;
+ size_t nstr = 0;
tb_char_t const *cstr = luaL_checklstring(lua, 1, &nstr);
// get delimiter
- size_t ndls = 0;
+ size_t ndls = 0;
tb_char_t const *cdls = luaL_checklstring(lua, 2, &ndls);
// is strict?
diff --git a/core/src/xmake/string/startswith.c b/core/src/xmake/string/startswith.c
index 04b53ffa7..2a07e356a 100644
--- a/core/src/xmake/string/startswith.c
+++ b/core/src/xmake/string/startswith.c
@@ -37,9 +37,9 @@ tb_int_t xm_string_startswith(lua_State *lua) {
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 54e6e4b5a..1dc7006f8 100644
--- a/core/src/xmake/string/trim.c
+++ b/core/src/xmake/string/trim.c
@@ -104,11 +104,11 @@ static tb_char_t const *xm_string_rtrim(tb_char_t const *sstr,
tb_int_t xm_string_trim(lua_State *lua) {
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;
+ 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, "", &ltrim);
- tb_int_t const trimtype = (tb_int_t)luaL_optinteger(lua, 3, 0);
+ tb_int_t const trimtype = (tb_int_t)luaL_optinteger(lua, 3, 0);
do {
tb_assert_and_check_break(sstr && trimchars);
tb_check_break(lstr != 0);
diff --git a/core/src/xmake/thread/event_init.c b/core/src/xmake/thread/event_init.c
index d661939b0..5b70cc283 100644
--- a/core/src/xmake/thread/event_init.c
+++ b/core/src/xmake/thread/event_init.c
@@ -36,7 +36,7 @@
tb_int_t xm_thread_event_init(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
xm_thread_event_t *thread_event = tb_null;
do {
thread_event = tb_malloc0_type(xm_thread_event_t);
diff --git a/core/src/xmake/thread/mutex_init.c b/core/src/xmake/thread/mutex_init.c
index bca78a134..1c784e716 100644
--- a/core/src/xmake/thread/mutex_init.c
+++ b/core/src/xmake/thread/mutex_init.c
@@ -36,7 +36,7 @@
tb_int_t xm_thread_mutex_init(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
xm_thread_mutex_t *thread_mutex = tb_null;
do {
thread_mutex = tb_malloc0_type(xm_thread_mutex_t);
diff --git a/core/src/xmake/thread/prefix.h b/core/src/xmake/thread/prefix.h
index 2ddd14adf..284b7364c 100644
--- a/core/src/xmake/thread/prefix.h
+++ b/core/src/xmake/thread/prefix.h
@@ -33,8 +33,8 @@
// the thread type
typedef struct __xm_thread_t {
tb_thread_ref_t handle;
- tb_string_t callback;
- tb_string_t callinfo;
+ tb_string_t callback;
+ tb_string_t callinfo;
} xm_thread_t;
// the thread value kind
@@ -51,42 +51,42 @@ typedef struct __xm_thread_value_t {
tb_uint32_t kind : 3;
tb_uint32_t size : 29;
union {
- tb_char_t *string;
- tb_bool_t boolean;
+ tb_char_t *string;
+ tb_bool_t boolean;
lua_Integer integer;
- lua_Number number;
+ lua_Number number;
} u;
} xm_thread_value_t;
// the thread event type
typedef struct __xm_thread_event_t {
tb_event_ref_t handle;
- tb_atomic_t refn;
+ tb_atomic_t refn;
} xm_thread_event_t;
// the thread mutex type
typedef struct __xm_thread_mutex_t {
tb_mutex_ref_t handle;
- tb_atomic_t refn;
+ tb_atomic_t refn;
} xm_thread_mutex_t;
// the thread semaphore type
typedef struct __xm_thread_semaphore_t {
tb_semaphore_ref_t handle;
- tb_atomic_t refn;
+ tb_atomic_t refn;
} xm_thread_semaphore_t;
// the thread queue type
typedef struct __xm_thread_queue_t {
tb_queue_ref_t handle;
- tb_atomic_t refn;
+ tb_atomic_t refn;
} xm_thread_queue_t;
// the thread sharedata type
typedef struct __xm_thread_sharedata_t {
xm_thread_value_t value;
- tb_buffer_t buffer;
- tb_atomic_t refn;
+ tb_buffer_t buffer;
+ tb_atomic_t refn;
} xm_thread_sharedata_t;
// get the thread event from arguments
diff --git a/core/src/xmake/thread/queue_init.c b/core/src/xmake/thread/queue_init.c
index a0d683dd3..8812536f9 100644
--- a/core/src/xmake/thread/queue_init.c
+++ b/core/src/xmake/thread/queue_init.c
@@ -52,7 +52,7 @@ static tb_void_t xm_thread_value_free(tb_element_ref_t element, tb_pointer_t buf
tb_int_t xm_thread_queue_init(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
xm_thread_queue_t *thread_queue = tb_null;
do {
thread_queue = tb_malloc0_type(xm_thread_queue_t);
diff --git a/core/src/xmake/thread/queue_push.c b/core/src/xmake/thread/queue_push.c
index 0a9ff63e1..f7ecd7c33 100644
--- a/core/src/xmake/thread/queue_push.c
+++ b/core/src/xmake/thread/queue_push.c
@@ -47,8 +47,8 @@ tb_int_t xm_thread_queue_push(lua_State *lua) {
xm_thread_value_t item;
if (lua_isstring(lua, 2)) {
- size_t data_size = 0;
- tb_char_t const *data = luaL_checklstring(lua, 2, &data_size);
+ size_t data_size = 0;
+ tb_char_t const *data = luaL_checklstring(lua, 2, &data_size);
tb_assert_and_check_return_val(data, 0);
item.kind = (tb_uint32_t)XM_THREAD_VALUE_STR;
diff --git a/core/src/xmake/thread/semaphore_init.c b/core/src/xmake/thread/semaphore_init.c
index a4c7a80fe..cb319727c 100644
--- a/core/src/xmake/thread/semaphore_init.c
+++ b/core/src/xmake/thread/semaphore_init.c
@@ -36,7 +36,7 @@
tb_int_t xm_thread_semaphore_init(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
xm_thread_semaphore_t *thread_semaphore = tb_null;
do {
tb_long_t value = (tb_long_t)luaL_checknumber(lua, 1);
diff --git a/core/src/xmake/thread/sharedata_init.c b/core/src/xmake/thread/sharedata_init.c
index ac712e5f3..63ea7c998 100644
--- a/core/src/xmake/thread/sharedata_init.c
+++ b/core/src/xmake/thread/sharedata_init.c
@@ -36,7 +36,7 @@
tb_int_t xm_thread_sharedata_init(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
xm_thread_sharedata_t *thread_sharedata = tb_null;
do {
thread_sharedata = tb_malloc0_type(xm_thread_sharedata_t);
diff --git a/core/src/xmake/thread/sharedata_set.c b/core/src/xmake/thread/sharedata_set.c
index 2bd66d1f9..8eb59e665 100644
--- a/core/src/xmake/thread/sharedata_set.c
+++ b/core/src/xmake/thread/sharedata_set.c
@@ -40,8 +40,8 @@ tb_int_t xm_thread_sharedata_set(lua_State *lua) {
tb_assert_and_check_return_val(thread_sharedata, 0);
if (lua_isstring(lua, 2)) {
- size_t data_size = 0;
- tb_char_t const *data = luaL_checklstring(lua, 2, &data_size);
+ size_t data_size = 0;
+ tb_char_t const *data = luaL_checklstring(lua, 2, &data_size);
tb_assert_and_check_return_val(data, 0);
thread_sharedata->value.kind = (tb_uint32_t)XM_THREAD_VALUE_STR;
diff --git a/core/src/xmake/thread/thread_init.c b/core/src/xmake/thread/thread_init.c
index 2d3e067f7..9adda1f54 100644
--- a/core/src/xmake/thread/thread_init.c
+++ b/core/src/xmake/thread/thread_init.c
@@ -55,7 +55,7 @@ static tb_int_t xm_thread_func(tb_cpointer_t priv) {
// pass callback
tb_char_t const *callback_data = tb_string_cstr(&thread->callback);
- tb_size_t callback_size = tb_string_size(&thread->callback);
+ tb_size_t callback_size = tb_string_size(&thread->callback);
if (callback_data && callback_size) {
lua_pushlstring(lua, callback_data, callback_size);
lua_setglobal(lua, "_THREAD_CALLBACK");
@@ -63,7 +63,7 @@ static tb_int_t xm_thread_func(tb_cpointer_t priv) {
// pass callinfo
tb_char_t const *callinfo_data = tb_string_cstr(&thread->callinfo);
- tb_size_t callinfo_size = tb_string_size(&thread->callinfo);
+ tb_size_t callinfo_size = tb_string_size(&thread->callinfo);
if (callinfo_data && callinfo_size) {
lua_pushlstring(lua, callinfo_data, callinfo_size);
lua_setglobal(lua, "_THREAD_CALLINFO");
@@ -85,19 +85,19 @@ static tb_int_t xm_thread_func(tb_cpointer_t priv) {
tb_int_t xm_thread_init(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
xm_thread_t *thread = tb_null;
do {
// get thread name
tb_char_t const *name = luaL_checkstring(lua, 1);
// get callback
- size_t callback_size = 0;
+ size_t callback_size = 0;
tb_char_t const *callback_data = luaL_checklstring(lua, 2, &callback_size);
tb_assert_and_check_break(callback_data && callback_size);
// get callinfo
- size_t callinfo_size = 0;
+ size_t callinfo_size = 0;
tb_char_t const *callinfo_data = luaL_checklstring(lua, 3, &callinfo_size);
tb_assert_and_check_break(callinfo_data && callinfo_size);
diff --git a/core/src/xmake/tty/term_mode.c b/core/src/xmake/tty/term_mode.c
index df5af5b4c..d9e2d39ec 100644
--- a/core/src/xmake/tty/term_mode.c
+++ b/core/src/xmake/tty/term_mode.c
@@ -49,7 +49,7 @@ tb_int_t xm_tty_term_mode(lua_State *lua) {
tb_int_t stdtype = (tb_int_t)luaL_checkinteger(lua, 1);
// get and set terminal mode
- DWORD mode = 0;
+ DWORD mode = 0;
HANDLE console_handle = INVALID_HANDLE_VALUE;
switch (stdtype) {
case 1:
diff --git a/core/src/xmake/utils/bin2c.c b/core/src/xmake/utils/bin2c.c
index 61befeaa9..b39217e0c 100644
--- a/core/src/xmake/utils/bin2c.c
+++ b/core/src/xmake/utils/bin2c.c
@@ -119,7 +119,7 @@ tb_int_t xm_utils_bin2c(lua_State *lua) {
tb_bool_t nozeroend = (tb_bool_t)lua_toboolean(lua, 4);
// do dump
- tb_bool_t ok = tb_false;
+ tb_bool_t ok = tb_false;
tb_stream_ref_t istream = tb_stream_init_from_file(binaryfile, TB_FILE_MODE_RO);
tb_stream_ref_t ostream = tb_stream_init_from_file(outputfile,
TB_FILE_MODE_RW | TB_FILE_MODE_CREAT | TB_FILE_MODE_TRUNC);
diff --git a/core/src/xmake/winos/logical_drives.c b/core/src/xmake/winos/logical_drives.c
index 9f6df60ea..c74603b9a 100644
--- a/core/src/xmake/winos/logical_drives.c
+++ b/core/src/xmake/winos/logical_drives.c
@@ -55,7 +55,7 @@ tb_int_t xm_winos_logical_drives(lua_State *lua) {
tb_assert_and_check_break(size);
// parse logical drives
- tb_size_t i = 1;
+ tb_size_t i = 1;
tb_char_t const *p = data;
while (*p) {
// save drive
diff --git a/core/src/xmake/winos/registry_keys.c b/core/src/xmake/winos/registry_keys.c
index 49ddf613f..c2823d181 100644
--- a/core/src/xmake/winos/registry_keys.c
+++ b/core/src/xmake/winos/registry_keys.c
@@ -36,13 +36,13 @@
// the enum info type
typedef struct __xm_winos_registry_enum_info_t {
- lua_State *lua;
- HKEY key;
- tb_int_t ok;
+ lua_State *lua;
+ HKEY key;
+ tb_int_t ok;
tb_char_t const *error;
- tb_int_t count;
- tb_wchar_t key_name[1024];
- tb_char_t key_path_a[TB_PATH_MAXN];
+ tb_int_t count;
+ tb_wchar_t key_name[1024];
+ tb_char_t key_path_a[TB_PATH_MAXN];
} xm_winos_registry_enum_info_t;
/* //////////////////////////////////////////////////////////////////////////////////////
@@ -52,10 +52,10 @@ static tb_void_t xm_winos_registry_enum_keys(xm_winos_registry_enum_info_t *info
tb_wchar_t const *rootdir,
tb_long_t recursion) {
// enum keys
- HKEY keynew = tb_null;
- lua_State *lua = info->lua;
- tb_wchar_t *key_path = tb_null;
- tb_size_t key_path_maxn = TB_PATH_MAXN;
+ HKEY keynew = tb_null;
+ lua_State *lua = info->lua;
+ tb_wchar_t *key_path = tb_null;
+ tb_size_t key_path_maxn = TB_PATH_MAXN;
do {
// open registry key
if (RegOpenKeyExW(info->key, rootdir, 0, KEY_READ, &keynew) != ERROR_SUCCESS && keynew) {
@@ -103,7 +103,7 @@ static tb_void_t xm_winos_registry_enum_keys(xm_winos_registry_enum_info_t *info
DWORD i = 0;
for (i = 0; i < key_name_num && info->ok > 0; i++) {
// get key name
- info->key_name[0] = L'\0';
+ info->key_name[0] = L'\0';
DWORD key_name_size = tb_arrayn(info->key_name);
if (RegEnumKeyExW(keynew, i, info->key_name, &key_name_size, tb_null, tb_null, tb_null, tb_null) !=
ERROR_SUCCESS) {
@@ -174,37 +174,37 @@ tb_int_t xm_winos_registry_keys(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get the arguments
- tb_char_t const *rootkey = luaL_checkstring(lua, 1);
- tb_char_t const *rootdir = luaL_checkstring(lua, 2);
- tb_long_t recursion = (tb_long_t)lua_tointeger(lua, 3);
- tb_bool_t is_function = lua_isfunction(lua, 4);
+ tb_char_t const *rootkey = luaL_checkstring(lua, 1);
+ tb_char_t const *rootdir = luaL_checkstring(lua, 2);
+ tb_long_t recursion = (tb_long_t)lua_tointeger(lua, 3);
+ tb_bool_t is_function = lua_isfunction(lua, 4);
tb_check_return_val(rootkey && rootdir && is_function, 0);
// enum keys
- tb_bool_t ok = tb_false;
- tb_int_t count = 0;
- HKEY key = tb_null;
+ tb_bool_t ok = tb_false;
+ tb_int_t count = 0;
+ 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;
diff --git a/core/src/xmake/winos/registry_query.c b/core/src/xmake/winos/registry_query.c
index bfaebe744..ac8fc20ca 100644
--- a/core/src/xmake/winos/registry_query.c
+++ b/core/src/xmake/winos/registry_query.c
@@ -49,18 +49,18 @@ tb_int_t xm_winos_registry_query(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get the arguments
- tb_char_t const *rootkey = luaL_checkstring(lua, 1);
- tb_char_t const *rootdir = luaL_checkstring(lua, 2);
+ tb_char_t const *rootkey = luaL_checkstring(lua, 1);
+ tb_char_t const *rootdir = luaL_checkstring(lua, 2);
tb_char_t const *valuename = luaL_checkstring(lua, 3);
tb_check_return_val(rootkey && rootdir && valuename, 0);
// query key-value
- tb_bool_t ok = tb_false;
- HKEY key = tb_null;
- HKEY keynew = tb_null;
- tb_char_t *value = tb_null;
+ tb_bool_t ok = tb_false;
+ HKEY key = tb_null;
+ HKEY keynew = tb_null;
+ tb_char_t *value = tb_null;
tb_wchar_t *value_w = tb_null;
- tb_size_t value_n = (tb_size_t)-1;
+ tb_size_t value_n = (tb_size_t)-1;
do {
// get registry rootkey
if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) {
diff --git a/core/src/xmake/winos/registry_values.c b/core/src/xmake/winos/registry_values.c
index 543665853..716b10dea 100644
--- a/core/src/xmake/winos/registry_values.c
+++ b/core/src/xmake/winos/registry_values.c
@@ -46,16 +46,16 @@ tb_int_t xm_winos_registry_values(lua_State *lua) {
tb_assert_and_check_return_val(lua, 0);
// get the arguments
- tb_char_t const *rootkey = luaL_checkstring(lua, 1);
- tb_char_t const *rootdir = luaL_checkstring(lua, 2);
- tb_bool_t is_function = lua_isfunction(lua, 3);
+ tb_char_t const *rootkey = luaL_checkstring(lua, 1);
+ tb_char_t const *rootdir = luaL_checkstring(lua, 2);
+ tb_bool_t is_function = lua_isfunction(lua, 3);
tb_check_return_val(rootkey && rootdir && is_function, 0);
// enum values
- tb_bool_t ok = tb_false;
- tb_int_t count = 0;
- HKEY key = tb_null;
- HKEY keynew = tb_null;
+ tb_bool_t ok = tb_false;
+ tb_int_t count = 0;
+ HKEY key = tb_null;
+ HKEY keynew = tb_null;
do {
// get registry rootkey
if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) {
@@ -119,7 +119,7 @@ tb_int_t xm_winos_registry_values(lua_State *lua) {
}
// get all values
- DWORD i = 0;
+ DWORD i = 0;
tb_char_t value_name_a[1024];
for (i = 0; i < value_name_num; i++) {
// get value name
diff --git a/core/src/xmake/winos/short_path.c b/core/src/xmake/winos/short_path.c
index 9c2192787..311fd1df8 100644
--- a/core/src/xmake/winos/short_path.c
+++ b/core/src/xmake/winos/short_path.c
@@ -63,7 +63,7 @@ tb_int_t xm_winos_short_path(lua_State *lua) {
// return result
tb_char_t *short_path_a = (tb_char_t *)long_path_w;
- tb_size_t short_path_n = tb_wtoa(short_path_a, short_path_w, TB_PATH_MAXN);
+ tb_size_t short_path_n = tb_wtoa(short_path_a, short_path_w, TB_PATH_MAXN);
if (short_path_n == (tb_size_t)-1) {
lua_pushnil(lua);
lua_pushfstring(lua, "invalid short path from %s!", long_path);