mirror of
https://github.com/weechat/weechat.git
synced 2026-07-03 16:23:14 +02:00
Rename function string_explode to string_split
This commit is contained in:
@@ -453,9 +453,9 @@ config_file_new_option (struct t_config_file *config_file,
|
||||
case CONFIG_OPTION_TYPE_INTEGER:
|
||||
if (string_values && string_values[0])
|
||||
{
|
||||
new_option->string_values = string_explode (string_values,
|
||||
"|", 0, 0,
|
||||
&argc);
|
||||
new_option->string_values = string_split (string_values,
|
||||
"|", 0, 0,
|
||||
&argc);
|
||||
if (!new_option->string_values)
|
||||
goto error;
|
||||
}
|
||||
@@ -2291,7 +2291,7 @@ config_file_option_free_data (struct t_config_option *option)
|
||||
if (option->description)
|
||||
free (option->description);
|
||||
if (option->string_values)
|
||||
string_free_exploded (option->string_values);
|
||||
string_free_split (option->string_values);
|
||||
if (option->default_value)
|
||||
free (option->default_value);
|
||||
if (option->value)
|
||||
@@ -2557,8 +2557,8 @@ config_file_add_to_infolist (struct t_infolist *infolist,
|
||||
free (option_full_name);
|
||||
return 0;
|
||||
}
|
||||
string_values = string_build_with_exploded ((const char **)ptr_option->string_values,
|
||||
"|");
|
||||
string_values = string_build_with_split_string ((const char **)ptr_option->string_values,
|
||||
"|");
|
||||
if (!infolist_new_var_string (ptr_item,
|
||||
"string_values",
|
||||
string_values))
|
||||
|
||||
@@ -760,7 +760,7 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
|
||||
{
|
||||
if (string_strcasecmp (option_name, "buffer") == 0)
|
||||
{
|
||||
argv = string_explode (value, ";", 0, 0, &argc);
|
||||
argv = string_split (value, ";", 0, 0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
if (argc >= 3)
|
||||
@@ -774,12 +774,12 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
|
||||
argv[0], argv[1], number1);
|
||||
}
|
||||
}
|
||||
string_free_exploded (argv);
|
||||
string_free_split (argv);
|
||||
}
|
||||
}
|
||||
else if (string_strcasecmp (option_name, "window") == 0)
|
||||
{
|
||||
argv = string_explode (value, ";", 0, 0, &argc);
|
||||
argv = string_split (value, ";", 0, 0, &argc);
|
||||
if (argv)
|
||||
{
|
||||
if (argc >= 6)
|
||||
@@ -808,7 +808,7 @@ config_weechat_layout_read_cb (void *data, struct t_config_file *config_file,
|
||||
argv[5] : NULL);
|
||||
}
|
||||
}
|
||||
string_free_exploded (argv);
|
||||
string_free_split (argv);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1035,17 +1035,17 @@ config_weechat_filter_read_cb (void *data,
|
||||
|
||||
if (option_name && value && value[0])
|
||||
{
|
||||
argv = string_explode (value, ";", 0, 0, &argc);
|
||||
argv_eol = string_explode (value, ";", 1, 0, NULL);
|
||||
argv = string_split (value, ";", 0, 0, &argc);
|
||||
argv_eol = string_split (value, ";", 1, 0, NULL);
|
||||
if (argv && argv_eol && (argc >= 4))
|
||||
{
|
||||
gui_filter_new ((string_strcasecmp (argv[0], "on") == 0) ? 1 : 0,
|
||||
option_name, argv[1], argv[2], argv_eol[3]);
|
||||
}
|
||||
if (argv)
|
||||
string_free_exploded (argv);
|
||||
string_free_split (argv);
|
||||
if (argv_eol)
|
||||
string_free_exploded (argv_eol);
|
||||
string_free_split (argv_eol);
|
||||
}
|
||||
|
||||
return WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE;
|
||||
|
||||
+14
-14
@@ -426,9 +426,9 @@ hook_command_build_completion (struct t_hook_command *hook_command)
|
||||
hook_command->cplt_templates_static[i] = strdup (hook_command->cplt_templates[i]);
|
||||
|
||||
/* build arguments for each template */
|
||||
hook_command->cplt_template_args[i] = string_explode (hook_command->cplt_templates[i],
|
||||
" ", 0, 0,
|
||||
&(hook_command->cplt_template_num_args[i]));
|
||||
hook_command->cplt_template_args[i] = string_split (hook_command->cplt_templates[i],
|
||||
" ", 0, 0,
|
||||
&(hook_command->cplt_template_num_args[i]));
|
||||
if (hook_command->cplt_template_num_args[i] > hook_command->cplt_template_num_args_concat)
|
||||
hook_command->cplt_template_num_args_concat = hook_command->cplt_template_num_args[i];
|
||||
}
|
||||
@@ -464,8 +464,8 @@ hook_command_build_completion (struct t_hook_command *hook_command)
|
||||
{
|
||||
if (i < hook_command->cplt_template_num_args[j])
|
||||
{
|
||||
items = string_explode (hook_command->cplt_template_args[j][i],
|
||||
"|", 0, 0, &num_items);
|
||||
items = string_split (hook_command->cplt_template_args[j][i],
|
||||
"|", 0, 0, &num_items);
|
||||
for (k = 0; k < num_items; k++)
|
||||
{
|
||||
if (!weelist_search (list, items[k]))
|
||||
@@ -478,7 +478,7 @@ hook_command_build_completion (struct t_hook_command *hook_command)
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
string_free_exploded (items);
|
||||
string_free_split (items);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -584,13 +584,13 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
|
||||
|
||||
rc = -1;
|
||||
|
||||
argv = string_explode (string, " ", 0, 0, &argc);
|
||||
argv = string_split (string, " ", 0, 0, &argc);
|
||||
if (argc == 0)
|
||||
{
|
||||
string_free_exploded (argv);
|
||||
string_free_split (argv);
|
||||
return -1;
|
||||
}
|
||||
argv_eol = string_explode (string, " ", 1, 0, NULL);
|
||||
argv_eol = string_split (string, " ", 1, 0, NULL);
|
||||
|
||||
hook_exec_start ();
|
||||
|
||||
@@ -660,8 +660,8 @@ hook_command_exec (struct t_gui_buffer *buffer, int any_plugin,
|
||||
}
|
||||
}
|
||||
|
||||
string_free_exploded (argv);
|
||||
string_free_exploded (argv_eol);
|
||||
string_free_split (argv);
|
||||
string_free_split (argv_eol);
|
||||
|
||||
hook_exec_end ();
|
||||
|
||||
@@ -1516,8 +1516,8 @@ hook_print (struct t_weechat_plugin *plugin, struct t_gui_buffer *buffer,
|
||||
new_hook_print->buffer = buffer;
|
||||
if (tags)
|
||||
{
|
||||
new_hook_print->tags_array = string_explode (tags, ",", 0, 0,
|
||||
&new_hook_print->tags_count);
|
||||
new_hook_print->tags_array = string_split (tags, ",", 0, 0,
|
||||
&new_hook_print->tags_count);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2173,7 +2173,7 @@ unhook (struct t_hook *hook)
|
||||
free (HOOK_COMMAND(hook, cplt_templates)[i]);
|
||||
if (HOOK_COMMAND(hook, cplt_templates_static)[i])
|
||||
free (HOOK_COMMAND(hook, cplt_templates_static)[i]);
|
||||
string_free_exploded (HOOK_COMMAND(hook, cplt_template_args)[i]);
|
||||
string_free_split (HOOK_COMMAND(hook, cplt_template_args)[i]);
|
||||
}
|
||||
free (HOOK_COMMAND(hook, cplt_templates));
|
||||
}
|
||||
|
||||
+31
-29
@@ -727,23 +727,23 @@ string_mask_to_regex (const char *mask)
|
||||
}
|
||||
|
||||
/*
|
||||
* string_explode: explode a string according to separators
|
||||
* examples:
|
||||
* string_explode ("abc de fghi", " ", 0, 0, NULL)
|
||||
* ==> array[0] = "abc"
|
||||
* array[1] = "de"
|
||||
* array[2] = "fghi"
|
||||
* array[3] = NULL
|
||||
* string_explode ("abc de fghi", " ", 1, 0, NULL)
|
||||
* ==> array[0] = "abc de fghi"
|
||||
* array[1] = "de fghi"
|
||||
* array[2] = "fghi"
|
||||
* array[3] = NULL
|
||||
* string_split: split a string according to separators
|
||||
* examples:
|
||||
* string_split ("abc de fghi", " ", 0, 0, NULL)
|
||||
* ==> array[0] = "abc"
|
||||
* array[1] = "de"
|
||||
* array[2] = "fghi"
|
||||
* array[3] = NULL
|
||||
* string_split ("abc de fghi", " ", 1, 0, NULL)
|
||||
* ==> array[0] = "abc de fghi"
|
||||
* array[1] = "de fghi"
|
||||
* array[2] = "fghi"
|
||||
* array[3] = NULL
|
||||
*/
|
||||
|
||||
char **
|
||||
string_explode (const char *string, const char *separators, int keep_eol,
|
||||
int num_items_max, int *num_items)
|
||||
string_split (const char *string, const char *separators, int keep_eol,
|
||||
int num_items_max, int *num_items)
|
||||
{
|
||||
int i, j, n_items;
|
||||
char *string2, **array;
|
||||
@@ -867,42 +867,44 @@ string_explode (const char *string, const char *separators, int keep_eol,
|
||||
}
|
||||
|
||||
/*
|
||||
* string_free_exploded: free an exploded string
|
||||
* string_free_split: free a split string
|
||||
*/
|
||||
|
||||
void
|
||||
string_free_exploded (char **exploded_string)
|
||||
string_free_split (char **split_string)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (exploded_string)
|
||||
if (split_string)
|
||||
{
|
||||
for (i = 0; exploded_string[i]; i++)
|
||||
free (exploded_string[i]);
|
||||
free (exploded_string);
|
||||
for (i = 0; split_string[i]; i++)
|
||||
free (split_string[i]);
|
||||
free (split_string);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* string_build_with_exploded: build a string with exploded string
|
||||
* note: returned value has to be free() after use
|
||||
* string_build_with_split_string: build a string with a split string
|
||||
* note: returned value has to be free() after
|
||||
* use
|
||||
*/
|
||||
|
||||
char *
|
||||
string_build_with_exploded (const char **exploded_string, const char *separator)
|
||||
string_build_with_split_string (const char **split_string,
|
||||
const char *separator)
|
||||
{
|
||||
int i, length, length_separator;
|
||||
char *result;
|
||||
|
||||
if (!exploded_string)
|
||||
if (!split_string)
|
||||
return NULL;
|
||||
|
||||
length = 0;
|
||||
length_separator = (separator) ? strlen (separator) : 0;
|
||||
|
||||
for (i = 0; exploded_string[i]; i++)
|
||||
for (i = 0; split_string[i]; i++)
|
||||
{
|
||||
length += strlen (exploded_string[i]) + length_separator;
|
||||
length += strlen (split_string[i]) + length_separator;
|
||||
}
|
||||
|
||||
result = malloc (length + 1);
|
||||
@@ -910,10 +912,10 @@ string_build_with_exploded (const char **exploded_string, const char *separator)
|
||||
{
|
||||
result[0] = '\0';
|
||||
|
||||
for (i = 0; exploded_string[i]; i++)
|
||||
for (i = 0; split_string[i]; i++)
|
||||
{
|
||||
strcat (result, exploded_string[i]);
|
||||
if (separator && exploded_string[i + 1])
|
||||
strcat (result, split_string[i]);
|
||||
if (separator && split_string[i + 1])
|
||||
strcat (result, separator);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,11 +42,11 @@ extern char *string_convert_hex_chars (const char *string);
|
||||
extern int string_has_highlight (const char *string,
|
||||
const char *highlight_words);
|
||||
extern char *string_mask_to_regex (const char *mask);
|
||||
extern char **string_explode (const char *string, const char *separators,
|
||||
int keep_eol, int num_items_max, int *num_items);
|
||||
extern void string_free_exploded (char **exploded_string);
|
||||
extern char *string_build_with_exploded (const char **exploded_string,
|
||||
const char *separator);
|
||||
extern char **string_split (const char *string, const char *separators,
|
||||
int keep_eol, int num_items_max, int *num_items);
|
||||
extern void string_free_split (char **split_string);
|
||||
extern char *string_build_with_split_string (const char **split_string,
|
||||
const char *separator);
|
||||
extern char **string_split_command (const char *command, char separator);
|
||||
extern void string_free_split_command (char **split_command);
|
||||
extern char *string_iconv (int from_utf8, const char *from_code,
|
||||
|
||||
@@ -263,7 +263,7 @@ upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
|
||||
fields = infolist_fields (infolist);
|
||||
if (fields)
|
||||
{
|
||||
argv = string_explode (fields, ",", 0, 0, &argc);
|
||||
argv = string_split (fields, ",", 0, 0, &argc);
|
||||
if (argv && (argc > 0))
|
||||
{
|
||||
for (i = 0; i < argc; i++)
|
||||
@@ -372,7 +372,7 @@ upgrade_file_write_object (struct t_upgrade_file *upgrade_file, int object_id,
|
||||
}
|
||||
}
|
||||
if (argv)
|
||||
string_free_exploded (argv);
|
||||
string_free_split (argv);
|
||||
}
|
||||
|
||||
/* write object end */
|
||||
|
||||
Reference in New Issue
Block a user