diff --git a/src/ChangeLog b/src/ChangeLog index e8ecb9b5e..25bdfb463 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2002-09-20 Pavel Roskin + * command.c: (command_insert): New function - insert quoted + text into the command line. + * main.c: Use command_insert() instead of stuff(). This ensures + that the names in the command line are quoted. + Reported by Arpad Biro + * command.c: Make `command' a standard WInput widget, just change its callback. Eliminate input_w(). Adjust all dependencies. diff --git a/src/command.c b/src/command.c index 24de5a6bd..b8f6f4197 100644 --- a/src/command.c +++ b/src/command.c @@ -272,3 +272,17 @@ command_new (int y, int x, int cols) return cmd; } +/* + * Insert quoted text in input line. The function is meant for the + * command line, so the percent sign is quoted as well. + */ +void +command_insert (WInput * in, char *text, int insert_extra_space) +{ + char *quoted_text; + + quoted_text = name_quote (text, 1); + stuff (in, quoted_text, insert_extra_space); + g_free (quoted_text); +} + diff --git a/src/command.h b/src/command.h index c26466dfe..34d874759 100644 --- a/src/command.h +++ b/src/command.h @@ -5,5 +5,6 @@ extern WInput *cmdline; WInput *command_new (int y, int x, int len); void do_cd_command (char *cmd); +void command_insert (WInput * in, char *text, int insert_extra_space); #endif /* __COMMAND_H */ diff --git a/src/main.c b/src/main.c index 2a9b461dc..ed9614e4b 100644 --- a/src/main.c +++ b/src/main.c @@ -1254,9 +1254,9 @@ static void copy_current_pathname (void) if (!command_prompt) return; - stuff (cmdline, cpanel->cwd, 0); + command_insert (cmdline, cpanel->cwd, 0); if (cpanel->cwd [strlen (cpanel->cwd) - 1] != PATH_SEP) - stuff (cmdline, PATH_SEP_STR, 0); + command_insert (cmdline, PATH_SEP_STR, 0); } static void copy_other_pathname (void) @@ -1267,9 +1267,9 @@ static void copy_other_pathname (void) if (!command_prompt) return; - stuff (cmdline, opanel->cwd, 0); + command_insert (cmdline, opanel->cwd, 0); if (cpanel->cwd [strlen (opanel->cwd) - 1] != PATH_SEP) - stuff (cmdline, PATH_SEP_STR, 0); + command_insert (cmdline, PATH_SEP_STR, 0); } static void copy_readlink (WPanel *panel) @@ -1285,7 +1285,7 @@ static void copy_readlink (WPanel *panel) g_free (p); if (i > 0) { buffer [i] = 0; - stuff (cmdline, buffer, 0); + command_insert (cmdline, buffer, 1); } } } @@ -1312,31 +1312,29 @@ void copy_prog_name (void) if (get_current_type () == view_tree){ WTree *tree = (WTree *) get_panel_widget (get_current_index ()); - tmp = name_quote (tree->selected_ptr->name, 1); + tmp = tree->selected_ptr->name; } else - tmp = name_quote (selection (cpanel)->fname, 1); - stuff (cmdline, tmp, 1); - g_free (tmp); + tmp = selection (cpanel)->fname; + + command_insert (cmdline, tmp, 1); } -static void copy_tagged (WPanel *panel) +static void +copy_tagged (WPanel * panel) { int i; if (!command_prompt) return; input_disable_update (cmdline); - if (panel->marked){ - for (i = 0; i < panel->count; i++) - if (panel->dir.list [i].f.marked) { - char *tmp = name_quote (panel->dir.list [i].fname, 1); - stuff (cmdline, tmp, 1); - g_free (tmp); - } + if (panel->marked) { + for (i = 0; i < panel->count; i++) { + if (panel->dir.list[i].f.marked) + command_insert (cmdline, panel->dir.list[i].fname, 1); + } } else { - char *tmp = name_quote (panel->dir.list [panel->selected].fname, 1); - stuff (cmdline, tmp, 1); - g_free (tmp); + command_insert (cmdline, panel->dir.list[panel->selected].fname, + 1); } input_enable_update (cmdline); }