[gnome-commander/parse_search_command] Parse search command




commit 4ecb6cb81647580950193bbe5090f05e99a7b25b
Author: Maik Pertermann <maik tapse gmx de>
Date:   Sat Feb 5 15:44:27 2022 +0100

    Parse search command

 src/gnome-cmd-user-actions.cc | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)
---
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index 7b3738b1..7199aacf 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -772,25 +772,31 @@ void file_edit_new_doc (GtkMenuItem *menuitem, gpointer not_used)
 
 void file_search (GtkMenuItem *menuitem, gpointer not_used)
 {
-           gchar       *command;
-
-           command = g_strdup (gnome_cmd_data.options.search);
-           if (!command || strlen(command) == 0)
-           {
-               DEBUG ('g', "Search command is empty.\n");
-               gnome_cmd_show_message (*main_win, _("No search command given."), _("You can set a command 
for a search tool in the program options."));
-               return;
-           }
+    string commandString;
+    commandString.reserve(2000);
 
+    if (parse_command(&commandString, (const gchar*) gnome_cmd_data.options.search) == 0)
+    {
+           DEBUG ('g', "Search command is empty.\n");
+           gnome_cmd_show_message (*main_win, _("No search command given."), _("You can set a command for a 
search tool in the program options."));
+           return;
+    }
+    else
+    {
         gint     argc;
         gchar  **argv  = nullptr;
         GError  *error = nullptr;
-        DEBUG ('g', "Executing: %s\n", command);
-        g_shell_parse_argv (command, &argc, &argv, nullptr);
+
+        DEBUG ('g', "Invoking search: %s\n", commandString.c_str());
+        // put command into argv
+        g_shell_parse_argv (commandString.c_str(), &argc, &argv, nullptr);
+        // execute command
         if (!g_spawn_async (nullptr, argv, nullptr, G_SPAWN_SEARCH_PATH, nullptr, nullptr, nullptr, &error))
-           gnome_cmd_error_message (_("Unable to execute command."), error);
+        {
+            gnome_cmd_error_message (_("Unable to execute command."), error);
+        }
         g_strfreev (argv);
-        g_free (command);
+    }
 }
 
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]