mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 08:43:13 +02:00
scripts: reformat some code to make it more readable
This commit is contained in:
@@ -222,11 +222,8 @@ weechat_guile_alist_to_hashtable (SCM alist, int size, const char *type_keys,
|
||||
SCM pair;
|
||||
char *str, *str2;
|
||||
|
||||
hashtable = weechat_hashtable_new (size,
|
||||
type_keys,
|
||||
type_values,
|
||||
NULL,
|
||||
NULL);
|
||||
hashtable = weechat_hashtable_new (size, type_keys, type_values,
|
||||
NULL, NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -124,11 +124,8 @@ weechat_lua_tohashtable (lua_State *interpreter, int index, int size,
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
hashtable = weechat_hashtable_new (size,
|
||||
type_keys,
|
||||
type_values,
|
||||
NULL,
|
||||
NULL);
|
||||
hashtable = weechat_hashtable_new (size, type_keys, type_values,
|
||||
NULL, NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
@@ -145,9 +142,10 @@ weechat_lua_tohashtable (lua_State *interpreter, int index, int size,
|
||||
{
|
||||
weechat_hashtable_set (hashtable,
|
||||
lua_tostring (interpreter, -2),
|
||||
plugin_script_str2ptr (weechat_lua_plugin,
|
||||
NULL, NULL,
|
||||
lua_tostring (interpreter, -1)));
|
||||
plugin_script_str2ptr (
|
||||
weechat_lua_plugin,
|
||||
NULL, NULL,
|
||||
lua_tostring (interpreter, -1)));
|
||||
}
|
||||
/* remove value from stack (keep key for next iteration) */
|
||||
lua_pop (interpreter, 1);
|
||||
|
||||
@@ -155,28 +155,30 @@ weechat_perl_hash_to_hashtable (SV *hash, int size, const char *type_keys,
|
||||
char *str_key;
|
||||
I32 retlen;
|
||||
|
||||
hashtable = weechat_hashtable_new (size,
|
||||
type_keys,
|
||||
type_values,
|
||||
NULL,
|
||||
NULL);
|
||||
hashtable = weechat_hashtable_new (size, type_keys, type_values,
|
||||
NULL, NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
if ((hash) && SvROK(hash) && SvRV(hash) && (SvTYPE(SvRV(hash)) == SVt_PVHV))
|
||||
if ((hash) && SvROK(hash) && SvRV(hash)
|
||||
&& (SvTYPE(SvRV(hash)) == SVt_PVHV))
|
||||
{
|
||||
hash2 = (HV *) SvRV(hash);
|
||||
hash2 = (HV *)SvRV(hash);
|
||||
hv_iterinit (hash2);
|
||||
while ((value = hv_iternextsv (hash2, &str_key, &retlen)))
|
||||
{
|
||||
if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
|
||||
weechat_hashtable_set (hashtable, str_key, SvPV (value, PL_na));
|
||||
{
|
||||
weechat_hashtable_set (hashtable, str_key,
|
||||
SvPV (value, PL_na));
|
||||
}
|
||||
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
|
||||
{
|
||||
weechat_hashtable_set (hashtable, str_key,
|
||||
plugin_script_str2ptr (weechat_perl_plugin,
|
||||
NULL, NULL,
|
||||
SvPV (value, PL_na)));
|
||||
plugin_script_str2ptr (
|
||||
weechat_perl_plugin,
|
||||
NULL, NULL,
|
||||
SvPV (value, PL_na)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -251,11 +251,8 @@ weechat_python_dict_to_hashtable (PyObject *dict, int size,
|
||||
Py_ssize_t pos;
|
||||
char *str_key, *str_value;
|
||||
|
||||
hashtable = weechat_hashtable_new (size,
|
||||
type_keys,
|
||||
type_values,
|
||||
NULL,
|
||||
NULL);
|
||||
hashtable = weechat_hashtable_new (size, type_keys, type_values,
|
||||
NULL, NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
@@ -270,19 +267,25 @@ weechat_python_dict_to_hashtable (PyObject *dict, int size,
|
||||
str_key = strdup (PyBytes_AsString (key));
|
||||
}
|
||||
else
|
||||
{
|
||||
str_key = weechat_python_unicode_to_string (key);
|
||||
}
|
||||
if (PyBytes_Check (value))
|
||||
{
|
||||
if (PyBytes_AsString (value))
|
||||
str_value = strdup (PyBytes_AsString (value));
|
||||
}
|
||||
else
|
||||
{
|
||||
str_value = weechat_python_unicode_to_string (value);
|
||||
}
|
||||
|
||||
if (str_key)
|
||||
{
|
||||
if (strcmp (type_values, WEECHAT_HASHTABLE_STRING) == 0)
|
||||
{
|
||||
weechat_hashtable_set (hashtable, str_key, str_value);
|
||||
}
|
||||
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
|
||||
{
|
||||
weechat_hashtable_set (hashtable, str_key,
|
||||
|
||||
@@ -164,6 +164,7 @@ weechat_ruby_hash_foreach_cb (VALUE key, VALUE value, void *arg)
|
||||
const char *type_values;
|
||||
|
||||
hashtable = (struct t_hashtable *)arg;
|
||||
|
||||
if ((TYPE(key) == T_STRING) && (TYPE(value) == T_STRING))
|
||||
{
|
||||
type_values = weechat_hashtable_get_string (hashtable, "type_values");
|
||||
@@ -175,11 +176,13 @@ weechat_ruby_hash_foreach_cb (VALUE key, VALUE value, void *arg)
|
||||
else if (strcmp (type_values, WEECHAT_HASHTABLE_POINTER) == 0)
|
||||
{
|
||||
weechat_hashtable_set (hashtable, StringValuePtr(key),
|
||||
plugin_script_str2ptr (weechat_ruby_plugin,
|
||||
NULL, NULL,
|
||||
StringValuePtr(value)));
|
||||
plugin_script_str2ptr (
|
||||
weechat_ruby_plugin,
|
||||
NULL, NULL,
|
||||
StringValuePtr(value)));
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -195,11 +198,8 @@ weechat_ruby_hash_to_hashtable (VALUE hash, int size, const char *type_keys,
|
||||
{
|
||||
struct t_hashtable *hashtable;
|
||||
|
||||
hashtable = weechat_hashtable_new (size,
|
||||
type_keys,
|
||||
type_values,
|
||||
NULL,
|
||||
NULL);
|
||||
hashtable = weechat_hashtable_new (size, type_keys, type_values,
|
||||
NULL, NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
|
||||
@@ -145,11 +145,8 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
|
||||
Tcl_Obj *key, *value;
|
||||
int done;
|
||||
|
||||
hashtable = weechat_hashtable_new (size,
|
||||
type_keys,
|
||||
type_values,
|
||||
NULL,
|
||||
NULL);
|
||||
hashtable = weechat_hashtable_new (size, type_keys, type_values,
|
||||
NULL, NULL);
|
||||
if (!hashtable)
|
||||
return NULL;
|
||||
|
||||
@@ -167,13 +164,15 @@ weechat_tcl_dict_to_hashtable (Tcl_Interp *interp, Tcl_Obj *dict,
|
||||
{
|
||||
weechat_hashtable_set (hashtable,
|
||||
Tcl_GetString (key),
|
||||
plugin_script_str2ptr (weechat_tcl_plugin,
|
||||
NULL, NULL,
|
||||
Tcl_GetString (value)));
|
||||
plugin_script_str2ptr (
|
||||
weechat_tcl_plugin,
|
||||
NULL, NULL,
|
||||
Tcl_GetString (value)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Tcl_DictObjDone(&search);
|
||||
|
||||
Tcl_DictObjDone (&search);
|
||||
|
||||
return hashtable;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user