1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-26 04:46:37 +02:00

Add "replacement" argument for string_remove_color in plugin API

This commit is contained in:
Sebastien Helleu
2009-03-18 18:02:48 +01:00
parent 5f243ddd86
commit a394ed5d6f
17 changed files with 160 additions and 87 deletions
+5 -4
View File
@@ -371,7 +371,7 @@ weechat_lua_api_ngettext (lua_State *L)
static int
weechat_lua_api_string_remove_color (lua_State *L)
{
const char *string;
const char *string, *replacement;
char *result;
int n;
@@ -388,15 +388,16 @@ weechat_lua_api_string_remove_color (lua_State *L)
n = lua_gettop (lua_current_interpreter);
if (n < 1)
if (n < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
LUA_RETURN_EMPTY;
}
string = lua_tostring (lua_current_interpreter, -1);
string = lua_tostring (lua_current_interpreter, -2);
replacement = lua_tostring (lua_current_interpreter, -1);
result = weechat_string_remove_color (string);
result = weechat_string_remove_color (string, replacement);
LUA_RETURN_STRING_FREE(result);
}
+4 -3
View File
@@ -316,7 +316,7 @@ static XS (XS_weechat_api_ngettext)
static XS (XS_weechat_api_string_remove_color)
{
char *result, *string;
char *result, *string, *replacement;
dXSARGS;
/* make C compiler happy */
@@ -328,14 +328,15 @@ static XS (XS_weechat_api_string_remove_color)
PERL_RETURN_EMPTY;
}
if (items < 1)
if (items < 2)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
PERL_RETURN_EMPTY;
}
string = SvPV (ST (0), PL_na);
result = weechat_string_remove_color (string);
replacement = SvPV (ST (1), PL_na);
result = weechat_string_remove_color (string, replacement);
PERL_RETURN_STRING_FREE(result);
}
@@ -324,7 +324,7 @@ weechat_python_api_ngettext (PyObject *self, PyObject *args)
static PyObject *
weechat_python_api_string_remove_color (PyObject *self, PyObject *args)
{
char *string, *result;
char *string, *replacement, *result;
PyObject *object;
/* make C compiler happy */
@@ -337,14 +337,15 @@ weechat_python_api_string_remove_color (PyObject *self, PyObject *args)
}
string = NULL;
replacement = NULL;
if (!PyArg_ParseTuple (args, "s", &string))
if (!PyArg_ParseTuple (args, "ss", &string, &replacement))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
PYTHON_RETURN_EMPTY;
}
result = weechat_string_remove_color (string);
result = weechat_string_remove_color (string, replacement);
PYTHON_RETURN_STRING_FREE(result);
}
+9 -5
View File
@@ -372,9 +372,10 @@ weechat_ruby_api_ngettext (VALUE class, VALUE single, VALUE plural,
*/
static VALUE
weechat_ruby_api_string_remove_color (VALUE class, VALUE string)
weechat_ruby_api_string_remove_color (VALUE class, VALUE string,
VALUE replacement)
{
char *c_string, *result;
char *c_string, *c_replacement, *result;
VALUE return_value;
/* make C compiler happy */
@@ -387,18 +388,21 @@ weechat_ruby_api_string_remove_color (VALUE class, VALUE string)
}
c_string = NULL;
c_replacement = NULL;
if (NIL_P (string))
if (NIL_P (string) || NIL_P (replacement))
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
RUBY_RETURN_EMPTY;
}
Check_Type (string, T_STRING);
Check_Type (replacement, T_STRING);
c_string = STR2CSTR (string);
c_replacement = STR2CSTR (replacement);
result = weechat_string_remove_color (c_string);
result = weechat_string_remove_color (c_string, c_replacement);
RUBY_RETURN_STRING_FREE(result);
}
@@ -6580,7 +6584,7 @@ weechat_ruby_api_init (VALUE ruby_mWeechat)
rb_define_module_function (ruby_mWeechat, "iconv_from_internal", &weechat_ruby_api_iconv_from_internal, 2);
rb_define_module_function (ruby_mWeechat, "gettext", &weechat_ruby_api_gettext, 1);
rb_define_module_function (ruby_mWeechat, "ngettext", &weechat_ruby_api_ngettext, 3);
rb_define_module_function (ruby_mWeechat, "string_remove_color", &weechat_ruby_api_string_remove_color, 1);
rb_define_module_function (ruby_mWeechat, "string_remove_color", &weechat_ruby_api_string_remove_color, 2);
rb_define_module_function (ruby_mWeechat, "mkdir_home", &weechat_ruby_api_mkdir_home, 2);
rb_define_module_function (ruby_mWeechat, "mkdir", &weechat_ruby_api_mkdir, 2);
rb_define_module_function (ruby_mWeechat, "mkdir_parents", &weechat_ruby_api_mkdir_parents, 2);
+4 -3
View File
@@ -443,7 +443,7 @@ weechat_tcl_api_string_remove_color (ClientData clientData, Tcl_Interp *interp,
int objc, Tcl_Obj *CONST objv[])
{
Tcl_Obj* objp;
char *result, *string;
char *result, *replacement, *string;
int i;
/* make C compiler happy */
@@ -455,14 +455,15 @@ weechat_tcl_api_string_remove_color (ClientData clientData, Tcl_Interp *interp,
TCL_RETURN_EMPTY;
}
if (objc < 2)
if (objc < 3)
{
WEECHAT_SCRIPT_MSG_WRONG_ARGUMENTS("string_remove_color");
TCL_RETURN_EMPTY;
}
string = Tcl_GetStringFromObj (objv[1], &i);
result = weechat_string_remove_color (string);
replacement = Tcl_GetStringFromObj (objv[2], &i);
result = weechat_string_remove_color (string, replacement);
TCL_RETURN_STRING_FREE(result);
}