From 800780e2b727fb97a3d363c73d0dc8cf1f6af3bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrico=20Tr=C3=B6ger?= Date: Wed, 19 Nov 2008 17:31:54 +0000 Subject: [PATCH] Rework search_close_pid() and let it handle the case when the grep command was killed externally. git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@3253 ea778897-0a13-0410-b9d1-a72fbfd435f5 --- ChangeLog | 7 +++++++ src/search.c | 51 ++++++++++++++++++++++++++++----------------------- 2 files changed, 35 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index e4e566d8..627c18c2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-11-19 Enrico Tröger + + * src/search.c: + Rework search_close_pid() and let it handle the case when the grep + command was killed externally. + + 2008-11-18 Enrico Tröger * src/notebook.c: diff --git a/src/search.c b/src/search.c index 90796f8c..dfbfe1d8 100644 --- a/src/search.c +++ b/src/search.c @@ -1428,34 +1428,39 @@ static void search_close_pid(GPid child_pid, gint status, gpointer user_data) #ifdef G_OS_UNIX const gchar *msg = _("Search failed (see Help->Debug Messages for details)."); gint color = COLOR_DARK_RED; + gint exit_status = 1; if (WIFEXITED(status)) { - switch (WEXITSTATUS(status)) - { - case 0: - { - gint count = gtk_tree_model_iter_n_children( - GTK_TREE_MODEL(msgwindow.store_msg), NULL) - 1; + exit_status = WEXITSTATUS(status); + } + else if (WIFSIGNALED(status)) + { + exit_status = -1; + g_warning("Find in Files: The command failed unexpectedly (signal received)."); + } - msgwin_msg_add_fmt(COLOR_BLUE, -1, NULL, - ngettext("Search completed with %d match.", - "Search completed with %d matches.", count), - count); - ui_set_statusbar(FALSE, - ngettext("Search completed with %d match.", - "Search completed with %d matches.", count), - count); - break; - } - case 1: - msg = _("No matches found."); - color = COLOR_BLUE; - default: - msgwin_msg_add(color, -1, NULL, msg); - ui_set_statusbar(FALSE, "%s", msg); - break; + switch (exit_status) + { + case 0: + { + gint count = gtk_tree_model_iter_n_children( + GTK_TREE_MODEL(msgwindow.store_msg), NULL) - 1; + gchar *text = ngettext( + "Search completed with %d match.", + "Search completed with %d matches.", count); + + msgwin_msg_add_fmt(COLOR_BLUE, -1, NULL, text, count); + ui_set_statusbar(FALSE, text, count); + break; } + case 1: + msg = _("No matches found."); + color = COLOR_BLUE; + default: + msgwin_msg_add(color, -1, NULL, msg); + ui_set_statusbar(FALSE, "%s", msg); + break; } #endif