Jakub Filak <jfilak(a)redhat.com> writes:
---
src/lib/event_xml_parser.c | 60 +++++++++++++++++++++----------------------
1 files changed, 29 insertions(+), 31 deletions(-)
diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c
index 8223685..69e1c43 100644
--- a/src/lib/event_xml_parser.c
+++ b/src/lib/event_xml_parser.c
@@ -19,6 +19,10 @@
#include "event_config.h"
#include "internal_libreport.h"
+#if HAVE_LOCALE_H
+# include <locale.h>
+#endif /* HAVE_LOCALE_H */
+
#define EVENT_ELEMENT "event"
#define LABEL_ELEMENT "label"
#define DESCRIPTION_ELEMENT "description"
@@ -258,9 +262,9 @@ static void text(GMarkupParseContext *context,
VERB2 log("new label:'%s'", text_copy);
free(opt->eo_label);
opt->eo_label = text_copy;
+ text_copy = NULL;
}
}
- return;
}
/*
* we can add a separate field for the default value
@@ -268,15 +272,14 @@ static void text(GMarkupParseContext *context,
* but for now using "value" should be enough and clients doesn't
* have to know about the "defaul-value"
*/
- if (strcmp(inner_element, DEFAULT_VALUE_ELEMENT) == 0)
+ else if (strcmp(inner_element, DEFAULT_VALUE_ELEMENT) == 0)
{
VERB2 log("default value:'%s'", text_copy);
free(opt->eo_value);
opt->eo_value = text_copy;
- return;
+ text_copy = NULL;
}
-
- if (strcmp(inner_element, NOTE_HTML_ELEMENT) == 0)
+ else if (strcmp(inner_element, NOTE_HTML_ELEMENT) == 0)
{
if (parse_data->attribute_lang != NULL) /* if it isn't for other
locale */
{
@@ -289,16 +292,14 @@ static void text(GMarkupParseContext *context,
VERB2 log("html note:'%s'", text_copy);
free(opt->eo_note_html);
opt->eo_note_html = text_copy;
+ text_copy = NULL;
}
}
- return;
}
-
- if (strcmp(inner_element, ALLOW_EMPTY_ELEMENT) == 0)
+ else if (strcmp(inner_element, ALLOW_EMPTY_ELEMENT) == 0)
{
VERB2 log("allow-empty:'%s'", text_copy);
opt->eo_allow_empty = string_to_bool(text_copy);
- return;
}
/*
if (strcmp(inner_element, DESCRIPTION_ELEMENT) == 0)
@@ -306,7 +307,7 @@ static void text(GMarkupParseContext *context,
VERB2 log("tooltip:'%s'", text_copy);
free(opt->eo_description);
opt->eo_description = text_copy;
- return;
+ text_copy = NULL;
}
*/
}
@@ -319,7 +320,7 @@ static void text(GMarkupParseContext *context,
VERB2 log("action description:'%s'", text_copy);
free(ui->action);
ui->action = text_copy;
- return;
+ text_copy = NULL;
}
*/
if (strcmp(inner_element, CREATES_ELEMENT) == 0)
@@ -327,9 +328,9 @@ static void text(GMarkupParseContext *context,
VERB2 log("ec_creates_items:'%s'", text_copy);
free(ui->ec_creates_items);
ui->ec_creates_items = text_copy;
- return;
+ text_copy = NULL;
}
- if (strcmp(inner_element, NAME_ELEMENT) == 0)
+ else if (strcmp(inner_element, NAME_ELEMENT) == 0)
{
if (parse_data->attribute_lang != NULL) /* if it isn't for other
locale */
{
@@ -342,11 +343,11 @@ static void text(GMarkupParseContext *context,
VERB2 log("event name:'%s'", text_copy);
free(ui->screen_name);
ui->screen_name = text_copy;
+ text_copy = NULL;
}
}
- return;
}
- if (strcmp(inner_element, DESCRIPTION_ELEMENT) == 0)
+ else if (strcmp(inner_element, DESCRIPTION_ELEMENT) == 0)
{
VERB3 log("event description:'%s'", text_copy);
@@ -360,11 +361,11 @@ static void text(GMarkupParseContext *context,
) {
free(ui->description);
ui->description = text_copy;
+ text_copy = NULL;
}
}
- return;
}
- if (strcmp(inner_element, LONG_DESCR_ELEMENT) == 0)
+ else if (strcmp(inner_element, LONG_DESCR_ELEMENT) == 0)
{
VERB3 log("event long description:'%s'", text_copy);
@@ -378,41 +379,39 @@ static void text(GMarkupParseContext *context,
) {
free(ui->long_descr);
ui->long_descr = text_copy;
+ text_copy = NULL;
}
}
- return;
}
- if (strcmp(inner_element, REQUIRES_ELEMENT) == 0)
+ else if (strcmp(inner_element, REQUIRES_ELEMENT) == 0)
{
free(ui->ec_requires_items);
ui->ec_requires_items = text_copy;
- return;
+ text_copy = NULL;
}
- if (strcmp(inner_element, EXCL_BY_DEFAULT_ELEMENT) == 0)
+ else if (strcmp(inner_element, EXCL_BY_DEFAULT_ELEMENT) == 0)
{
free(ui->ec_exclude_items_by_default);
ui->ec_exclude_items_by_default = text_copy;
- return;
+ text_copy = NULL;
}
- if (strcmp(inner_element, INCL_BY_DEFAULT_ELEMENT) == 0)
+ else if (strcmp(inner_element, INCL_BY_DEFAULT_ELEMENT) == 0)
{
free(ui->ec_include_items_by_default);
ui->ec_include_items_by_default = text_copy;
- return;
+ text_copy = NULL;
}
- if (strcmp(inner_element, EXCL_ALWAYS_ELEMENT) == 0)
+ else if (strcmp(inner_element, EXCL_ALWAYS_ELEMENT) == 0)
{
free(ui->ec_exclude_items_always);
ui->ec_exclude_items_always = text_copy;
- return;
+ text_copy = NULL;
}
- if (strcmp(inner_element, EXCL_BINARY_ELEMENT) == 0)
+ else if (strcmp(inner_element, EXCL_BINARY_ELEMENT) == 0)
{
ui->ec_exclude_binary_items = string_to_bool(text_copy);
- free(text_copy);
- return;
}
- if (strcmp(inner_element, MINIMAL_RATING_ELEMENT) == 0)
+ else if (strcmp(inner_element, MINIMAL_RATING_ELEMENT) == 0)
{
char *endptr;
errno = 0;
@@ -422,7 +421,6 @@ static void text(GMarkupParseContext *context,
log("invalid minimal-rating number '%s', set to default
4", text_copy);
ui->ec_minimal_rating = 4;
}
- return;
}
}
free(text_copy);
mixing two problems into one patch. one is adding locale and second is
fix memory leak. separate them.
--
Nikola