On Mon, 2010-10-04 at 12:05 +0200, Nikola Pajkovsky wrote:
Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
src/cli/Makefile.am | 6 ++++--
src/cli/report.cpp | 21 ++++++++++++++-------
2 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/src/cli/Makefile.am b/src/cli/Makefile.am
index 3c1a343..94363d7 100644
--- a/src/cli/Makefile.am
+++ b/src/cli/Makefile.am
@@ -12,12 +12,14 @@ abrt_cli_CPPFLAGS = \
-DVAR_RUN=\"$(VAR_RUN)\" \
$(ENABLE_SOCKET_OR_DBUS) \
$(DBUS_CFLAGS) \
- -D_GNU_SOURCE
+ -D_GNU_SOURCE \
+ $(GLIB_CFLAGS)
# $(GTK_CFLAGS)
I think it's neater if $(GLIB_CFLAGS) line would be moved up, so that
all $(Foo_CFLAGS) lines are together.
--- a/src/cli/report.cpp
+++ b/src/cli/report.cpp
@@ -18,6 +18,7 @@
#include <cassert>
#include <algorithm>
Since you remove std::find usage below, #include <algorithm> might be
not needed anymore. Try commenting it out...
#include <termios.h>
+#include <glib.h>
#include "report.h"
#include "run-command.h"
#include "dbus.h"
@@ -445,13 +446,13 @@ static void read_from_stdin(const char *question, char *result, int
result_size)
* Specifies a set of characters that delimit the
* tokens in the parsed string
*/
-static vector_string_t split(const char *s, const char delim)
+static GList *split(const char *s, const char delim)
{
- std::vector<std::string> elems;
+ GList *elems = NULL;
while (1)
{
const char *end = strchrnul(s, delim);
- elems.push_back(std::string(s, end - s));
+ elems = g_list_append(elems, xstrndup(s, end - s));
if (*end == '\0')
break;
s = end + 1;
@@ -505,7 +506,7 @@ static vector_string_t get_enabled_reporters(map_crash_data_t
&crash_data)
}
/* Reporters found, now parse the list. */
- vector_string_t reporter_vec = split(reporters_iter->second.c_str(),
',');
+ GList *reporter_list = split(reporters_iter->second.c_str(), ',');
// Get informations about all plugins.
map_map_string_t plugins = call_GetPluginsInfo();
@@ -520,10 +521,16 @@ static vector_string_t get_enabled_reporters(map_crash_data_t
&crash_data)
if (0 != strcmp(it->second["Type"].c_str(), "Reporter"))
continue;
// Skip plugins not used in this particular crash.
- if (reporter_vec.end() == std::find(reporter_vec.begin(), reporter_vec.end(),
std::string(it->first)))
- continue;
- result.push_back(it->first);
+ for (GList *li = reporter_list; li != NULL; li = g_list_next(li))
+ {
+ if (strcmp((char*)li->data, it->first.c_str()) == 0)
+ result.push_back(it->first);
+ }
}
+
+ for (GList *li = reporter_list; li != NULL; li = g_list_next(li))
+ free((char*)li->data);
+
Don't you need to g_list_free(reporter_list) too?
--
vda