summaryrefslogtreecommitdiff
path: root/core/src/xmake/winos
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/winos
parent831447a51da0b094e08bb047247bf269a6e6cf71 (diff)
format more if-else codes in core
Diffstat (limited to 'core/src/xmake/winos')
-rw-r--r--core/src/xmake/winos/ansi.c6
-rw-r--r--core/src/xmake/winos/logical_drives.c3
-rw-r--r--core/src/xmake/winos/registry_keys.c32
-rw-r--r--core/src/xmake/winos/registry_query.c29
-rw-r--r--core/src/xmake/winos/registry_values.c26
5 files changed, 54 insertions, 42 deletions
diff --git a/core/src/xmake/winos/ansi.c b/core/src/xmake/winos/ansi.c
index 48bb9df82..9646db59b 100644
--- a/core/src/xmake/winos/ansi.c
+++ b/core/src/xmake/winos/ansi.c
@@ -38,10 +38,12 @@
static tb_int_t xm_expand_cp(tb_int_t cp) {
tb_assert_and_check_return_val(cp >= 0 && cp <= 65535, 0);
- if (cp == CP_OEMCP)
+ if (cp == CP_OEMCP) {
return GetOEMCP();
- if (cp == CP_ACP)
+ }
+ if (cp == CP_ACP) {
return GetACP();
+ }
return cp;
}
diff --git a/core/src/xmake/winos/logical_drives.c b/core/src/xmake/winos/logical_drives.c
index 7227069b9..9f6df60ea 100644
--- a/core/src/xmake/winos/logical_drives.c
+++ b/core/src/xmake/winos/logical_drives.c
@@ -69,8 +69,9 @@ tb_int_t xm_winos_logical_drives(lua_State *lua) {
} while (0);
// exit data
- if (data)
+ if (data) {
tb_free(data);
+ }
data = tb_null;
return 1;
diff --git a/core/src/xmake/winos/registry_keys.c b/core/src/xmake/winos/registry_keys.c
index 7daf44ff4..49ddf613f 100644
--- a/core/src/xmake/winos/registry_keys.c
+++ b/core/src/xmake/winos/registry_keys.c
@@ -138,20 +138,23 @@ static tb_void_t xm_winos_registry_enum_keys(xm_winos_registry_enum_info_t *info
}
// enum all subkeys
- if (recursion > 0 || recursion < 0)
+ if (recursion > 0 || recursion < 0) {
xm_winos_registry_enum_keys(info, key_path, recursion > 0 ? recursion - 1 : recursion);
+ }
}
} while (0);
// exit registry key
- if (keynew)
+ if (keynew) {
RegCloseKey(keynew);
+ }
keynew = tb_null;
// free key path
- if (key_path)
+ if (key_path) {
tb_free(key_path);
+ }
key_path = tb_null;
}
@@ -183,25 +186,25 @@ tb_int_t xm_winos_registry_keys(lua_State *lua) {
HKEY key = tb_null;
do {
// get registry rootkey
- if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT"))
+ if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) {
key = HKEY_CLASSES_ROOT;
- else if (!tb_strcmp(rootkey, "HKCR"))
+ } else if (!tb_strcmp(rootkey, "HKCR")) {
key = HKEY_CLASSES_ROOT;
- else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG"))
+ } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG")) {
key = HKEY_CURRENT_CONFIG;
- else if (!tb_strcmp(rootkey, "HKCC"))
+ } else if (!tb_strcmp(rootkey, "HKCC")) {
key = HKEY_CURRENT_CONFIG;
- else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER"))
+ } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER")) {
key = HKEY_CURRENT_USER;
- else if (!tb_strcmp(rootkey, "HKCU"))
+ } else if (!tb_strcmp(rootkey, "HKCU")) {
key = HKEY_CURRENT_USER;
- else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE"))
+ } else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE")) {
key = HKEY_LOCAL_MACHINE;
- else if (!tb_strcmp(rootkey, "HKLM"))
+ } else if (!tb_strcmp(rootkey, "HKLM")) {
key = HKEY_LOCAL_MACHINE;
- else if (!tb_strcmp(rootkey, "HKEY_USERS"))
+ } else if (!tb_strcmp(rootkey, "HKEY_USERS")) {
key = HKEY_USERS;
- else {
+ } else {
lua_pushnil(lua);
lua_pushfstring(lua, "invalid registry rootkey: %s", rootkey);
break;
@@ -233,6 +236,7 @@ tb_int_t xm_winos_registry_keys(lua_State *lua) {
if (ok) {
lua_pushinteger(lua, count);
return 1;
- } else
+ } else {
return 2;
+ }
}
diff --git a/core/src/xmake/winos/registry_query.c b/core/src/xmake/winos/registry_query.c
index 5e98af2cd..bfaebe744 100644
--- a/core/src/xmake/winos/registry_query.c
+++ b/core/src/xmake/winos/registry_query.c
@@ -63,25 +63,25 @@ tb_int_t xm_winos_registry_query(lua_State *lua) {
tb_size_t value_n = (tb_size_t)-1;
do {
// get registry rootkey
- if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT"))
+ if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) {
key = HKEY_CLASSES_ROOT;
- else if (!tb_strcmp(rootkey, "HKCR"))
+ } else if (!tb_strcmp(rootkey, "HKCR")) {
key = HKEY_CLASSES_ROOT;
- else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG"))
+ } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG")) {
key = HKEY_CURRENT_CONFIG;
- else if (!tb_strcmp(rootkey, "HKCC"))
+ } else if (!tb_strcmp(rootkey, "HKCC")) {
key = HKEY_CURRENT_CONFIG;
- else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER"))
+ } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER")) {
key = HKEY_CURRENT_USER;
- else if (!tb_strcmp(rootkey, "HKCU"))
+ } else if (!tb_strcmp(rootkey, "HKCU")) {
key = HKEY_CURRENT_USER;
- else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE"))
+ } else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE")) {
key = HKEY_LOCAL_MACHINE;
- else if (!tb_strcmp(rootkey, "HKLM"))
+ } else if (!tb_strcmp(rootkey, "HKLM")) {
key = HKEY_LOCAL_MACHINE;
- else if (!tb_strcmp(rootkey, "HKEY_USERS"))
+ } else if (!tb_strcmp(rootkey, "HKEY_USERS")) {
key = HKEY_USERS;
- else {
+ } else {
lua_pushnil(lua);
lua_pushfstring(lua, "invalid registry rootkey: %s", rootkey);
break;
@@ -213,16 +213,19 @@ tb_int_t xm_winos_registry_query(lua_State *lua) {
} while (0);
// exit registry key
- if (keynew)
+ if (keynew) {
RegCloseKey(keynew);
+ }
keynew = tb_null;
// exit value
- if (value)
+ if (value) {
tb_free(value);
+ }
value = tb_null;
- if (value_w)
+ if (value_w) {
tb_free(value_w);
+ }
value_w = tb_null;
return ok ? 1 : 2;
diff --git a/core/src/xmake/winos/registry_values.c b/core/src/xmake/winos/registry_values.c
index 6bda8e690..543665853 100644
--- a/core/src/xmake/winos/registry_values.c
+++ b/core/src/xmake/winos/registry_values.c
@@ -58,25 +58,25 @@ tb_int_t xm_winos_registry_values(lua_State *lua) {
HKEY keynew = tb_null;
do {
// get registry rootkey
- if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT"))
+ if (!tb_strcmp(rootkey, "HKEY_CLASSES_ROOT")) {
key = HKEY_CLASSES_ROOT;
- else if (!tb_strcmp(rootkey, "HKCR"))
+ } else if (!tb_strcmp(rootkey, "HKCR")) {
key = HKEY_CLASSES_ROOT;
- else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG"))
+ } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_CONFIG")) {
key = HKEY_CURRENT_CONFIG;
- else if (!tb_strcmp(rootkey, "HKCC"))
+ } else if (!tb_strcmp(rootkey, "HKCC")) {
key = HKEY_CURRENT_CONFIG;
- else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER"))
+ } else if (!tb_strcmp(rootkey, "HKEY_CURRENT_USER")) {
key = HKEY_CURRENT_USER;
- else if (!tb_strcmp(rootkey, "HKCU"))
+ } else if (!tb_strcmp(rootkey, "HKCU")) {
key = HKEY_CURRENT_USER;
- else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE"))
+ } else if (!tb_strcmp(rootkey, "HKEY_LOCAL_MACHINE")) {
key = HKEY_LOCAL_MACHINE;
- else if (!tb_strcmp(rootkey, "HKLM"))
+ } else if (!tb_strcmp(rootkey, "HKLM")) {
key = HKEY_LOCAL_MACHINE;
- else if (!tb_strcmp(rootkey, "HKEY_USERS"))
+ } else if (!tb_strcmp(rootkey, "HKEY_USERS")) {
key = HKEY_USERS;
- else {
+ } else {
lua_pushnil(lua);
lua_pushfstring(lua, "invalid registry rootkey: %s", rootkey);
break;
@@ -161,13 +161,15 @@ tb_int_t xm_winos_registry_values(lua_State *lua) {
} while (0);
// exit registry key
- if (keynew)
+ if (keynew) {
RegCloseKey(keynew);
+ }
keynew = tb_null;
if (ok) {
lua_pushinteger(lua, count);
return 1;
- } else
+ } else {
return 2;
+ }
}