summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2018-04-10 21:26:15 +0200
committerSébastien Helleu <flashcode@flashtux.org>2018-04-10 21:26:15 +0200
commit3467d6eb430d132ff94e04ad7485d8f705317099 (patch)
treebcf6a9684d2f08c41e50ec95963be55ddb53144a
parent9a969c41dbd938f598fd06f2dee8bbd3feafea57 (diff)
downloadweechat-3467d6eb430d132ff94e04ad7485d8f705317099.zip
scripts: return long integer instead of string in function infolist_time
-rw-r--r--ChangeLog.adoc1
-rw-r--r--src/plugins/guile/weechat-guile-api.c17
-rw-r--r--src/plugins/javascript/weechat-js-api.cpp10
-rw-r--r--src/plugins/lua/weechat-lua-api.c19
-rw-r--r--src/plugins/perl/weechat-perl-api.c17
-rw-r--r--src/plugins/php/weechat-php-api.c11
-rw-r--r--src/plugins/python/weechat-python-api.c21
-rw-r--r--src/plugins/ruby/weechat-ruby-api.c18
-rw-r--r--src/plugins/tcl/weechat-tcl-api.c17
9 files changed, 33 insertions, 98 deletions
diff --git a/ChangeLog.adoc b/ChangeLog.adoc
index 6e3fd9c9c..78e0dbe50 100644
--- a/ChangeLog.adoc
+++ b/ChangeLog.adoc
@@ -37,6 +37,7 @@ Bug fixes::
* php: fix return code of functions config_write_option and config_write_line
* php: fix memory leak in 72 functions returning allocated strings
* ruby: fix memory leak in 7 functions returning allocated strings
+ * scripts: return long integer instead of string in function infolist_time
* xfer: set option TCP_NODELAY on socket when receiving a file via DCC (issue #1171)
Documentation::
diff --git a/src/plugins/guile/weechat-guile-api.c b/src/plugins/guile/weechat-guile-api.c
index a0a7450b9..90af55799 100644
--- a/src/plugins/guile/weechat-guile-api.c
+++ b/src/plugins/guile/weechat-guile-api.c
@@ -4284,27 +4284,16 @@ weechat_guile_api_infolist_pointer (SCM infolist, SCM variable)
SCM
weechat_guile_api_infolist_time (SCM infolist, SCM variable)
{
- char timebuffer[64], *result;
time_t time;
- struct tm *date_tmp;
- SCM return_value;
- API_INIT_FUNC(1, "infolist_time", API_RETURN_EMPTY);
+ API_INIT_FUNC(1, "infolist_time", API_RETURN_LONG(0));
if (!scm_is_string (infolist) || !scm_is_string (variable))
- API_WRONG_ARGS(API_RETURN_EMPTY);
+ API_WRONG_ARGS(API_RETURN_LONG(0));
- timebuffer[0] = '\0';
time = weechat_infolist_time (API_STR2PTR(API_SCM_TO_STRING(infolist)),
API_SCM_TO_STRING(variable));
- date_tmp = localtime (&time);
- if (date_tmp)
- {
- if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0)
- timebuffer[0] = '\0';
- }
- result = strdup (timebuffer);
- API_RETURN_STRING_FREE(result);
+ API_RETURN_LONG(time);
}
SCM
diff --git a/src/plugins/javascript/weechat-js-api.cpp b/src/plugins/javascript/weechat-js-api.cpp
index f51debb67..307dd886c 100644
--- a/src/plugins/javascript/weechat-js-api.cpp
+++ b/src/plugins/javascript/weechat-js-api.cpp
@@ -4184,11 +4184,9 @@ API_FUNC(infolist_pointer)
API_FUNC(infolist_time)
{
- char timebuffer[64], *result;
time_t time;
- struct tm *date_tmp;
- API_INIT_FUNC(1, "infolist_time", "ss", API_RETURN_EMPTY);
+ API_INIT_FUNC(1, "infolist_time", "ss", API_RETURN_LONG(0));
v8::String::Utf8Value infolist(args[0]);
v8::String::Utf8Value variable(args[1]);
@@ -4196,12 +4194,8 @@ API_FUNC(infolist_time)
time = weechat_infolist_time (
(struct t_infolist *)API_STR2PTR(*infolist),
*variable);
- date_tmp = localtime (&time);
- if (date_tmp)
- strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp);
- result = strdup (timebuffer);
- API_RETURN_STRING_FREE(result);
+ API_RETURN_LONG(time);
}
API_FUNC(infolist_free)
diff --git a/src/plugins/lua/weechat-lua-api.c b/src/plugins/lua/weechat-lua-api.c
index 1fb82b8cd..418fbf811 100644
--- a/src/plugins/lua/weechat-lua-api.c
+++ b/src/plugins/lua/weechat-lua-api.c
@@ -4524,28 +4524,17 @@ API_FUNC(infolist_time)
{
const char *infolist, *variable;
time_t time;
- struct tm *date_tmp;
- char timebuffer[64], *result;
- API_INIT_FUNC(1, "infolist_time", API_RETURN_EMPTY);
+ API_INIT_FUNC(1, "infolist_time", API_RETURN_LONG(0));
if (lua_gettop (L) < 2)
- API_WRONG_ARGS(API_RETURN_EMPTY);
+ API_WRONG_ARGS(API_RETURN_LONG(0));
infolist = lua_tostring (L, -2);
variable = lua_tostring (L, -1);
- timebuffer[0] = '\0';
- time = weechat_infolist_time (API_STR2PTR(infolist),
- variable);
- date_tmp = localtime (&time);
- if (date_tmp)
- {
- if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0)
- timebuffer[0] = '\0';
- }
- result = strdup (timebuffer);
+ time = weechat_infolist_time (API_STR2PTR(infolist), variable);
- API_RETURN_STRING_FREE(result);
+ API_RETURN_LONG(time);
}
API_FUNC(infolist_free)
diff --git a/src/plugins/perl/weechat-perl-api.c b/src/plugins/perl/weechat-perl-api.c
index 2ac22a3a1..bc57e2e0a 100644
--- a/src/plugins/perl/weechat-perl-api.c
+++ b/src/plugins/perl/weechat-perl-api.c
@@ -4469,28 +4469,19 @@ API_FUNC(infolist_pointer)
API_FUNC(infolist_time)
{
time_t time;
- struct tm *date_tmp;
- char timebuffer[64], *result, *infolist, *variable;
+ char *infolist, *variable;
dXSARGS;
- API_INIT_FUNC(1, "infolist_time", API_RETURN_EMPTY);
+ API_INIT_FUNC(1, "infolist_time", API_RETURN_LONG(0));
if (items < 2)
- API_WRONG_ARGS(API_RETURN_EMPTY);
+ API_WRONG_ARGS(API_RETURN_LONG(0));
infolist = SvPV_nolen (ST (0));
variable = SvPV_nolen (ST (1));
- timebuffer[0] = '\0';
time = weechat_infolist_time (API_STR2PTR(infolist), variable);
- date_tmp = localtime (&time);
- if (date_tmp)
- {
- if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0)
- timebuffer[0] = '\0';
- }
- result = strdup (timebuffer);
- API_RETURN_STRING_FREE(result);
+ API_RETURN_LONG(time);
}
API_FUNC(infolist_free)
diff --git a/src/plugins/php/weechat-php-api.c b/src/plugins/php/weechat-php-api.c
index 1bb039556..1801e79b1 100644
--- a/src/plugins/php/weechat-php-api.c
+++ b/src/plugins/php/weechat-php-api.c
@@ -4422,18 +4422,19 @@ API_FUNC(infolist_time)
zend_string *z_infolist, *z_var;
struct t_infolist *infolist;
char *var;
- time_t result;
+ time_t time;
- API_INIT_FUNC(1, "infolist_time", API_RETURN_EMPTY);
+ API_INIT_FUNC(1, "infolist_time", API_RETURN_LONG(0));
if (zend_parse_parameters (ZEND_NUM_ARGS(),
"SS", &z_infolist, &z_var) == FAILURE)
- API_WRONG_ARGS(API_RETURN_EMPTY);
+ API_WRONG_ARGS(API_RETURN_LONG(0));
infolist = (struct t_infolist *)API_STR2PTR(ZSTR_VAL(z_infolist));
var = ZSTR_VAL(z_var);
- result = weechat_infolist_time (infolist, (const char *)var);
- API_RETURN_INT(result);
+ time = weechat_infolist_time (infolist, (const char *)var);
+
+ API_RETURN_LONG(time);
}
API_FUNC(infolist_free)
diff --git a/src/plugins/python/weechat-python-api.c b/src/plugins/python/weechat-python-api.c
index 5b08c9bb4..905795ab4 100644
--- a/src/plugins/python/weechat-python-api.c
+++ b/src/plugins/python/weechat-python-api.c
@@ -4460,29 +4460,18 @@ API_FUNC(infolist_pointer)
API_FUNC(infolist_time)
{
- char *infolist, *variable, timebuffer[64], *result;
+ char *infolist, *variable;
time_t time;
- struct tm *date_tmp;
- PyObject *return_value;
- API_INIT_FUNC(1, "infolist_time", API_RETURN_EMPTY);
+ API_INIT_FUNC(1, "infolist_time", API_RETURN_LONG(0));
infolist = NULL;
variable = NULL;
if (!PyArg_ParseTuple (args, "ss", &infolist, &variable))
- API_WRONG_ARGS(API_RETURN_EMPTY);
+ API_WRONG_ARGS(API_RETURN_LONG(0));
- timebuffer[0] = '\0';
- time = weechat_infolist_time (API_STR2PTR(infolist),
- variable);
- date_tmp = localtime (&time);
- if (date_tmp)
- {
- if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0)
- timebuffer[0] = '\0';
- }
- result = strdup (timebuffer);
+ time = weechat_infolist_time (API_STR2PTR(infolist), variable);
- API_RETURN_STRING_FREE(result);
+ API_RETURN_LONG(time);
}
API_FUNC(infolist_free)
diff --git a/src/plugins/ruby/weechat-ruby-api.c b/src/plugins/ruby/weechat-ruby-api.c
index eec272e6f..f440c599c 100644
--- a/src/plugins/ruby/weechat-ruby-api.c
+++ b/src/plugins/ruby/weechat-ruby-api.c
@@ -5403,14 +5403,12 @@ weechat_ruby_api_infolist_pointer (VALUE class, VALUE infolist, VALUE variable)
static VALUE
weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable)
{
- char *c_infolist, *c_variable, timebuffer[64], *result;
+ char *c_infolist, *c_variable;
time_t time;
- struct tm *date_tmp;
- VALUE return_value;
- API_INIT_FUNC(1, "infolist_time", API_RETURN_EMPTY);
+ API_INIT_FUNC(1, "infolist_time", API_RETURN_LONG(0));
if (NIL_P (infolist) || NIL_P (variable))
- API_WRONG_ARGS(API_RETURN_EMPTY);
+ API_WRONG_ARGS(API_RETURN_LONG(0));
Check_Type (infolist, T_STRING);
Check_Type (variable, T_STRING);
@@ -5418,17 +5416,9 @@ weechat_ruby_api_infolist_time (VALUE class, VALUE infolist, VALUE variable)
c_infolist = StringValuePtr (infolist);
c_variable = StringValuePtr (variable);
- timebuffer[0] = '\0';
time = weechat_infolist_time (API_STR2PTR(c_infolist), c_variable);
- date_tmp = localtime (&time);
- if (date_tmp)
- {
- if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0)
- timebuffer[0] = '\0';
- }
- result = strdup (timebuffer);
- API_RETURN_STRING_FREE(result);
+ API_RETURN_LONG(time);
}
static VALUE
diff --git a/src/plugins/tcl/weechat-tcl-api.c b/src/plugins/tcl/weechat-tcl-api.c
index 876f4224f..c292871b7 100644
--- a/src/plugins/tcl/weechat-tcl-api.c
+++ b/src/plugins/tcl/weechat-tcl-api.c
@@ -4818,28 +4818,19 @@ API_FUNC(infolist_time)
{
Tcl_Obj *objp;
time_t time;
- struct tm *date_tmp;
- char timebuffer[64], *result, *infolist, *variable;
+ char *infolist, *variable;
int i;
- API_INIT_FUNC(1, "infolist_time", API_RETURN_EMPTY);
+ API_INIT_FUNC(1, "infolist_time", API_RETURN_LONG(0));
if (objc < 3)
- API_WRONG_ARGS(API_RETURN_EMPTY);
+ API_WRONG_ARGS(API_RETURN_LONG(0));
infolist = Tcl_GetStringFromObj (objv[1], &i);
variable = Tcl_GetStringFromObj (objv[2], &i);
- timebuffer[0] = '\0';
time = weechat_infolist_time (API_STR2PTR(infolist), variable);
- date_tmp = localtime (&time);
- if (date_tmp)
- {
- if (strftime (timebuffer, sizeof (timebuffer), "%F %T", date_tmp) == 0)
- timebuffer[0] = '\0';
- }
- result = strdup (timebuffer);
- API_RETURN_STRING_FREE(result);
+ API_RETURN_LONG(time);
}
API_FUNC(infolist_free)