scripts: return long integer instead of string in function infolist_time
This commit is contained in:
parent
9a969c41db
commit
3467d6eb43
@ -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::
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user