summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2015-02-21 09:16:25 +0100
committerSébastien Helleu <flashcode@flashtux.org>2015-02-21 09:16:25 +0100
commitc1a5a76d087d716e5f49afeb88352d3a126614af (patch)
tree85cb4c5ef5dfbd1465b5ca0f4340b0ddfb387b5c /src
parent8f11de68631bc707e818da8eb15845efbcb162f4 (diff)
downloadweechat-c1a5a76d087d716e5f49afeb88352d3a126614af.zip
scripts: reformat some code to make it more readable
Diffstat (limited to 'src')
-rw-r--r--src/plugins/guile/weechat-guile.c7
-rw-r--r--src/plugins/lua/weechat-lua.c14
-rw-r--r--src/plugins/perl/weechat-perl.c24
-rw-r--r--src/plugins/python/weechat-python.c13
-rw-r--r--src/plugins/ruby/weechat-ruby.c16
-rw-r--r--src/plugins/tcl/weechat-tcl.c17
6 files changed, 45 insertions, 46 deletions
diff --git a/src/plugins/guile/weechat-guile.c b/src/plugins/guile/weechat-guile.c
index 77af713de..fde52babd 100644
--- a/src/plugins/guile/weechat-guile.c
+++ b/src/plugins/guile/weechat-guile.c
@@ -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;
diff --git a/src/plugins/lua/weechat-lua.c b/src/plugins/lua/weechat-lua.c
index 8d22946bc..43a4cc13f 100644
--- a/src/plugins/lua/weechat-lua.c
+++ b/src/plugins/lua/weechat-lua.c
@@ -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);
diff --git a/src/plugins/perl/weechat-perl.c b/src/plugins/perl/weechat-perl.c
index 90bcb3178..d8c22a64b 100644
--- a/src/plugins/perl/weechat-perl.c
+++ b/src/plugins/perl/weechat-perl.c
@@ -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)));
}
}
}
diff --git a/src/plugins/python/weechat-python.c b/src/plugins/python/weechat-python.c
index a9b004ee7..21fd90b7b 100644
--- a/src/plugins/python/weechat-python.c
+++ b/src/plugins/python/weechat-python.c
@@ -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,
diff --git a/src/plugins/ruby/weechat-ruby.c b/src/plugins/ruby/weechat-ruby.c
index 19b63fc8d..11c0fe9e7 100644
--- a/src/plugins/ruby/weechat-ruby.c
+++ b/src/plugins/ruby/weechat-ruby.c
@@ -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;
diff --git a/src/plugins/tcl/weechat-tcl.c b/src/plugins/tcl/weechat-tcl.c
index b08831e60..d0b557c26 100644
--- a/src/plugins/tcl/weechat-tcl.c
+++ b/src/plugins/tcl/weechat-tcl.c
@@ -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;
}