Skip to content

Commit

Permalink
tab_completion_do(): use g_build_filename(), G_DIR_SEPARATOR, G_DIR_S…
Browse files Browse the repository at this point in the history
…EPARATOR_S.
  • Loading branch information
Laurent Monin committed May 21, 2008
1 parent a847d10 commit 0be6f79
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/ui_tabcomp.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,10 +379,11 @@ static gint tab_completion_do(TabCompData *td)
g_free(entry_dir);
return home_exp;
}

if (isdir(entry_dir) && strcmp(entry_file, ".") != 0 && strcmp(entry_file, "..") != 0)
{
ptr = entry_dir + strlen(entry_dir) - 1;
if (ptr[0] == '/')
if (ptr[0] == G_DIR_SEPARATOR)
{
if (home_exp)
{
Expand All @@ -398,11 +399,12 @@ static gint tab_completion_do(TabCompData *td)
const gchar *file;

file = td->file_list->data;
buf = g_strconcat(entry_dir, file, NULL);
buf = g_build_filename(entry_dir, file, NULL);
if (isdir(buf))
{
gchar *tmp = g_strconcat(buf, G_DIR_SEPARATOR_S, NULL);
g_free(buf);
buf = g_strconcat(entry_dir, file, "/", NULL);
buf = tmp;
}
gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
Expand All @@ -422,7 +424,7 @@ static gint tab_completion_do(TabCompData *td)
}
else
{
gchar *buf = g_strconcat(entry_dir, "/", NULL);
gchar *buf = g_strconcat(entry_dir, G_DIR_SEPARATOR_S, NULL);
gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
g_free(buf);
Expand All @@ -438,7 +440,7 @@ static gint tab_completion_do(TabCompData *td)
if (strlen(entry_dir) == 0)
{
g_free(entry_dir);
entry_dir = g_strdup("/");
entry_dir = g_strdup(G_DIR_SEPARATOR_S); /* FIXME: win32 */
}

if (isdir(entry_dir))
Expand All @@ -452,7 +454,7 @@ static gint tab_completion_do(TabCompData *td)
tab_completion_read_dir(td, entry_dir);
}

if (strcmp(entry_dir, "/") == 0) entry_dir[0] = '\0';
if (strcmp(entry_dir, G_DIR_SEPARATOR_S) == 0) entry_dir[0] = '\0'; /* FIXME: win32 */

list = td->file_list;
while (list)
Expand All @@ -472,12 +474,13 @@ static gint tab_completion_do(TabCompData *td)
gchar *file = poss->data;
gchar *buf;

buf = g_strconcat(entry_dir, "/", file, NULL);
buf = g_build_filename(entry_dir, file, NULL);

if (isdir(buf))
{
gchar *tmp = g_strconcat(buf, G_DIR_SEPARATOR_S, NULL);
g_free(buf);
buf = g_strconcat(entry_dir, "/", file, "/", NULL);
buf = tmp;
}
gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));
Expand Down Expand Up @@ -514,7 +517,7 @@ static gint tab_completion_do(TabCompData *td)
gchar *buf;
file = g_strdup(test_file);
file[c] = '\0';
buf = g_strconcat(entry_dir, "/", file, NULL);
buf = g_build_filename(entry_dir, file, NULL);
gtk_entry_set_text(GTK_ENTRY(td->entry), buf);
gtk_editable_set_position(GTK_EDITABLE(td->entry), strlen(buf));

Expand Down

0 comments on commit 0be6f79

Please sign in to comment.