summaryrefslogtreecommitdiff
path: root/core/src/xmake/utf8/codes.c
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-20 23:28:32 +0800
committerruki <[email protected]>2026-01-20 23:28:32 +0800
commit92423451b623e79ac464d388bfb1bfed2780b792 (patch)
tree12e6734a2bfa8799cd2a97d763bf205583fbfca8 /core/src/xmake/utf8/codes.c
parenta22dc9398d5323bf6c4c636915be836de3d1d850 (diff)
format code
Diffstat (limited to 'core/src/xmake/utf8/codes.c')
-rw-r--r--core/src/xmake/utf8/codes.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/core/src/xmake/utf8/codes.c b/core/src/xmake/utf8/codes.c
index 46664e891..420584835 100644
--- a/core/src/xmake/utf8/codes.c
+++ b/core/src/xmake/utf8/codes.c
@@ -29,19 +29,24 @@
*/
static tb_int_t xm_utf8_codes_iter(lua_State *lua, tb_bool_t strict) {
+ tb_assert_and_check_return_val(lua, 0);
+
size_t len;
tb_char_t const* s = luaL_checklstring(lua, 1, &len);
lua_Unsigned n = (lua_Unsigned)lua_tointeger(lua, 2);
if (n < len) {
- while (n < len && xm_utf8_iscontp(s + n)) n++; /* go to next character */
+ while (n < len && xm_utf8_iscontp(s + n)) {
+ n++; // go to next character
+ }
}
- if (n >= len) /* (also handles original 'n' being negative) */
- return 0; /* no more codepoints */
- else {
+ if (n >= len) { // (also handles original 'n' being negative)
+ return 0; // no more codepoints
+ } else {
xm_utf8_int_t code;
tb_char_t const* next = xm_utf8_decode(s + n, &code, strict);
- if (next == NULL || xm_utf8_iscontp(next))
+ if (next == NULL || xm_utf8_iscontp(next)) {
return luaL_error(lua, XM_UTF8_MSGInvalid);
+ }
lua_pushinteger(lua, n + 1);
lua_pushinteger(lua, code);
return 2;