1
0
mirror of https://github.com/weechat/weechat.git synced 2026-06-28 13:56:37 +02:00

script: use util functions to parse integers

This commit is contained in:
Sébastien Helleu
2026-06-20 11:31:33 +02:00
parent cb0a9a3c42
commit 4d2d93a694
3 changed files with 15 additions and 33 deletions
+7 -18
View File
@@ -45,9 +45,7 @@ script_command_action (struct t_gui_buffer *buffer,
{
struct t_script_repo *ptr_script;
char str_action[4096];
long value;
char *error;
int quiet;
int quiet, value;
if (arguments)
{
@@ -62,9 +60,7 @@ script_command_action (struct t_gui_buffer *buffer,
arguments++;
}
}
error = NULL;
value = strtol (arguments, &error, 10);
if (error && !error[0])
if (weechat_util_parse_int (arguments, 10, &value))
{
ptr_script = script_repo_search_displayed_by_number (value);
if (ptr_script)
@@ -132,9 +128,8 @@ script_command_script (const void *pointer, void *data,
struct t_gui_buffer *buffer, int argc,
char **argv, char **argv_eol)
{
char *error, command[128];
long value;
int line;
char command[128];
int line, value;
/* make C compiler happy */
(void) pointer;
@@ -227,9 +222,7 @@ script_command_script (const void *pointer, void *data,
}
else
{
error = NULL;
value = strtol (argv[2], &error, 10);
if (error && !error[0])
if (weechat_util_parse_int (argv[2], 10, &value))
line = value;
}
if (line >= 0)
@@ -248,9 +241,7 @@ script_command_script (const void *pointer, void *data,
value = 1;
if (argc > 2)
{
error = NULL;
value = strtol (argv[2], &error, 10);
if (!error || error[0])
if (!weechat_util_parse_int (argv[2], 10, &value))
value = 1;
}
if (script_buffer_detail_script)
@@ -282,9 +273,7 @@ script_command_script (const void *pointer, void *data,
value = 1;
if (argc > 2)
{
error = NULL;
value = strtol (argv[2], &error, 10);
if (!error || error[0])
if (!weechat_util_parse_int (argv[2], 10, &value))
value = 1;
}
if (script_buffer_detail_script)
+7 -10
View File
@@ -40,11 +40,10 @@ script_mouse_focus_chat_cb (const void *pointer, void *data,
struct t_hashtable *info)
{
const char *buffer;
int rc;
int rc, y;
unsigned long value;
struct t_gui_buffer *ptr_buffer;
long x;
char *error, str_date[64];
char str_date[64];
struct t_script_repo *ptr_script;
struct tm *tm;
@@ -72,15 +71,13 @@ script_mouse_focus_chat_cb (const void *pointer, void *data,
ptr_script = script_buffer_detail_script;
else
{
error = NULL;
x = strtol (weechat_hashtable_get (info, "_chat_line_y"), &error, 10);
if (!error || error[0])
if (!weechat_util_parse_int (weechat_hashtable_get (info, "_chat_line_y"), 10, &y)
|| (y < 0))
{
return info;
}
if (x < 0)
return info;
ptr_script = script_repo_search_displayed_by_number (x);
ptr_script = script_repo_search_displayed_by_number (y);
if (!ptr_script)
return info;
}
+1 -5
View File
@@ -1312,11 +1312,7 @@ script_repo_file_read (int quiet)
script->url = strdup (value);
else if (strcmp (name, "popularity") == 0)
{
error = NULL;
script->popularity = (int)strtol (value,
&error,
10);
if (!error || error[0])
if (!weechat_util_parse_int (value, 10, &(script->popularity)))
script->popularity = 0;
}
else if (strcmp (name, "added") == 0)