mirror of
https://github.com/MidnightCommander/mc
synced 2025-04-02 13:12:53 +03:00
(mc_g_string_dup): new API that extends GString one.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
6f859e52d0
commit
d88f439a69
@ -186,3 +186,25 @@ mc_g_string_copy (GString * dest, const GString * src)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* mc_g_string_dup:
|
||||
* @s: (nullable): the source #GString
|
||||
* @return: @copy of @s
|
||||
*
|
||||
* Copies the bytes from one #GString to another.
|
||||
*
|
||||
* There is no such API in GLib2.
|
||||
*/
|
||||
GString *
|
||||
mc_g_string_dup (const GString * s)
|
||||
{
|
||||
GString *ret = NULL;
|
||||
|
||||
if (s != NULL)
|
||||
ret = g_string_new_len (s->str, s->len);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -27,6 +27,9 @@ void g_queue_clear_full (GQueue * queue, GDestroyNotify free_func);
|
||||
/* There is no such API in GLib2 */
|
||||
GString *mc_g_string_copy (GString * dest, const GString * src);
|
||||
|
||||
/* There is no such API in GLib2 */
|
||||
GString *mc_g_string_dup (const GString * s);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC_GLIBCOMPAT_H */
|
||||
|
@ -222,7 +222,8 @@ GString *
|
||||
mc_search_hex_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str)
|
||||
{
|
||||
(void) lc_mc_search;
|
||||
return g_string_new_len (replace_str->str, replace_str->len);
|
||||
|
||||
return mc_g_string_dup (replace_str);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -109,5 +109,6 @@ GString *
|
||||
mc_search_normal_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str)
|
||||
{
|
||||
(void) lc_mc_search;
|
||||
return g_string_new_len (replace_str->str, replace_str->len);
|
||||
|
||||
return mc_g_string_dup (replace_str);
|
||||
}
|
||||
|
@ -1006,7 +1006,7 @@ mc_search_regex_prepare_replace_str (mc_search_t * lc_mc_search, GString * repla
|
||||
mc_search_regex__get_max_num_of_replace_tokens (replace_str->str, replace_str->len);
|
||||
|
||||
if (lc_mc_search->num_results < 0)
|
||||
return g_string_new_len (replace_str->str, replace_str->len);
|
||||
return mc_g_string_dup (replace_str);
|
||||
|
||||
if (num_replace_tokens > lc_mc_search->num_results - 1
|
||||
|| num_replace_tokens > MC_SEARCH__NUM_REPLACE_ARGS)
|
||||
|
@ -363,7 +363,7 @@ mc_search_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str
|
||||
return g_string_new ("");
|
||||
|
||||
if (lc_mc_search == NULL)
|
||||
return g_string_new_len (replace_str->str, replace_str->len);
|
||||
return mc_g_string_dup (replace_str);
|
||||
|
||||
switch (lc_mc_search->search_type)
|
||||
{
|
||||
@ -380,7 +380,7 @@ mc_search_prepare_replace_str (mc_search_t * lc_mc_search, GString * replace_str
|
||||
ret = mc_search_hex_prepare_replace_str (lc_mc_search, replace_str);
|
||||
break;
|
||||
default:
|
||||
ret = g_string_new_len (replace_str->str, replace_str->len);
|
||||
ret = mc_g_string_dup (replace_str);
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
|
@ -725,7 +725,7 @@ dir_list_reload (dir_list * list, const vfs_path_t * vpath, GCompareFunc sort,
|
||||
fentry = &list->list[i];
|
||||
dfentry = &dir_copy.list[i];
|
||||
|
||||
dfentry->fname = g_string_new_len (fentry->fname->str, fentry->fname->len);
|
||||
dfentry->fname = mc_g_string_dup (fentry->fname);
|
||||
dfentry->f.marked = fentry->f.marked;
|
||||
dfentry->f.dir_size_computed = fentry->f.dir_size_computed;
|
||||
dfentry->f.link_to_dir = fentry->f.link_to_dir;
|
||||
|
@ -1857,8 +1857,7 @@ do_find (WPanel * panel, const char *start_dir, ssize_t start_dir_len, const cha
|
||||
continue;
|
||||
}
|
||||
|
||||
list->list[list->len].fname = g_string_new_len (list->list[list->len].fname->str,
|
||||
list->list[list->len].fname->len);
|
||||
list->list[list->len].fname = mc_g_string_dup (list->list[list->len].fname);
|
||||
list->list[list->len].f.marked = 0;
|
||||
list->list[list->len].f.link_to_dir = link_to_dir ? 1 : 0;
|
||||
list->list[list->len].f.stale_link = stale_link ? 1 : 0;
|
||||
|
@ -2273,7 +2273,7 @@ goto_parent_dir (WPanel * panel)
|
||||
vfs_path_t *dname_vpath;
|
||||
|
||||
if (g_path_is_absolute (fname->str))
|
||||
fname = g_string_new_len (fname->str, fname->len);
|
||||
fname = mc_g_string_dup (fname);
|
||||
else
|
||||
{
|
||||
char *fname2;
|
||||
|
@ -461,8 +461,7 @@ do_panelize_cd (WPanel * panel)
|
||||
for (i = 0; i < panelized_panel.list.len; i++)
|
||||
{
|
||||
if (panelized_same || DIR_IS_DOTDOT (panelized_panel.list.list[i].fname->str))
|
||||
list->list[i].fname = g_string_new_len (panelized_panel.list.list[i].fname->str,
|
||||
panelized_panel.list.list[i].fname->len);
|
||||
list->list[i].fname = mc_g_string_dup (panelized_panel.list.list[i].fname);
|
||||
else
|
||||
{
|
||||
vfs_path_t *tmp_vpath;
|
||||
@ -523,8 +522,7 @@ panelize_save_panel (WPanel * panel)
|
||||
|
||||
for (i = 0; i < panel->dir.len; i++)
|
||||
{
|
||||
panelized_panel.list.list[i].fname =
|
||||
g_string_new_len (list->list[i].fname->str, list->list[i].fname->len);
|
||||
panelized_panel.list.list[i].fname = mc_g_string_dup (list->list[i].fname);
|
||||
panelized_panel.list.list[i].f.link_to_dir = list->list[i].f.link_to_dir;
|
||||
panelized_panel.list.list[i].f.stale_link = list->list[i].f.stale_link;
|
||||
panelized_panel.list.list[i].f.dir_size_computed = list->list[i].f.dir_size_computed;
|
||||
|
@ -115,7 +115,7 @@ editcmd_dialog_completion_show (const WEdit * edit, GQueue * compl, int max_widt
|
||||
GString *s = (GString *) i->data;
|
||||
|
||||
g_queue_push_tail (editcmd_dialog_completion_show__compl,
|
||||
g_string_new_len (s->str, s->len));
|
||||
mc_g_string_dup (s));
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user