Blame SOURCES/0022-localization-properly-handle-locales-with-encoding-s.patch

562801
From 09da182cd50ee9df08a20180d5fd1d136dc794d3 Mon Sep 17 00:00:00 2001
562801
From: Jakub Filak <jfilak@redhat.com>
562801
Date: Sat, 8 Feb 2014 09:15:35 +0100
562801
Subject: [LIBREPORT PATCH 22/24] localization: properly handle locales with
562801
 encoding suffix
562801
562801
XML nodes contain xml:lang attributes whose values are plain language
562801
codes (en_GB, zh_CN, ...).
562801
562801
libreport tries to find exact match with cur locale which may be
562801
suffixed with char set identifier (.UTF-8). Therefore libreport never
562801
finds exact match.
562801
562801
This patch removes the encoding suffix from cur locale string.
562801
562801
Closes to rhbz#1063320
562801
562801
Signed-off-by: Jakub Filak <jfilak@redhat.com>
562801
---
562801
 src/include/xml_parser.h      | 2 +-
562801
 src/lib/event_xml_parser.c    | 6 ++++--
562801
 src/lib/workflow_xml_parser.c | 4 +++-
562801
 3 files changed, 8 insertions(+), 4 deletions(-)
562801
562801
diff --git a/src/include/xml_parser.h b/src/include/xml_parser.h
562801
index 59517b3..36fd2ae 100644
562801
--- a/src/include/xml_parser.h
562801
+++ b/src/include/xml_parser.h
562801
@@ -22,7 +22,7 @@
562801
 struct my_parse_data
562801
 {
562801
     workflow_t *workflow;
562801
-    const char *cur_locale;
562801
+    char *cur_locale;
562801
     char *attribute_lang;
562801
     bool in_event_list;
562801
     bool exact_name;
562801
diff --git a/src/lib/event_xml_parser.c b/src/lib/event_xml_parser.c
562801
index 2a6f477..1f98158 100644
562801
--- a/src/lib/event_xml_parser.c
562801
+++ b/src/lib/event_xml_parser.c
562801
@@ -60,7 +60,7 @@ struct my_parse_data
562801
 {
562801
     parsed_event_config_t event_config;
562801
     parsed_event_option_t cur_option;
562801
-    const char *cur_locale;
562801
+    char *cur_locale;
562801
     char *attribute_lang;
562801
     bool in_adv_option;
562801
 };
562801
@@ -511,7 +511,8 @@ void load_event_description_from_file(event_config_t *event_config, const char*
562801
 {
562801
     log_notice("loading event: '%s'", filename);
562801
     struct my_parse_data parse_data = { {event_config, false, false, false}, {NULL, false, false}, NULL, NULL };
562801
-    parse_data.cur_locale = setlocale(LC_ALL, NULL);
562801
+    parse_data.cur_locale = xstrdup(setlocale(LC_ALL, NULL));
562801
+    strchrnul(parse_data.cur_locale, '.')[0] = '\0';
562801
 
562801
     GMarkupParser parser;
562801
     memset(&parser, 0, sizeof(parser)); /* just in case */
562801
@@ -541,4 +542,5 @@ void load_event_description_from_file(event_config_t *event_config, const char*
562801
 
562801
     consume_cur_option(&parse_data); /* just in case */
562801
     free(parse_data.attribute_lang); /* just in case */
562801
+    free(parse_data.cur_locale);
562801
 }
562801
diff --git a/src/lib/workflow_xml_parser.c b/src/lib/workflow_xml_parser.c
562801
index 681b171..0efc733 100644
562801
--- a/src/lib/workflow_xml_parser.c
562801
+++ b/src/lib/workflow_xml_parser.c
562801
@@ -165,7 +165,8 @@ void load_workflow_description_from_file(workflow_t *workflow, const char* filen
562801
 {
562801
     log_notice("loading workflow: '%s'", filename);
562801
     struct my_parse_data parse_data = { workflow, NULL, NULL, 0, 0, 0};
562801
-    parse_data.cur_locale = setlocale(LC_ALL, NULL);
562801
+    parse_data.cur_locale = xstrdup(setlocale(LC_ALL, NULL));
562801
+    strchrnul(parse_data.cur_locale, '.')[0] = '\0';
562801
 
562801
     GMarkupParser parser;
562801
     memset(&parser, 0, sizeof(parser)); /* just in case */
562801
@@ -194,4 +195,5 @@ void load_workflow_description_from_file(workflow_t *workflow, const char* filen
562801
     g_markup_parse_context_free(context);
562801
 
562801
     free(parse_data.attribute_lang); /* just in case */
562801
+    free(parse_data.cur_locale);
562801
 }
562801
-- 
562801
1.8.3.1
562801