diff options
| author | ruki <[email protected]> | 2025-11-10 21:00:21 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-10 21:00:21 +0800 |
| commit | 2c387895657ae13cd717d7f42f5baed5eb028a8e (patch) | |
| tree | 8f005a8dfc3272e9f027560e5e1b5881a7a8bc70 /core/src/xmake/string/lastof.c | |
| parent | 831447a51da0b094e08bb047247bf269a6e6cf71 (diff) | |
format more if-else codes in core
Diffstat (limited to 'core/src/xmake/string/lastof.c')
| -rw-r--r-- | core/src/xmake/string/lastof.c | 15 |
1 files changed, 9 insertions, 6 deletions
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; } |
