scripts: fix type of value returned by function hdata_time (from string to long integer) in perl/ruby/lua/tcl/guile plugins

This commit is contained in:
Sébastien Helleu 2015-03-01 09:06:18 +01:00
parent 3cd0259575
commit 5a70597516
6 changed files with 21 additions and 40 deletions

View File

@ -36,6 +36,8 @@ https://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
* relay: fix up/down keys on relay buffer (closes #335)
* relay: remove v4-mapped addresses in /help relay.network.allowed_ips
(closes #325)
* scripts: fix type of value returned by function hdata_time (from string to
long integer) in perl/ruby/lua/tcl/guile plugins
== Version 1.1.1 (2015-01-25)

View File

@ -4439,22 +4439,17 @@ weechat_guile_api_hdata_pointer (SCM hdata, SCM pointer, SCM name)
SCM
weechat_guile_api_hdata_time (SCM hdata, SCM pointer, SCM name)
{
char timebuffer[64], *result;
time_t time;
SCM return_value;
API_INIT_FUNC(1, "hdata_time", API_RETURN_EMPTY);
API_INIT_FUNC(1, "hdata_time", API_RETURN_LONG(0));
if (!scm_is_string (hdata) || !scm_is_string (pointer) || !scm_is_string (name))
API_WRONG_ARGS(API_RETURN_EMPTY);
API_WRONG_ARGS(API_RETURN_LONG(0));
timebuffer[0] = '\0';
time = weechat_hdata_time (API_STR2PTR(API_SCM_TO_STRING(hdata)),
API_STR2PTR(API_SCM_TO_STRING(pointer)),
API_SCM_TO_STRING(name));
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)time);
result = strdup (timebuffer);
API_RETURN_STRING_FREE(result);
API_RETURN_LONG(time);
}
SCM

View File

@ -4737,24 +4737,20 @@ API_FUNC(hdata_time)
{
const char *hdata, *pointer, *name;
time_t time;
char timebuffer[64], *result;
API_INIT_FUNC(1, "hdata_time", API_RETURN_EMPTY);
API_INIT_FUNC(1, "hdata_time", API_RETURN_LONG(0));
if (lua_gettop (L) < 3)
API_WRONG_ARGS(API_RETURN_EMPTY);
API_WRONG_ARGS(API_RETURN_LONG(0));
hdata = lua_tostring (L, -3);
pointer = lua_tostring (L, -2);
name = lua_tostring (L, -1);
timebuffer[0] = '\0';
time = weechat_hdata_time (API_STR2PTR(hdata),
API_STR2PTR(pointer),
name);
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)time);
result = strdup (timebuffer);
API_RETURN_STRING_FREE(result);
API_RETURN_LONG(time);
}
API_FUNC(hdata_hashtable)

View File

@ -4664,25 +4664,20 @@ API_FUNC(hdata_pointer)
API_FUNC(hdata_time)
{
time_t time;
char timebuffer[64], *result, *hdata, *pointer, *name;
char *hdata, *pointer, *name;
dXSARGS;
API_INIT_FUNC(1, "hdata_time", API_RETURN_EMPTY);
API_INIT_FUNC(1, "hdata_time", API_RETURN_LONG(0));
if (items < 3)
API_WRONG_ARGS(API_RETURN_EMPTY);
API_WRONG_ARGS(API_RETURN_LONG(0));
hdata = SvPV_nolen (ST (0));
pointer = SvPV_nolen (ST (1));
name = SvPV_nolen (ST (2));
timebuffer[0] = '\0';
time = weechat_hdata_time (API_STR2PTR(hdata),
API_STR2PTR(pointer),
name);
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)time);
result = strdup (timebuffer);
time = weechat_hdata_time (API_STR2PTR(hdata), API_STR2PTR(pointer), name);
API_RETURN_STRING_FREE(result);
API_RETURN_LONG(time);
}
API_FUNC(hdata_hashtable)

View File

@ -5691,13 +5691,12 @@ static VALUE
weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer,
VALUE name)
{
char *c_hdata, *c_pointer, *c_name, timebuffer[64], *result;
char *c_hdata, *c_pointer, *c_name;
time_t time;
VALUE return_value;
API_INIT_FUNC(1, "hdata_time", API_RETURN_EMPTY);
API_INIT_FUNC(1, "hdata_time", API_RETURN_LONG(0));
if (NIL_P (hdata) || NIL_P (pointer) || NIL_P (name))
API_WRONG_ARGS(API_RETURN_EMPTY);
API_WRONG_ARGS(API_RETURN_LONG(0));
Check_Type (hdata, T_STRING);
Check_Type (pointer, T_STRING);
@ -5707,14 +5706,11 @@ weechat_ruby_api_hdata_time (VALUE class, VALUE hdata, VALUE pointer,
c_pointer = StringValuePtr (pointer);
c_name = StringValuePtr (name);
timebuffer[0] = '\0';
time = weechat_hdata_time (API_STR2PTR(c_hdata),
API_STR2PTR(c_pointer),
c_name);
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)time);
result = strdup (timebuffer);
API_RETURN_STRING_FREE(result);
API_RETURN_LONG(time);
}
static VALUE

View File

@ -5014,25 +5014,22 @@ API_FUNC(hdata_time)
{
Tcl_Obj *objp;
time_t time;
char timebuffer[64], *result, *hdata, *pointer, *name;
char *hdata, *pointer, *name;
int i;
API_INIT_FUNC(1, "hdata_time", API_RETURN_EMPTY);
API_INIT_FUNC(1, "hdata_time", API_RETURN_LONG(0));
if (objc < 4)
API_WRONG_ARGS(API_RETURN_EMPTY);
API_WRONG_ARGS(API_RETURN_LONG(0));
hdata = Tcl_GetStringFromObj (objv[1], &i);
pointer = Tcl_GetStringFromObj (objv[2], &i);
name = Tcl_GetStringFromObj (objv[3], &i);
timebuffer[0] = '\0';
time = weechat_hdata_time (API_STR2PTR(hdata),
API_STR2PTR(pointer),
name);
snprintf (timebuffer, sizeof (timebuffer), "%ld", (long int)time);
result = strdup (timebuffer);
API_RETURN_STRING_FREE(result);
API_RETURN_LONG(time);
}
API_FUNC(hdata_hashtable)