mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
(vfs_path_build_url_params_str): return GString.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
ab897e4ca6
commit
5a40f24658
@ -535,7 +535,7 @@ vfs_path_tokens_add_class_info (const vfs_path_element_t * element, GString * re
|
||||
if (((element->class->flags & VFSF_LOCAL) == 0 || ret_tokens->len > 0)
|
||||
&& element_tokens->len > 0)
|
||||
{
|
||||
char *url_str;
|
||||
GString *url_str;
|
||||
|
||||
if (ret_tokens->len > 0 && !IS_PATH_SEP (ret_tokens->str[ret_tokens->len - 1]))
|
||||
g_string_append_c (ret_tokens, PATH_SEP);
|
||||
@ -544,13 +544,13 @@ vfs_path_tokens_add_class_info (const vfs_path_element_t * element, GString * re
|
||||
g_string_append (ret_tokens, VFS_PATH_URL_DELIMITER);
|
||||
|
||||
url_str = vfs_path_build_url_params_str (element, TRUE);
|
||||
if (*url_str != '\0')
|
||||
if (url_str->len != 0)
|
||||
{
|
||||
g_string_append (ret_tokens, url_str);
|
||||
g_string_append_len (ret_tokens, url_str->str, url_str->len);
|
||||
g_string_append_c (ret_tokens, PATH_SEP);
|
||||
}
|
||||
|
||||
g_free (url_str);
|
||||
g_string_free (url_str, TRUE);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
@ -651,7 +651,8 @@ vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_fl
|
||||
element = vfs_path_get_by_index (vpath, element_index);
|
||||
if (element->vfs_prefix != NULL)
|
||||
{
|
||||
char *url_str;
|
||||
GString *url_str;
|
||||
|
||||
if (!is_relative && (buffer->len == 0 || !IS_PATH_SEP (buffer->str[buffer->len - 1])))
|
||||
g_string_append_c (buffer, PATH_SEP);
|
||||
|
||||
@ -659,14 +660,13 @@ vfs_path_to_str_flags (const vfs_path_t * vpath, int elements_count, vfs_path_fl
|
||||
g_string_append (buffer, VFS_PATH_URL_DELIMITER);
|
||||
|
||||
url_str = vfs_path_build_url_params_str (element, !(flags & VPF_STRIP_PASSWORD));
|
||||
|
||||
if (*url_str != '\0')
|
||||
if (url_str->len != 0)
|
||||
{
|
||||
g_string_append (buffer, url_str);
|
||||
g_string_append_len (buffer, url_str->str, url_str->len);
|
||||
g_string_append_c (buffer, PATH_SEP);
|
||||
}
|
||||
|
||||
g_free (url_str);
|
||||
g_string_free (url_str, TRUE);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CHARSET
|
||||
@ -1504,7 +1504,7 @@ vfs_path_vtokens_get (const vfs_path_t * vpath, ssize_t start_position, ssize_t
|
||||
* @return newly allocated string
|
||||
*/
|
||||
|
||||
char *
|
||||
GString *
|
||||
vfs_path_build_url_params_str (const vfs_path_element_t * element, gboolean keep_password)
|
||||
{
|
||||
GString *buffer;
|
||||
@ -1512,7 +1512,7 @@ vfs_path_build_url_params_str (const vfs_path_element_t * element, gboolean keep
|
||||
if (element == NULL)
|
||||
return NULL;
|
||||
|
||||
buffer = g_string_new ("");
|
||||
buffer = g_string_sized_new (64);
|
||||
|
||||
if (element->user != NULL)
|
||||
g_string_append (buffer, element->user);
|
||||
@ -1540,7 +1540,7 @@ vfs_path_build_url_params_str (const vfs_path_element_t * element, gboolean keep
|
||||
g_string_append_printf (buffer, "%d", element->port);
|
||||
}
|
||||
|
||||
return g_string_free (buffer, FALSE);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
@ -1555,15 +1555,14 @@ vfs_path_build_url_params_str (const vfs_path_element_t * element, gboolean keep
|
||||
GString *
|
||||
vfs_path_element_build_pretty_path_str (const vfs_path_element_t * element)
|
||||
{
|
||||
char *url_params;
|
||||
GString *pretty_path;
|
||||
GString *url_params, *pretty_path;
|
||||
|
||||
pretty_path = g_string_new (element->class->prefix);
|
||||
g_string_append (pretty_path, VFS_PATH_URL_DELIMITER);
|
||||
|
||||
url_params = vfs_path_build_url_params_str (element, FALSE);
|
||||
g_string_append (pretty_path, url_params);
|
||||
g_free (url_params);
|
||||
g_string_append_len (pretty_path, url_params->str, url_params->len);
|
||||
g_string_free (url_params, TRUE);
|
||||
|
||||
if (!IS_PATH_SEP (*element->path))
|
||||
g_string_append_c (pretty_path, PATH_SEP);
|
||||
|
@ -89,7 +89,7 @@ vfs_path_t *vfs_path_change_encoding (vfs_path_t * vpath, const char *encoding);
|
||||
char *vfs_path_serialize (const vfs_path_t * vpath, GError ** error);
|
||||
vfs_path_t *vfs_path_deserialize (const char *data, GError ** error);
|
||||
|
||||
char *vfs_path_build_url_params_str (const vfs_path_element_t * element, gboolean keep_password);
|
||||
GString *vfs_path_build_url_params_str (const vfs_path_element_t * element, gboolean keep_password);
|
||||
GString *vfs_path_element_build_pretty_path_str (const vfs_path_element_t * element);
|
||||
|
||||
size_t vfs_path_len (const vfs_path_t * vpath);
|
||||
|
Loading…
Reference in New Issue
Block a user