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

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