mirror of https://github.com/MidnightCommander/mc
(mc_build_filenamev): refactoring.
Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
0c53039155
commit
9584973453
|
@ -1221,13 +1221,13 @@ mc_build_filenamev (const char *first_element, va_list args)
|
||||||
GString *path;
|
GString *path;
|
||||||
char *ret;
|
char *ret;
|
||||||
|
|
||||||
if (element == NULL)
|
if (first_element == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
path = g_string_new ("");
|
|
||||||
|
|
||||||
absolute = IS_PATH_SEP (*first_element);
|
absolute = IS_PATH_SEP (*first_element);
|
||||||
|
|
||||||
|
path = g_string_new (absolute ? PATH_SEP_STR : "");
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (*element == '\0')
|
if (*element == '\0')
|
||||||
|
@ -1235,7 +1235,6 @@ mc_build_filenamev (const char *first_element, va_list args)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *tmp_element;
|
char *tmp_element;
|
||||||
size_t len;
|
|
||||||
const char *start;
|
const char *start;
|
||||||
|
|
||||||
tmp_element = g_strdup (element);
|
tmp_element = g_strdup (element);
|
||||||
|
@ -1243,11 +1242,10 @@ mc_build_filenamev (const char *first_element, va_list args)
|
||||||
element = va_arg (args, char *);
|
element = va_arg (args, char *);
|
||||||
|
|
||||||
canonicalize_pathname (tmp_element);
|
canonicalize_pathname (tmp_element);
|
||||||
len = strlen (tmp_element);
|
|
||||||
start = IS_PATH_SEP (tmp_element[0]) ? tmp_element + 1 : tmp_element;
|
start = IS_PATH_SEP (tmp_element[0]) ? tmp_element + 1 : tmp_element;
|
||||||
|
|
||||||
g_string_append (path, start);
|
g_string_append (path, start);
|
||||||
if (!IS_PATH_SEP (tmp_element[len - 1]) && element != NULL)
|
if (!IS_PATH_SEP (path->str[path->len - 1]) && element != NULL)
|
||||||
g_string_append_c (path, PATH_SEP);
|
g_string_append_c (path, PATH_SEP);
|
||||||
|
|
||||||
g_free (tmp_element);
|
g_free (tmp_element);
|
||||||
|
@ -1255,9 +1253,6 @@ mc_build_filenamev (const char *first_element, va_list args)
|
||||||
}
|
}
|
||||||
while (element != NULL);
|
while (element != NULL);
|
||||||
|
|
||||||
if (absolute)
|
|
||||||
g_string_prepend_c (path, PATH_SEP);
|
|
||||||
|
|
||||||
ret = g_string_free (path, FALSE);
|
ret = g_string_free (path, FALSE);
|
||||||
canonicalize_pathname (ret);
|
canonicalize_pathname (ret);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue