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

core, api: use "const char *" variables for result of string functions with const parameter

This commit is contained in:
Sébastien Helleu
2026-06-15 07:44:01 +02:00
parent cf702d541f
commit 7e3afaf46d
16 changed files with 61 additions and 41 deletions
+2 -1
View File
@@ -705,7 +705,8 @@ config_file_new_option (struct t_config_file *config_file,
{
struct t_config_option *new_option;
int var_type, int_value, argc, i, index_value, number;
char *pos, *option_name, *parent_name;
const char *pos;
char *option_name, *parent_name;
new_option = NULL;
option_name = NULL;
+10 -6
View File
@@ -1709,7 +1709,7 @@ config_weechat_update_cb (const void *pointer, void *data,
int version_read,
struct t_hashtable *data_read)
{
const char *ptr_config, *ptr_section, *ptr_option, *ptr_value;
const char *ptr_config, *ptr_section, *ptr_option, *ptr_value, *pos_option;
char *new_commands[][2] = {
/* old command, new command */
{ "/input jump_smart", "/buffer jump smart" },
@@ -1739,7 +1739,7 @@ config_weechat_update_cb (const void *pointer, void *data,
{ "number_desc" "-buffer.number" },
{ NULL, NULL },
};
char *new_option, *new_value, *pos_option;
char *new_option, *new_value;
int changes, i;
/* make C compiler happy */
@@ -2262,7 +2262,8 @@ config_weechat_proxy_read_cb (const void *pointer, void *data,
struct t_config_section *section,
const char *option_name, const char *value)
{
char *pos_option, *proxy_name;
const char *pos_option;
char *proxy_name;
struct t_proxy *ptr_temp_proxy;
int index_option;
@@ -2341,7 +2342,8 @@ config_weechat_bar_read_cb (const void *pointer, void *data,
struct t_config_section *section,
const char *option_name, const char *value)
{
char *pos_option, *bar_name;
const char *pos_option;
char *bar_name;
struct t_gui_bar *ptr_temp_bar;
int index_option;
@@ -2421,7 +2423,8 @@ config_weechat_custom_bar_item_read_cb (const void *pointer, void *data,
struct t_config_section *section,
const char *option_name, const char *value)
{
char *pos_option, *item_name;
const char *pos_option;
char *item_name;
struct t_gui_bar_item_custom *ptr_temp_item;
int index_option;
@@ -2512,7 +2515,8 @@ config_weechat_layout_read_cb (const void *pointer, void *data,
const char *option_name, const char *value)
{
int argc, force_current_layout, number1, number2, number3, number4;
char **argv, *pos, *layout_name;
const char *pos;
char **argv, *layout_name;
const char *ptr_option_name;
struct t_gui_layout *ptr_layout;
struct t_gui_layout_window *parent;
+14 -9
View File
@@ -508,7 +508,8 @@ eval_string_repeat (const char *text)
char *
eval_string_split (const char *text)
{
char *pos, *pos2, *pos3, *str_number, *separators, **items, *value;
const char *pos, *pos2, *pos3;
char *str_number, *separators, **items, *value;
char str_value[32], *str_flags, **list_flags, *strip_items, **ptr_flag;
int num_items, count_items, random_item, flags, max_items;
long number;
@@ -655,7 +656,8 @@ end:
char *
eval_string_split_shell (const char *text)
{
char *pos, *str_number, **items, *value, str_value[32];
const char *pos;
char *str_number, **items, *value, str_value[32];
int num_items, count_items, random_item;
long number;
@@ -1046,7 +1048,8 @@ eval_string_if (const char *text, struct t_eval_context *eval_context)
char *
eval_string_random (const char *text)
{
char *pos, *tmp, result[128];
const char *pos;
char *tmp, result[128];
long long min_number, max_number;
if (!text || !text[0])
@@ -1112,7 +1115,8 @@ eval_string_translate (const char *text)
void
eval_string_define (const char *text, struct t_eval_context *eval_context)
{
char *pos, *name;
const char *pos;
char *name;
pos = strchr (text, ',');
if (!pos)
@@ -1139,7 +1143,8 @@ eval_hdata_count (const char *text, struct t_eval_context *eval_context)
struct t_hdata *hdata;
unsigned long ptr_value;
void *pointer;
char *pos1, *pos2, *value, *hdata_name, *pointer_name, str_count[64];
const char *pos1, *pos2;
char *value, *hdata_name, *pointer_name, str_count[64];
int rc, count;
value = NULL;
@@ -1211,8 +1216,8 @@ char *
eval_hdata_get_value (struct t_hdata *hdata, void *pointer, const char *path,
struct t_eval_context *eval_context)
{
char *value, *var_name, str_value[128], *pos, *property;
const char *ptr_value, *hdata_name, *ptr_var_name, *pos_open_paren;
char *value, *var_name, str_value[128], *property;
const char *ptr_value, *hdata_name, *ptr_var_name, *pos, *pos_open_paren;
int type, debug_id;
struct t_hashtable *hashtable;
@@ -1539,8 +1544,8 @@ eval_syntax_highlight_add_markers (const char *prefix, const char *text,
char *
eval_syntax_highlight_colorize (const char *value)
{
const char *ptr_value;
char **result, *pos;
const char *ptr_value, *pos;
char **result;
int color;
if (!value)
+2 -1
View File
@@ -688,7 +688,8 @@ hdata_count (struct t_hdata *hdata, void *pointer)
void
hdata_get_index_and_name (const char *name, int *index, const char **ptr_name)
{
char *pos, *str_index;
const char *pos;
char *str_index;
int number;
if (index)
+8 -3
View File
@@ -242,8 +242,8 @@ int
input_data (struct t_gui_buffer *buffer, const char *data,
const char *commands_allowed, int split_newline, int user_data)
{
char *pos, str_buffer[128], *new_data, *buffer_full_name;
const char *ptr_data, *ptr_data_for_buffer;
const char *ptr_data_for_buffer;
char *pos, str_buffer[128], *new_data, *buffer_full_name, *ptr_data;
int first_command, rc;
if (!buffer || !gui_buffer_valid (buffer) || !data)
@@ -272,8 +272,13 @@ input_data (struct t_gui_buffer *buffer, const char *data,
if (data[0] && new_data && !new_data[0])
goto end;
if (!new_data)
new_data = strdup (data);
if (!new_data)
goto end;
first_command = 1;
ptr_data = (new_data) ? new_data : data;
ptr_data = new_data;
while (ptr_data)
{
/*
+6 -6
View File
@@ -1686,9 +1686,8 @@ string_mask_to_regex (const char *mask)
const char *
string_regex_flags (const char *regex, int default_flags, int *flags)
{
const char *ptr_regex, *ptr_flags;
const char *ptr_regex, *ptr_flags, *pos;
int set_flag, flag;
char *pos;
if (flags)
*flags = default_flags;
@@ -2966,8 +2965,9 @@ char **
string_split_command (const char *command, char separator)
{
int nb_substr, arr_idx, str_idx, type;
const char *p;
char **array, **array2;
char *buffer, *p;
char *buffer;
const char *ptr;
if (!command || !command[0])
@@ -4138,8 +4138,7 @@ string_is_command_char (const char *string)
const char *
string_input_for_buffer (const char *string)
{
char *pos_slash, *pos_space, *pos_newline;
const char *next_char;
const char *pos_slash, *pos_space, *pos_newline, *next_char;
if (!string)
return NULL;
@@ -4476,7 +4475,8 @@ string_get_priority_and_name (const char *string,
int *priority, const char **name,
int default_priority)
{
char *pos, *str_priority;
const char *pos;
char *str_priority;
int number;
if (priority)
+2 -2
View File
@@ -416,8 +416,8 @@ util_strftimeval (char *string, int max, const char *format, struct timeval *tv)
int
util_parse_time (const char *datetime, struct timeval *tv)
{
char *string, *pos, *pos2, *pos_colon, *pos_hyphen, *pos_dot;
char str_usec[16], str_date[128];
const char *pos_colon, *pos_hyphen, *pos_dot;
char *pos, *pos2, *string, str_usec[16], str_date[128];
struct tm tm_date, tm_date_gm, tm_date_local, *local_time;
time_t time_now, time_gm, time_local;
long long value;
+2 -2
View File
@@ -597,8 +597,8 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
struct t_hook *hook_plugin, *hook_other_plugin, *hook_other_plugin2;
struct t_hook *hook_incomplete_command;
struct t_hook_exec_cb hook_exec_cb;
char **argv, **argv_eol, *command_name, *pos;
const char *ptr_string;
char **argv, **argv_eol, *command_name;
const char *ptr_string, *pos;
int argc, rc, length_command_name, allow_incomplete_commands;
int count_other_plugin, count_incomplete_commands, flags;
+2 -1
View File
@@ -132,7 +132,8 @@ void
hook_signal_extract_flags (const char *signal, const char **ptr_signal,
int *stop_on_error, int *ignore_eat)
{
char *pos, *str_flags, **flags;
const char *pos;
char *str_flags, **flags;
int i, num_flags;
if (!signal || !ptr_signal || !stop_on_error || !ignore_eat)
+2 -1
View File
@@ -138,7 +138,8 @@ gui_bar_item_custom_search (const char *item_name)
struct t_gui_bar_item_custom *
gui_bar_item_custom_search_with_option_name (const char *option_name)
{
char *item_name, *pos_option;
const char *pos_option;
char *item_name;
struct t_gui_bar_item_custom *ptr_item;
if (!option_name)
+2 -1
View File
@@ -515,7 +515,8 @@ gui_bar_search (const char *name)
struct t_gui_bar *
gui_bar_search_with_option_name (const char *option_name)
{
char *bar_name, *pos_option;
const char *pos_option;
char *bar_name;
struct t_gui_bar *ptr_bar;
if (!option_name)
+2 -2
View File
@@ -118,8 +118,8 @@ gui_chat_init (void)
void
gui_chat_prefix_build (void)
{
const char *ptr_prefix;
char prefix[512], *pos_color;
const char *ptr_prefix, *pos_color;
char prefix[512];
int prefix_color[GUI_CHAT_NUM_PREFIXES] =
{ GUI_COLOR_CHAT_PREFIX_ERROR, GUI_COLOR_CHAT_PREFIX_NETWORK,
GUI_COLOR_CHAT_PREFIX_ACTION, GUI_COLOR_CHAT_PREFIX_JOIN,
+2 -2
View File
@@ -254,8 +254,8 @@ 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 *pos_delim, *str_fg, *pos_bg, *error, *color_attr;
const char *ptr_color_name;
char *str_fg, *error, *color_attr;
const char *ptr_color_name, *pos_delim, *pos_bg;
/* attribute or other color name (GUI dependent) */
index_color = (index_color + 1) % 32;
+2 -2
View File
@@ -366,8 +366,8 @@ gui_filter_new (int enabled, const char *name, const char *buffer_name,
{
struct t_gui_filter *new_filter;
regex_t *regex1, *regex2;
char *pos_tab, *regex_prefix, buf[512], str_error[1024];
const char *ptr_start_regex, *pos_regex_message;
char *regex_prefix, buf[512], str_error[1024];
const char *ptr_start_regex, *pos_regex_message, *pos_tab;
int rc;
if (!name || !buffer_name || !tags || !regex)
+1 -1
View File
@@ -1076,7 +1076,7 @@ gui_key_set_area_type_name (const char *area,
int *area_type, char **area_name)
{
int focus, length;
char *pos_end;
const char *pos_end;
for (focus = 0; focus < GUI_KEY_NUM_FOCUS; focus++)
{
+2 -1
View File
@@ -802,7 +802,8 @@ plugin_api_info_color_rgb2term_cb (const void *pointer, void *data,
const char *info_name,
const char *arguments)
{
char value[32], *pos, *color;
const char *pos;
char value[32], *color;
int rgb, limit;
/* make C compiler happy */