summaryrefslogtreecommitdiff
path: root/core/src/xmake/semver
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-10 21:00:21 +0800
committerruki <[email protected]>2025-11-10 21:00:21 +0800
commit2c387895657ae13cd717d7f42f5baed5eb028a8e (patch)
tree8f005a8dfc3272e9f027560e5e1b5881a7a8bc70 /core/src/xmake/semver
parent831447a51da0b094e08bb047247bf269a6e6cf71 (diff)
format more if-else codes in core
Diffstat (limited to 'core/src/xmake/semver')
-rw-r--r--core/src/xmake/semver/select.c8
-rw-r--r--core/src/xmake/semver/semver.c10
2 files changed, 11 insertions, 7 deletions
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);
}