mirror of
https://github.com/weechat/weechat.git
synced 2026-06-23 03:16:37 +02:00
Compare commits
22 Commits
main
...
parse-integers
| Author | SHA1 | Date | |
|---|---|---|---|
| 0ba30fc217 | |||
| 9cf398afa1 | |||
| c150f67cf9 | |||
| 3df0d2d4d3 | |||
| 4d2d93a694 | |||
| cb0a9a3c42 | |||
| 15f0cef09e | |||
| 49c4c2267a | |||
| b6f4343d78 | |||
| 0ae7ce165e | |||
| 8d69194398 | |||
| 054b7ff600 | |||
| 0ade9757eb | |||
| 64c0c34735 | |||
| 6d89ea1324 | |||
| bbab9eceb9 | |||
| 958c1b84fa | |||
| c545cf75f3 | |||
| f34cb85ca3 | |||
| bed3467efb | |||
| d5bb81fd2b | |||
| c03bb825c4 |
@@ -5536,7 +5536,7 @@ COMMAND_CALLBACK(print)
|
||||
struct timeval tv_date;
|
||||
char *tags, *pos, *text, *text2, empty_string[1] = { '\0' };
|
||||
const char *prefix, *ptr_text;
|
||||
long value;
|
||||
long long value;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -5609,7 +5609,7 @@ COMMAND_CALLBACK(print)
|
||||
i++;
|
||||
if ((argv[i][0] == '-') || (argv[i][0] == '+'))
|
||||
{
|
||||
if (!util_parse_long (argv[i] + 1, 10, &value))
|
||||
if (!util_parse_longlong (argv[i] + 1, 10, &value))
|
||||
COMMAND_ERROR;
|
||||
gettimeofday (&tv_date, NULL);
|
||||
tv_date.tv_sec += (argv[i][0] == '+') ? value : value * -1;
|
||||
|
||||
@@ -1313,9 +1313,9 @@ hdata_set (struct t_hdata *hdata, void *pointer, const char *name,
|
||||
}
|
||||
break;
|
||||
case WEECHAT_HDATA_TIME:
|
||||
if (util_parse_long (value, 10, &number_long) && (number_long >= 0))
|
||||
if (util_parse_longlong (value, 10, &number_longlong) && (number_longlong >= 0))
|
||||
{
|
||||
*((time_t *)(pointer + var->offset)) = (time_t)number_long;
|
||||
*((time_t *)(pointer + var->offset)) = (time_t)number_longlong;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
||||
+39
-98
@@ -1764,17 +1764,13 @@ void
|
||||
gui_buffer_set_notify (struct t_gui_buffer *buffer, const char *notify)
|
||||
{
|
||||
const char *ptr_notify;
|
||||
char *error;
|
||||
long number;
|
||||
int mute_old;
|
||||
int mute_old, number;
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
ptr_notify = NULL;
|
||||
error = NULL;
|
||||
number = strtol (notify, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (notify, 10, &number))
|
||||
{
|
||||
if (number < GUI_BUFFER_NUM_NOTIFY)
|
||||
{
|
||||
@@ -2232,9 +2228,8 @@ void
|
||||
gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
|
||||
const char *new_hotlist_max_level_nicks)
|
||||
{
|
||||
char **nicks, *pos, *error;
|
||||
int nicks_count, value, i;
|
||||
long number;
|
||||
char **nicks, *pos;
|
||||
int nicks_count, number, value, i;
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
@@ -2260,13 +2255,10 @@ gui_buffer_set_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
|
||||
{
|
||||
pos[0] = '\0';
|
||||
pos++;
|
||||
error = NULL;
|
||||
number = strtol (pos, &error, 10);
|
||||
if (error && !error[0])
|
||||
value = (int)number;
|
||||
if (util_parse_int (pos, 10, &number))
|
||||
value = number;
|
||||
}
|
||||
hashtable_set (buffer->hotlist_max_level_nicks, nicks[i],
|
||||
&value);
|
||||
hashtable_set (buffer->hotlist_max_level_nicks, nicks[i], &value);
|
||||
}
|
||||
string_free_split (nicks);
|
||||
}
|
||||
@@ -2279,9 +2271,8 @@ void
|
||||
gui_buffer_add_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
|
||||
const char *nicks_to_add)
|
||||
{
|
||||
char **nicks, *pos, *error;
|
||||
int nicks_count, value, i;
|
||||
long number;
|
||||
char **nicks, *pos;
|
||||
int nicks_count, number, value, i;
|
||||
|
||||
if (!buffer || !nicks_to_add)
|
||||
return;
|
||||
@@ -2302,13 +2293,10 @@ gui_buffer_add_hotlist_max_level_nicks (struct t_gui_buffer *buffer,
|
||||
{
|
||||
pos[0] = '\0';
|
||||
pos++;
|
||||
error = NULL;
|
||||
number = strtol (pos, &error, 10);
|
||||
if (error && !error[0])
|
||||
value = (int)number;
|
||||
if (util_parse_int (pos, 10, &number))
|
||||
value = number;
|
||||
}
|
||||
hashtable_set (buffer->hotlist_max_level_nicks, nicks[i],
|
||||
&value);
|
||||
hashtable_set (buffer->hotlist_max_level_nicks, nicks[i], &value);
|
||||
}
|
||||
string_free_split (nicks);
|
||||
}
|
||||
@@ -2454,9 +2442,7 @@ void
|
||||
gui_buffer_set_unread (struct t_gui_buffer *buffer, const char *argument)
|
||||
{
|
||||
struct t_gui_line *old_last_read_line;
|
||||
int i, old_first_line_not_read;
|
||||
long number;
|
||||
char *error;
|
||||
int i, number, old_first_line_not_read;
|
||||
|
||||
if (!buffer || (buffer->type != GUI_BUFFER_TYPE_FORMATTED))
|
||||
return;
|
||||
@@ -2479,9 +2465,7 @@ gui_buffer_set_unread (struct t_gui_buffer *buffer, const char *argument)
|
||||
else if (argument[0] == '-')
|
||||
{
|
||||
/* move the unread marker N lines towards the first line */
|
||||
error = NULL;
|
||||
number = strtol (argument, &error, 10);
|
||||
if (error && !error[0] && (number < 0))
|
||||
if (util_parse_int (argument, 10, &number) && (number < 0))
|
||||
{
|
||||
for (i = 0; i > number; i--)
|
||||
{
|
||||
@@ -2507,9 +2491,7 @@ gui_buffer_set_unread (struct t_gui_buffer *buffer, const char *argument)
|
||||
else if (argument[0] == '+')
|
||||
{
|
||||
/* move the unread marker N lines towards the last line */
|
||||
error = NULL;
|
||||
number = strtol (argument, &error, 10);
|
||||
if (error && !error[0] && (number > 0))
|
||||
if (util_parse_int (argument, 10, &number) && (number > 0))
|
||||
{
|
||||
for (i = 0; i < number; i++)
|
||||
{
|
||||
@@ -2533,9 +2515,7 @@ gui_buffer_set_unread (struct t_gui_buffer *buffer, const char *argument)
|
||||
else
|
||||
{
|
||||
/* move the unread marker N lines from the end towards the first line */
|
||||
error = NULL;
|
||||
number = strtol (argument, &error, 10);
|
||||
if (error && !error[0] && (number > 0))
|
||||
if (util_parse_int (argument, 10, &number) && (number > 0))
|
||||
{
|
||||
buffer->lines->last_read_line = buffer->lines->last_line;
|
||||
buffer->lines->first_line_not_read = 0;
|
||||
@@ -2569,8 +2549,7 @@ void
|
||||
gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
const char *value)
|
||||
{
|
||||
long number;
|
||||
char *error;
|
||||
int number;
|
||||
|
||||
if (!property || !value)
|
||||
return;
|
||||
@@ -2584,9 +2563,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
gui_add_hotlist = 1;
|
||||
else if (buffer)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
{
|
||||
if (number < 0)
|
||||
{
|
||||
@@ -2614,9 +2591,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
/* properties that need a buffer */
|
||||
if (strcmp (property, "hotlist_conditions") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
{
|
||||
if (number < 0)
|
||||
{
|
||||
@@ -2650,9 +2625,7 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
}
|
||||
else if (strcmp (property, "hidden") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
{
|
||||
if (number)
|
||||
gui_buffer_hide (buffer);
|
||||
@@ -2662,37 +2635,27 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
}
|
||||
else if (strcmp (property, "print_hooks_enabled") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
buffer->print_hooks_enabled = (number) ? 1 : 0;
|
||||
}
|
||||
else if (strcmp (property, "day_change") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_day_change (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "clear") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
buffer->clear = (number) ? 1 : 0;
|
||||
}
|
||||
else if (strcmp (property, "filter") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_filter (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "number") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0] && (number >= 1))
|
||||
if (util_parse_int (value, 10, &number) && (number >= 1))
|
||||
gui_buffer_move_to_number (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "name") == 0)
|
||||
@@ -2724,30 +2687,22 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
}
|
||||
else if (strcmp (property, "time_for_each_line") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_time_for_each_line (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "nicklist") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_nicklist (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "nicklist_case_sensitive") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_nicklist_case_sensitive (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "nicklist_display_groups") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_nicklist_display_groups (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "highlight_words") == 0)
|
||||
@@ -2816,37 +2771,27 @@ gui_buffer_set (struct t_gui_buffer *buffer, const char *property,
|
||||
}
|
||||
else if (strcmp (property, "input_pos") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_input_set_pos (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "input_get_any_user_data") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_input_get_any_user_data (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "input_get_unknown_commands") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_input_get_unknown_commands (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "input_get_empty") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_input_get_empty (buffer, number);
|
||||
}
|
||||
else if (strcmp (property, "input_multiline") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
gui_buffer_set_input_multiline (buffer, number);
|
||||
}
|
||||
else if (strncmp (property, "localvar_set_", 13) == 0)
|
||||
@@ -3076,7 +3021,6 @@ gui_buffer_search (const char *plugin, const char *name)
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
int plugin_match, plugin_case_sensitive, name_case_sensitive;
|
||||
long long id;
|
||||
char *error;
|
||||
|
||||
if (!name || !name[0])
|
||||
return gui_current_window->buffer;
|
||||
@@ -3086,9 +3030,9 @@ gui_buffer_search (const char *plugin, const char *name)
|
||||
|
||||
if (plugin && (strcmp (plugin, "==id") == 0))
|
||||
{
|
||||
error = NULL;
|
||||
id = strtoll (name, &error, 10);
|
||||
return (error && !error[0]) ? gui_buffer_search_by_id (id) : NULL;
|
||||
if (util_parse_longlong (name, 10, &id))
|
||||
return gui_buffer_search_by_id (id);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
plugin_case_sensitive = 1;
|
||||
@@ -3317,16 +3261,13 @@ gui_buffer_search_by_id_number_name (const char *string)
|
||||
{
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
long long number;
|
||||
char *error;
|
||||
|
||||
if (!string)
|
||||
if (!string || !string[0])
|
||||
return NULL;
|
||||
|
||||
ptr_buffer = NULL;
|
||||
|
||||
error = NULL;
|
||||
number = strtoll (string, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_longlong (string, 10, &number))
|
||||
{
|
||||
ptr_buffer = gui_buffer_search_by_id (number);
|
||||
if (!ptr_buffer)
|
||||
|
||||
+3
-7
@@ -1400,7 +1400,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
|
||||
struct timeval tv;
|
||||
struct t_gui_line *ptr_line;
|
||||
int is_nick, rc;
|
||||
char str_time[128], *str, *error;
|
||||
char str_time[128], *str;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -1415,9 +1415,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
|
||||
hashtable_get (hashtable, "_chat_line_date") : NULL;
|
||||
if (ptr_date)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtoll (ptr_date, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_longlong (ptr_date, 10, &number))
|
||||
{
|
||||
tv.tv_sec = (time_t)number;
|
||||
tv.tv_usec = 0;
|
||||
@@ -1425,9 +1423,7 @@ gui_chat_hsignal_quote_line_cb (const void *pointer, void *data,
|
||||
hashtable_get (hashtable, "_chat_line_date_usec") : NULL;
|
||||
if (ptr_date_usec)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtoll (ptr_date_usec, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_longlong (ptr_date_usec, 10, &number))
|
||||
tv.tv_usec = (long)number;
|
||||
}
|
||||
util_strftimeval (str_time, sizeof (str_time),
|
||||
|
||||
+15
-38
@@ -41,6 +41,7 @@
|
||||
#include "../core/core-list.h"
|
||||
#include "../core/core-string.h"
|
||||
#include "../core/core-utf8.h"
|
||||
#include "../core/core-util.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "gui-color.h"
|
||||
#include "gui-chat.h"
|
||||
@@ -254,7 +255,7 @@ gui_color_get_custom (const char *color_name)
|
||||
static char color[32][96];
|
||||
static int index_color = 0;
|
||||
char color_fg[32], color_bg[32];
|
||||
char *str_fg, *error, *color_attr;
|
||||
char *str_fg, *color_attr;
|
||||
const char *ptr_color_name, *pos_delim, *pos_bg;
|
||||
|
||||
/* attribute or other color name (GUI dependent) */
|
||||
@@ -438,9 +439,7 @@ gui_color_get_custom (const char *color_name)
|
||||
fg_term = gui_color_palette_get_alias (str_fg);
|
||||
if (fg_term < 0)
|
||||
{
|
||||
error = NULL;
|
||||
term_color = (int)strtol (str_fg, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_fg, 10, &term_color))
|
||||
{
|
||||
fg_term = term_color;
|
||||
if (fg_term < 0)
|
||||
@@ -457,9 +456,7 @@ gui_color_get_custom (const char *color_name)
|
||||
bg_term = gui_color_palette_get_alias (pos_bg);
|
||||
if (bg_term < 0)
|
||||
{
|
||||
error = NULL;
|
||||
term_color = (int)strtol (pos_bg, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (pos_bg, 10, &term_color))
|
||||
{
|
||||
bg_term = term_color;
|
||||
if (bg_term < 0)
|
||||
@@ -1286,7 +1283,7 @@ char *
|
||||
gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
const unsigned char *ptr_string;
|
||||
char **out, str_concat[128], str_color[8], *error;
|
||||
char **out, str_concat[128], str_color[8];
|
||||
int flag, color, length, ansi_color, fg, bg, attrs;
|
||||
|
||||
if (!string)
|
||||
@@ -1320,9 +1317,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 5);
|
||||
str_color[5] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_color, 10, &color))
|
||||
{
|
||||
snprintf (str_concat, sizeof (str_concat),
|
||||
"\x1B[38;5;%dm",
|
||||
@@ -1343,9 +1338,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 2);
|
||||
str_color[2] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_color, 10, &color))
|
||||
{
|
||||
ansi_color = gui_color_weechat_to_ansi (color);
|
||||
snprintf (str_concat, sizeof (str_concat),
|
||||
@@ -1370,9 +1363,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 5);
|
||||
str_color[5] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_color, 10, &color))
|
||||
{
|
||||
snprintf (str_concat, sizeof (str_concat),
|
||||
"\x1B[48;5;%dm",
|
||||
@@ -1388,9 +1379,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 2);
|
||||
str_color[2] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_color, 10, &color))
|
||||
{
|
||||
ansi_color = gui_color_weechat_to_ansi (color);
|
||||
snprintf (str_concat, sizeof (str_concat),
|
||||
@@ -1420,9 +1409,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 5);
|
||||
str_color[5] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_color, 10, &color))
|
||||
{
|
||||
snprintf (str_concat, sizeof (str_concat),
|
||||
"\x1B[38;5;%dm",
|
||||
@@ -1443,9 +1430,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 2);
|
||||
str_color[2] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_color, 10, &color))
|
||||
{
|
||||
ansi_color = gui_color_weechat_to_ansi (color);
|
||||
snprintf (str_concat, sizeof (str_concat),
|
||||
@@ -1476,9 +1461,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 5);
|
||||
str_color[5] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_color, 10, &color))
|
||||
{
|
||||
snprintf (str_concat, sizeof (str_concat),
|
||||
"\x1B[48;5;%dm",
|
||||
@@ -1495,9 +1478,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 2);
|
||||
str_color[2] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_color, 10, &color))
|
||||
{
|
||||
ansi_color = gui_color_weechat_to_ansi (color);
|
||||
snprintf (str_concat, sizeof (str_concat),
|
||||
@@ -1521,9 +1502,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 5);
|
||||
str_color[5] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (str_color, 10, &color))
|
||||
{
|
||||
snprintf (str_concat, sizeof (str_concat),
|
||||
"\x1B[38;5;%dm",
|
||||
@@ -1595,9 +1574,7 @@ gui_color_encode_ansi (const char *string)
|
||||
{
|
||||
memcpy (str_color, ptr_string, 2);
|
||||
str_color[2] = '\0';
|
||||
error = NULL;
|
||||
color = (int)strtol (str_color, &error, 10);
|
||||
if (error && !error[0]
|
||||
if (util_parse_int (str_color, 10, &color)
|
||||
&& (color >= 0)
|
||||
&& (color < GUI_COLOR_NUM_COLORS))
|
||||
{
|
||||
|
||||
+5
-9
@@ -32,6 +32,7 @@
|
||||
#include "../core/core-hashtable.h"
|
||||
#include "../core/core-hook.h"
|
||||
#include "../core/core-string.h"
|
||||
#include "../core/core-util.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "gui-bar.h"
|
||||
#include "gui-bar-window.h"
|
||||
@@ -280,11 +281,10 @@ gui_focus_info_hashtable_gui_focus_info_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
struct t_hashtable *hashtable)
|
||||
{
|
||||
char *error;
|
||||
const char *ptr_value;
|
||||
int x, y;
|
||||
struct t_gui_focus_info *focus_info;
|
||||
struct t_hashtable *focus_hashtable, *ret_hashtable;
|
||||
const char *ptr_value;
|
||||
int x, y;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -298,17 +298,13 @@ gui_focus_info_hashtable_gui_focus_info_cb (const void *pointer, void *data,
|
||||
ptr_value = hashtable_get (hashtable, "x");
|
||||
if (!ptr_value)
|
||||
return NULL;
|
||||
error = NULL;
|
||||
x = (int)strtol (ptr_value, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!util_parse_int (ptr_value, 10, &x))
|
||||
return NULL;
|
||||
|
||||
ptr_value = hashtable_get (hashtable, "y");
|
||||
if (!ptr_value)
|
||||
return NULL;
|
||||
error = NULL;
|
||||
y = (int)strtol (ptr_value, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!util_parse_int (ptr_value, 10, &y))
|
||||
return NULL;
|
||||
|
||||
/* get focus info */
|
||||
|
||||
@@ -623,10 +623,8 @@ void
|
||||
gui_hotlist_clear_level_string (struct t_gui_buffer *buffer,
|
||||
const char *str_level_mask)
|
||||
{
|
||||
long level_mask;
|
||||
char *error;
|
||||
struct t_gui_hotlist *ptr_hotlist;
|
||||
int priority;
|
||||
int level_mask, priority;
|
||||
|
||||
if (str_level_mask)
|
||||
{
|
||||
@@ -665,11 +663,9 @@ gui_hotlist_clear_level_string (struct t_gui_buffer *buffer,
|
||||
else
|
||||
{
|
||||
/* clear hotlist using a mask of levels */
|
||||
error = NULL;
|
||||
level_mask = strtol (str_level_mask, &error, 10);
|
||||
if (error && !error[0] && (level_mask > 0))
|
||||
if (util_parse_int (str_level_mask, 10, &level_mask) && (level_mask > 0))
|
||||
{
|
||||
gui_hotlist_clear ((int)level_mask);
|
||||
gui_hotlist_clear (level_mask);
|
||||
gui_hotlist_initial_buffer = buffer;
|
||||
}
|
||||
}
|
||||
|
||||
+3
-5
@@ -44,6 +44,7 @@
|
||||
#include "../core/core-log.h"
|
||||
#include "../core/core-string.h"
|
||||
#include "../core/core-utf8.h"
|
||||
#include "../core/core-util.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "gui-key.h"
|
||||
#include "gui-bar.h"
|
||||
@@ -193,8 +194,7 @@ gui_key_get_current_context (void)
|
||||
void
|
||||
gui_key_grab_init (int grab_command, const char *delay)
|
||||
{
|
||||
long milliseconds;
|
||||
char *error;
|
||||
int milliseconds;
|
||||
|
||||
gui_key_grab = 1;
|
||||
gui_key_grab_count = 0;
|
||||
@@ -203,9 +203,7 @@ gui_key_grab_init (int grab_command, const char *delay)
|
||||
gui_key_grab_delay = CONFIG_INTEGER(config_look_key_grab_delay);
|
||||
if (delay != NULL)
|
||||
{
|
||||
error = NULL;
|
||||
milliseconds = strtol (delay, &error, 10);
|
||||
if (error && !error[0] && (milliseconds >= 0))
|
||||
if (util_parse_int (delay, 10, &milliseconds) && (milliseconds >= 0))
|
||||
{
|
||||
gui_key_grab_delay = milliseconds;
|
||||
if (gui_key_grab_delay == 0)
|
||||
|
||||
+24
-28
@@ -39,6 +39,7 @@
|
||||
#include "../core/core-infolist.h"
|
||||
#include "../core/core-log.h"
|
||||
#include "../core/core-string.h"
|
||||
#include "../core/core-util.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "gui-line.h"
|
||||
#include "gui-buffer.h"
|
||||
@@ -1674,10 +1675,10 @@ gui_line_hook_update (struct t_gui_line *line,
|
||||
const char *ptr_value, *ptr_value2;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
unsigned long value_pointer;
|
||||
long value;
|
||||
char *error, *new_message, *pos_newline;
|
||||
long long value_longlong;
|
||||
char *new_message, *pos_newline;
|
||||
int rc, tags_updated, notify_level_updated, highlight_updated;
|
||||
int max_notify_level;
|
||||
int max_notify_level, value;
|
||||
|
||||
tags_updated = 0;
|
||||
notify_level_updated = 0;
|
||||
@@ -1730,9 +1731,7 @@ gui_line_hook_update (struct t_gui_line *line,
|
||||
ptr_value = hashtable_get (hashtable2, "y");
|
||||
if (ptr_value)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value, &error, 10);
|
||||
if (error && !error[0] && (value >= 0))
|
||||
if (util_parse_int (ptr_value, 10, &value) && (value >= 0))
|
||||
line->data->y = value;
|
||||
}
|
||||
}
|
||||
@@ -1740,9 +1739,8 @@ gui_line_hook_update (struct t_gui_line *line,
|
||||
ptr_value2 = hashtable_get (hashtable2, "notify_level");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0] && (value >= -1) && (value <= GUI_HOTLIST_MAX))
|
||||
if (util_parse_int (ptr_value2, 10, &value)
|
||||
&& (value >= -1) && (value <= GUI_HOTLIST_MAX))
|
||||
{
|
||||
notify_level_updated = 1;
|
||||
line->data->notify_level = value;
|
||||
@@ -1752,9 +1750,7 @@ gui_line_hook_update (struct t_gui_line *line,
|
||||
ptr_value2 = hashtable_get (hashtable2, "highlight");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (ptr_value2, 10, &value))
|
||||
{
|
||||
highlight_updated = 1;
|
||||
line->data->highlight = (value) ? 1 : 0;
|
||||
@@ -1764,11 +1760,10 @@ gui_line_hook_update (struct t_gui_line *line,
|
||||
ptr_value2 = hashtable_get (hashtable2, "date");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0] && (value >= 0))
|
||||
if (util_parse_longlong (ptr_value2, 10, &value_longlong)
|
||||
&& (value_longlong >= 0))
|
||||
{
|
||||
line->data->date = (time_t)value;
|
||||
line->data->date = (time_t)value_longlong;
|
||||
free (line->data->str_time);
|
||||
line->data->str_time = gui_chat_get_time_string (
|
||||
line->data->date,
|
||||
@@ -1780,11 +1775,10 @@ gui_line_hook_update (struct t_gui_line *line,
|
||||
ptr_value2 = hashtable_get (hashtable2, "date_usec");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0] && (value >= 0) && (value <= 999999))
|
||||
if (util_parse_int (ptr_value2, 10, &value)
|
||||
&& (value >= 0) && (value <= 999999))
|
||||
{
|
||||
line->data->date_usec = (int)value;
|
||||
line->data->date_usec = value;
|
||||
free (line->data->str_time);
|
||||
line->data->str_time = gui_chat_get_time_string (
|
||||
line->data->date,
|
||||
@@ -1796,19 +1790,21 @@ gui_line_hook_update (struct t_gui_line *line,
|
||||
ptr_value2 = hashtable_get (hashtable2, "date_printed");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0] && (value >= 0))
|
||||
line->data->date_printed = (time_t)value;
|
||||
if (util_parse_longlong (ptr_value2, 10, &value_longlong)
|
||||
&& (value_longlong >= 0))
|
||||
{
|
||||
line->data->date_printed = (time_t)value_longlong;
|
||||
}
|
||||
}
|
||||
|
||||
ptr_value2 = hashtable_get (hashtable2, "date_usec_printed");
|
||||
if (ptr_value2)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (ptr_value2, &error, 10);
|
||||
if (error && !error[0] && (value >= 0) && (value <= 999999))
|
||||
line->data->date_usec_printed = (int)value;
|
||||
if (util_parse_int (ptr_value2, 10, &value)
|
||||
&& (value >= 0) && (value <= 999999))
|
||||
{
|
||||
line->data->date_usec_printed = value;
|
||||
}
|
||||
}
|
||||
|
||||
ptr_value = hashtable_get (hashtable, "str_time");
|
||||
|
||||
+9
-22
@@ -44,6 +44,7 @@
|
||||
#include "../core/core-log.h"
|
||||
#include "../core/core-string.h"
|
||||
#include "../core/core-utf8.h"
|
||||
#include "../core/core-util.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "gui-nicklist.h"
|
||||
#include "gui-buffer.h"
|
||||
@@ -275,7 +276,6 @@ gui_nicklist_search_group (struct t_gui_buffer *buffer,
|
||||
const char *name)
|
||||
{
|
||||
const char *ptr_name;
|
||||
char *error;
|
||||
long long id;
|
||||
|
||||
if ((!buffer && !from_group)
|
||||
@@ -287,8 +287,7 @@ gui_nicklist_search_group (struct t_gui_buffer *buffer,
|
||||
|
||||
if (strncmp (name, "==id:", 5) == 0)
|
||||
{
|
||||
id = strtoll (name + 5, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_longlong (name + 5, 10, &id))
|
||||
return gui_nicklist_search_group_id (buffer, from_group, id);
|
||||
}
|
||||
|
||||
@@ -570,7 +569,6 @@ gui_nicklist_search_nick (struct t_gui_buffer *buffer,
|
||||
const char *name)
|
||||
{
|
||||
long long id;
|
||||
char *error;
|
||||
|
||||
if ((!buffer && !from_group)
|
||||
|| !name
|
||||
@@ -581,8 +579,7 @@ gui_nicklist_search_nick (struct t_gui_buffer *buffer,
|
||||
|
||||
if (strncmp (name, "==id:", 5) == 0)
|
||||
{
|
||||
id = strtoll (name + 5, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_longlong (name + 5, 10, &id))
|
||||
return gui_nicklist_search_nick_id (buffer, from_group, id);
|
||||
}
|
||||
|
||||
@@ -1036,9 +1033,7 @@ gui_nicklist_group_set (struct t_gui_buffer *buffer,
|
||||
const char *property, const char *value)
|
||||
{
|
||||
long long id;
|
||||
long number;
|
||||
char *error;
|
||||
int group_changed;
|
||||
int group_changed, number;
|
||||
|
||||
if (!buffer || !group || !property || !value)
|
||||
return;
|
||||
@@ -1047,8 +1042,7 @@ gui_nicklist_group_set (struct t_gui_buffer *buffer,
|
||||
|
||||
if (strcmp (property, "id") == 0)
|
||||
{
|
||||
id = strtoll (value, &error, 10);
|
||||
if (error && !error[0]
|
||||
if (util_parse_longlong (value, 10, &id)
|
||||
&& (id != group->id)
|
||||
&& !gui_nicklist_search_group_id (buffer, NULL, id))
|
||||
{
|
||||
@@ -1064,9 +1058,7 @@ gui_nicklist_group_set (struct t_gui_buffer *buffer,
|
||||
}
|
||||
else if (strcmp (property, "visible") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
group->visible = (number) ? 1 : 0;
|
||||
group_changed = 1;
|
||||
}
|
||||
@@ -1158,9 +1150,7 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer,
|
||||
const char *property, const char *value)
|
||||
{
|
||||
long long id;
|
||||
long number;
|
||||
char *error;
|
||||
int nick_changed;
|
||||
int nick_changed, number;
|
||||
|
||||
if (!buffer || !nick || !property || !value)
|
||||
return;
|
||||
@@ -1169,8 +1159,7 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer,
|
||||
|
||||
if (strcmp (property, "id") == 0)
|
||||
{
|
||||
id = strtoll (value, &error, 10);
|
||||
if (error && !error[0]
|
||||
if (util_parse_longlong (value, 10, &id)
|
||||
&& (id != nick->id)
|
||||
&& !gui_nicklist_search_nick_id (buffer, NULL, id))
|
||||
{
|
||||
@@ -1198,9 +1187,7 @@ gui_nicklist_nick_set (struct t_gui_buffer *buffer,
|
||||
}
|
||||
else if (strcmp (property, "visible") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (value, 10, &number))
|
||||
nick->visible = (number) ? 1 : 0;
|
||||
nick_changed = 1;
|
||||
}
|
||||
|
||||
+6
-10
@@ -43,6 +43,7 @@
|
||||
#include "../core/core-log.h"
|
||||
#include "../core/core-string.h"
|
||||
#include "../core/core-utf8.h"
|
||||
#include "../core/core-util.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "gui-window.h"
|
||||
#include "gui-bar.h"
|
||||
@@ -1182,7 +1183,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
|
||||
int direction, stop, count_msg, scroll_from_end_free_buffer;
|
||||
char time_letter, saved_char;
|
||||
time_t old_date, diff_date;
|
||||
char *pos, *error;
|
||||
char *pos;
|
||||
long number;
|
||||
struct t_gui_line *ptr_line;
|
||||
struct tm *date_tmp, line_date, old_line_date;
|
||||
@@ -1231,9 +1232,7 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
|
||||
time_letter = pos[0];
|
||||
saved_char = pos[0];
|
||||
pos[0] = '\0';
|
||||
error = NULL;
|
||||
number = strtol (scroll, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!util_parse_long (scroll, 10, &number))
|
||||
number = 0;
|
||||
pos[0] = saved_char;
|
||||
}
|
||||
@@ -1430,9 +1429,8 @@ gui_window_scroll (struct t_gui_window *window, char *scroll)
|
||||
void
|
||||
gui_window_scroll_horiz (struct t_gui_window *window, char *scroll)
|
||||
{
|
||||
int direction, percentage, start_col;
|
||||
char saved_char, *pos, *error;
|
||||
long number;
|
||||
int direction, percentage, start_col, number;
|
||||
char saved_char, *pos;
|
||||
|
||||
if (!window || !window->buffer->lines->first_line)
|
||||
return;
|
||||
@@ -1464,9 +1462,7 @@ gui_window_scroll_horiz (struct t_gui_window *window, char *scroll)
|
||||
percentage = (pos[0] == '%') ? 1 : 0;
|
||||
saved_char = pos[0];
|
||||
pos[0] = '\0';
|
||||
error = NULL;
|
||||
number = strtol (scroll, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!util_parse_int (scroll, 10, &number))
|
||||
number = 0;
|
||||
pos[0] = saved_char;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,8 @@ struct t_hashtable *
|
||||
buflist_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
|
||||
{
|
||||
const char *ptr_bar_item_name, *ptr_bar_item_line, *keys, *ptr_value;
|
||||
long item_line;
|
||||
char *error, str_value[128], **list_keys;
|
||||
int i, item_index, num_keys, type;
|
||||
char str_value[128], **list_keys;
|
||||
int i, item_index, item_line, num_keys, type;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -64,15 +63,10 @@ buflist_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
|
||||
ptr_bar_item_line = weechat_hashtable_get (info, "_bar_item_line");
|
||||
if (!ptr_bar_item_line)
|
||||
goto end;
|
||||
error = NULL;
|
||||
item_line = strtol (ptr_bar_item_line, &error, 10);
|
||||
if (!error || error[0])
|
||||
goto end;
|
||||
if ((item_line < 0)
|
||||
if (!weechat_util_parse_int (ptr_bar_item_line, 10, &item_line)
|
||||
|| (item_line < 0)
|
||||
|| (item_line >= weechat_arraylist_size (buflist_list_buffers[item_index])))
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
/* check if buffer pointer is still valid */
|
||||
ptr_buffer = weechat_arraylist_get (buflist_list_buffers[item_index],
|
||||
@@ -333,10 +327,9 @@ buflist_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
const char *ptr_key, *ptr_pointer, *ptr_number, *ptr_number2;
|
||||
const char *ptr_full_name;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
char *error, str_command[1024];
|
||||
long number, number2;
|
||||
char str_command[1024];
|
||||
unsigned long value;
|
||||
int rc, current_buffer_number;
|
||||
int rc, current_buffer_number, number, number2;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -360,13 +353,9 @@ buflist_hsignal_cb (const void *pointer, void *data, const char *signal,
|
||||
return WEECHAT_RC_OK;
|
||||
ptr_buffer = (struct t_gui_buffer *)value;
|
||||
|
||||
error = NULL;
|
||||
number = strtol (ptr_number, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (ptr_number, 10, &number))
|
||||
return WEECHAT_RC_OK;
|
||||
error = NULL;
|
||||
number2 = strtol (ptr_number2, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (ptr_number2, 10, &number2))
|
||||
return WEECHAT_RC_OK;
|
||||
|
||||
current_buffer_number = weechat_buffer_get_integer (
|
||||
|
||||
@@ -185,8 +185,7 @@ exec_command_parse_options (struct t_exec_cmd_options *cmd_options,
|
||||
int argc, char **argv, int start_arg,
|
||||
int set_command_index)
|
||||
{
|
||||
int i, j, end, length, length_total;
|
||||
char *error;
|
||||
int i, j, end, length, length_total, timeout;
|
||||
|
||||
for (i = start_arg; i < argc; i++)
|
||||
{
|
||||
@@ -318,10 +317,9 @@ exec_command_parse_options (struct t_exec_cmd_options *cmd_options,
|
||||
if (i + 1 >= argc)
|
||||
return 0;
|
||||
i++;
|
||||
error = NULL;
|
||||
cmd_options->timeout = strtol (argv[i], &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (argv[i], 10, &timeout))
|
||||
return 0;
|
||||
cmd_options->timeout = timeout;
|
||||
}
|
||||
else if (weechat_strcmp (argv[i], "-name") == 0)
|
||||
{
|
||||
|
||||
@@ -85,15 +85,12 @@ struct t_exec_cmd *
|
||||
exec_search_by_id (const char *id)
|
||||
{
|
||||
struct t_exec_cmd* ptr_exec_cmd;
|
||||
char *error;
|
||||
long number;
|
||||
|
||||
if (!id)
|
||||
return NULL;
|
||||
|
||||
error = NULL;
|
||||
number = strtol (id, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_long (id, 10, &number))
|
||||
number = -1;
|
||||
|
||||
for (ptr_exec_cmd = exec_cmds; ptr_exec_cmd;
|
||||
|
||||
@@ -60,15 +60,12 @@ int
|
||||
fset_command_get_int_arg (int argc, char **argv, int arg_number,
|
||||
int default_value)
|
||||
{
|
||||
long value;
|
||||
char *error;
|
||||
int value;
|
||||
|
||||
value = default_value;
|
||||
if (argc > arg_number)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (argv[arg_number], &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (argv[arg_number], 10, &value))
|
||||
value = default_value;
|
||||
}
|
||||
return (int)value;
|
||||
|
||||
@@ -42,11 +42,10 @@ struct t_hashtable *
|
||||
fset_mouse_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
|
||||
{
|
||||
const char *buffer;
|
||||
int rc, format_number;
|
||||
int rc, format_number, y, option_index;
|
||||
unsigned long value;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
long y, option_index;
|
||||
char *error, str_value[128];
|
||||
char str_value[128];
|
||||
struct t_fset_option *ptr_fset_option;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -69,13 +68,11 @@ fset_mouse_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
|
||||
if (!ptr_buffer || (ptr_buffer != fset_buffer))
|
||||
return info;
|
||||
|
||||
error = NULL;
|
||||
y = strtol (weechat_hashtable_get (info, "_chat_line_y"), &error, 10);
|
||||
if (!error || error[0])
|
||||
return info;
|
||||
|
||||
if (y < 0)
|
||||
if (!weechat_util_parse_int (weechat_hashtable_get (info, "_chat_line_y"), 10, &y)
|
||||
|| (y < 0))
|
||||
{
|
||||
return info;
|
||||
}
|
||||
|
||||
format_number = weechat_config_integer (fset_config_look_format_number);
|
||||
option_index = y / fset_config_format_option_num_lines[format_number - 1];
|
||||
@@ -87,7 +84,7 @@ fset_mouse_focus_cb (const void *pointer, void *data, struct t_hashtable *info)
|
||||
snprintf (str_value, sizeof (str_value),
|
||||
"0x%lx", (unsigned long)ptr_fset_option);
|
||||
weechat_hashtable_set (info, "fset_option", str_value);
|
||||
snprintf (str_value, sizeof (str_value), "%ld", option_index);
|
||||
snprintf (str_value, sizeof (str_value), "%d", option_index);
|
||||
weechat_hashtable_set (info, "fset_option_index", str_value);
|
||||
weechat_hashtable_set (info, "fset_option_name", ptr_fset_option->name);
|
||||
weechat_hashtable_set (info, "fset_option_parent_name", ptr_fset_option->parent_name);
|
||||
@@ -137,15 +134,12 @@ fset_mouse_get_hashtable_int (struct t_hashtable *hashtable,
|
||||
int default_value)
|
||||
{
|
||||
const char *ptr_value;
|
||||
char *error;
|
||||
int value;
|
||||
|
||||
ptr_value = weechat_hashtable_get (hashtable, variable);
|
||||
if (!ptr_value)
|
||||
return default_value;
|
||||
error = NULL;
|
||||
value = (int)strtol (ptr_value, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (ptr_value, 10, &value))
|
||||
return default_value;
|
||||
|
||||
return value;
|
||||
|
||||
+15
-28
@@ -96,8 +96,8 @@ char *irc_color_string_decoded[32];
|
||||
int
|
||||
irc_color_convert_rgb2term (long rgb)
|
||||
{
|
||||
char str_color[64], *info_color, *error;
|
||||
long number;
|
||||
char str_color[64], *info_color;
|
||||
int number;
|
||||
|
||||
if (rgb < 0)
|
||||
return -1;
|
||||
@@ -111,9 +111,7 @@ irc_color_convert_rgb2term (long rgb)
|
||||
return -1;
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
number = strtol (info_color, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (info_color, 10, &number))
|
||||
{
|
||||
free (info_color);
|
||||
return -1;
|
||||
@@ -121,7 +119,7 @@ irc_color_convert_rgb2term (long rgb)
|
||||
|
||||
free (info_color);
|
||||
|
||||
return (int)number;
|
||||
return number;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -133,8 +131,8 @@ irc_color_convert_rgb2term (long rgb)
|
||||
int
|
||||
irc_color_convert_rgb2irc (long rgb)
|
||||
{
|
||||
char str_color[64], *error, *info_color;
|
||||
long number;
|
||||
char str_color[64], *info_color;
|
||||
int number;
|
||||
|
||||
if (rgb < 0)
|
||||
return -1;
|
||||
@@ -151,9 +149,7 @@ irc_color_convert_rgb2irc (long rgb)
|
||||
return -1;
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
number = strtol (info_color, &error, 10);
|
||||
if (!error || error[0]
|
||||
if (!weechat_util_parse_int (info_color, 10, &number)
|
||||
|| (number < 0) || (number >= IRC_COLOR_TERM2IRC_NUM_COLORS))
|
||||
{
|
||||
free (info_color);
|
||||
@@ -174,7 +170,7 @@ irc_color_convert_rgb2irc (long rgb)
|
||||
int
|
||||
irc_color_convert_term2irc (int color)
|
||||
{
|
||||
char str_color[64], *error, *info_color;
|
||||
char str_color[64], *info_color;
|
||||
long number;
|
||||
|
||||
snprintf (str_color, sizeof (str_color), "%d", color);
|
||||
@@ -186,9 +182,8 @@ irc_color_convert_term2irc (int color)
|
||||
return -1;
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
number = strtol (info_color, &error, 10);
|
||||
if (!error || error[0] || (number < 0) || (number > 0xFFFFFF))
|
||||
if (!weechat_util_parse_long (info_color, 10, &number)
|
||||
|| (number < 0) || (number > 0xFFFFFF))
|
||||
{
|
||||
free (info_color);
|
||||
return -1;
|
||||
@@ -211,7 +206,7 @@ irc_color_convert_term2irc (int color)
|
||||
char *
|
||||
irc_color_decode (const char *string, int keep_colors)
|
||||
{
|
||||
char **out, *error;
|
||||
char **out;
|
||||
char str_fg[16], str_bg[16], str_color[128], str_key[128], str_to_add[128];
|
||||
const char *remapped_color;
|
||||
unsigned char *ptr_string;
|
||||
@@ -337,18 +332,14 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
bg = -1;
|
||||
if (str_fg[0])
|
||||
{
|
||||
error = NULL;
|
||||
fg = (int)strtol (str_fg, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (str_fg, 10, &fg))
|
||||
fg %= IRC_NUM_COLORS;
|
||||
else
|
||||
fg = -1;
|
||||
}
|
||||
if (str_bg[0])
|
||||
{
|
||||
error = NULL;
|
||||
bg = (int)strtol (str_bg, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (str_bg, 10, &bg))
|
||||
bg %= IRC_NUM_COLORS;
|
||||
else
|
||||
bg = -1;
|
||||
@@ -422,16 +413,12 @@ irc_color_decode (const char *string, int keep_colors)
|
||||
bg_rgb = -1;
|
||||
if (str_fg[0])
|
||||
{
|
||||
error = NULL;
|
||||
fg_rgb = strtol (str_fg, &error, 16);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_long (str_fg, 16, &fg_rgb))
|
||||
fg_rgb = -1;
|
||||
}
|
||||
if (str_bg[0])
|
||||
{
|
||||
error = NULL;
|
||||
bg_rgb = strtol (str_bg, &error, 16);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_long (str_bg, 16, &bg_rgb))
|
||||
bg_rgb = -1;
|
||||
}
|
||||
str_fg[0] = '\0';
|
||||
|
||||
@@ -232,9 +232,8 @@ irc_command_mode_nicks (struct t_irc_server *server,
|
||||
char **
|
||||
irc_command_mode_masks_convert_ranges (char **argv, int arg_start)
|
||||
{
|
||||
char **str_masks, **masks, *error1, *error2, *pos, str_number[32];
|
||||
int i, length, added;
|
||||
long j, number1, number2;
|
||||
char **str_masks, **masks, *pos, str_number[32];
|
||||
int i, j, length, added, number1, number2;
|
||||
|
||||
if (!argv || (arg_start < 0))
|
||||
return NULL;
|
||||
@@ -255,12 +254,8 @@ irc_command_mode_masks_convert_ranges (char **argv, int arg_start)
|
||||
&& (argv[i][length - 1] != '-'))
|
||||
{
|
||||
pos[0] = '\0';
|
||||
error1 = NULL;
|
||||
number1 = strtol (argv[i], &error1, 10);
|
||||
error2 = NULL;
|
||||
number2 = strtol (pos + 1, &error2, 10);
|
||||
if (error1 && !error1[0]
|
||||
&& error2 && !error2[0]
|
||||
if (weechat_util_parse_int (argv[i], 10, &number1)
|
||||
&& weechat_util_parse_int (pos + 1, 10, &number2)
|
||||
&& (number1 > 0) && (number1 < 128)
|
||||
&& (number2 > 0) && (number2 < 128)
|
||||
&& (number1 < number2))
|
||||
@@ -269,8 +264,7 @@ irc_command_mode_masks_convert_ranges (char **argv, int arg_start)
|
||||
{
|
||||
if ((*str_masks)[0])
|
||||
weechat_string_dyn_concat (str_masks, " ", -1);
|
||||
snprintf (str_number, sizeof (str_number),
|
||||
"%ld", j);
|
||||
snprintf (str_number, sizeof (str_number), "%d", j);
|
||||
weechat_string_dyn_concat (str_masks, str_number, -1);
|
||||
}
|
||||
added = 1;
|
||||
@@ -312,14 +306,12 @@ irc_command_mode_masks (struct t_irc_server *server,
|
||||
const char *set, const char *mode,
|
||||
char **argv, int pos_masks)
|
||||
{
|
||||
int max_modes, modes_added, msg_priority;
|
||||
int max_modes, modes_added, msg_priority, number;
|
||||
char **modes, **masks, *mask;
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
struct t_irc_modelist *ptr_modelist;
|
||||
struct t_irc_modelist_item *ptr_item;
|
||||
long number;
|
||||
char *error;
|
||||
|
||||
if (irc_mode_get_chanmode_type (server, mode[0]) != 'A')
|
||||
{
|
||||
@@ -367,9 +359,7 @@ irc_command_mode_masks (struct t_irc_server *server,
|
||||
/* use modelist item for number arguments */
|
||||
if (ptr_modelist && (set[0] == '-'))
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (argv[pos_masks], &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (argv[pos_masks], 10, &number))
|
||||
{
|
||||
ptr_item = irc_modelist_item_search_number (ptr_modelist,
|
||||
number - 1);
|
||||
@@ -2622,9 +2612,8 @@ irc_command_ignore_display (struct t_irc_ignore *ignore)
|
||||
IRC_COMMAND_CALLBACK(ignore)
|
||||
{
|
||||
struct t_irc_ignore *ptr_ignore;
|
||||
char *mask, *regex, *regex2, *ptr_regex, *pos, *server, *channel, *error;
|
||||
int length, update;
|
||||
long number;
|
||||
char *mask, *regex, *regex2, *ptr_regex, *pos, *server, *channel;
|
||||
int length, number, update;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -2767,9 +2756,7 @@ IRC_COMMAND_CALLBACK(ignore)
|
||||
}
|
||||
else
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (argv[2], &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (argv[2], 10, &number))
|
||||
{
|
||||
ptr_ignore = irc_ignore_search_by_number (number);
|
||||
if (ptr_ignore)
|
||||
@@ -3430,18 +3417,15 @@ int
|
||||
irc_command_list_get_int_arg (int argc, char **argv, int arg_number,
|
||||
int default_value)
|
||||
{
|
||||
long value;
|
||||
char *error;
|
||||
int value;
|
||||
|
||||
value = default_value;
|
||||
if (argc > arg_number)
|
||||
{
|
||||
error = NULL;
|
||||
value = strtol (argv[arg_number], &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (argv[arg_number], 10, &value))
|
||||
value = default_value;
|
||||
}
|
||||
return (int)value;
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1288,10 +1288,8 @@ irc_config_server_check_value_cb (const void *pointer, void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value)
|
||||
{
|
||||
int index_option, proxy_found;
|
||||
int index_option, number, proxy_found;
|
||||
const char *pos_error, *proxy_name;
|
||||
char *error;
|
||||
long number;
|
||||
struct t_infolist *infolist;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -1364,9 +1362,7 @@ irc_config_server_check_value_cb (const void *pointer, void *data,
|
||||
case IRC_SERVER_OPTION_SPLIT_MSG_MAX_LENGTH:
|
||||
if (!value || !value[0])
|
||||
break;
|
||||
error = NULL;
|
||||
number = strtol (value, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (value, 10, &number))
|
||||
{
|
||||
/*
|
||||
* not a valid number, but we return 1 (OK) to let WeeChat
|
||||
|
||||
@@ -985,9 +985,8 @@ irc_info_infolist_irc_modelist_item_cb (const void *pointer, void *data,
|
||||
struct t_irc_channel *ptr_channel;
|
||||
struct t_irc_modelist *ptr_modelist;
|
||||
struct t_irc_modelist_item *ptr_item;
|
||||
char **argv, *error;
|
||||
int argc;
|
||||
long number;
|
||||
char **argv;
|
||||
int argc, number;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -1029,15 +1028,12 @@ irc_info_infolist_irc_modelist_item_cb (const void *pointer, void *data,
|
||||
}
|
||||
if (!obj_pointer && (argc >= 4))
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (argv[3], &error, 10);
|
||||
if (!error || error[0] || (number < 0))
|
||||
if (!weechat_util_parse_int (argv[3], 10, &number) || (number < 0))
|
||||
{
|
||||
weechat_string_free_split (argv);
|
||||
return NULL;
|
||||
}
|
||||
obj_pointer = irc_modelist_item_search_number (ptr_modelist,
|
||||
(int)number);
|
||||
obj_pointer = irc_modelist_item_search_number (ptr_modelist, number);
|
||||
if (!obj_pointer)
|
||||
{
|
||||
weechat_string_free_split (argv);
|
||||
|
||||
+13
-18
@@ -234,9 +234,8 @@ int
|
||||
irc_list_channel_match_filter (struct t_irc_server *server,
|
||||
struct t_irc_list_channel *channel)
|
||||
{
|
||||
char *error, *result;
|
||||
long number;
|
||||
int match;
|
||||
char *result;
|
||||
int match, number;
|
||||
|
||||
/* no filter? then any channel is matching */
|
||||
if (!server->list->filter)
|
||||
@@ -280,25 +279,22 @@ irc_list_channel_match_filter (struct t_irc_server *server,
|
||||
else if (strncmp (server->list->filter, "u:>", 3) == 0)
|
||||
{
|
||||
/* filter by users (> N)*/
|
||||
error = NULL;
|
||||
number = strtol (server->list->filter + 3, &error, 10);
|
||||
if (error && !error[0] && channel->users > (int)number)
|
||||
if (weechat_util_parse_int (server->list->filter + 3, 10, &number)
|
||||
&& (channel->users > number))
|
||||
return 1;
|
||||
}
|
||||
else if (strncmp (server->list->filter, "u:<", 3) == 0)
|
||||
{
|
||||
/* filter by users (< N)*/
|
||||
error = NULL;
|
||||
number = strtol (server->list->filter + 3, &error, 10);
|
||||
if (error && !error[0] && channel->users < (int)number)
|
||||
if (weechat_util_parse_int (server->list->filter + 3, 10, &number)
|
||||
&& (channel->users < number))
|
||||
return 1;
|
||||
}
|
||||
else if (strncmp (server->list->filter, "u:", 2) == 0)
|
||||
{
|
||||
/* filter by users */
|
||||
error = NULL;
|
||||
number = strtol (server->list->filter + 2, &error, 10);
|
||||
if (error && !error[0] && channel->users >= (int)number)
|
||||
if (weechat_util_parse_int (server->list->filter + 2, 10, &number)
|
||||
&& (channel->users >= number))
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
@@ -375,10 +371,9 @@ int
|
||||
irc_list_parse_messages (struct t_irc_server *server, const char *output)
|
||||
{
|
||||
struct t_irc_list_channel *channel;
|
||||
char **irc_msgs, *command, **params, *error;
|
||||
char **irc_msgs, *command, **params;
|
||||
const char *ptr_name;
|
||||
int i, count_irc_msgs, num_params, length, keep_colors;
|
||||
long number;
|
||||
int i, count_irc_msgs, num_params, length, keep_colors, number;
|
||||
|
||||
if (server->list->channels)
|
||||
{
|
||||
@@ -439,9 +434,9 @@ irc_list_parse_messages (struct t_irc_server *server, const char *output)
|
||||
ptr_name++;
|
||||
}
|
||||
channel->name2 = strdup (ptr_name);
|
||||
error = NULL;
|
||||
number = strtol (params[2], &error, 10);
|
||||
channel->users = (error && !error[0]) ? number : 0;
|
||||
if (!weechat_util_parse_int (params[2], 10, &number))
|
||||
number = 0;
|
||||
channel->users = number;
|
||||
channel->topic = (num_params > 3) ?
|
||||
irc_color_decode (params[3], keep_colors) : NULL;
|
||||
length = weechat_utf8_strlen_screen (channel->name);
|
||||
|
||||
@@ -598,8 +598,7 @@ irc_message_parse_cap_multiline_value (struct t_irc_server *server,
|
||||
{
|
||||
struct t_hashtable *values;
|
||||
const char *ptr_value;
|
||||
char *error;
|
||||
long number;
|
||||
int number;
|
||||
|
||||
if (!server)
|
||||
return;
|
||||
@@ -617,18 +616,14 @@ irc_message_parse_cap_multiline_value (struct t_irc_server *server,
|
||||
ptr_value = (const char *)weechat_hashtable_get (values, "max-bytes");
|
||||
if (ptr_value)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (ptr_value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (ptr_value, 10, &number))
|
||||
server->multiline_max_bytes = number;
|
||||
}
|
||||
|
||||
ptr_value = (const char *)weechat_hashtable_get (values, "max-lines");
|
||||
if (ptr_value)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (ptr_value, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (ptr_value, 10, &number))
|
||||
server->multiline_max_lines = number;
|
||||
}
|
||||
|
||||
|
||||
@@ -4061,9 +4061,8 @@ IRC_PROTOCOL_CALLBACK(001)
|
||||
|
||||
IRC_PROTOCOL_CALLBACK(005)
|
||||
{
|
||||
char *str_info, *error, *isupport2;
|
||||
int i, arg_last, length_isupport, length, casemapping, utf8mapping;
|
||||
long value;
|
||||
char *str_info, *isupport2;
|
||||
int i, arg_last, length_isupport, length, casemapping, utf8mapping, value;
|
||||
|
||||
IRC_PROTOCOL_MIN_PARAMS(2);
|
||||
|
||||
@@ -4081,34 +4080,26 @@ IRC_PROTOCOL_CALLBACK(005)
|
||||
else if (strncmp (ctxt->params[i], "LINELEN=", 8) == 0)
|
||||
{
|
||||
/* save max message length */
|
||||
error = NULL;
|
||||
value = strtol (ctxt->params[i] + 8, &error, 10);
|
||||
if (error && !error[0] && (value > 0))
|
||||
ctxt->server->msg_max_length = (int)value;
|
||||
if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
|
||||
ctxt->server->msg_max_length = value;
|
||||
}
|
||||
else if (strncmp (ctxt->params[i], "NICKLEN=", 8) == 0)
|
||||
{
|
||||
/* save max nick length */
|
||||
error = NULL;
|
||||
value = strtol (ctxt->params[i] + 8, &error, 10);
|
||||
if (error && !error[0] && (value > 0))
|
||||
ctxt->server->nick_max_length = (int)value;
|
||||
if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
|
||||
ctxt->server->nick_max_length = value;
|
||||
}
|
||||
else if (strncmp (ctxt->params[i], "USERLEN=", 8) == 0)
|
||||
{
|
||||
/* save max user length */
|
||||
error = NULL;
|
||||
value = strtol (ctxt->params[i] + 8, &error, 10);
|
||||
if (error && !error[0] && (value > 0))
|
||||
ctxt->server->user_max_length = (int)value;
|
||||
if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
|
||||
ctxt->server->user_max_length = value;
|
||||
}
|
||||
else if (strncmp (ctxt->params[i], "HOSTLEN=", 8) == 0)
|
||||
{
|
||||
/* save max host length */
|
||||
error = NULL;
|
||||
value = strtol (ctxt->params[i] + 8, &error, 10);
|
||||
if (error && !error[0] && (value > 0))
|
||||
ctxt->server->host_max_length = (int)value;
|
||||
if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
|
||||
ctxt->server->host_max_length = value;
|
||||
}
|
||||
else if (strncmp (ctxt->params[i], "CASEMAPPING=", 12) == 0)
|
||||
{
|
||||
@@ -4144,10 +4135,8 @@ IRC_PROTOCOL_CALLBACK(005)
|
||||
else if (strncmp (ctxt->params[i], "MONITOR=", 8) == 0)
|
||||
{
|
||||
/* save monitor (limit) */
|
||||
error = NULL;
|
||||
value = strtol (ctxt->params[i] + 8, &error, 10);
|
||||
if (error && !error[0] && (value > 0))
|
||||
ctxt->server->monitor = (int)value;
|
||||
if (weechat_util_parse_int (ctxt->params[i] + 8, 10, &value) && (value > 0))
|
||||
ctxt->server->monitor = value;
|
||||
}
|
||||
else if (strncmp (ctxt->params[i], "CLIENTTAGDENY=", 14) == 0)
|
||||
{
|
||||
|
||||
@@ -404,9 +404,8 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
const char *cmd_filter)
|
||||
{
|
||||
struct t_irc_redirect *new_redirect;
|
||||
char **items[4], *item_upper, *pos, *error;
|
||||
int i, j, num_items[4];
|
||||
long value;
|
||||
char **items[4], *item_upper, *pos;
|
||||
int i, j, num_items[4], value;
|
||||
struct t_hashtable *hash_cmd[4];
|
||||
|
||||
new_redirect = malloc (sizeof (*new_redirect));
|
||||
@@ -460,9 +459,7 @@ irc_redirect_new_with_commands (struct t_irc_server *server,
|
||||
if (pos)
|
||||
{
|
||||
pos[0] = '\0';
|
||||
error = NULL;
|
||||
value = strtol (pos + 1, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (pos + 1, 10, &value))
|
||||
value = -1;
|
||||
}
|
||||
item_upper = weechat_string_toupper (items[i][j]);
|
||||
@@ -1257,7 +1254,6 @@ irc_redirect_pattern_hsignal_cb (const void *pointer, void *data,
|
||||
struct t_hashtable *hashtable)
|
||||
{
|
||||
const char *pattern, *str_timeout, *cmd_start, *cmd_stop, *cmd_extra;
|
||||
char *error;
|
||||
int number, timeout;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -1295,9 +1291,7 @@ irc_redirect_pattern_hsignal_cb (const void *pointer, void *data,
|
||||
timeout = 0;
|
||||
if (str_timeout && str_timeout[0])
|
||||
{
|
||||
error = NULL;
|
||||
number = (int)strtol (str_timeout, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (str_timeout, 10, &number))
|
||||
timeout = number;
|
||||
}
|
||||
|
||||
@@ -1325,7 +1319,6 @@ irc_redirect_command_hsignal_cb (const void *pointer, void *data,
|
||||
{
|
||||
const char *server, *pattern, *redirect_signal, *str_count, *string;
|
||||
const char *str_timeout, *cmd_filter;
|
||||
char *error;
|
||||
struct t_irc_server *ptr_server;
|
||||
int number, count, timeout;
|
||||
|
||||
@@ -1366,18 +1359,14 @@ irc_redirect_command_hsignal_cb (const void *pointer, void *data,
|
||||
count = 1;
|
||||
if (str_count && str_count[0])
|
||||
{
|
||||
error = NULL;
|
||||
number = (int)strtol (str_count, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (str_count, 10, &number))
|
||||
count = number;
|
||||
}
|
||||
|
||||
timeout = 0;
|
||||
if (str_timeout && str_timeout[0])
|
||||
{
|
||||
error = NULL;
|
||||
number = (int)strtol (str_timeout, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (str_timeout, 10, &number))
|
||||
timeout = number;
|
||||
}
|
||||
|
||||
|
||||
@@ -109,7 +109,7 @@ irc_sasl_mechanism_scram (struct t_irc_server *server,
|
||||
const char *sasl_password,
|
||||
char **sasl_error)
|
||||
{
|
||||
char *answer_base64, *string, *username, *username2, *data, **attrs, *error;
|
||||
char *answer_base64, *string, *username, *username2, *data, **attrs;
|
||||
char nonce_client[18], nonce_client_base64[24 + 1], *nonce_server;
|
||||
char *salt_base64, *salt, *verifier_base64, *verifier, *attr_error;
|
||||
char *auth_no_proof, *auth_message;
|
||||
@@ -117,10 +117,10 @@ irc_sasl_mechanism_scram (struct t_irc_server *server,
|
||||
char client_signature[512 / 8], client_proof[512 / 8];
|
||||
char client_proof_base64[((512 / 8) * 4) + 1], server_key[512 / 8];
|
||||
char server_signature[512 / 8];
|
||||
int i, rc, length, num_attrs, iterations, salt_size, salted_password_size;
|
||||
int i, rc, length, num_attrs, iterations, number;
|
||||
int salt_size, salted_password_size;
|
||||
int client_key_size, stored_key_size, client_signature_size;
|
||||
int server_key_size, server_signature_size, verifier_size;
|
||||
long number;
|
||||
|
||||
if (!server || !hash_algo || !data_base64 || !sasl_username
|
||||
|| !sasl_password)
|
||||
@@ -202,10 +202,8 @@ irc_sasl_mechanism_scram (struct t_irc_server *server,
|
||||
}
|
||||
else if (strncmp (attrs[i], "i=", 2) == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (attrs[i] + 2, &error, 10);
|
||||
if (error && !error[0])
|
||||
iterations = (int)number;
|
||||
if (weechat_util_parse_int (attrs[i] + 2, 10, &number))
|
||||
iterations = number;
|
||||
}
|
||||
else if (strncmp (attrs[i], "v=", 2) == 0)
|
||||
{
|
||||
|
||||
@@ -676,10 +676,9 @@ int
|
||||
irc_server_set_addresses (struct t_irc_server *server, const char *addresses,
|
||||
int tls)
|
||||
{
|
||||
int rc, i, default_port;
|
||||
char *pos, *error, *addresses_eval;
|
||||
int rc, i, default_port, number;
|
||||
char *pos, *addresses_eval;
|
||||
const char *ptr_addresses;
|
||||
long number;
|
||||
|
||||
if (!server)
|
||||
return 0;
|
||||
@@ -753,19 +752,14 @@ irc_server_set_addresses (struct t_irc_server *server, const char *addresses,
|
||||
server->addresses_count * sizeof (server->retry_array[0]));
|
||||
for (i = 0; i < server->addresses_count; i++)
|
||||
{
|
||||
server->ports_array[i] = default_port;
|
||||
pos = strchr (server->addresses_array[i], '/');
|
||||
if (pos)
|
||||
{
|
||||
pos[0] = 0;
|
||||
pos++;
|
||||
error = NULL;
|
||||
number = strtol (pos, &error, 10);
|
||||
server->ports_array[i] = (error && !error[0]) ?
|
||||
number : default_port;
|
||||
}
|
||||
else
|
||||
{
|
||||
server->ports_array[i] = default_port;
|
||||
if (weechat_util_parse_int (pos, 10, &number))
|
||||
server->ports_array[i] = number;
|
||||
}
|
||||
server->retry_array[i] = 0;
|
||||
}
|
||||
@@ -1518,18 +1512,14 @@ int
|
||||
irc_server_get_max_modes (struct t_irc_server *server)
|
||||
{
|
||||
const char *support_modes;
|
||||
char *error;
|
||||
long number;
|
||||
int max_modes;
|
||||
int max_modes, number;
|
||||
|
||||
max_modes = 4;
|
||||
|
||||
support_modes = irc_server_get_isupport_value (server, "MODES");
|
||||
if (support_modes)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (support_modes, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (support_modes, 10, &number))
|
||||
{
|
||||
max_modes = number;
|
||||
if (max_modes < 1)
|
||||
|
||||
@@ -356,11 +356,10 @@ irc_upgrade_read_cb (const void *pointer, void *data,
|
||||
int object_id,
|
||||
struct t_infolist *infolist)
|
||||
{
|
||||
int flags, sock, size, i, index, nicks_count, num_items, utf8mapping;
|
||||
long number;
|
||||
int flags, sock, size, i, index, nicks_count, num_items, number, utf8mapping;
|
||||
long long number_longlong;
|
||||
time_t join_time;
|
||||
char *buf, option_name[64], **nicks, *nick_join, *pos, *error;
|
||||
char **items;
|
||||
char *buf, option_name[64], **nicks, *nick_join, *pos, **items;
|
||||
const char *buffer_name, *str, *nick;
|
||||
struct t_irc_server *ptr_server;
|
||||
struct t_irc_nick *ptr_nick;
|
||||
@@ -521,10 +520,8 @@ irc_upgrade_read_cb (const void *pointer, void *data,
|
||||
"LINELEN");
|
||||
if (str)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (str, &error, 10);
|
||||
if (error && !error[0])
|
||||
irc_upgrade_current_server->msg_max_length = (int)number;
|
||||
if (weechat_util_parse_int (str, 10, &number))
|
||||
irc_upgrade_current_server->msg_max_length = number;
|
||||
}
|
||||
}
|
||||
irc_upgrade_current_server->nick_max_length = weechat_infolist_integer (infolist, "nick_max_length");
|
||||
@@ -540,10 +537,8 @@ irc_upgrade_read_cb (const void *pointer, void *data,
|
||||
"USERLEN");
|
||||
if (str)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (str, &error, 10);
|
||||
if (error && !error[0])
|
||||
irc_upgrade_current_server->user_max_length = (int)number;
|
||||
if (weechat_util_parse_int (str, 10, &number))
|
||||
irc_upgrade_current_server->user_max_length = number;
|
||||
}
|
||||
}
|
||||
/* "host_max_length" is new in WeeChat 2.6 */
|
||||
@@ -558,10 +553,8 @@ irc_upgrade_read_cb (const void *pointer, void *data,
|
||||
"HOSTLEN");
|
||||
if (str)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (str, &error, 10);
|
||||
if (error && !error[0])
|
||||
irc_upgrade_current_server->host_max_length = (int)number;
|
||||
if (weechat_util_parse_int (str, 10, &number))
|
||||
irc_upgrade_current_server->host_max_length = number;
|
||||
}
|
||||
}
|
||||
irc_upgrade_current_server->casemapping = weechat_infolist_integer (infolist, "casemapping");
|
||||
@@ -621,10 +614,8 @@ irc_upgrade_read_cb (const void *pointer, void *data,
|
||||
"MONITOR");
|
||||
if (str)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (str, &error, 10);
|
||||
if (error && !error[0])
|
||||
irc_upgrade_current_server->monitor = (int)number;
|
||||
if (weechat_util_parse_int (str, 10, &number))
|
||||
irc_upgrade_current_server->monitor = number;
|
||||
}
|
||||
}
|
||||
/* "clienttagdeny" is new in WeeChat 3.3 */
|
||||
@@ -771,11 +762,9 @@ irc_upgrade_read_cb (const void *pointer, void *data,
|
||||
pos - nicks[i]);
|
||||
if (nick_join)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (pos + 1, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_longlong (pos + 1, 10, &number_longlong))
|
||||
{
|
||||
join_time = (time_t)number;
|
||||
join_time = (time_t)number_longlong;
|
||||
irc_channel_join_smart_filtered_add (irc_upgrade_current_channel,
|
||||
nick_join,
|
||||
join_time);
|
||||
|
||||
@@ -2982,7 +2982,6 @@ API_FUNC(hook_signal)
|
||||
|
||||
API_FUNC(hook_signal_send)
|
||||
{
|
||||
char *error;
|
||||
int number, rc;
|
||||
|
||||
API_INIT_FUNC(1, "hook_signal_send", "sss", API_RETURN_INT(WEECHAT_RC_ERROR));
|
||||
@@ -2998,9 +2997,7 @@ API_FUNC(hook_signal_send)
|
||||
}
|
||||
else if (strcmp (*type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = (int)strtol (*signal_data, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (*signal_data, 10, &number))
|
||||
rc = weechat_hook_signal_send (*signal, *type_data, &number);
|
||||
else
|
||||
rc = WEECHAT_RC_ERROR;
|
||||
|
||||
@@ -904,9 +904,8 @@ plugin_api_info_nick_color_ignore_case_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
{
|
||||
char **items, *result, *error;
|
||||
int num_items, case_range;
|
||||
long number;
|
||||
char **items, *result;
|
||||
int num_items, case_range, number;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -918,10 +917,8 @@ plugin_api_info_nick_color_ignore_case_cb (const void *pointer, void *data,
|
||||
case_range = -1;
|
||||
if (num_items >= 2)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (items[1], &error, 10);
|
||||
if (error && !error[0])
|
||||
case_range = (int)number;
|
||||
if (util_parse_int (items[1], 10, &number))
|
||||
case_range = number;
|
||||
}
|
||||
|
||||
result = gui_nick_find_color (
|
||||
@@ -943,9 +940,8 @@ plugin_api_info_nick_color_name_ignore_case_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
{
|
||||
char **items, *result, *error;
|
||||
int num_items, case_range;
|
||||
long number;
|
||||
char **items, *result;
|
||||
int num_items, case_range, number;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -957,10 +953,8 @@ plugin_api_info_nick_color_name_ignore_case_cb (const void *pointer, void *data,
|
||||
case_range = -1;
|
||||
if (num_items >= 2)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (items[1], &error, 10);
|
||||
if (error && !error[0])
|
||||
case_range = (int)number;
|
||||
if (util_parse_int (items[1], 10, &number))
|
||||
case_range = number;
|
||||
}
|
||||
|
||||
result = gui_nick_find_color_name (
|
||||
@@ -1064,9 +1058,9 @@ plugin_api_info_totp_generate_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
{
|
||||
char **argv, *ptr_secret, *error, *totp;
|
||||
int argc, digits;
|
||||
long number;
|
||||
char **argv, *ptr_secret, *totp;
|
||||
int argc, digits, number_int;
|
||||
long long number_longlong;
|
||||
time_t totp_time;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -1094,19 +1088,15 @@ plugin_api_info_totp_generate_cb (const void *pointer, void *data,
|
||||
|
||||
if (argc > 1)
|
||||
{
|
||||
error = NULL;
|
||||
number = (int)strtol (argv[1], &error, 10);
|
||||
if (!error || error[0] || (number < 0))
|
||||
if (!util_parse_longlong (argv[1], 10, &number_longlong) || (number_longlong < 0))
|
||||
goto error;
|
||||
totp_time = (time_t)number;
|
||||
totp_time = (time_t)number_longlong;
|
||||
}
|
||||
if (argc > 2)
|
||||
{
|
||||
error = NULL;
|
||||
number = (int)strtol (argv[2], &error, 10);
|
||||
if (!error || error[0] || (number < 0))
|
||||
if (!util_parse_int (argv[2], 10, &number_int) || (number_int < 0))
|
||||
goto error;
|
||||
digits = number;
|
||||
digits = number_int;
|
||||
}
|
||||
|
||||
totp = weecrypto_totp_generate (ptr_secret, totp_time, digits);
|
||||
@@ -1135,9 +1125,9 @@ plugin_api_info_totp_validate_cb (const void *pointer, void *data,
|
||||
const char *info_name,
|
||||
const char *arguments)
|
||||
{
|
||||
char value[16], **argv, *ptr_secret, *ptr_otp, *error;
|
||||
int argc, window, rc;
|
||||
long number;
|
||||
char value[16], **argv, *ptr_secret, *ptr_otp;
|
||||
int argc, window, rc, number_int;
|
||||
long long number_longlong;
|
||||
time_t totp_time;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -1165,19 +1155,15 @@ plugin_api_info_totp_validate_cb (const void *pointer, void *data,
|
||||
|
||||
if (argc > 2)
|
||||
{
|
||||
error = NULL;
|
||||
number = (int)strtol (argv[2], &error, 10);
|
||||
if (!error || error[0] || (number < 0))
|
||||
if (!util_parse_longlong (argv[2], 10, &number_longlong) || (number_longlong < 0))
|
||||
goto error;
|
||||
totp_time = (time_t)number;
|
||||
totp_time = (time_t)number_longlong;
|
||||
}
|
||||
if (argc > 3)
|
||||
{
|
||||
error = NULL;
|
||||
number = (int)strtol (argv[3], &error, 10);
|
||||
if (!error || error[0] || (number < 0))
|
||||
if (!util_parse_int (argv[3], 10, &number_int) || (number_int < 0))
|
||||
goto error;
|
||||
window = number;
|
||||
window = number_int;
|
||||
}
|
||||
|
||||
rc = weecrypto_totp_validate (ptr_secret, totp_time, window, ptr_otp);
|
||||
@@ -1236,8 +1222,8 @@ plugin_api_info_window_cb (const void *pointer, void *data,
|
||||
const char *arguments)
|
||||
{
|
||||
struct t_gui_window *ptr_window;
|
||||
long number;
|
||||
char *error, value[64];
|
||||
int number;
|
||||
char value[64];
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -1247,9 +1233,7 @@ plugin_api_info_window_cb (const void *pointer, void *data,
|
||||
if (!arguments || !arguments[0])
|
||||
return NULL;
|
||||
|
||||
error = NULL;
|
||||
number = (int)strtol (arguments, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!util_parse_int (arguments, 10, &number))
|
||||
return NULL;
|
||||
|
||||
ptr_window = gui_window_search_by_number (number);
|
||||
@@ -2041,7 +2025,6 @@ plugin_api_infolist_window_cb (const void *pointer, void *data,
|
||||
struct t_infolist *ptr_infolist;
|
||||
struct t_gui_window *ptr_window;
|
||||
int number;
|
||||
char *error;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
@@ -2085,9 +2068,7 @@ plugin_api_infolist_window_cb (const void *pointer, void *data,
|
||||
return NULL;
|
||||
}
|
||||
/* check if argument is a window number */
|
||||
error = NULL;
|
||||
number = (int)strtol (arguments, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (util_parse_int (arguments, 10, &number))
|
||||
{
|
||||
ptr_window = gui_window_search_by_number (number);
|
||||
if (ptr_window)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "../core/core-input.h"
|
||||
#include "../core/core-proxy.h"
|
||||
#include "../core/core-string.h"
|
||||
#include "../core/core-util.h"
|
||||
#include "../gui/gui-bar.h"
|
||||
#include "../gui/gui-bar-item.h"
|
||||
#include "../gui/gui-bar-window.h"
|
||||
@@ -394,7 +395,7 @@ plugin_api_command_options (struct t_weechat_plugin *plugin,
|
||||
struct t_gui_buffer *buffer, const char *command,
|
||||
struct t_hashtable *options)
|
||||
{
|
||||
char *command2, *error;
|
||||
char *command2;
|
||||
const char *ptr_commands_allowed, *ptr_delay, *ptr_split_newline;
|
||||
long delay;
|
||||
int rc, split_newline;
|
||||
@@ -412,9 +413,7 @@ plugin_api_command_options (struct t_weechat_plugin *plugin,
|
||||
ptr_delay = hashtable_get (options, "delay");
|
||||
if (ptr_delay)
|
||||
{
|
||||
error = NULL;
|
||||
delay = strtol (ptr_delay, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!util_parse_long (ptr_delay, 10, &delay))
|
||||
delay = 0;
|
||||
}
|
||||
ptr_split_newline = hashtable_get (options, "split_newline");
|
||||
|
||||
@@ -3120,7 +3120,7 @@ API_FUNC(hook_signal)
|
||||
|
||||
API_FUNC(hook_signal_send)
|
||||
{
|
||||
char *signal, *type_data, *signal_data, *error;
|
||||
char *signal, *type_data, *signal_data;
|
||||
int number, rc;
|
||||
|
||||
API_INIT_FUNC(1, "hook_signal_send", API_RETURN_INT(WEECHAT_RC_ERROR));
|
||||
@@ -3137,9 +3137,7 @@ API_FUNC(hook_signal_send)
|
||||
}
|
||||
else if (strcmp (type_data, WEECHAT_HOOK_SIGNAL_INT) == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = (int)strtol (signal_data, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (signal_data, 10, &number))
|
||||
rc = weechat_hook_signal_send (signal, type_data, &number);
|
||||
else
|
||||
rc = WEECHAT_RC_ERROR;
|
||||
|
||||
@@ -77,7 +77,6 @@ relay_api_protocol_signal_buffer_cb (const void *pointer, void *data,
|
||||
long long buffer_id;
|
||||
int nicks;
|
||||
const char *ptr_id;
|
||||
char *error;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
@@ -119,9 +118,7 @@ relay_api_protocol_signal_buffer_cb (const void *pointer, void *data,
|
||||
ptr_buffer);
|
||||
if (ptr_id)
|
||||
{
|
||||
error = NULL;
|
||||
buffer_id = strtoll (ptr_id, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_longlong (ptr_id, 10, &buffer_id))
|
||||
buffer_id = -1;
|
||||
weechat_hashtable_remove (
|
||||
RELAY_API_DATA(ptr_client, buffers_closing),
|
||||
@@ -499,7 +496,7 @@ invalid_hash_algo:
|
||||
RELAY_API_PROTOCOL_CALLBACK(version)
|
||||
{
|
||||
cJSON *json;
|
||||
char *version, *error;
|
||||
char *version;
|
||||
long number;
|
||||
|
||||
json = cJSON_CreateObject ();
|
||||
@@ -517,9 +514,7 @@ RELAY_API_PROTOCOL_CALLBACK(version)
|
||||
free (version);
|
||||
|
||||
version = weechat_info_get ("version_number", NULL);
|
||||
error = NULL;
|
||||
number = strtol (version, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_long (version, 10, &number))
|
||||
{
|
||||
cJSON_AddItemToObject (json,
|
||||
"weechat_version_number",
|
||||
@@ -561,10 +556,9 @@ RELAY_API_PROTOCOL_CALLBACK(buffers)
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
struct t_gui_line *ptr_line;
|
||||
struct t_gui_line_data *ptr_line_data;
|
||||
long lines, lines_free, line_id;
|
||||
int colors, nicks;
|
||||
long lines, lines_free;
|
||||
int colors, nicks, line_id;
|
||||
const char *ptr_colors;
|
||||
char *error;
|
||||
|
||||
json = NULL;
|
||||
|
||||
@@ -610,9 +604,10 @@ RELAY_API_PROTOCOL_CALLBACK(buffers)
|
||||
{
|
||||
if (client->http_req->num_path_items > 4)
|
||||
{
|
||||
line_id = strtol (client->http_req->path_items[4], &error, 10);
|
||||
ptr_line = (error && !error[0]) ?
|
||||
weechat_line_search_by_id (ptr_buffer, line_id) : NULL;
|
||||
if (weechat_util_parse_int (client->http_req->path_items[4], 10, &line_id))
|
||||
ptr_line = weechat_line_search_by_id (ptr_buffer, line_id);
|
||||
else
|
||||
ptr_line = NULL;
|
||||
ptr_line_data = (ptr_line) ?
|
||||
weechat_hdata_pointer (relay_hdata_line, ptr_line, "data") : NULL;
|
||||
if (!ptr_line_data)
|
||||
|
||||
@@ -51,7 +51,6 @@ long long
|
||||
relay_api_get_buffer_id (struct t_gui_buffer *buffer)
|
||||
{
|
||||
const char *ptr_id;
|
||||
char *error;
|
||||
long long id;
|
||||
|
||||
if (!buffer)
|
||||
@@ -61,9 +60,7 @@ relay_api_get_buffer_id (struct t_gui_buffer *buffer)
|
||||
if (!ptr_id)
|
||||
return -1;
|
||||
|
||||
error = NULL;
|
||||
id = strtoll (ptr_id, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_longlong (ptr_id, 10, &id))
|
||||
return -1;
|
||||
|
||||
return id;
|
||||
|
||||
@@ -113,7 +113,6 @@ long long
|
||||
relay_remote_event_get_buffer_id (struct t_gui_buffer *buffer)
|
||||
{
|
||||
const char *ptr_id;
|
||||
char *error;
|
||||
long long buffer_id;
|
||||
|
||||
if (!buffer)
|
||||
@@ -123,9 +122,7 @@ relay_remote_event_get_buffer_id (struct t_gui_buffer *buffer)
|
||||
if (!ptr_id)
|
||||
return -1;
|
||||
|
||||
error = NULL;
|
||||
buffer_id = strtoll (ptr_id, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_longlong (ptr_id, 10, &buffer_id))
|
||||
return -1;
|
||||
|
||||
return buffer_id;
|
||||
|
||||
@@ -429,9 +429,8 @@ relay_irc_signal_irc_in2_cb (const void *pointer, void *data,
|
||||
int
|
||||
relay_irc_tag_relay_client_id (const char *tags)
|
||||
{
|
||||
char **argv, *error;
|
||||
int result, argc, i;
|
||||
long number;
|
||||
char **argv;
|
||||
int number, result, argc, i;
|
||||
|
||||
result = -1;
|
||||
|
||||
@@ -449,9 +448,7 @@ relay_irc_tag_relay_client_id (const char *tags)
|
||||
{
|
||||
if (strncmp (argv[i], "relay_client_", 13) == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (argv[i] + 13, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (argv[i] + 13, 10, &number))
|
||||
{
|
||||
result = number;
|
||||
break;
|
||||
@@ -1606,10 +1603,9 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
|
||||
const char *ptr_data, *ptr_nick_modes, *pos;
|
||||
char str_time[128], str_signal[128], str_server_channel[256], *nick;
|
||||
char str_param[128], *str_args, *version, str_command[128], **params;
|
||||
char *password, *irc_is_channel, *info, *error, *str_cmd_lower;
|
||||
char *password, *irc_is_channel, *info, *str_cmd_lower;
|
||||
char modifier_data[128], *new_data, *ctcp_type, *ctcp_params, *nick_modes;
|
||||
long num_params;
|
||||
int i, redirect_msg;
|
||||
int i, num_params, redirect_msg;
|
||||
|
||||
new_data = NULL;
|
||||
hash_parsed = NULL;
|
||||
@@ -1650,9 +1646,7 @@ relay_irc_recv (struct t_relay_client *client, const char *data)
|
||||
goto end;
|
||||
irc_command = weechat_hashtable_get (hash_parsed, "command");
|
||||
str_num_params = weechat_hashtable_get (hash_parsed, "num_params");
|
||||
error = NULL;
|
||||
num_params = strtol (str_num_params, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (str_num_params, 10, &num_params))
|
||||
num_params = 0;
|
||||
if (num_params > 0)
|
||||
{
|
||||
|
||||
@@ -283,7 +283,7 @@ relay_auth_parse_pbkdf2 (const char *parameters,
|
||||
char **salt_hexa, char **salt, int *salt_size,
|
||||
int *iterations, char **hash)
|
||||
{
|
||||
char **argv, *error;
|
||||
char **argv;
|
||||
int argc;
|
||||
|
||||
if (salt_hexa)
|
||||
@@ -329,9 +329,7 @@ relay_auth_parse_pbkdf2 (const char *parameters,
|
||||
}
|
||||
|
||||
/* parameter 2: iterations */
|
||||
error = NULL;
|
||||
*iterations = (int)strtol (argv[1], &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (argv[1], 10, iterations))
|
||||
*iterations = 0;
|
||||
|
||||
/* parameter 3: the PBKDF2 hash */
|
||||
@@ -362,9 +360,7 @@ int
|
||||
relay_auth_check_salt (struct t_relay_client *client,
|
||||
const char *salt_hexa, const char *salt, int salt_size)
|
||||
{
|
||||
long number;
|
||||
int time_window;
|
||||
char *error;
|
||||
long long number, time_window;
|
||||
time_t time_now;
|
||||
|
||||
if (!client)
|
||||
@@ -374,12 +370,10 @@ relay_auth_check_salt (struct t_relay_client *client,
|
||||
{
|
||||
if (!salt || (salt_size < 1))
|
||||
return 0;
|
||||
error = NULL;
|
||||
number = strtol (salt, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_longlong (salt, 10, &number))
|
||||
return 0;
|
||||
time_now = time (NULL);
|
||||
time_window = weechat_config_integer (relay_config_network_time_window);
|
||||
time_window = (long long)weechat_config_integer (relay_config_network_time_window);
|
||||
return ((number >= time_now - time_window)
|
||||
&& (number <= time_now + time_window)) ? 1 : 0;
|
||||
}
|
||||
|
||||
@@ -652,23 +652,46 @@ relay_config_check_port_cb (const void *pointer, void *data,
|
||||
struct t_config_option *option,
|
||||
const char *value)
|
||||
{
|
||||
char *error;
|
||||
long port;
|
||||
struct t_relay_server *ptr_server;
|
||||
int number, port;
|
||||
long long new_port;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) pointer;
|
||||
(void) data;
|
||||
(void) option;
|
||||
|
||||
error = NULL;
|
||||
port = strtol (value, &error, 10);
|
||||
ptr_server = relay_server_search_port ((int)port);
|
||||
if (strncmp (value, "++", 2) == 0)
|
||||
{
|
||||
/* relative value: add to the current port */
|
||||
if (!weechat_util_parse_int (value + 2, 10, &number))
|
||||
return 1;
|
||||
new_port = (long long)weechat_config_integer (option) + number;
|
||||
}
|
||||
else if (strncmp (value, "--", 2) == 0)
|
||||
{
|
||||
/* relative value: subtract from the current port */
|
||||
if (!weechat_util_parse_int (value + 2, 10, &number))
|
||||
return 1;
|
||||
new_port = (long long)weechat_config_integer (option) - number;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* let WeeChat display the error if value is not a valid integer */
|
||||
if (!weechat_util_parse_int (value, 10, &port))
|
||||
return 1;
|
||||
new_port = port;
|
||||
}
|
||||
|
||||
/* if port is out of range, let WeeChat validate and display the error */
|
||||
if ((new_port < 0) || (new_port > 65535))
|
||||
return 1;
|
||||
|
||||
ptr_server = relay_server_search_port ((int)new_port);
|
||||
if (ptr_server)
|
||||
{
|
||||
weechat_printf (NULL, _("%s%s: error: port \"%d\" is already used"),
|
||||
weechat_prefix ("error"),
|
||||
RELAY_PLUGIN_NAME, (int)port);
|
||||
RELAY_PLUGIN_NAME, (int)new_port);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -866,9 +889,8 @@ relay_config_create_option_port_path (const void *pointer, void *data,
|
||||
const char *option_name,
|
||||
const char *value)
|
||||
{
|
||||
int rc, protocol_number, ipv4, ipv6, tls, unix_socket;
|
||||
char *error, *protocol, *protocol_args;
|
||||
long port;
|
||||
int rc, protocol_number, ipv4, ipv6, tls, unix_socket, port;
|
||||
char *protocol, *protocol_args;
|
||||
struct t_relay_server *ptr_server;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -925,9 +947,10 @@ relay_config_create_option_port_path (const void *pointer, void *data,
|
||||
}
|
||||
else
|
||||
{
|
||||
error = NULL;
|
||||
port = strtol (value, &error, 10);
|
||||
ptr_server = relay_server_search_port ((int)port);
|
||||
if (weechat_util_parse_int (value, 10, &port))
|
||||
ptr_server = relay_server_search_port (port);
|
||||
else
|
||||
ptr_server = NULL;
|
||||
}
|
||||
if (ptr_server)
|
||||
{
|
||||
|
||||
@@ -212,7 +212,6 @@ relay_http_get_param_long (struct t_relay_http_request *request,
|
||||
long *value)
|
||||
{
|
||||
const char *ptr_value;
|
||||
char *error;
|
||||
long number;
|
||||
|
||||
if (!value)
|
||||
@@ -223,8 +222,7 @@ relay_http_get_param_long (struct t_relay_http_request *request,
|
||||
return 0;
|
||||
if (ptr_value)
|
||||
{
|
||||
number = strtol (ptr_value, &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_long (ptr_value, 10, &number))
|
||||
return 0;
|
||||
*value = number;
|
||||
}
|
||||
@@ -411,10 +409,9 @@ relay_http_parse_header (struct t_relay_http_request *request,
|
||||
const char *header,
|
||||
int ws_deflate_allowed)
|
||||
{
|
||||
char *name, *name_lower, *error, **items;
|
||||
char *name, *name_lower, **items;
|
||||
const char *pos, *existing_value, *ptr_value;
|
||||
int i, num_items;
|
||||
long number;
|
||||
int i, number, num_items;
|
||||
|
||||
weechat_string_dyn_concat (request->raw, header, -1);
|
||||
weechat_string_dyn_concat (request->raw, "\n", -1);
|
||||
@@ -475,10 +472,8 @@ relay_http_parse_header (struct t_relay_http_request *request,
|
||||
/* if header is "Content-Length", save the length */
|
||||
if (strcmp (name_lower, "content-length") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (ptr_value, &error, 10);
|
||||
if (error && !error[0])
|
||||
request->content_length = (int)number;
|
||||
if (weechat_util_parse_int (ptr_value, 10, &number))
|
||||
request->content_length = number;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -606,7 +601,7 @@ relay_http_get_auth_status (struct t_relay_client *client)
|
||||
{
|
||||
const char *auth, *sec_websocket_protocol, *client_totp, *pos;
|
||||
char *relay_password, *totp_secret, *info_totp_args, *info_totp;
|
||||
char *user_pass, **protocol_array, *error;
|
||||
char *user_pass, **protocol_array;
|
||||
int rc, i, length, protocol_count, use_base64url, totp_ok;
|
||||
long number;
|
||||
|
||||
@@ -626,8 +621,8 @@ relay_http_get_auth_status (struct t_relay_client *client)
|
||||
rc = -4;
|
||||
goto end;
|
||||
}
|
||||
number = strtol (client_totp, &error, 10);
|
||||
if (!error || error[0] || (number < 0) || (number > 999999))
|
||||
if (!weechat_util_parse_long (client_totp, 10, &number)
|
||||
|| (number < 0) || (number > 999999))
|
||||
{
|
||||
rc = -4;
|
||||
goto end;
|
||||
@@ -1496,8 +1491,8 @@ relay_http_parse_response_code (struct t_relay_http_response *response,
|
||||
const char *response_code)
|
||||
{
|
||||
const char *pos, *pos2;
|
||||
char *error, *return_code;
|
||||
long value;
|
||||
char *return_code;
|
||||
int value;
|
||||
|
||||
if (!response)
|
||||
return 0;
|
||||
@@ -1528,10 +1523,8 @@ relay_http_parse_response_code (struct t_relay_http_response *response,
|
||||
if (!return_code)
|
||||
goto error;
|
||||
|
||||
error = NULL;
|
||||
value = strtol (return_code, &error, 10);
|
||||
if (error && !error[0])
|
||||
response->return_code = (int)value;
|
||||
if (weechat_util_parse_int (return_code, 10, &value))
|
||||
response->return_code = value;
|
||||
|
||||
free (return_code);
|
||||
|
||||
@@ -1566,9 +1559,9 @@ int
|
||||
relay_http_parse_response_header (struct t_relay_http_response *response,
|
||||
const char *header)
|
||||
{
|
||||
char *name, *name_lower, *error;
|
||||
char *name, *name_lower;
|
||||
const char *pos, *ptr_value;
|
||||
long number;
|
||||
int number;
|
||||
|
||||
/* empty line => end of headers */
|
||||
if (!header || !header[0])
|
||||
@@ -1608,10 +1601,8 @@ relay_http_parse_response_header (struct t_relay_http_response *response,
|
||||
/* if header is "Content-Length", save the length */
|
||||
if (strcmp (name_lower, "content-length") == 0)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (ptr_value, &error, 10);
|
||||
if (error && !error[0])
|
||||
response->content_length = (int)number;
|
||||
if (weechat_util_parse_int (ptr_value, 10, &number))
|
||||
response->content_length = number;
|
||||
}
|
||||
|
||||
free (name);
|
||||
|
||||
@@ -203,7 +203,7 @@ relay_remote_parse_url (const char *url,
|
||||
int *tls, char **address, int *port)
|
||||
{
|
||||
const char *ptr_url, *pos;
|
||||
char *str_port, *error;
|
||||
char *str_port;
|
||||
long number;
|
||||
|
||||
if (tls)
|
||||
@@ -270,12 +270,11 @@ relay_remote_parse_url (const char *url,
|
||||
weechat_strndup (ptr_url, pos - ptr_url) : strdup (ptr_url);
|
||||
if (!str_port)
|
||||
return 0;
|
||||
error = NULL;
|
||||
number = strtol (str_port, &error, 10);
|
||||
if (error && !error[0] && (number >= 0) && (number <= 65535))
|
||||
if (weechat_util_parse_long (str_port, 10, &number)
|
||||
&& (number >= 0) && (number <= 65535))
|
||||
{
|
||||
if (port)
|
||||
*port = number;
|
||||
*port = (int)number;
|
||||
free (str_port);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -306,9 +306,8 @@ relay_websocket_parse_extensions (const char *extensions,
|
||||
struct t_relay_websocket_deflate *ws_deflate,
|
||||
int ws_deflate_allowed)
|
||||
{
|
||||
char **exts, **params, **items, *error;
|
||||
int i, j, num_exts, num_params, num_items;
|
||||
long number;
|
||||
char **exts, **params, **items;
|
||||
int i, j, number, num_exts, num_params, num_items;
|
||||
|
||||
if (!extensions || !ws_deflate)
|
||||
return;
|
||||
@@ -351,9 +350,7 @@ relay_websocket_parse_extensions (const char *extensions,
|
||||
number = 15;
|
||||
if (num_items >= 2)
|
||||
{
|
||||
error = NULL;
|
||||
number = strtol (items[1], &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (items[1], 10, &number))
|
||||
{
|
||||
if (number < 8)
|
||||
number = 8;
|
||||
@@ -368,12 +365,12 @@ relay_websocket_parse_extensions (const char *extensions,
|
||||
if (strcmp (items[0], "server_max_window_bits") == 0)
|
||||
{
|
||||
ws_deflate->server_max_window_bits_recv = 1;
|
||||
ws_deflate->window_bits_deflate = (int)number;
|
||||
ws_deflate->window_bits_deflate = number;
|
||||
}
|
||||
else
|
||||
{
|
||||
ws_deflate->client_max_window_bits_recv = 1;
|
||||
ws_deflate->window_bits_inflate = (int)number;
|
||||
ws_deflate->window_bits_inflate = number;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -362,7 +362,7 @@ relay_weechat_msg_add_hdata_path (struct t_relay_weechat_msg *msg,
|
||||
{
|
||||
int num_added, i, j, count, count_all, var_type, array_size, max_array_size;
|
||||
int length;
|
||||
char *pos, *pos2, *str_count, *error, *name;
|
||||
char *pos, *pos2, *str_count, *name;
|
||||
void *sub_pointer;
|
||||
struct t_hdata *sub_hdata;
|
||||
const char *sub_hdata_name;
|
||||
@@ -384,9 +384,7 @@ relay_weechat_msg_add_hdata_path (struct t_relay_weechat_msg *msg,
|
||||
count_all = 1;
|
||||
else
|
||||
{
|
||||
error = NULL;
|
||||
count = (int)strtol (str_count, &error, 10);
|
||||
if (error && !error[0])
|
||||
if (weechat_util_parse_int (str_count, 10, &count))
|
||||
{
|
||||
if (count > 0)
|
||||
count--;
|
||||
|
||||
@@ -684,7 +684,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(completion)
|
||||
struct t_gui_completion_word *word;
|
||||
struct t_arraylist *ptr_list;
|
||||
struct t_relay_weechat_msg *msg;
|
||||
char *error, *pos_data;
|
||||
char *pos_data;
|
||||
int i, position, length_data, context, pos_start, size;
|
||||
|
||||
RELAY_WEECHAT_PROTOCOL_MIN_ARGS(0);
|
||||
@@ -709,9 +709,7 @@ RELAY_WEECHAT_PROTOCOL_CALLBACK(completion)
|
||||
goto error;
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
position = (int)strtol (argv[1], &error, 10);
|
||||
if (!error || error[0])
|
||||
if (!weechat_util_parse_int (argv[1], 10, &position))
|
||||
goto error;
|
||||
|
||||
pos_data = strchr (argv_eol[1], ' ');
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -303,10 +303,9 @@ void
|
||||
trigger_hook (struct t_trigger *trigger)
|
||||
{
|
||||
char **argv, **argv_eol, *buffer_type, *buffer_name, *tags, *message;
|
||||
char *error1, *error2, *error3;
|
||||
char *eval_desc, *eval_args, *eval_desc_args, *eval_completion;
|
||||
int i, argc, strip_colors;
|
||||
long interval, align_second, max_calls;
|
||||
int i, argc, align_second, max_calls, strip_colors;
|
||||
long interval;
|
||||
struct t_hashtable *extra_vars;
|
||||
|
||||
if (!weechat_config_boolean (trigger->options[TRIGGER_OPTION_ENABLED]))
|
||||
@@ -488,17 +487,11 @@ trigger_hook (struct t_trigger *trigger)
|
||||
case TRIGGER_HOOK_TIMER:
|
||||
if (argv && (argc >= 1))
|
||||
{
|
||||
error1 = NULL;
|
||||
error2 = NULL;
|
||||
error3 = NULL;
|
||||
interval = strtol (argv[0], &error1, 10);
|
||||
align_second = strtol ((argc >= 2) ? argv[1] : "0", &error2, 10);
|
||||
max_calls = strtol ((argc >= 3) ? argv[2] : "0", &error3, 10);
|
||||
if (error1 && !error1[0]
|
||||
&& error2 && !error2[0]
|
||||
&& error3 && !error3[0]
|
||||
if (weechat_util_parse_long (argv[0], 10, &interval)
|
||||
&& (interval > 0)
|
||||
&& weechat_util_parse_int ((argc >= 2) ? argv[1] : "0", 10, &align_second)
|
||||
&& (align_second >= 0)
|
||||
&& weechat_util_parse_int ((argc >= 3) ? argv[2] : "0", 10, &max_calls)
|
||||
&& (max_calls >= 0))
|
||||
{
|
||||
trigger->hooks = malloc (sizeof (trigger->hooks[0]));
|
||||
@@ -507,8 +500,8 @@ trigger_hook (struct t_trigger *trigger)
|
||||
trigger->hooks_count = 1;
|
||||
trigger->hooks[0] = weechat_hook_timer (
|
||||
interval,
|
||||
(int)align_second,
|
||||
(int)max_calls,
|
||||
align_second,
|
||||
max_calls,
|
||||
&trigger_callback_timer_cb,
|
||||
trigger, NULL);
|
||||
}
|
||||
|
||||
@@ -59,15 +59,14 @@
|
||||
char *
|
||||
xfer_network_convert_integer_to_ipv4 (const char *str_address)
|
||||
{
|
||||
char *error, result[128];
|
||||
char result[128];
|
||||
long long number;
|
||||
|
||||
if (!str_address || !str_address[0])
|
||||
return NULL;
|
||||
|
||||
error = NULL;
|
||||
number = strtoll (str_address, &error, 10);
|
||||
if (!error || error[0] || (number <= 0) || (number > UINT32_MAX))
|
||||
if (!weechat_util_parse_longlong (str_address, 10, &number)
|
||||
|| (number <= 0) || (number > UINT32_MAX))
|
||||
return NULL;
|
||||
|
||||
snprintf (result, sizeof (result),
|
||||
|
||||
@@ -1008,7 +1008,7 @@ TEST(GuiBuffer, Set)
|
||||
LONGS_EQUAL(0, buffer->hidden);
|
||||
gui_buffer_set (buffer, "hidden", "2");
|
||||
LONGS_EQUAL(1, buffer->hidden);
|
||||
gui_buffer_set (buffer, "hidden", "");
|
||||
gui_buffer_set (buffer, "hidden", "0");
|
||||
LONGS_EQUAL(0, buffer->hidden);
|
||||
|
||||
/* print_hooks_enabled */
|
||||
@@ -1017,7 +1017,7 @@ TEST(GuiBuffer, Set)
|
||||
LONGS_EQUAL(0, buffer->print_hooks_enabled);
|
||||
gui_buffer_set (buffer, "print_hooks_enabled", "1");
|
||||
LONGS_EQUAL(1, buffer->print_hooks_enabled);
|
||||
gui_buffer_set (buffer, "print_hooks_enabled", "");
|
||||
gui_buffer_set (buffer, "print_hooks_enabled", "0");
|
||||
LONGS_EQUAL(0, buffer->print_hooks_enabled);
|
||||
gui_buffer_set (buffer, "print_hooks_enabled", "2");
|
||||
LONGS_EQUAL(1, buffer->print_hooks_enabled);
|
||||
@@ -1028,7 +1028,7 @@ TEST(GuiBuffer, Set)
|
||||
LONGS_EQUAL(0, buffer->day_change);
|
||||
gui_buffer_set (buffer, "day_change", "1");
|
||||
LONGS_EQUAL(1, buffer->day_change);
|
||||
gui_buffer_set (buffer, "day_change", "");
|
||||
gui_buffer_set (buffer, "day_change", "0");
|
||||
LONGS_EQUAL(0, buffer->day_change);
|
||||
gui_buffer_set (buffer, "day_change", "2");
|
||||
LONGS_EQUAL(1, buffer->day_change);
|
||||
@@ -1039,14 +1039,14 @@ TEST(GuiBuffer, Set)
|
||||
LONGS_EQUAL(0, buffer->clear);
|
||||
gui_buffer_set (buffer, "clear", "1");
|
||||
LONGS_EQUAL(1, buffer->clear);
|
||||
gui_buffer_set (buffer, "clear", "");
|
||||
gui_buffer_set (buffer, "clear", "0");
|
||||
LONGS_EQUAL(0, buffer->clear);
|
||||
gui_buffer_set (buffer, "clear", "2");
|
||||
LONGS_EQUAL(1, buffer->clear);
|
||||
|
||||
/* filter */
|
||||
LONGS_EQUAL(1, buffer->filter);
|
||||
gui_buffer_set (buffer, "filter", "");
|
||||
gui_buffer_set (buffer, "filter", "0");
|
||||
LONGS_EQUAL(0, buffer->filter);
|
||||
gui_buffer_set (buffer, "filter", "1");
|
||||
LONGS_EQUAL(1, buffer->filter);
|
||||
@@ -1292,7 +1292,7 @@ TEST(GuiBuffer, Set)
|
||||
LONGS_EQUAL(0, buffer->input_buffer_pos);
|
||||
gui_buffer_set (buffer, "input_pos", "2");
|
||||
LONGS_EQUAL(2, buffer->input_buffer_pos);
|
||||
gui_buffer_set (buffer, "input_pos", "");
|
||||
gui_buffer_set (buffer, "input_pos", "0");
|
||||
LONGS_EQUAL(0, buffer->input_buffer_pos);
|
||||
gui_buffer_set (buffer, "input", "");
|
||||
STRCMP_EQUAL("", buffer->input_buffer);
|
||||
|
||||
Reference in New Issue
Block a user